[MediaWiki-commits] [Gerrit] pywikibot/core[master]: [IMPR] code cleanup
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/395696 ) Change subject: [IMPR] code cleanup .. [IMPR] code cleanup - remove obsolete pass statements - fix dicstring in imageuncat.py - use context manager to open a file in solve_disambiguation.py Change-Id: I5d0c862a9cdb11ce4bd12d9d68b397b19c62d602 --- M pywikibot/date.py M pywikibot/page.py M pywikibot/throttle.py M scripts/cfd.py M scripts/imageuncat.py M scripts/makecat.py M scripts/redirect.py M scripts/solve_disambiguation.py M scripts/upload.py M scripts/welcome.py M tests/aspects.py M tests/ui_tests.py 12 files changed, 19 insertions(+), 40 deletions(-) Approvals: Dalba: Looks good to me, approved jenkins-bot: Verified diff --git a/pywikibot/date.py b/pywikibot/date.py index a9b0e39..f3ec6fb 100644 --- a/pywikibot/date.py +++ b/pywikibot/date.py @@ -7,7 +7,7 @@ # (C) Andre Engels, 2004-2005 # (C) Yuri Astrakhan, 2005-2006 (@gmail.com) # (years/decades/centuries/millenniums str <=> int conversions) -# (C) Pywikibot team, 2004-2016 +# (C) Pywikibot team, 2004-2017 # # Distributed under the terms of the MIT license. # @@ -377,10 +377,10 @@ decoders = [] for s in _reParameters.split(pattern): if s is None: -pass -elif (len(s) in (2, 3) and s[0] == '%' and - s[-1] in _digitDecoders and - (len(s) == 2 or s[1] in _decimalDigits)): +continue +if (len(s) in (2, 3) and s[0] == '%' and +s[-1] in _digitDecoders and +(len(s) == 2 or s[1] in _decimalDigits)): # Must match a "%2d" or "%d" style dec = _digitDecoders[s[-1]] if isinstance(dec, basestring): diff --git a/pywikibot/page.py b/pywikibot/page.py index ad87584..d9580b6 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -5978,6 +5978,5 @@ except UnicodeError as ex: if not firstException: firstException = ex -pass # Couldn't convert, raise the original exception raise firstException diff --git a/pywikibot/throttle.py b/pywikibot/throttle.py index 71c0da8..0f82b68 100644 --- a/pywikibot/throttle.py +++ b/pywikibot/throttle.py @@ -89,9 +89,7 @@ try: f = open(self.ctrlfilename, 'r') except IOError: -if not pid: -pass -else: +if pid: raise else: now = time.time() diff --git a/scripts/cfd.py b/scripts/cfd.py index b09db1f..7a56747 100755 --- a/scripts/cfd.py +++ b/scripts/cfd.py @@ -178,11 +178,7 @@ robot = CategoryMoveBot(oldcat=src, batch=True, comment=summary, deletion_comment=action_summary, inplace=True) -else: -# This line does not fit any of our regular expressions, -# so ignore it. -pass -if summary != "" and robot is not None: +if summary and robot is not None: pywikibot.stdout(summary) # Run, robot, run! robot.run() diff --git a/scripts/imageuncat.py b/scripts/imageuncat.py index 315f839..f285299 100755 --- a/scripts/imageuncat.py +++ b/scripts/imageuncat.py @@ -1294,7 +1294,7 @@ Add the uncat template to the page. @param page: Page to be modified -@rtype: Page +@type page: pywikibot.Page """ newtext = page.get() + puttext pywikibot.showDiff(page.get(), newtext) diff --git a/scripts/makecat.py b/scripts/makecat.py index c4c6f1b..0f647ad 100755 --- a/scripts/makecat.py +++ b/scripts/makecat.py @@ -79,7 +79,6 @@ pass except pywikibot.IsRedirectPage: cl = True -pass else: cats = [x for x in pl.categories()] if workingcat not in cats: diff --git a/scripts/redirect.py b/scripts/redirect.py index 4ce593a..4fd4448 100755 --- a/scripts/redirect.py +++ b/scripts/redirect.py @@ -291,7 +291,6 @@ pass except KeyError: result = None -pass yield (redirect, result, target, final) def retrieve_broken_redirects(self): @@ -513,10 +512,8 @@ pywikibot.warning( u'Redirect target %s is not a valid page title.' % str(e)[10:]) -pass except pywikibot.InvalidTitle: pywikibot.exception() -pass except pywikibot.NoPage: movedTarget = None try: @@ -611,8 +608,7 @@ u'Skipping: Redirect target %s is not a redirect.' % newRedir.title(asLink=True))
[MediaWiki-commits] [Gerrit] pywikibot/core[master]: [IMPR] code cleanup
Xqt has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/395696 ) Change subject: [IMPR] code cleanup .. [IMPR] code cleanup - remove obsolete pass statements - fix dicstring in imageuncat.py - use context manager to open a file in solve_disambiguation.py Change-Id: I5d0c862a9cdb11ce4bd12d9d68b397b19c62d602 --- M pywikibot/date.py M pywikibot/page.py M pywikibot/throttle.py M scripts/cfd.py M scripts/imageuncat.py M scripts/makecat.py M scripts/redirect.py M scripts/solve_disambiguation.py M scripts/upload.py M scripts/welcome.py M tests/aspects.py M tests/ui_tests.py 12 files changed, 20 insertions(+), 40 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core refs/changes/96/395696/1 diff --git a/pywikibot/date.py b/pywikibot/date.py index a9b0e39..f3ec6fb 100644 --- a/pywikibot/date.py +++ b/pywikibot/date.py @@ -7,7 +7,7 @@ # (C) Andre Engels, 2004-2005 # (C) Yuri Astrakhan, 2005-2006 (@gmail.com) # (years/decades/centuries/millenniums str <=> int conversions) -# (C) Pywikibot team, 2004-2016 +# (C) Pywikibot team, 2004-2017 # # Distributed under the terms of the MIT license. # @@ -377,10 +377,10 @@ decoders = [] for s in _reParameters.split(pattern): if s is None: -pass -elif (len(s) in (2, 3) and s[0] == '%' and - s[-1] in _digitDecoders and - (len(s) == 2 or s[1] in _decimalDigits)): +continue +if (len(s) in (2, 3) and s[0] == '%' and +s[-1] in _digitDecoders and +(len(s) == 2 or s[1] in _decimalDigits)): # Must match a "%2d" or "%d" style dec = _digitDecoders[s[-1]] if isinstance(dec, basestring): diff --git a/pywikibot/page.py b/pywikibot/page.py index ad87584..d9580b6 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -5978,6 +5978,5 @@ except UnicodeError as ex: if not firstException: firstException = ex -pass # Couldn't convert, raise the original exception raise firstException diff --git a/pywikibot/throttle.py b/pywikibot/throttle.py index 71c0da8..0f82b68 100644 --- a/pywikibot/throttle.py +++ b/pywikibot/throttle.py @@ -89,9 +89,7 @@ try: f = open(self.ctrlfilename, 'r') except IOError: -if not pid: -pass -else: +if pid: raise else: now = time.time() diff --git a/scripts/cfd.py b/scripts/cfd.py index b09db1f..7a56747 100755 --- a/scripts/cfd.py +++ b/scripts/cfd.py @@ -178,11 +178,7 @@ robot = CategoryMoveBot(oldcat=src, batch=True, comment=summary, deletion_comment=action_summary, inplace=True) -else: -# This line does not fit any of our regular expressions, -# so ignore it. -pass -if summary != "" and robot is not None: +if summary and robot is not None: pywikibot.stdout(summary) # Run, robot, run! robot.run() diff --git a/scripts/imageuncat.py b/scripts/imageuncat.py index 315f839..f285299 100755 --- a/scripts/imageuncat.py +++ b/scripts/imageuncat.py @@ -1294,7 +1294,7 @@ Add the uncat template to the page. @param page: Page to be modified -@rtype: Page +@type page: pywikibot.Page """ newtext = page.get() + puttext pywikibot.showDiff(page.get(), newtext) diff --git a/scripts/makecat.py b/scripts/makecat.py index c4c6f1b..0f647ad 100755 --- a/scripts/makecat.py +++ b/scripts/makecat.py @@ -79,7 +79,6 @@ pass except pywikibot.IsRedirectPage: cl = True -pass else: cats = [x for x in pl.categories()] if workingcat not in cats: diff --git a/scripts/redirect.py b/scripts/redirect.py index 4ce593a..4fd4448 100755 --- a/scripts/redirect.py +++ b/scripts/redirect.py @@ -291,7 +291,6 @@ pass except KeyError: result = None -pass yield (redirect, result, target, final) def retrieve_broken_redirects(self): @@ -513,10 +512,8 @@ pywikibot.warning( u'Redirect target %s is not a valid page title.' % str(e)[10:]) -pass except pywikibot.InvalidTitle: pywikibot.exception() -pass except pywikibot.NoPage: movedTarget = None try: @@ -611,8 +608,7 @@ u'Skipping: Redirect target %s is not a redirect.' % newRedir.title(asLink=True))