Revision: 4137 Author: btongminh Date: 2007-08-29 20:01:51 +0000 (Wed, 29 Aug 2007)
Log Message: ----------- New config setting: template_threshold.
Modified Paths: -------------- trunk/pywikipedia/delinker.py trunk/pywikipedia/delinker.txt
Modified: trunk/pywikipedia/delinker.py =================================================================== --- trunk/pywikipedia/delinker.py 2007-08-29 19:56:26 UTC (rev 4136) +++ trunk/pywikipedia/delinker.py 2007-08-29 20:01:51 UTC (rev 4137) @@ -396,7 +396,7 @@ http_callback = wait_callback, no_db = True) - def check_usage(self, image, timestamp, admin, reason, replacement): + def check_usage(self, image, timestamp, admin, reason, replacement, namespace = None): """ Check whether this image needs to be delinked. """ # Check whether the image still is deleted on Commons. @@ -420,7 +420,7 @@ if self.CommonsDelinker.config['global']: - usage = self.CheckUsage.get_usage(image) + usage = self.CheckUsage.get_usage(image, namespace = namespace) usage_domains = {} count = 0 @@ -434,12 +434,15 @@ #FIX! usage_domains = {(self.site.lang, self.site.family.name): list(self.CheckUsage.get_usage_live(self.site, - image))} + image, namespace = namespace))} count = len(usage_domains[(self.site.lang, self.site.family.name)]) output(u'%s %s used on %s pages' % (self, image, count)) if count: + if count > self.CommonsDelinker.config.get('template_threshold', sys.maxint): + output('%s Only delinking %s from template namespace' % (self, image)) + return check_usage(image, timestamp, admin, reason, replacement, 10) # Pass the usage to the Delinker pool along with other arguments self.CommonsDelinker.Delinkers.append((image, usage_domains, timestamp, admin, reason, replacement))
Modified: trunk/pywikipedia/delinker.txt =================================================================== --- trunk/pywikipedia/delinker.txt 2007-08-29 19:56:26 UTC (rev 4136) +++ trunk/pywikipedia/delinker.txt 2007-08-29 20:01:51 UTC (rev 4137) @@ -95,6 +95,8 @@ * ''exclude_string = "no-delink"'': If this string is included in the deletion summary, the file is not delinked. * ''summary_cache = 3600'': Time before on-wiki settings are updated. +* ''template_threshold = 1000'': If more an image is used more often than this + value, only delink from the template namespace.
=== Replacer settings === Those variables only need to be set if the replacer is enabled.