[Pywikipedia-svn] SVN: [7322] trunk/pywikipedia/userlib.py
alexsh at svn.wikimedia.org
alexsh at svn.wikimedia.org
Sat Sep 26 13:55:02 UTC 2009
Revision: 7322
Author: alexsh
Date: 2009-09-26 13:55:02 +0000 (Sat, 26 Sep 2009)
Log Message:
-----------
batchLoadUI():cleanup name and use dict() to get data one time.
[new] batchDumpInfo():load user object userinfo by one time batchLoadUI().
Modified Paths:
--------------
trunk/pywikipedia/userlib.py
Modified: trunk/pywikipedia/userlib.py
===================================================================
--- trunk/pywikipedia/userlib.py 2009-09-26 09:56:11 UTC (rev 7321)
+++ trunk/pywikipedia/userlib.py 2009-09-26 13:55:02 UTC (rev 7322)
@@ -77,10 +77,11 @@
else:
self._groups = []
- if not data['registration']:
- self._registrationTime = "unknown"
+ if data['registration']:
+ self._registrationTime = data['registration']
else:
- self._registrationTime = data['registration']
+ self._registrationTime = u'unknown'
+
self._blocked = data.has_key('blockedby')
@@ -384,22 +385,24 @@
'action': 'query',
'list': 'users',
'usprop': 'blockinfo|groups|editcount|registration|emailable|gender',
- #'': '',
+ 'ususers': query.ListToParam(names),
}
- if type(names) == list():
- params['ususers'] = query.ListToParam(names)
- else:
- params['ususers'] = names
-
#if site.versionnumber() >= 16:
# params['ustoken'] = 'userrights'
- #result = dict([[sig['name'], sig] for sig in query.GetData(params, site)])
- for sig in query.GetData(params, site)['query']['users']:
- result[sig['name']] = sig
+
+ result = dict([(sig['name'].lower(), sig) for sig in query.GetData(params, site)['query']['users'] ])
return result
+def batchDumpInfo(user):
+ totals = batchLoadUI([x.name() for x in user])
+ for oj in user:
+ data = totals[oj.name().lower()]
+ oj._editcount = data['editcount']
+ oj._groups = data['groups']
+ oj._blocked = data.has_key('blockedby')
+
if __name__ == '__main__':
"""
Simple testing code for the [[User:Example]] on the English Wikipedia.
More information about the Pywikipedia-svn
mailing list