Revision: 7165 Author: siebrand Date: 2009-08-20 20:53:10 +0000 (Thu, 20 Aug 2009)
Log Message: ----------- Revert r7131 in image_replacer.py. Caused:
[2009-08-20 20:46:48] Warning! Unable to read replacement log. [2009-08-20 20:46:48] UnboundLocalError: local variable 'response' referenced before assignment
Modified Paths: -------------- trunk/pywikipedia/commonsdelinker/image_replacer.py
Modified: trunk/pywikipedia/commonsdelinker/image_replacer.py =================================================================== --- trunk/pywikipedia/commonsdelinker/image_replacer.py 2009-08-20 20:44:49 UTC (rev 7164) +++ trunk/pywikipedia/commonsdelinker/image_replacer.py 2009-08-20 20:53:10 UTC (rev 7165) @@ -10,7 +10,7 @@ # Distributed under the terms of the MIT license. # __version__ = '$Id$' -import config, wikipedia, query +import config, wikipedia, simplejson import re, time import threadpool import sys, os, signal, traceback @@ -149,19 +149,21 @@ """ Fetch the last 50 revisions using the API """
address = self.site.api_address() - predata = { - 'action': 'query', - 'prop': 'revisions', - 'titles': title.encode('utf-8'), - 'rvprop': 'timestamp|user|comment|content', - 'rvlimit': '50', - } + predata = [ + ('action', 'query'), + ('prop', 'revisions'), + ('titles', title.encode('utf-8')), + ('rvprop', 'timestamp|user|comment|content'), + ('rvlimit', '50'), + ('format', 'json'), + ] if username: - predata['rvexcludeuser'] = username.encode('utf-8') + predata.append(('rvexcludeuser', username.encode('utf-8'))) if since: - predata['rvend'] = since - response, data = query.GetData(predata, self.site, back_response = True) - if data.has_key('error'): + predata.append(('rvend', since)) + response, data = self.site.postForm(address, predata) + data = simplejson.loads(data) + if 'error' in data: raise RuntimeError(data['error'])
page = data['query']['pages'].values()[0]
pywikipedia-svn@lists.wikimedia.org