Revision: 7691 Author: alexsh Date: 2009-11-25 12:01:46 +0000 (Wed, 25 Nov 2009)
Log Message: ----------- cut bulk retrieve up if size > 500
Modified Paths: -------------- trunk/pywikipedia/userlib.py
Modified: trunk/pywikipedia/userlib.py =================================================================== --- trunk/pywikipedia/userlib.py 2009-11-24 17:04:42 UTC (rev 7690) +++ trunk/pywikipedia/userlib.py 2009-11-25 12:01:46 UTC (rev 7691) @@ -543,7 +543,19 @@ """ users = list(users) # if pages is an iterator, we need to make it a list if len(users) > 1: wikipedia.output(u'Getting %d users data from %s...' % (len(users), site)) - _GetAllUI(site, users, throttle, force).run() + + if len(users) > 500: + for urg in range(0, len(users), 500): + if urg == range(0, len(users), 500)[-1]: #latest + k = users[urg:] + _GetAllUI(site, k, throttle, force).run() + users[urg:] = k + else: + k = users[urg:urg + 500] + _GetAllUI(site, k, throttle, force).run() + users[urg:urg + 500] = k + else: + _GetAllUI(site, users, throttle, force).run()
class _GetAllUI(object): def __init__(self, site, users, throttle, force): @@ -596,9 +608,7 @@ 'usprop': ['blockinfo', 'groups', 'editcount', 'registration', 'emailable', 'gender'], 'ususers': u'|'.join([n.name() for n in self.users]), } - for n in query.GetData(params, self.site)['query']['users']: - datas[n['name']] = n - return datas + return dict([(n['name'], n) for n in query.GetData(params, self.site)['query']['users']])
if __name__ == '__main__': """
pywikipedia-svn@lists.wikimedia.org