jenkins-bot has submitted this change and it was merged. ( 
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
M tests/utils.py
5 files changed, 11 insertions(+), 11 deletions(-)

Approvals:
  Dalba: Looks good to me, approved
  jenkins-bot: Verified



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('/'):
diff --git a/tests/utils.py b/tests/utils.py
index e3c6526..8ebce88 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -259,8 +259,9 @@
             # Ignore socket IO warnings (T183696, T184996)
             if (PYTHON_VERSION >= (3, 2)
                     and issubclass(warn_msg.category, ResourceWarning)
-                    and any(str(warn_msg.message).startswith(msg) for msg in (
-                    'unclosed <ssl.SSLSocket', 'unclosed <socket.socket'))):
+                    and str(warn_msg.message).startswith(
+                        ('unclosed <ssl.SSLSocket',
+                         'unclosed <socket.socket'))):
                 return
 
             log.append(warn_msg)

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia70e78a67352574d3031ce6c9851bf6ec5213714
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <i...@gno.de>
Gerrit-Reviewer: Dalba <dalba.w...@gmail.com>
Gerrit-Reviewer: Framawiki <framaw...@tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jay...@gmail.com>
Gerrit-Reviewer: Xqt <i...@gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to