Xqt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/231894

Change subject: [L10N] Update Arabic (ar) for welcome.py
......................................................................

[L10N] Update Arabic (ar) for welcome.py

backport bot script from core

Bug: T109225
Change-Id: If5cd8d3febaa9601c5d85aeea28bf0218db995e7
---
M welcome.py
1 file changed, 62 insertions(+), 54 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/compat 
refs/changes/94/231894/1

diff --git a/welcome.py b/welcome.py
index db880c8..4e95d11 100644
--- a/welcome.py
+++ b/welcome.py
@@ -1,21 +1,20 @@
 # -*- coding: utf-8  -*-
 """
-Script to welcome new users. This script works out of the box for Wikis that
+Script to welcome new users.
+
+This script works out of the box for Wikis that
 have been defined in the script. It is currently used on the Dutch, Norwegian,
 Albanian, Italian Wikipedia, Wikimedia Commons and English Wikiquote.
-
-Note: You can download the latest version available
-from here: http://botwiki.sno.cc/wiki/Python:Welcome.py
 
 Ensure you have community support before running this bot!
 
 URLs to current implementations:
-* Wikimedia Commons: http://commons.wikimedia.org/wiki/Commons:Welcome_log
-* Dutch Wikipedia: http://nl.wikipedia.org/wiki/Wikipedia:Logboek_welkom
-* Italian Wikipedia: http://it.wikipedia.org/wiki/Wikipedia:Benvenuto_log
-* English Wikiquote: http://en.wikiquote.org/wiki/Wikiquote:Welcome_log
-* Persian Wikipedia: http://fa.wikipedia.org/wiki/ویکی‌پدیا:سیاهه_خوشامد
-* Korean Wikipedia: http://ko.wikipedia.org/wiki/위키백과:Welcome_log
+* Wikimedia Commons: https://commons.wikimedia.org/wiki/Commons:Welcome_log
+* Dutch Wikipedia: https://nl.wikipedia.org/wiki/Wikipedia:Logboek_welkom
+* Italian Wikipedia: https://it.wikipedia.org/wiki/Wikipedia:Benvenuto_log
+* English Wikiquote: https://en.wikiquote.org/wiki/Wikiquote:Welcome_log
+* Persian Wikipedia: https://fa.wikipedia.org/wiki/ویکی‌پدیا:سیاهه_خوشامد
+* Korean Wikipedia: https://ko.wikipedia.org/wiki/위키백과:Welcome_log
 
 Everything that needs customisation to support additional projects is
 indicated by comments.
@@ -109,9 +108,9 @@
         * dio is a badword
         * Claudio is a normal name
         * The username is "Claudio90 fuck!"
-        * The Bot find dio and set "warning"
-        * The Bot find Claudio and set "ok"
-        * The Bot find fuck at the end and set "warning"
+        * The Bot finds dio and sets "warning"
+        * The Bot finds Claudio and sets "ok"
+        * The Bot finds fuck at the end and sets "warning"
         * Result: The username is reported.
 4)  When a user is reported you have to check him and do:
         * If he's ok, put the {{welcome}}
@@ -173,8 +172,8 @@
 # (C) Filnik, 2007-2011
 # (C) Daniel Herding, 2007
 # (C) Alex Shih-Han Lin, 2009-2010
-# (C) xqt, 2009-2011
-# (C) Pywikipedia bot team, 2008-2010
+# (C) xqt, 2009-2015
+# (C) Pywikibot team, 2008-2015
 #
 # Distributed under the terms of the MIT license.
 #
@@ -196,7 +195,7 @@
 
 locale.setlocale(locale.LC_ALL, '')
 
-# Script users the class pywikibot.translate() to find the right
+# Script uses the method pywikibot.translate() to find the right
 # page/user/summary/etc so the need to specify language and project have
 # been eliminated.
 # FIXME: Not all language/project combinations have been defined yet.
@@ -213,7 +212,7 @@
 
 # The page where the bot will save the log (e.g. Wikipedia:Welcome log).
 #
-# ATTENTION: Not listed projects are disabled to log welcomed users, and no 
necessary to set details.
+# ATTENTION: Projects not listed won't write a log to the wiki.
 logbook = {
     'ar': u'Project:سجل الترحيب',
     'fr': u'Wikipedia:Prise de décision/Accueil automatique des nouveaux par 
un robot/log',
@@ -263,6 +262,7 @@
         'zh-yue': u'{{歡迎}}--%s',
     },
     'wikinews': {
+        'ar': u'{{subst:ترحيب}} %s',
         'fa': u'{{خوشامد۲|%s}}',
         'it': u'{{subst:benvenuto}}',
         'zh': u'{{subst:welcome}} %s',
@@ -285,7 +285,9 @@
 }
 # The page where the bot will report users with a possibly bad username.
 report_page = {
-    'commons': {'_default': u'Project:Administrators\' noticeboard/User 
problems/Usernames to be checked', },
+    'commons': {
+        '_default': u'Project:Administrators\' noticeboard/User 
problems/Usernames to be checked',
+    },
     'wikipedia': {
         'am': u'User:Beria/Report',
         'ar': 'Project:إخطار الإداريين/أسماء مستخدمين للفحص',
@@ -392,9 +394,15 @@
 #
 #
 logpage_header = {
-    '_default': u'{|border="2" cellpadding="4" cellspacing="0" style="margin: 
0.5em 0.5em 0.5em 1em; padding: 0.5em; background: #bfcda5; border: 1px #b6fd2c 
solid; border-collapse: collapse; font-size: 95%;"',
+    '_default': u'{|border="2" cellpadding="4" cellspacing="0" style="margin: '
+                u'0.5em 0.5em 0.5em 1em; padding: 0.5em; background: #bfcda5; '
+                u'border: 1px #b6fd2c solid; border-collapse: collapse; '
+                u'font-size: 95%;"',
     'no': u'[[Kategori:Velkomstlogg|{{PAGENAME}}]]\n{| class="wikitable"',
-    'it': u'[[Categoria:Benvenuto log|{{subst:PAGENAME}}]]\n{|border="2" 
cellpadding="4" cellspacing="0" style="margin: 0.5em 0.5em 0.5em 1em; padding: 
0.5em; background: #bfcda5; border: 1px #b6fd2c solid; border-collapse: 
collapse; font-size: 95%;"'
+    'it': u'[[Categoria:Benvenuto log|{{subst:PAGENAME}}]]\n{|border="2" '
+          u'cellpadding="4" cellspacing="0" style="margin: 0.5em 0.5em 0.5em '
+          u'1em; padding: 0.5em; background: #bfcda5; border: 1px #b6fd2c '
+          u'solid; border-collapse: collapse; font-size: 95%;"'
 }
 
 # Ok, that's all. What is below, is the rest of code, now the code is fixed
@@ -405,12 +413,13 @@
 
 
 class FilenameNotSet(pywikibot.Error):
+
     """An exception indicating that a signature filename was not specifed."""
 
 
 class Global(object):
-    """Container class for global settings.
-       Use of globals outside of this is to be avoided."""
+
+    """Container class for global settings."""
 
     attachEditCount = 1     # number of edits that an user required to be 
welcomed
     dumpToLog = 15          # number of users that are required to add the log 
:)
@@ -429,13 +438,14 @@
     queryLimit = 50         # number of users that the bot load to check
     quiet = False           # Prevents users without contributions are 
displayed
     quick = False           # Provide quick check by API bulk-retrieve user 
datas
-##    fileOption = False     # check if the user wants to use a file or the 
wikipage
 
 
 class WelcomeBot(object):
 
+    """Bot to add welcome messages on User pages."""
+
     def __init__(self):
-        #Initial
+        """Constructor."""
         self.site = pywikibot.getSite()
         self.bname = dict()
 
@@ -451,7 +461,7 @@
         if not globalvar.filtBadName:
             return False
 
-        #initialize blacklist
+        # initialize blacklist
         if not hasattr(self, '_blacklist') or force:
             elenco = [
                 ' ano', ' anus', 'anal ', 'babies', 'baldracca', 'balle', 
'bastardo',
@@ -489,7 +499,8 @@
 
             # blacklist from wikipage
             badword_page = pywikibot.Page(self.site,
-                                          pywikibot.translate(self.site, 
bad_pag))
+                                          pywikibot.translate(self.site,
+                                                              bad_pag))
             list_loaded = list()
             if badword_page.exists():
                 pywikibot.output(u'\nLoading the bad words list from %s...'
@@ -542,7 +553,7 @@
         return False
 
     def reportBadAccount(self, name=None, final=False):
-        #Queue process
+        # Queue process
         if name:
             if globalvar.confirm:
                 answer = pywikibot.inputChoice(
@@ -588,7 +599,8 @@
                                      % username)
                 else:
                     # Adding the log.
-                    rep_text += pywikibot.translate(self.site, report_text) % 
username
+                    rep_text += pywikibot.translate(self.site,
+                                                    report_text) % username
                     if self.site.lang == 'it':
                         rep_text = "%s%s}}" % (rep_text, self.bname[username])
 
@@ -623,7 +635,7 @@
         if logPage.exists():
             text = logPage.get()
         else:
-            #make new log page
+            # make new log page
             showStatus()
             pywikibot.output(
                 'Log page is not exist, getting information for page creation')
@@ -637,14 +649,14 @@
             luser = pywikibot.url2link(result.name(), self.site, self.site)
             text += u'\n{{WLE|user=%s|contribs=%d}}' % (
                 luser, result.editCount())
-        #update log page.
+        # update log page.
         while True:
             try:
                 logPage.put(text, i18n.twtranslate(self.site,
                                                    'welcome-updating'))
                 return True
             except pywikibot.EditConflict:
-                pywikibot.output(u'An edit conflict has occured. Pausing for '
+                pywikibot.output(u'An edit conflict has occurred. Pausing for '
                                  u'10 seconds before continuing.')
                 time.sleep(10)
 
@@ -806,8 +818,6 @@
                     pywikibot.output(u'%s might be a global bot!'
                                      % users.name())
                     continue
-                #if globalvar.offset != 0 and 
time.strptime(users.registrationTime(), "%Y-%m-%dT%H:%M:%SZ") >= 
globalvar.offset:
-                #
                 if users.editCount() >= globalvar.attachEditCount:
                     showStatus(2)
                     pywikibot.output(u'%s has enough edits to be welcomed.'
@@ -824,15 +834,15 @@
                             continue
                         welcome_text = pywikibot.translate(self.site, netext)
                         if globalvar.randomSign:
-                            if self.site.family != 'wikinews':
+                            if self.site.family.name != 'wikinews':
                                 welcome_text = (welcome_text
                                                 % choice(self.defineSign()))
-                            if self.site.family == 'wiktionary' and \
+                            if self.site.family.name == 'wiktionary' and \
                                self.site.lang == 'it':
                                 pass
                             else:
                                 welcome_text += timeselected
-                        elif (self.site.family != 'wikinews' and
+                        elif (self.site.family.name != 'wikinews' and
                               self.site.lang != 'it'):
                             welcome_text = (welcome_text
                                             % globalvar.defaultSign)
@@ -842,7 +852,7 @@
                         welcome_comment = i18n.twtranslate(self.site,
                                                            'welcome-welcome')
                         try:
-                            #append welcomed, welcome_count++
+                            # append welcomed, welcome_count++
                             ustp.put(welcome_text, welcome_comment,
                                      minorEdit=False)
                             welcomed_count += 1
@@ -850,7 +860,7 @@
                             self.welcomed_users.append(users)
                         except pywikibot.EditConflict:
                             showStatus(4)
-                            pywikibot.output(u'An edit conflict has occured, '
+                            pywikibot.output(u'An edit conflict has occurred, '
                                              u'skipping this user.')
 
                     if globalvar.makeWelcomeLog and \
@@ -917,24 +927,11 @@
                 else:
                     raise KeyboardInterrupt
             except KeyboardInterrupt:
-                #if globalvar.makeWelcomeLog and len(self.welcomed_users) > 0:
-                #    pywikibot.output("Update log before qutting script.")
-                #    self.makelogpage(self.welcomed_users)
-                #if hasattr(self, '_BAQueue') and len(self._BAQueue) > 0 and 
globalvar.filtBadName:
-                #    self.reportBadAccount(None, final = True)
                 break
-    #if __name__ != '__main__':
-    #    globalvar.offset = int(time.strftime("%Y%m%d%H%M%S", time.gmtime()))
-    #
-    #    def putName(nm):
-    #
-    #        self._checkQueue.append(name)
-    #        if len(self._checkQueue) >= globalvar.dumpToLog:
-    #            self.run()
-    #            self._checkQueue = []
 
 
 def showStatus(n=0):
+    """Output colorized status."""
     staColor = {
         0: 'lightpurple',
         1: 'lightaqua',
@@ -956,7 +953,7 @@
 
 
 def load_word_function(raw):
-    """ This is a function used to load the badword and the whitelist."""
+    """Load the badword list and the whitelist."""
     page = re.compile(r"(?:\"|\')(.*?)(?:\"|\')(?:, |\))", re.UNICODE)
     list_loaded = page.findall(raw)
     if len(list_loaded) == 0:
@@ -965,7 +962,16 @@
 
 globalvar = Global()
 
-if __name__ == "__main__":
+
+def main(*args):
+    """
+    Process command line arguments and invoke bot.
+
+    If args is an empty list, sys.argv is used.
+
+    @param args: command line arguments
+    @type args: list of unicode
+    """
     try:
         number_user = 0
         for arg in pywikibot.handleArgs():
@@ -1069,3 +1075,5 @@
             cPickle.dump(bot.welcomed_users, f)
             f.close()
         pywikibot.stopme()
+if __name__ == "__main__":
+    main()

-- 
To view, visit https://gerrit.wikimedia.org/r/231894
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If5cd8d3febaa9601c5d85aeea28bf0218db995e7
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Xqt <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to