Revision: 6874 Author: nicdumz Date: 2009-05-12 09:41:35 +0000 (Tue, 12 May 2009)
Log Message: ----------- isDisambig improvements * Capitalize titles for (case sensitive) comparisons (bug #2788226) * use self._site instead of self.site()
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2009-05-12 09:07:46 UTC (rev 6873) +++ trunk/pywikipedia/wikipedia.py 2009-05-12 09:41:35 UTC (rev 6874) @@ -1125,21 +1125,28 @@
""" if not hasattr(self, "_isDisambig"): - if not hasattr(self.site(), "_disambigtemplates"): - self.site()._disambigtemplates = self.site().family.disambig(self.site().lang) - if self.site()._disambigtemplates is None: + + if not hasattr(self._site, "_disambigtemplates"): + distl = self._site.family.disambig(self._site.lang) + if distl is None: try: - disambigpages = Page(self.site(), + disambigpages = Page(self._site, "MediaWiki:Disambiguationspage") - self.site()._disambigtemplates = [ + self._site._disambigtemplates = [ link.titleWithoutNamespace() for link in disambigpages.linkedPages() if link.namespace() == 10 ] except NoPage: - self.site()._disambigtemplates = ['Disambig'] + self._site._disambigtemplates = ['Disambig'] + else: + # Normalize template capitalization + self._site._disambigtemplates = [ + t[0].upper() + t[1:] + for t in distl + ] for t in self.templates(): - if t in self.site()._disambigtemplates: + if t in self._site._disambigtemplates: self._isDisambig = True break else:
pywikipedia-svn@lists.wikimedia.org