http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10388
Revision: 10388 Author: xqt Date: 2012-06-20 14:56:03 +0000 (Wed, 20 Jun 2012) Log Message: ----------- ignore minor version changes, see bug #3536604
Modified Paths: -------------- trunk/pywikipedia/family.py trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/family.py =================================================================== --- trunk/pywikipedia/family.py 2012-06-20 14:16:58 UTC (rev 10387) +++ trunk/pywikipedia/family.py 2012-06-20 14:56:03 UTC (rev 10388) @@ -4030,15 +4030,17 @@ # to not break family files. return '1.20wmf4'
- def versionnumber(self, code): + def versionnumber(self, code, version=None): """Return an int identifying MediaWiki version.
Currently this is implemented as returning the minor version number; i.e., 'X' in version '1.X.Y'
+ if version is given (e.g. from a mw page), extract that number + """ R = re.compile(r"(\d+).(\d+)") - M = R.search(self.version(code)) + M = R.search(version or self.version(code)) if not M: # Version string malformatted; assume it should have been 1.10 return 10
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2012-06-20 14:16:58 UTC (rev 10387) +++ trunk/pywikipedia/wikipedia.py 2012-06-20 14:56:03 UTC (rev 10388) @@ -4526,8 +4526,13 @@ m = p.match(version) if m: version = m.group(1) - if version != self.site.version(): - output(u'WARNING: Family file %s contains version number %s, but it should be %s' % (self.site.family.name, self.site.version(), version)) + # only warn operator when versionnumber has been changed + versionnumber = self.site.family.versionnumber + if version != self.site.version() and \ + versionnumber(self.site.lang, + version=version) != versionnumber(self.site.lang): + output(u'WARNING: Family file %s contains version number %s, but it should be %s' + % (self.site.family.name, self.site.version(), version))
# Verify case if self.site.nocapitalize: @@ -4687,8 +4692,13 @@ m = p.match(header['general']['generator']) if m: version = m.group(1) - if version != self.site.version(): - output(u'WARNING: Family file %s contains version number %s, but it should be %s' % (self.site.family.name, self.site.version(), version)) + # only warn operator when versionnumber has been changed + versionnumber = self.site.family.versionnumber + if version != self.site.version() and \ + versionnumber(self.site.lang, + version=version) != versionnumber(self.site.lang): + output(u'WARNING: Family file %s contains version number %s, but it should be %s' + % (self.site.family.name, self.site.version(), version))
# Verify case if self.site.nocapitalize:
pywikipedia-svn@lists.wikimedia.org