r9647 pywikipedia - Code Review archive

Repository:pywikipedia
Revision:r9646‎ | r9647 | r9648 >
Date:14:11, 22 October 2011
Author:xqt
Status:resolved
Tags:
Comment:
get version from sqlite table while using TortoiseSVN 1.7
Modified paths:
  • /trunk/pywikipedia/version.py (modified) (history)

Diff [purge]

Index: trunk/pywikipedia/version.py
@@ -2,6 +2,7 @@
33 """ Module to determine the pywikipedia version (tag, revision and date) """
44 #
55 # (C) Merlijn 'valhallasw' van Deen, 2007-2008
 6+# (C) xqt, 2010-2011
67 # (C) Pywikipedia bot team, 2007-2011
78 #
89 # Distributed under the terms of the MIT license.
@@ -28,6 +29,7 @@
2930 try:
3031 (tag, rev, date) = getversion_svn()
3132 except Exception, e:
 33+ print e
3234 try:
3335 (tag, rev, date) = getversion_nightly()
3436 except Exception, e:
@@ -52,16 +54,31 @@
5355 # if not os.path.isabs(_program_dir):
5456 # _program_dir = os.path.normpath(os.path.join(os.getcwd(), _program_dir))
5557 entries = open(os.path.join(_program_dir, '.svn/entries'))
56 - for i in range(4):
57 - entries.readline()
58 - tag = entries.readline().strip()
59 - t = tag.split('://')
60 - t[1] = t[1].replace('svn.wikimedia.org/svnroot/pywikipedia/', '')
61 - tag = '[%s] %s' % (t[0], t[1])
62 - for i in range(4):
63 - entries.readline()
64 - date = time.strptime(entries.readline()[:19],'%Y-%m-%dT%H:%M:%S')
65 - rev = entries.readline()[:-1]
 58+ version = entries.readline().strip()
 59+ #use sqlite table for new entries format
 60+ if version == "12":
 61+ entries.close()
 62+ from sqlite3 import dbapi2 as sqlite
 63+ from datetime import datetime
 64+ con = sqlite.connect(os.path.join(_program_dir, ".svn/wc.db"))
 65+ cur = con.cursor()
 66+ cur.execute( '''select local_relpath, repos_path, revision, changed_date from nodes order by revision desc''')
 67+ name, tag, rev, date = cur.fetchone()
 68+ con.close()
 69+ tag = tag.rstrip(name)
 70+ date = time.gmtime(date/1000000)
 71+ else:
 72+ for i in range(3):
 73+ entries.readline()
 74+ tag = entries.readline().strip()
 75+ t = tag.split('://')
 76+ t[1] = t[1].replace('svn.wikimedia.org/svnroot/pywikipedia/', '')
 77+ tag = '[%s] %s' % (t[0], t[1])
 78+ for i in range(4):
 79+ entries.readline()
 80+ date = time.strptime(entries.readline()[:19],'%Y-%m-%dT%H:%M:%S')
 81+ rev = entries.readline()[:-1]
 82+ entries.close()
6683 if not date or not tag or not rev:
6784 raise ParseError
6885 return (tag, rev, date)

Follow-up revisions

RevisionCommit summaryAuthorDate
r9913Follow-up to r9647, see bug #3489508binbot08:52, 20 February 2012

Status & tagging log