Revision: 6916 Author: cosoleto Date: 2009-05-24 10:37:36 +0000 (Sun, 24 May 2009)
Log Message: ----------- Site.allpages(): avoid some pointless repeated code execution in while loop.
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2009-05-22 23:45:12 UTC (rev 6915) +++ trunk/pywikipedia/wikipedia.py 2009-05-24 10:37:36 UTC (rev 6916) @@ -5492,16 +5492,20 @@ yield page return
+ api_url_basename = "%saction=query&format=xml&list=allpages" \ + "&aplimit=%i&apnamespace=%i" % \ + (self.api_address(), config.special_page_limit, + namespace) + + if not includeredirects: + api_url_basename += '&apfilterredir=nonredirects' + elif includeredirects == 'only': + api_url_basename += '&apfilterredir=redirects' + while True: - api_url = self.api_address() startEncoded = urllib.quote(start.encode(self.encoding())) - api_url += 'action=query&format=xml&list=allpages&apfrom=%s&aplimit=%i&apnamespace=%i' % (startEncoded, config.special_page_limit, namespace) + api_url = '%s&apfrom=%s' % (api_url_basename, startEncoded)
- if not includeredirects: - api_url += '&apfilterredir=nonredirects' - elif includeredirects == 'only': - api_url += '&apfilterredir=redirects' - if throttle: get_throttle() text = self.getUrl(api_url)
pywikipedia-svn@lists.wikimedia.org