http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10880
Revision: 10880 Author: drtrigon Date: 2013-01-10 21:11:31 +0000 (Thu, 10 Jan 2013) Log Message: ----------- improvement; make it a little bit more versatile
Modified Paths: -------------- trunk/pywikipedia/version.py
Modified: trunk/pywikipedia/version.py =================================================================== --- trunk/pywikipedia/version.py 2013-01-10 17:09:15 UTC (rev 10879) +++ trunk/pywikipedia/version.py 2013-01-10 21:11:31 UTC (rev 10880) @@ -12,6 +12,7 @@ import os import time import sys +import urllib import config
cache = None @@ -48,8 +49,8 @@ cache = dict(tag=tag, rev=rev, date=datestring) return cache
-def getversion_svn(): - _program_dir = os.path.normpath(os.path.dirname(sys.argv[0])) +def getversion_svn(path=None): + _program_dir = path or os.path.normpath(os.path.dirname(sys.argv[0])) # if not os.path.isabs(_program_dir): # _program_dir = os.path.normpath(os.path.join(os.getcwd(), _program_dir)) entries = open(os.path.join(_program_dir, '.svn/entries')) @@ -78,7 +79,7 @@ date = time.strptime(entries.readline()[:19],'%Y-%m-%dT%H:%M:%S') rev = entries.readline()[:-1] entries.close() - if not date or not tag or not rev: + if (not date or not tag or not rev) and not path: raise ParseError return (tag, rev, date)
@@ -91,6 +92,18 @@ raise ParseError return (tag, rev, date)
+## Retrieve revision number of framework online repository's svnroot +# +def getversion_onlinerepo(repo=None): + url = repo or 'http://svn.wikimedia.org/svnroot/pywikipedia/trunk/pywikipedia/' + rev = None + try: + buf = urllib.urlopen(url).read() + rev = buf.split(' ')[3][:-1] + except: + raise ParseError + return rev + if __name__ == '__main__': print 'Pywikipedia %s' % getversion() print 'Python %s' % sys.version
pywikipedia-svn@lists.wikimedia.org