Revision: 8110 Author: alexsh Date: 2010-04-18 19:42:57 +0000 (Sun, 18 Apr 2010)
Log Message: ----------- change all query:logevents to use site().logpages(). logpages():add newer param
Modified Paths: -------------- trunk/pywikipedia/imageuncat.py trunk/pywikipedia/redirect.py trunk/pywikipedia/welcome.py trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/imageuncat.py =================================================================== --- trunk/pywikipedia/imageuncat.py 2010-04-18 19:23:24 UTC (rev 8109) +++ trunk/pywikipedia/imageuncat.py 2010-04-18 19:42:57 UTC (rev 8110) @@ -1238,26 +1238,9 @@ today = datetime.utcnow() yesterday = today + timedelta(days=-1)
- params = { - 'action' :'query', - 'list' :'logevents', - 'leprop' :'title', - 'letype' :'upload', - 'ledir' :'newer', - 'lelimit' :'5000', - 'lestart' :yesterday.strftime(dateformat), - 'leend' :today.strftime(dateformat) - } - - data = query.GetData(params, site, encodeTitle = False) - try: - for item in data['query']['logevents']: - result.append(item['title']) - except IndexError: - raise NoPage(u'API Error, nothing found in the APIs') - except KeyError: - raise NoPage(u'API Error, nothing found in the APIs') - + for item in site.logpages( number = 5000, mode = 'upload', start = yesterday.strftime(dateformat), + end = today.strftime(dateformat), newer = True, dump = True): + result.append(item['title']) return pagegenerators.PagesFromTitlesGenerator(result, site)
def recentChanges(site = None, delay=0, block=70):
Modified: trunk/pywikipedia/redirect.py =================================================================== --- trunk/pywikipedia/redirect.py 2010-04-18 19:23:24 UTC (rev 8109) +++ trunk/pywikipedia/redirect.py 2010-04-18 19:42:57 UTC (rev 8110) @@ -463,23 +463,10 @@ start = datetime.datetime.utcnow() \ - datetime.timedelta(0, self.offset*3600) offset_time = start.strftime("%Y%m%d%H%M%S") - params = { - 'action' :'query', - 'list' :'logevents', - 'letype' :'move', - 'leprop' :'title|details', - 'lelimit' : self.api_number, - 'lestart' : offset_time, - } - data = query.GetData(params, encodeTitle = False) - if 'warnings' in data: - raise - allmoves = data['query']['logevents'] wikipedia.output(u'Retrieving %d moved pages via API...' % len(allmoves)) if wikipedia.verbose: wikipedia.output(u"[%s]" % offset_time) - for moved in allmoves: - moved_page = wikipedia.Page(self.site, moved['title']) + for moved_page,u,t,c in self.site.logpages(number = api_number, mode = 'move',start = offset_time): try: if not moved_page.isRedirectPage(): continue
Modified: trunk/pywikipedia/welcome.py =================================================================== --- trunk/pywikipedia/welcome.py 2010-04-18 19:23:24 UTC (rev 8109) +++ trunk/pywikipedia/welcome.py 2010-04-18 19:42:57 UTC (rev 8110) @@ -680,26 +680,17 @@ yield x return
- params = { - 'action':'query', - 'list':'logevents', - 'letype':'newusers', - 'ledir':'older', - 'leprop':'ids|type|user', - 'lelimit':int(globalvar.queryLimit), - } + starttime = None if globalvar.timeoffset != 0: now = self.site.server_time() - timedelta(minutes=globalvar.timeoffset) - params['lestart'] = int(now.strftime("%Y%m%d%H%M%S")) + starttime = int(now.strftime("%Y%m%d%H%M%S")) elif globalvar.offset != 0: - params['lestart'] = globalvar.offset + starttime = globalvar.offset
count_auto = 0 wikipedia.output("Querying new user log from API....") while True: - lev = query.GetData(params, self.site) - count = len(lev['query']['logevents']) - for x in lev['query']['logevents']: + for x in self.site.logpages(number = int(globalvar.queryLimit), mode = 'newusers',start = starttime, dump = True) someone_found = True if 'user' not in x: continue @@ -715,10 +706,6 @@
yield userlib.User(self.site, x['user'])
- if count < globalvar.queryLimit and 'query-continue' in lev: - params['lestart'] = lev['query-continue']['logevents']['lestart'] - else: - break if someone_found: if globalvar.quick and count_auto > 0: showStatus()
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2010-04-18 19:23:24 UTC (rev 8109) +++ trunk/pywikipedia/wikipedia.py 2010-04-18 19:42:57 UTC (rev 8110) @@ -5686,7 +5686,7 @@ # TODO: avoid code duplication for the following methods
def logpages(self, number = 50, mode = '', title = None, user = None, repeat = False, - namespace = [], start = None, end = None, tag = None, dump = False): + namespace = [], start = None, end = None, tag = None, newer = False, dump = False):
if not self.has_api() or self.versionnumber() < 11 or \ mode not in ('block', 'protect', 'rights', 'delete', 'upload', @@ -5707,6 +5707,8 @@ params['lelimit'] = config.special_page_limit if number > 5000 and self.isAllowed('apihighlimits'): params['lelimit'] = 5000 + if newer: + params['ledir'] = 'newer' if user: params['leuser'] = user if title:
pywikipedia-svn@lists.wikimedia.org