Revision: 6878 Author: nicdumz Date: 2009-05-13 04:51:42 +0000 (Wed, 13 May 2009)
Log Message: ----------- Use sets instead of lists to compute disambiguation intersections
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2009-05-12 10:10:46 UTC (rev 6877) +++ trunk/pywikipedia/wikipedia.py 2009-05-13 04:51:42 UTC (rev 6878) @@ -1132,25 +1132,21 @@ try: disambigpages = Page(self._site, "MediaWiki:Disambiguationspage") - self._site._disambigtemplates = [ + self._site._disambigtemplates = set( link.titleWithoutNamespace() for link in disambigpages.linkedPages() if link.namespace() == 10 - ] + ) except NoPage: - self._site._disambigtemplates = ['Disambig'] + self._site._disambigtemplates = set(['Disambig']) else: # Normalize template capitalization - self._site._disambigtemplates = [ + self._site._disambigtemplates = set( t[0].upper() + t[1:] for t in distl - ] - for t in self.templates(): - if t in self._site._disambigtemplates: - self._isDisambig = True - break - else: - self._isDisambig = False + ) + disambigInPage = self._site._disambigtemplates.intersection(self.templates()) + self._isDisambig = len(disambigInPage) > 0 return self._isDisambig
def getReferences(self,
pywikipedia-svn@lists.wikimedia.org