Xqt has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405584 )

Change subject: [IMPR] Simplify startswith/endswith code
......................................................................

[IMPR] Simplify startswith/endswith code

startswith or endswith prefix may be a tuple since py 2.5

Change-Id: Ia70e78a67352574d3031ce6c9851bf6ec5213714
---
M pywikibot/family.py
M scripts/checkimages.py
M scripts/delete.py
M scripts/weblinkchecker.py
4 files changed, 8 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/84/405584/1

diff --git a/pywikibot/family.py b/pywikibot/family.py
index 317b73c..0dae080 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 """Objects representing MediaWiki families."""
 #
-# (C) Pywikibot team, 2004-2017
+# (C) Pywikibot team, 2004-2018
 #
 # Distributed under the terms of the MIT license.
 #
@@ -937,7 +937,7 @@
         if fam in config.family_files:
             family_file = config.family_files[fam]
 
-            if family_file.startswith('http://') or 
family_file.startswith('https://'):
+            if family_file.startswith(('http://', 'https://')):
                 myfamily = AutoFamily(fam, family_file)
                 Family._families[fam] = myfamily
                 return Family._families[fam]
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index 99ef506..02b340e 100755
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -80,7 +80,7 @@
 # (C) Kyle/Orgullomoore, 2006-2007 (newimage.py)
 # (C) Siebrand Mazeland, 2007-2010
 # (C) Filnik, 2007-2011
-# (C) Pywikibot team, 2007-2017
+# (C) Pywikibot team, 2007-2018
 #
 # Distributed under the terms of the MIT license.
 #
@@ -1581,7 +1581,7 @@
                     u'How many files do you want to check?'))
             else:
                 limit = int(arg[7:])
-        if arg.startswith('-sleep') or arg.startswith('-time'):
+        if arg.startswith(('-sleep', '-time')):
             if arg.startswith('-sleep'):
                 length = len('-sleep')
             else:
diff --git a/scripts/delete.py b/scripts/delete.py
index 359c588..57e99fe 100755
--- a/scripts/delete.py
+++ b/scripts/delete.py
@@ -49,7 +49,7 @@
     python pwb.py delete -cat:"To delete" -always
 """
 #
-# (C) Pywikibot team, 2017
+# (C) Pywikibot team, 2017-2018
 #
 # Distributed under the terms of the MIT license.
 #
@@ -267,7 +267,7 @@
         if not summary:
             un = 'un' if 'undelete' in options else ''
             if pageName:
-                if arg.startswith('-cat') or arg.startswith('-subcats'):
+                if arg.startswith(('-cat', '-subcats')):
                     summary = i18n.twtranslate(mysite, 'delete-from-category',
                                                {'page': pageName})
                 elif arg.startswith('-links'):
diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py
index 54ac583..bc73f08 100755
--- a/scripts/weblinkchecker.py
+++ b/scripts/weblinkchecker.py
@@ -99,7 +99,7 @@
 """
 #
 # (C) Daniel Herding, 2005
-# (C) Pywikibot team, 2005-2017
+# (C) Pywikibot team, 2005-2018
 #
 # Distributed under the terms of the MIT license.
 #
@@ -442,8 +442,7 @@
                 except UnicodeError:
                     redirTarget = redirTarget.decode(
                         self.getEncodingUsedByServer())
-                if redirTarget.startswith('http://') or \
-                   redirTarget.startswith('https://'):
+                if redirTarget.startswith(('http://', 'https://')):
                     self.changeUrl(redirTarget)
                     return True
                 elif redirTarget.startswith('/'):

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia70e78a67352574d3031ce6c9851bf6ec5213714
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
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