jenkins-bot has submitted this change and it was merged.
Change subject: [PEP8] changes ......................................................................
[PEP8] changes
Change-Id: Id72f0267538d42e23b4db7ae1e3f9aea5bcf6611 --- M interwiki.py 1 file changed, 41 insertions(+), 31 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/interwiki.py b/interwiki.py index a100d5c..0f0e212 100644 --- a/interwiki.py +++ b/interwiki.py @@ -666,7 +666,8 @@ index = 1 while True: path = config.datafilepath('cache', 'pagestore' + str(index)) - if not os.path.exists(path): break + if not os.path.exists(path): + break index += 1 StoredPage.SPpath = path StoredPage.SPstore = shelve.open(path) @@ -1257,8 +1258,8 @@ """ # Loop over all the pages that should have been taken care of for page in self.pending: - if page.title == None: ### seems a DataPage - page.get() ### get it's title (and content) + if page.title is None: # seems a DataPage + page.get() # get it's title (and content) # Mark the page as done self.done.add(page)
@@ -1347,7 +1348,7 @@ pywikibot.output( u"NOTE: not following static %sredirects." % redir) elif page.site.family == redirectTargetPage.site.family \ - and not self.skipPage(page, redirectTargetPage, counter): + and not self.skipPage(page, redirectTargetPage, counter): if self.addIfNew(redirectTargetPage, counter, page): if config.interwiki_shownew or pywikibot.verbose: pywikibot.output(u"%s: %s gives new %sredirect %s" @@ -1426,21 +1427,26 @@ self.makeForcedStop(counter) try: f = codecs.open( - pywikibot.config.datafilepath('autonomous_problems.dat'), - 'a', 'utf-8') + pywikibot.config.datafilepath( + 'autonomous_problems.dat'), + 'a', 'utf-8') f.write(u"* %s {Found more than one link for %s}" % (self.originPage, page.site)) if config.interwiki_graph and config.interwiki_graph_url: - filename = interwiki_graph.getFilename(self.originPage, extension = config.interwiki_graph_formats[0]) - f.write(u" [%s%s graph]" % (config.interwiki_graph_url, filename)) + filename = interwiki_graph.getFilename( + self.originPage, + extension=config.interwiki_graph_formats[0]) + f.write(u" [%s%s graph]" + % (config.interwiki_graph_url, filename)) f.write("\n") f.close() # FIXME: What errors are we catching here? # except: should be avoided!! except: #raise - pywikibot.output(u'File autonomous_problems.dat open or corrupted! Try again with -restore.') - sys.exit() + pywikibot.output(u'File autonomous_problems.dat open or ' + u'corrupted! Try again with -restore.') + sys.exit() iw = () elif page.isEmpty() and not page.isCategory(): globalvar.remove.append(unicode(page)) @@ -1462,9 +1468,10 @@ if self.addIfNew(linkedPage, counter, page): # It is new. Also verify whether it is the second on the # same site - lpsite=linkedPage.site + lpsite = linkedPage.site for prevPage in self.foundIn: - if prevPage != linkedPage and prevPage.site == lpsite: + if prevPage != linkedPage and \ + prevPage.site == lpsite: # Still, this could be "no problem" as either may be a # redirect to the other. No way to find out quickly! pywikibot.output(u"NOTE: %s: %s gives duplicate interwiki on same site %s" @@ -1489,7 +1496,7 @@ """Return True if all the work for this subject has completed.""" return len(self.todo) == 0
- def problem(self, txt, createneed = True): + def problem(self, txt, createneed=True): """Report a problem with the resolution of this subject.""" pywikibot.output(u"ERROR: %s" % txt) self.confirm = True @@ -1503,7 +1510,6 @@ else: pywikibot.output(u" "*indent + unicode(page2))
- def assemble(self): # No errors have been seen so far, except.... errorCount = self.problemfound @@ -1512,11 +1518,13 @@ # Each value will be a list of pages. new = {} for page in self.done: - if page.exists() and not page.isRedirectPage() and not page.isCategoryRedirect(): + if page.exists() and not page.isRedirectPage() and \ + not page.isCategoryRedirect(): site = page.site if site.family.interwiki_forward: - #TODO: allow these cases to be propagated! - continue # inhibit the forwarding families pages to be updated. + # TODO: allow these cases to be propagated! + # inhibit the forwarding families pages to be updated. + continue if site == self.originPage.site: if page != self.originPage: self.problem(u"Found link to %s" % page) @@ -1560,7 +1568,7 @@ i += 1 pywikibot.output(u" (%d) Found link to %s in:" % (i, page2)) - self.whereReport(page2, indent = 8) + self.whereReport(page2, indent=8) while True: #TODO: allow answer to repeat previous or go back after a mistake answer = pywikibot.input(u"Which variant should be used? (<number>, [n]one, [g]ive up) ").lower() @@ -1588,7 +1596,7 @@ pywikibot.output(u"=" * 30) page2 = pages[0] pywikibot.output(u"Found link to %s in:" % page2) - self.whereReport(page2, indent = 4) + self.whereReport(page2, indent=4) while True: if acceptall: answer = 'a' @@ -1627,7 +1635,7 @@ return if not self.untranslated and globalvar.untranslatedonly: return - if self.forcedStop: # autonomous with problem + if self.forcedStop: # autonomous with problem pywikibot.output(u"======Aborted processing %s======" % self.originPage) return @@ -1696,7 +1704,7 @@ (len(modifying) > 0 and self.problemfound) or \ len(old) == 0 or \ (globalvar.needlimit and - len(adding) + len(modifying) >= globalvar.needlimit + 1): + len(adding) + len(modifying) >= globalvar.needlimit + 1): try: if self.replaceLinks(new[site], new): updatedSites.append(site) @@ -1722,7 +1730,7 @@ if smallWikiAllowed and globalvar.autonomous and \ (page.site.sitename() == 'wikipedia:is' or page.site.sitename() == 'wikipedia:zh' and - page.namespace() == 10): + page.namespace() == 10): old = {} try: for mypage in new[page.site].interwiki(): @@ -1742,19 +1750,20 @@ if not smallWikiAllowed: import userlib user = userlib.User(page.site, page.userName()) - if not 'bot' in user.groups() \ - and not 'bot' in page.userName().lower(): #erstmal auch keine namen mit bot + if not ('bot' in user.groups() or + # ignore account names containing 'bot' (yet) + 'bot' in page.userName().lower()): smallWikiAllowed = True else: _now = datetime.datetime.utcnow() - _editTime = datetime.datetime.strptime(str(page.editTime()), - "%Y%m%d%H%M%S") + _editTime = datetime.datetime.strptime( + str(page.editTime()), "%Y%m%d%H%M%S") if abs((_now - _editTime).days) > 30: smallWikiAllowed = True else: pywikibot.output( - u'NOTE: number of edits are restricted at %s' - % page.site.sitename()) + u'NOTE: number of edits are restricted at ' + u'%s' % page.site.sitename())
# if we have an account for this site if site.family.name in config.usernames and \ @@ -1862,7 +1871,8 @@ pltmp = new[page.site] if pltmp != page: s = u"None" - if pltmp is not None: s = pltmp + if pltmp is not None: + s = pltmp pywikibot.output( u"BUG>>> %s is not in the list of new links! Found %s." % (page, s)) @@ -1993,7 +2003,7 @@ if answer == 'y': if not globalvar.quiet or pywikibot.verbose: pywikibot.output(u"NOTE: Updating live wiki...") - timeout=60 + timeout = 60 while True: try: if dp: @@ -2021,7 +2031,7 @@ pywikibot.error(u'putting page: %s' % (error.args,)) raise SaveError(u'PageNotSaved') except (socket.error, IOError), error: - if timeout>3600: + if timeout > 3600: raise pywikibot.error(u'putting page: %s' % (error.args,)) pywikibot.output(u'Sleeping %i seconds before trying again.'
pywikibot-commits@lists.wikimedia.org