Difference between revisions of "User:Strcat"

From ArchWiki
Jump to: navigation, search
m (File -> hc)
 
(37 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
{{DISPLAYTITLE:User:strcat}}
 
{{DISPLAYTITLE:User:strcat}}
[[User:Thestinger|thestinger]]'s cute little bot. Still needs a bot tag but I'm just making edits we would have done by hand anyway.
+
[[User:Thestinger|thestinger]]'s cute little bot.
  
 
==About this bot==
 
==About this bot==
Line 6: Line 6:
  
 
pywikipediabot/pywikibot archwiki family file:
 
pywikipediabot/pywikibot archwiki family file:
{{File|archwiki_family.py|<nowiki>import family
+
{{hc|archwiki_family.py|2=<nowiki>import family
  
 
class Family(family.Family):
 
class Family(family.Family):
Line 12: Line 12:
 
         family.Family.__init__(self)
 
         family.Family.__init__(self)
 
         self.name = 'archwiki'
 
         self.name = 'archwiki'
         self.langs = {'en':'wiki.archlinux.org'}
+
         self.langs = {'en':'wiki.archlinux.org',
 +
                      'fr':'wiki.archlinux.fr',
 +
                      'ro':'wiki.archlinux.ro'}
  
         self.namespaces[4] = {'_default':'ArchWiki'}
+
        self.namespaces[1]['ro'] = u'Discuţie'
         self.namespaces[5] = {'_default':'ArchWiki talk'}
+
        self.namespaces[3]['ro'] = u'Discuţie Utilizator'
 +
        self.namespaces[6]['ro'] = u'Fişier'
 +
        self.namespaces[7]['ro'] = u'Discuţie Fişier'
 +
        self.namespaces[9]['ro'] = u'Discuţie MediaWiki'
 +
        self.namespaces[11]['ro'] = u'Discuţie Format'
 +
        self.namespaces[13]['ro'] = u'Discuţie Ajutor'
 +
        self.namespaces[15]['ro'] = u'Discuţie Categorie'
 +
 
 +
         self.namespaces[4] = {'_default':'ArchWiki',
 +
                              'fr':'ArchwikiFR',
 +
                              'ro':'ArchWikiRo'}
 +
         self.namespaces[5] = {'_default':'ArchWiki talk',
 +
                              'fr':'Discussion ArchwikiFR',
 +
                              'ro':u'Discuţie ArchWikiRo'}
  
 
         self.category_attop = ['en']
 
         self.category_attop = ['en']
Line 26: Line 41:
 
     def protocol(self, code):
 
     def protocol(self, code):
 
         # The ArchWiki is https only and the bot ignores the redirect
 
         # The ArchWiki is https only and the bot ignores the redirect
         return "https"
+
         if code == 'en':
 +
            return "https"
 +
        else:
 +
            return "http"
  
 
     def scriptpath(self, code):
 
     def scriptpath(self, code):
Line 33: Line 51:
 
     def version(self, code):
 
     def version(self, code):
 
         # https://wiki.archlinux.org/index.php/Special:Version
 
         # https://wiki.archlinux.org/index.php/Special:Version
         return '1.17.0'</nowiki>}}
+
         if code == 'fr':
 +
            return '1.16.2'
 +
        elif code == 'ro':
 +
            return '1.15.5'
 +
        else:
 +
            return '1.17.0'</nowiki>}}
  
 
patch to fix [https://wiki.archlinux.org/index.php?title=User:Strcat&diff=156816&oldid=155320 the marker not being removed] with the category_attop setting (for pywikipediabot, don't know if pywikibot has the same problem since I'm not using it for categories) [I should probably report this upstream, but I'm not sure if the ArchWiki causes the problem]:
 
patch to fix [https://wiki.archlinux.org/index.php?title=User:Strcat&diff=156816&oldid=155320 the marker not being removed] with the category_attop setting (for pywikipediabot, don't know if pywikibot has the same problem since I'm not using it for categories) [I should probably report this upstream, but I'm not sure if the ArchWiki causes the problem]:
{{File|pywikipediabot-category-attop.patch|content=<nowiki>--- pywikibot/textlib.py 2011-09-06 21:49:22.386749427 -0400
+
{{hc|pywikipediabot-category-attop.patch|2=<nowiki>--- pywikibot/textlib.py 2011-09-06 21:49:22.386749427 -0400
 
+++ pywikibot/textlib.py.new 2011-09-06 21:46:31.544743236 -0400
 
+++ pywikibot/textlib.py.new 2011-09-06 21:46:31.544743236 -0400
 
@@ -675,7 +675,7 @@
 
@@ -675,7 +675,7 @@
Line 47: Line 70:
 
             # calculate what was after the categories links on the page
 
             # calculate what was after the categories links on the page
 
             firstafter = s2.find(marker)</nowiki>}}
 
             firstafter = s2.find(marker)</nowiki>}}
 
==Current tasks==
 
*<nowiki><tt>text</tt></nowiki> -> <nowiki>{{Codeline|text}}</nowiki> - per [[ArchWiki:Requests#&lt;tt&gt; is deprecated in HTML 5]]
 
*use language tag in category names - per [[Talk:Table of Contents#ToC restructuring]] (this is the first step towards i18n standardization for categories)
 
 
wrapper for category.py:
 
{{File|use_language_tag.sh|#!/bin/sh
 
#
 
# usage: ./use_language_tag.sh "category name" "language tag to add"
 
#
 
 
python2 category.py move -from:"$1" -to:"$1 ($2)" -summary:'use language tag in category names'}}
 

Latest revision as of 12:20, 5 January 2012

thestinger's cute little bot.

About this bot

Right now I'm using pywikipediabot/pywikibot, and so far just the scripts that are included (the newer pywikibot has a nicer API but doesn't include all the nice scripts) because they cover almost everything (replace.py lets you use regex).

pywikipediabot/pywikibot archwiki family file:

archwiki_family.py
import family

class Family(family.Family):
    def __init__(self):
        family.Family.__init__(self)
        self.name = 'archwiki'
        self.langs = {'en':'wiki.archlinux.org',
                      'fr':'wiki.archlinux.fr',
                      'ro':'wiki.archlinux.ro'}

        self.namespaces[1]['ro'] = u'Discuţie'
        self.namespaces[3]['ro'] = u'Discuţie Utilizator'
        self.namespaces[6]['ro'] = u'Fişier'
        self.namespaces[7]['ro'] = u'Discuţie Fişier'
        self.namespaces[9]['ro'] = u'Discuţie MediaWiki'
        self.namespaces[11]['ro'] = u'Discuţie Format'
        self.namespaces[13]['ro'] = u'Discuţie Ajutor'
        self.namespaces[15]['ro'] = u'Discuţie Categorie'

        self.namespaces[4] = {'_default':'ArchWiki',
                              'fr':'ArchwikiFR',
                              'ro':'ArchWikiRo'}
        self.namespaces[5] = {'_default':'ArchWiki talk',
                              'fr':'Discussion ArchwikiFR',
                              'ro':u'Discuţie ArchWikiRo'}

        self.category_attop = ['en']
        self.interwiki_attop = ['en']

        # Using newlines looks nicer but sometimes creates gaps
        self.category_text_separator = ''
        self.interwiki_text_separator = ''

    def protocol(self, code):
        # The ArchWiki is https only and the bot ignores the redirect
        if code == 'en':
            return "https"
        else:
            return "http"

    def scriptpath(self, code):
        return ''

    def version(self, code):
        # https://wiki.archlinux.org/index.php/Special:Version
        if code == 'fr':
            return '1.16.2'
        elif code == 'ro':
            return '1.15.5'
        else:
            return '1.17.0'

patch to fix the marker not being removed with the category_attop setting (for pywikipediabot, don't know if pywikibot has the same problem since I'm not using it for categories) [I should probably report this upstream, but I'm not sure if the ArchWiki causes the problem]:

pywikipediabot-category-attop.patch
--- pywikibot/textlib.py	2011-09-06 21:49:22.386749427 -0400
+++ pywikibot/textlib.py.new	2011-09-06 21:46:31.544743236 -0400
@@ -675,7 +675,7 @@
     s = categoryFormat(new, insite = site)
     if s:
         if site.language() in site.family.category_attop:
-            newtext = s + separator + s2
+            newtext = s + separator + s2.replace(marker, '')
         else:
             # calculate what was after the categories links on the page
             firstafter = s2.find(marker)