Revision: 8109 Author: alexsh Date: 2010-04-18 19:23:24 +0000 (Sun, 18 Apr 2010)
Log Message: ----------- change two functions to use Site().logpages()
Modified Paths: -------------- trunk/pywikipedia/userlib.py trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/userlib.py =================================================================== --- trunk/pywikipedia/userlib.py 2010-04-18 18:36:22 UTC (rev 8108) +++ trunk/pywikipedia/userlib.py 2010-04-18 19:23:24 UTC (rev 8109) @@ -285,27 +285,10 @@ yield p,t,c,a return
- params = { - 'action': 'query', - 'list': 'logevents', - 'letype': 'upload', - 'leuser': self.name(), - 'lelimit': int(number), - } - count = 0 - while True: - data = query.GetData(params, self.site()) - for info in data['query']['logevents']: - count += 1 - yield wikipedia.ImagePage(self.site(), info['title']), info['timestamp'], info['comment'], False + for s in self.site().logpages(number, mode = 'upload', user = self.name(), dump = True) + yield wikipedia.ImagePage(self.site(), s['title']), s['timestamp'], s['comment'], s['pageid'] > 0 + return
- if count >= number: - break - if 'query-continue' in data and count < number: - params['lestart'] = data['query-continue']['logevents']['lestart'] - else: - break - def _uploadedImagesOld(self, number = 10): """Yield ImagePages from Special:Log&type=upload"""
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2010-04-18 18:36:22 UTC (rev 8108) +++ trunk/pywikipedia/wikipedia.py 2010-04-18 19:23:24 UTC (rev 8109) @@ -6000,35 +6000,12 @@ No more than 500 (5000 for bots) allowed. Default: 10 """ - params = { - 'action' :'query', - 'list' :'logevents', - 'letype' :'upload', - 'lelimit' :int(number), - } - if lestart: params['lestart'] = lestart - if leend: params['leend'] = leend - if leuser: params['leuser'] = leuser - if letitle: params['letitle'] = letitle - while True: - if self.versionnumber() >= 11: - imagesData = query.GetData(params, self, encodeTitle = False) - else: - raise NotImplementedError("The site version is not support this action.") - - if 'error' in imagesData: - raise RuntimeError('%s' % data['error']) + + for o, u, t, c in self.logpages(number = number, mode = 'upload', title = letitle, user = leuser, + repeat = repeat, start = lestart, end = leend): + yield o, t, u, c + return
- for i in imagesData['query']['logevents']: - comment = '' - if 'comment' in i: - comment = i['comment'] - #pageid = i['pageid'] - ##logid = i['logid'] #no use current now - yield ImagePage(self, i['title']), i['timestamp'], i['user'], comment - if not repeat: - break - def recentchanges(self, number = 100, rcstart = None, rcend = None, rcshow = None, rcdir='older', rctype ='edit|new', namespace=None, includeredirects=True, repeat = False): """ Yield ImagePages from APIs, call: action=query&list=recentchanges&rctype=edit|new&rclimit=500
pywikipedia-svn@lists.wikimedia.org