jenkins-bot has submitted this change and it was merged.
Change subject: remove global day, don't use mutable types as predefined arguments ......................................................................
remove global day, don't use mutable types as predefined arguments
Change-Id: Ia292eeddd9d519de076c763b4691756be46b1427 --- M scripts/weblinkchecker.py 1 file changed, 14 insertions(+), 13 deletions(-)
Approvals: John Vandenberg: Looks good to me, but someone else must approve Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py index c5a2086..f58c326 100644 --- a/scripts/weblinkchecker.py +++ b/scripts/weblinkchecker.py @@ -477,7 +477,7 @@ will die.
""" - def __init__(self, page, url, history, HTTPignore): + def __init__(self, page, url, history, HTTPignore, day): threading.Thread.__init__(self) self.page = page self.url = url @@ -486,6 +486,7 @@ self.setName((u'%s - %s' % (page.title(), url)).encode('utf-8', 'replace')) self.HTTPignore = HTTPignore + self.day = day
def run(self): linkChecker = LinkChecker(self.url, HTTPignore=self.HTTPignore) @@ -502,7 +503,7 @@ else: pywikibot.output('*[[%s]] links to %s - %s.' % (self.page.title(), self.url, message)) - self.history.setLinkDead(self.url, message, self.page, day) + self.history.setLinkDead(self.url, message, self.page, self.day)
class History: @@ -616,20 +617,18 @@ return False
def save(self): - """ - Saves the .dat file to disk. - """ + """ Saves the .dat file to disk. """ datfile = open(self.datfilename, 'w') pickle.dump(self.historyDict, datfile) datfile.close()
class DeadLinkReportThread(threading.Thread): - ''' + """ A Thread that is responsible for posting error reports on talk pages. There will only be one DeadLinkReportThread, and it is using a semaphore to make sure that two LinkCheckerThreads can not access the queue at the same time. - ''' + """ def __init__(self): threading.Thread.__init__(self) self.semaphore = threading.Semaphore() @@ -727,7 +726,7 @@ weblinks on pages provided by the given generator.
""" - def __init__(self, generator, HTTPignore=[]): + def __init__(self, generator, HTTPignore=None, day=7): self.generator = generator if config.report_dead_links_on_talk: #pywikibot.output("Starting talk page thread") @@ -738,7 +737,11 @@ else: reportThread = None self.history = History(reportThread) - self.HTTPignore = HTTPignore + if HTTPignore is None: + self.HTTPignore = [] + else: + self.HTTPignore = HTTPignore + self.day = day
def run(self): for page in self.generator: @@ -762,7 +765,7 @@ # wait 100 ms time.sleep(0.1) thread = LinkCheckThread(page, url, self.history, - self.HTTPignore) + self.HTTPignore, self.day) # thread dies when program terminates thread.setDaemon(True) thread.start() @@ -797,8 +800,6 @@
def main(): - global day - gen = None singlePageTitle = [] xmlFilename = None @@ -865,7 +866,7 @@ pageNumber = max(240, config.max_external_links * 2) gen = pagegenerators.PreloadingGenerator(gen, step=pageNumber) gen = pagegenerators.RedirectFilterPageGenerator(gen) - bot = WeblinkCheckerRobot(gen, HTTPignore) + bot = WeblinkCheckerRobot(gen, HTTPignore, day) try: bot.run() finally:
pywikibot-commits@lists.wikimedia.org