Xqt has uploaded a new change for review.

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

Change subject: [IMPR] Simplify arg parsing in handle_args method
......................................................................

[IMPR] Simplify arg parsing in handle_args method

- avoid length checking logic per argument

Change-Id: I5e517d7add5e3659fe797801bf9e129e258c610a
---
M scripts/casechecker.py
1 file changed, 17 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/90/270290/1

diff --git a/scripts/casechecker.py b/scripts/casechecker.py
index 06ee014..23adaa4 100755
--- a/scripts/casechecker.py
+++ b/scripts/casechecker.py
@@ -2,7 +2,7 @@
 # -*- coding: utf-8  -*-
 """Bot to find all pages on the wiki with mixed latin and cyrilic alphabets."""
 #
-# (C) Pywikibot team, 2006-2015
+# (C) Pywikibot team, 2006-2016
 #
 # Distributed under the terms of the MIT license.
 #
@@ -145,13 +145,12 @@
     def __init__(self):
 
         for arg in pywikibot.handle_args():
-            if arg.startswith('-from'):
-                if arg.startswith('-from:'):
-                    self.apfrom = arg[6:]
-                else:
-                    self.apfrom = pywikibot.input(u'Which page to start from: 
')
-            elif arg.startswith('-reqsize:'):
-                self.aplimit = int(arg[9:])
+            arg, sep, value = arg.partition(':')
+            if arg == '-from':
+                self.apfrom = value or pywikibot.input(
+                    'Which page to start from: ')
+            elif arg == '-reqsize':
+                self.aplimit = int(value)
             elif arg == '-links':
                 self.links = True
             elif arg == '-linksonly':
@@ -163,16 +162,16 @@
                 self.filterredir = 'all'
             elif arg == '-redironly':
                 self.filterredir = 'redirects'
-            elif arg.startswith('-limit:'):
-                self.stopAfter = int(arg[7:])
-            elif arg == '-autonomous' or arg == '-a':
+            elif == '-limit':
+                self.stopAfter = int(value)
+            elif arg in ('-autonomous', '-a'):
                 self.autonomous = True
-            elif arg.startswith('-ns:'):
-                self.namespaces.append(int(arg[4:]))
-            elif arg.startswith('-wikilog:'):
-                self.wikilogfile = arg[9:]
-            elif arg.startswith('-failedlog:'):
-                self.failedTitles = arg[11:]
+            elif arg == '-ns:':
+                self.namespaces.append(int(value))
+            elif arg == '-wikilog':
+                self.wikilogfile = value
+            elif arg == '-failedlog':
+                self.failedTitles = value
             elif arg == '-failed':
                 self.doFailed = True
             else:
@@ -261,7 +260,7 @@
 
         # TODO: handle "continue"
         if self.site.code in self.whitelists:
-            wlpage = self.whitelists[self.site.code]
+            wlpage = pywikibot.Page(self.site, self.whitelists[self.site.code])
             pywikibot.output(u'Loading whitelist from %s' % wlpage)
             wlparams = {
                 'action': 'query',

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5e517d7add5e3659fe797801bf9e129e258c610a
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <i...@gno.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to