http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10887
Revision: 10887 Author: drtrigon Date: 2013-01-11 22:18:43 +0000 (Fri, 11 Jan 2013) Log Message: ----------- follow-up; to r10880 in order to "print a message if the release is old" as requested
Modified Paths: -------------- trunk/pywikipedia/version.py
Modified: trunk/pywikipedia/version.py =================================================================== --- trunk/pywikipedia/version.py 2013-01-11 21:35:15 UTC (rev 10886) +++ trunk/pywikipedia/version.py 2013-01-11 22:18:43 UTC (rev 10887) @@ -21,7 +21,14 @@ """ Parsing went wrong """
def getversion(): - return '%(tag)s (r%(rev)s, %(date)s)' % getversiondict() + data = getversiondict() + try: + rev2 = int(getversion_onlinerepo()) + rev1 = int(data['rev'].split()[0]) + data['cmp_ver'] = 'OUTDATED' if cmp_ver(rev1, rev2)=='<' else 'ok' + except ParseError: + data['cmp_ver'] = 'n/a' + return '%(tag)s (r%(rev)s, %(date)s, %(cmp_ver)s)' % data
def getversiondict(): global cache @@ -104,6 +111,10 @@ raise ParseError return rev
+## Simple version comparison +# +cmp_ver = lambda a, b, tol=1: {-1: '<', 0: '~', 1: '>'}[cmp((a-b)//tol, 0)] + if __name__ == '__main__': print 'Pywikipedia %s' % getversion() print 'Python %s' % sys.version