File: versionchecker.py

package info (click to toggle)
psyco 1.4-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,316 kB
  • ctags: 3,217
  • sloc: ansic: 23,466; python: 5,142; perl: 1,570; makefile: 165; sh: 88
file content (41 lines) | stat: -rw-r--r-- 1,451 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
import re


explicitnumber = {
    '0x010100f0': '1.1.1',   # bugfix release, no change in hex version
    '0x010200f0': '1.2',
    '0x010300f0': '1.3',
    '0x010400f0': '1.4',
    }

FILES = {
    'Python/pyver.h': re.compile(r'PSYCO_VERSION_HEX\s+(0x[0-9a-fA-F]+)'),
    '../psyco/support.py': re.compile(r'__version__\s*=\s*(0x[0-9a-fA-F]+)'),
    '../doc/psycoguide.tex': re.compile(r'\\release\{([0-9.]+)\}'),
    '../setup.py': re.compile(r'version\s*=\s*\"([0-9.]+)\"'),
    '../../my/psyco/dist/Makefile': re.compile(r'version\s*=\s*([0-9.]+)'),
    '../../my/psyco/site/content/index.rst': re.compile(r'`Psyco ([0-9.]+)@'),
    '../../my/psyco/site/content/download.rst': re.compile(r'Current version is ([0-9.]+)'),
    '../../my/psyco/site/content/./download.rst': re.compile(r'Download Release ([0-9.]+)'),
    '../../my/psyco/site/content/doc.rst': re.compile(r'Psyco release ([0-9.]+)'),
    '../README.txt': re.compile(r'VERSION ([0-9.]+)'),
    }

versions = {}
for filename, regexp  in FILES.items():
    for line in open(filename, 'r'):
        match = regexp.search(line)
        if match:
            break
    else:
        raise Exception, "No version number found in " + filename
    ver = match.group(1)
    print '%20s  %s' % (ver, filename)
    if ver.startswith('0x'):
        ver = explicitnumber[ver]
    versions[ver] = filename

if len(versions) != 1:
    raise Exception, versions
else:
    print "versionchecker: ok"