Revision: 4040 Author: btongminh Date: 2007-08-13 21:41:28 +0000 (Mon, 13 Aug 2007)
Log Message: ----------- Fix stuff for reporting feature.
Modified Paths: -------------- trunk/pywikipedia/delinker.py trunk/pywikipedia/delinker.txt trunk/pywikipedia/image_replacer.py
Modified: trunk/pywikipedia/delinker.py =================================================================== --- trunk/pywikipedia/delinker.py 2007-08-13 21:05:24 UTC (rev 4039) +++ trunk/pywikipedia/delinker.py 2007-08-13 21:41:28 UTC (rev 4040) @@ -452,6 +452,8 @@ # Pass the usage to the Delinker pool along with other arguments self.CommonsDelinker.Delinkers.append((image, usage_domains, timestamp, admin, reason, replacement)) + elif replacement: + self.CommonsDelinker.Loggers.append((timestamp, image, replacement)) def do(self, args): try:
Modified: trunk/pywikipedia/delinker.txt =================================================================== --- trunk/pywikipedia/delinker.txt 2007-08-13 21:05:24 UTC (rev 4039) +++ trunk/pywikipedia/delinker.txt 2007-08-13 21:41:28 UTC (rev 4040) @@ -245,6 +245,10 @@ CommonsDelinker['clean_list'] = False CommonsDelinker['disallowed_replacements'] = [(r'.png$', r'.svg$')]
+CommonsDelinker['replacer_report_replacements'] = False +CommonsDelinker['replacer_report_template'] = 'universally replaced' + + ## SQL connection information. # Database engine to use. Currently supported: MySQL, sqlite3. # Global delinker requires MySQL.
Modified: trunk/pywikipedia/image_replacer.py =================================================================== --- trunk/pywikipedia/image_replacer.py 2007-08-13 21:05:24 UTC (rev 4039) +++ trunk/pywikipedia/image_replacer.py 2007-08-13 21:41:28 UTC (rev 4040) @@ -31,9 +31,8 @@ def site_prefix(site): if site.lang == site.family.name: return site.lang - # TODO: fix - #if (site.lang, site.family.name) == ('-', 'wikisource'): - # return 'wikisource' + if (site.lang, site.family.name) == ('-', 'wikisource'): + return 'oldwikisource' return '%s:%s' % (site.family.name, site.lang)
class Replacer(object): @@ -52,7 +51,7 @@ self.first_revision = 0 if self.config.get('replacer_report_replacements', False): - self.reporters = threadpool.ThreadPool(self.reporter) + self.reporters = threadpool.ThreadPool(Reporter) self.reporters.add_thread(self.site, self.config) @@ -113,8 +112,8 @@ for timestamp, user, text in revisions[1:]: if replacement.group(0) in text and user != username: db_time = db_timestamp(timestamp) - if db_time < self.first_revision or not revision: - self.first_revision = db_time + if db_time < self.first_revision or not self.first_revision: + self.first_revision = int(db_time) return (db_time, strip_image(replacement.group(1)), strip_image(replacement.group(2)), user, replacement.group(3)) @@ -137,7 +136,7 @@ for old_image, new_image, user, comment in finished_images: self.cursor.execute("""SELECT wiki, namespace, page_title FROM %s WHERE img = %%s AND status <> 'ok'""" % - self.config['delinker_table'], (old_image, )) + self.config['log_table'], (old_image, )) not_ok = list(self.cursor) self.reporters.append((old_image, new_image, user, @@ -161,11 +160,11 @@ return True
class Reporter(threadpool.Thread): - def __init__(self, site, config): + def __init__(self, pool, site, config): self.site = site self.config = config - threadpool.Thread.__init__(self) + threadpool.Thread.__init__(self, pool) def do(self, (old_image, new_image, user, comment, not_ok)): not_ok_items = [] for wiki, namespace, page_title in not_ok:
pywikipedia-l@lists.wikimedia.org