jenkins-bot has submitted this change and it was merged.
Change subject: Fix some indentation issues ......................................................................
Fix some indentation issues
E111 indentation is not a multiple of four E112 expected an indented block E113 unexpected indentation
Change-Id: I017555315f266aeb851fb874e0224be6013ed038 --- M pywikibot/__init__.py M pywikibot/bot.py M pywikibot/botirc.py M pywikibot/comms/threadedhttp.py M pywikibot/site.py M pywikibot/throttle.py M scripts/checkimages.py M scripts/interwiki.py M scripts/redirect.py M scripts/unusedfiles.py M tests/site_tests.py 11 files changed, 91 insertions(+), 72 deletions(-)
Approvals: Siebrand: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py index ec27878..ff2f61a 100644 --- a/pywikibot/__init__.py +++ b/pywikibot/__init__.py @@ -519,7 +519,8 @@
def remaining(): remainingPages = page_put_queue.qsize() - 1 - # -1 because we added a None element to stop the queue + # -1 because we added a None element to stop the queue + remainingSeconds = datetime.timedelta( seconds=(remainingPages * config.put_throttle)) return (remainingPages, remainingSeconds) diff --git a/pywikibot/bot.py b/pywikibot/bot.py index 7beda63..e8487e2 100644 --- a/pywikibot/bot.py +++ b/pywikibot/bot.py @@ -16,7 +16,8 @@
import logging import logging.handlers - # all output goes thru python std library "logging" module +# all output goes thru python std library "logging" module + import os import os.path import sys @@ -188,12 +189,14 @@ moduleName = "terminal-interface"
logging.addLevelName(VERBOSE, "VERBOSE") - # for messages to be displayed on terminal at "verbose" setting - # use INFO for messages to be displayed even on non-verbose setting + # for messages to be displayed on terminal at "verbose" setting + # use INFO for messages to be displayed even on non-verbose setting + logging.addLevelName(STDOUT, "STDOUT") - # for messages to be displayed to stdout + # for messages to be displayed to stdout + logging.addLevelName(INPUT, "INPUT") - # for prompts requiring user response + # for prompts requiring user response
root_logger = logging.getLogger("pywiki") root_logger.setLevel(DEBUG + 1) # all records except DEBUG go to logger diff --git a/pywikibot/botirc.py b/pywikibot/botirc.py index d374a93..9a7073c 100644 --- a/pywikibot/botirc.py +++ b/pywikibot/botirc.py @@ -19,7 +19,8 @@
import logging.handlers - # all output goes thru python std library "logging" module +# all output goes thru python std library "logging" module + import re
from ircbot import SingleServerIRCBot diff --git a/pywikibot/comms/threadedhttp.py b/pywikibot/comms/threadedhttp.py index 38636cd..1acb1b0 100644 --- a/pywikibot/comms/threadedhttp.py +++ b/pywikibot/comms/threadedhttp.py @@ -358,35 +358,36 @@
# Metaweb Technologies, Inc. License: - # ======================================================================== - # The following dummy classes are: - # ======================================================================== - # Copyright (c) 2007, Metaweb Technologies, Inc. - # All rights reserved. - # - # Redistribution and use in source and binary forms, with or without - # modification, are permitted provided that the following conditions - # are met: - # * Redistributions of source code must retain the above copyright - # notice, this list of conditions and the following disclaimer. - # * Redistributions in binary form must reproduce the above - # copyright notice, this list of conditions and the following - # disclaimer in the documentation and/or other materials provided - # with the distribution. - # - # THIS SOFTWARE IS PROVIDED BY METAWEB TECHNOLOGIES AND CONTRIBUTORS - # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL METAWEB - # TECHNOLOGIES OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - # POSSIBILITY OF SUCH DAMAGE. - # ======================================================================== +# +# ======================================================================== +# The following dummy classes are: +# ======================================================================== +# Copyright (c) 2007, Metaweb Technologies, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY METAWEB TECHNOLOGIES AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL METAWEB +# TECHNOLOGIES OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# ========================================================================
class DummyRequest(object): """Simulated urllib2.Request object for httplib2 diff --git a/pywikibot/site.py b/pywikibot/site.py index c5d647f..ef20492 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -1341,7 +1341,7 @@ # no "pages" element indicates a circular redirect raise pywikibot.CircularRedirect(redirmap[title]) pagedata = list(result['query']['pages'].values())[0] - # there should be only one value in 'pages', and it is the target + # there should be only one value in 'pages', and it is the target if self.sametitle(pagedata['title'], target_title): target = pywikibot.Page(self, pagedata['title'], pagedata['ns']) api.update_page(target, pagedata) @@ -1391,13 +1391,13 @@ pywikibot.debug(u"Preloading %s" % pagedata, _logger) try: if pagedata['title'] not in cache: -# API always returns a "normalized" title which is -# usually the same as the canonical form returned by -# page.title(), but sometimes not (e.g., -# gender-specific localizations of "User" namespace). -# This checks to see if there is a normalized title in -# the response that corresponds to the canonical form -# used in the query. + # API always returns a "normalized" title which is + # usually the same as the canonical form returned by + # page.title(), but sometimes not (e.g., + # gender-specific localizations of "User" namespace). + # This checks to see if there is a normalized title in + # the response that corresponds to the canonical form + # used in the query. for key in cache: if self.sametitle(key, pagedata['title']): cache[pagedata['title']] = cache[key] diff --git a/pywikibot/throttle.py b/pywikibot/throttle.py index 4e56464..aebeb94 100644 --- a/pywikibot/throttle.py +++ b/pywikibot/throttle.py @@ -19,10 +19,12 @@
_logger = "wiki.throttle"
-pid = False # global process identifier - # when the first Throttle is instantiated, it will set this - # variable to a positive integer, which will apply to all - # throttle objects created by this process. +# global process identifier +# +# When the first Throttle is instantiated, it will set this variable to a +# positive integer, which will apply to all throttle objects created by this +# process. +pid = False
class Throttle(object): @@ -52,10 +54,16 @@ self.last_read = 0 self.last_write = 0 self.next_multiplicity = 1.0 - self.checkdelay = 300 # Check logfile again after this many seconds - self.dropdelay = 600 # Ignore processes that have not made - # a check in this many seconds - self.releasepid = 1200 # Free the process id after this many seconds + + # Check logfile again after this many seconds: + self.checkdelay = 300 + + # Ignore processes that have not made a check in this many seconds: + self.dropdelay = 600 + + # Free the process id after this many seconds: + self.releasepid = 1200 + self.lastwait = 0.0 self.delay = 0 self.checktime = 0 @@ -94,8 +102,8 @@ ptime = int(line[1].split('.')[0]) this_site = line[2].rstrip() except (IndexError, ValueError): - continue # Sometimes the file gets corrupted - # ignore that line + # Sometimes the file gets corrupted ignore that line + continue if now - ptime > self.releasepid: continue # process has expired, drop from file if now - ptime <= self.dropdelay \ @@ -208,8 +216,8 @@ ptime = int(line[1].split('.')[0]) this_site = line[2].rstrip() except (IndexError, ValueError): - continue # Sometimes the file gets corrupted - # ignore that line + # Sometimes the file gets corrupted ignore that line + continue if now - ptime <= self.releasepid \ and this_pid != pid: processes.append({'pid': this_pid, diff --git a/scripts/checkimages.py b/scripts/checkimages.py index 2e69333..64ae192 100644 --- a/scripts/checkimages.py +++ b/scripts/checkimages.py @@ -1450,10 +1450,12 @@
if self.allLicenses: self.license_found = self.allLicenses[0].title() - self.some_problem = False # If it has "some_problem" it must check - # the additional settings. - # if self.settingsData, use addictional settings + + # If it has "some_problem" it must check the additional settings. + self.some_problem = False + if self.settingsData: + # use additional settings self.findAdditionalProblems()
if self.some_problem: @@ -1601,9 +1603,9 @@ newGen.append(imageData[0]) return newGen else: -## pywikibot.output( -## u"The wait option is available only with the standard " -## u"generator.") + #pywikibot.output( + # u"The wait option is available only with the standard " + # u"generator.") pywikibot.output( u"The wait option is not available at core yet.") return generator diff --git a/scripts/interwiki.py b/scripts/interwiki.py index 019b478..772ef0e 100755 --- a/scripts/interwiki.py +++ b/scripts/interwiki.py @@ -2370,10 +2370,11 @@ useFrom = False
if adding or removing or modifying: - #Version info marks bots without unicode error - #This also prevents abuse filter blocking on de-wiki -## if not pywikibot.unicode_error: -## mcomment += u'r%s) (' % sys.version.split()[0] + # Version info marks bots without unicode error + # This also prevents abuse filter blocking on de-wiki + + #if not pywikibot.unicode_error: + # mcomment += u'r%s) (' % sys.version.split()[0]
mcomment += globalvar.summary
diff --git a/scripts/redirect.py b/scripts/redirect.py index a4b625d..80de7bb 100755 --- a/scripts/redirect.py +++ b/scripts/redirect.py @@ -129,7 +129,7 @@ if target.startswith('%s:' % code) \ or target.startswith(':%s:' % code): if code == self.site.language(): - # link to our wiki, but with the lang prefix + # link to our wiki, but with the lang prefix target = target[(len(code) + 1):] if target.startswith(':'): target = target[1:] @@ -777,15 +777,17 @@ elif arg.startswith('-namespace:'): ns = arg[11:] if ns == '': - ## "-namespace:" does NOT yield -namespace:0 further down the road! + # "-namespace:" does NOT yield -namespace:0 further down the road! ns = i18n.input('pywikibot-enter-namespace-number') -# TODO! at least for some generators enter a namespace by its name or number + # TODO! at least for some generators enter a namespace by its name + # or number if ns == '': ns = '0' try: ns = int(ns) except ValueError: -#-namespace:all Process all namespaces. Works only with the API read interface. + # -namespace:all Process all namespaces. + # Only works with the API read interface. pass if ns not in namespaces: namespaces.append(ns) diff --git a/scripts/unusedfiles.py b/scripts/unusedfiles.py index 9529e70..86628f9 100644 --- a/scripts/unusedfiles.py +++ b/scripts/unusedfiles.py @@ -122,7 +122,7 @@ usertalkname = 'User Talk:%s' % uploader usertalkpage = pywikibot.Page(mysite, usertalkname) msg2uploader = template_user % {'title': page.title()} - # msg2uploader = msg2uploader.encode("utf-8") + # msg2uploader = msg2uploader.encode("utf-8") appendtext(usertalkpage, msg2uploader) if __name__ == "__main__": main() diff --git a/tests/site_tests.py b/tests/site_tests.py index 739d103..f70ef0e 100644 --- a/tests/site_tests.py +++ b/tests/site_tests.py @@ -106,7 +106,7 @@ ns = mysite.namespaces() self.assertType(ns, dict) self.assertTrue(all(x in ns for x in range(0, 16))) - # built-in namespaces always present + # built-in namespaces always present self.assertType(mysite.ns_normalize("project"), basestring) self.assertTrue(all(isinstance(key, int) for key in ns))
pywikibot-commits@lists.wikimedia.org