File: version.py

package info (click to toggle)
torchat 0.9.9.550-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 772 kB
  • sloc: python: 5,527; makefile: 45; sh: 5
file content (48 lines) | stat: -rw-r--r-- 1,381 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os
import version_cached

NAME = "TorChat"
VERSION_MAJOR = "0.9.9"
SVN_OFFSET = 0

EXPERIMENTAL = False

def getDirMaxSvn(dir):
    try:
        #read all revisions in all-wcprops
        lines = open(os.path.join(dir, ".svn/all-wcprops")).readlines()
        max = 0
        for line in lines:
            if "/svn/!svn/ver/" in line:
                ver = int(line.split("/")[4])
                if ver > max:
                    max = ver
        
        #dive into all subdirs recursively
        subdirs = os.listdir(dir)
        for subdir in subdirs:
            if os.path.isdir(subdir) and subdir not in [".", "..", ".svn"]:
                subdir_ver = getDirMaxSvn(os.path.join(dir, subdir))
                if subdir_ver > max:
                    max = subdir_ver
        return max
    except:
        return False

svn_current = getDirMaxSvn(".")
svn_cached = version_cached.SVN_REVISION

if not svn_current:
    svn = svn_cached
else:
    svn = svn_current
    if svn_cached != svn_current:
        f = open("version_cached.py", "w")
        f.write("# this file is generated by version.py\nSVN_REVISION = %i\n" % svn_current)
        f.close()
                    
VERSION = VERSION_MAJOR + "." + str(svn - SVN_OFFSET)
VERSION_ONLY = VERSION
if EXPERIMENTAL:
    VERSION += "-experimental"
VERSION_SVN = svn