Mpaa has uploaded a new change for review.

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


Change subject: Rewritten handling of generic integer arguments
......................................................................

Rewritten handling of generic integer arguments

Change-Id: Ic45856cc7ec894da67d97f75a38638b0806e5db4
---
M pywikibot/bot.py
1 file changed, 10 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/39/87639/1

diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 8aaa050..c8ee10e 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -622,18 +622,15 @@
             import daemonize
             daemonize.daemonize(redirect_std=arg[11:])
         else:
-            # the argument depends numerical config settings
-            cmd = []
-            if ':' in arg:
-                cmd = arg[1:].split(':')
-            if len(cmd) == 2 and len(cmd[1]) > 0 and \
-               hasattr(config, cmd[0]) and \
-               type(getattr(config, cmd[0])) == int:
-                setattr(config, cmd[0], cmd[1])
-            # the argument is not global. Let the specific bot script care
-            # about it.
-            else:
+            # the argument depends on numerical config settings
+            try:
+                _arg, _val = arg[1:].split(':')
+                if isinstance(getattr(config, _arg), int):
+                    setattr(config, _arg, int(_val))
+            except:
+            # argument not global -> specific bot script will take care
                 nonGlobalArgs.append(arg)
+            print getattr(config, _arg)
 
     if username:
         config.usernames[config.family][config.mylang] = username
@@ -647,7 +644,8 @@
         # have to - some git versions (like 1.7.0.4) seem to treat lines
         # containing just `$Id:` as if they were ident lines (see
         # gitattributes(5)) leading to unwanted behaviour like automatic
-        # replacement with `$Id$` or `$Id$`.
+        # replacement with `$Id$`
+        # or `$Id$`.
         m = re.search(r"\$Id"
                       r": (\w+) \$", ver)
         pywikibot.output(u'Pywikipediabot r%s' % m.group(1))

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic45856cc7ec894da67d97f75a38638b0806e5db4
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <[email protected]>

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

Reply via email to