saper has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/175610

Change subject: Introduce config.days_dead insted of global day
......................................................................

Introduce config.days_dead insted 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, 10 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/compat 
refs/changes/10/175610/1

diff --git a/config.py b/config.py
index 50fafa2..3d53166 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
+days_dead = 7
+
 ############## DATABASE SETTINGS ##############
 db_hostname = 'localhost'
 db_username = 'wikiuser'
diff --git a/weblinkchecker.py b/weblinkchecker.py
index e7f2a90..cc36b81 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.
@@ -500,7 +501,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.days_dead)
 
 
 class History:
@@ -570,7 +571,7 @@
             self.reportThread.report(url, errorReport, containingPage,
                                      archiveURL)
 
-    def setLinkDead(self, url, error, page, day):
+    def setLinkDead(self, url, error, page, days_dead):
         """
         Adds the fact that the link was found dead to the .dat file.
         """
@@ -586,7 +587,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 * days_dead:
                 # search for archived page
                 archiveURL = pywikibot.weblib.getInternetArchiveURL(self.site, 
url)
                 if archiveURL is None:
@@ -806,8 +807,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 +822,7 @@
         elif arg.startswith('-ignore:'):
             HTTPignore.append(int(arg[8:]))
         elif arg.startswith('-day:'):
-            day = int(arg[5:])
+            config.days_dead = int(arg[5:])
         elif arg.startswith('-xmlstart'):
             if len(arg) == 9:
                 xmlStart = pywikibot.input(

-- 
To view, visit https://gerrit.wikimedia.org/r/175610
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic95c31ecc7dbb557db8319b5857a4e94e4347db6
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: saper <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to