jenkins-bot has submitted this change and it was merged.
Change subject: Introduce config.weblink_dead_days instead of global day ......................................................................
Introduce config.weblink_dead_days instead of global day
Using "global day" prevents from importing linkchecker classes into another script.
Rename the variable and add it to 'config.py'
Change-Id: Ic95c31ecc7dbb557db8319b5857a4e94e4347db6 --- M config.py M weblinkchecker.py 2 files changed, 13 insertions(+), 8 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/config.py b/config.py index 50fafa2..19f8369 100644 --- a/config.py +++ b/config.py @@ -336,6 +336,9 @@
report_dead_links_on_talk = False
+# Don't alert on links days_dead old or younger +weblink_dead_days = 7 + ############## DATABASE SETTINGS ############## db_hostname = 'localhost' db_username = 'wikiuser' diff --git a/weblinkchecker.py b/weblinkchecker.py index e7f2a90..501e01d 100644 --- a/weblinkchecker.py +++ b/weblinkchecker.py @@ -51,8 +51,9 @@
-notalk Overrides the report_dead_links_on_talk config variable, disabling the feature. --day the first time found dead link longer than x day ago, it should - probably be fixed or removed. if no set, default is 7 day. + +-day Do not report broken link if the link is there only since + x days or less. If not set, the default is 7 days.
All other parameters will be regarded as part of the title of a single page, and the bot will only work on that single page. @@ -71,6 +72,9 @@ links on the article's talk page if (and ONLY if) the linked page has been unavailable at least two times during a timespan of at least one week. + +weblink_dead_days - sets the timespan (default: one week) after which + a dead link will be reported
Syntax examples: python weblinkchecker.py -start:! @@ -500,7 +504,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, config.weblink_dead_days)
class History: @@ -570,7 +574,7 @@ self.reportThread.report(url, errorReport, containingPage, archiveURL)
- def setLinkDead(self, url, error, page, day): + def setLinkDead(self, url, error, page, weblink_dead_days): """ Adds the fact that the link was found dead to the .dat file. """ @@ -586,7 +590,7 @@ # if the first time we found this link longer than x day ago # (default is a week), it should probably be fixed or removed. # We'll list it in a file so that it can be removed manually. - if timeSinceFirstFound > 60 * 60 * 24 * day: + if timeSinceFirstFound > 60 * 60 * 24 * weblink_dead_days: # search for archived page archiveURL = pywikibot.weblib.getInternetArchiveURL(self.site, url) if archiveURL is None: @@ -806,8 +810,6 @@ # that are also used by other scripts and that determine on which pages # to work on. genFactory = pagegenerators.GeneratorFactory() - global day - day = 7 for arg in pywikibot.handleArgs(): if arg == '-talk': config.report_dead_links_on_talk = True @@ -823,7 +825,7 @@ elif arg.startswith('-ignore:'): HTTPignore.append(int(arg[8:])) elif arg.startswith('-day:'): - day = int(arg[5:]) + config.weblink_dead_days = int(arg[5:]) elif arg.startswith('-xmlstart'): if len(arg) == 9: xmlStart = pywikibot.input(
pywikibot-commits@lists.wikimedia.org