Revision: 6855 Author: russblau Date: 2009-05-07 18:27:55 +0000 (Thu, 07 May 2009)
Log Message: ----------- Save title normalization information in QueryGenerator objects
Modified Paths: -------------- branches/rewrite/pywikibot/data/api.py
Modified: branches/rewrite/pywikibot/data/api.py =================================================================== --- branches/rewrite/pywikibot/data/api.py 2009-05-07 13:07:14 UTC (rev 6854) +++ branches/rewrite/pywikibot/data/api.py 2009-05-07 18:27:55 UTC (rev 6855) @@ -474,16 +474,23 @@ % (self.__class__.__name__, self.resultkey)) logger.debug(unicode(self.data)) return - pagedata = self.data["query"][self.resultkey] - if isinstance(pagedata, dict): + resultdata = self.data["query"][self.resultkey] + if isinstance(resultdata, dict): logger.debug(u"%s received %s; limit=%s" - % (self.__class__.__name__, pagedata.keys(), + % (self.__class__.__name__, resultdata.keys(), self.limit)) - pagedata = [pagedata[k] for k in sorted(pagedata.keys())] + resultdata = [resultdata[k] for k in sorted(resultdata.keys())] else: logger.debug(u"%s received %s; limit=%s" - % (self.__class__.__name__, pagedata, self.limit)) - for item in pagedata: + % (self.__class__.__name__, resultdata, + self.limit)) + if "normalized" in self.data["query"]: + self.normalized = dict((item['to'], item['from']) + for item in + self.data["query"]["normalized"]) + else: + self.normalized = {} + for item in resultdata: yield self.result(item) count += 1 if self.limit is not None and self.limit > 0 \ @@ -625,6 +632,7 @@ """ QueryGenerator.__init__(self, list=listaction, **kwargs)
+ class LogEntryListGenerator(ListGenerator): """ Like ListGenerator, but specialized for listaction="logevents" : @@ -639,6 +647,7 @@ def result(self, pagedata): return self.entryFactory.create(pagedata)
+ class LoginManager(login.LoginManager): """Supplies getCookie() method to use API interface.""" def getCookie(self, remember=True, captchaId=None, captchaAnswer=None):