http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9742
Revision: 9742 Author: xqt Date: 2011-11-11 00:29:54 +0000 (Fri, 11 Nov 2011) Log Message: ----------- mw 1.18 changes: POST request ist needed for watch action
Modified Paths: -------------- trunk/pywikipedia/query.py
Modified: trunk/pywikipedia/query.py =================================================================== --- trunk/pywikipedia/query.py 2011-11-10 23:22:44 UTC (rev 9741) +++ trunk/pywikipedia/query.py 2011-11-11 00:29:54 UTC (rev 9742) @@ -37,7 +37,8 @@ import simplejson as json
-def GetData(params, site = None, useAPI = True, retryCount = 5, encodeTitle = True, sysop = False, back_response = False): +def GetData(params, site=None, useAPI=True, retryCount=5, encodeTitle=True, + sysop=False, back_response=False): """Get data from the query api, and convert it into a data object """ if not site: @@ -74,7 +75,7 @@ if wikipedia.verbose: #dump params info. wikipedia.output(u"==== API action:%s ====" % params[u'action']) if data and 'file' not in data: - wikipedia.output(u"%s: (%d items)" % (data.keys()[0], titlecount ) ) + wikipedia.output(u"%s: (%d items)" % (data.keys()[0], titlecount))
for k, v in params.iteritems(): if k not in ['action', 'format', 'file', 'xml', 'text']: @@ -87,9 +88,12 @@
postAC = [ - 'edit', 'login', 'purge', 'rollback', 'delete', 'undelete', 'protect', 'parse', - 'block', 'unblock', 'move', 'emailuser','import', 'userrights', 'upload', 'patrol' + 'edit', 'login', 'purge', 'rollback', 'delete', 'undelete', 'protect', + 'parse', 'block', 'unblock', 'move', 'emailuser','import', 'userrights', + 'upload', 'patrol' ] + if site.versionnumber() >= 18: + postAC.append('watch') if useAPI: if params['action'] in postAC: path = site.api_address() @@ -102,7 +106,8 @@
if wikipedia.verbose: if titlecount > 1: - wikipedia.output(u"Requesting %d %s from %s" % (titlecount, data.keys()[0], site)) + wikipedia.output(u"Requesting %d %s from %s" + % (titlecount, data.keys()[0], site)) else: wikipedia.output(u"Requesting API query from %s" % site)