File: versionchecker.py

package info (click to toggle)
psyco-doc 1.6-1
  • links: PTS
  • area: contrib
  • in suites: lenny
  • size: 1,832 kB
  • ctags: 3,236
  • sloc: ansic: 23,895; python: 5,646; perl: 1,309; makefile: 153
file content (47 lines) | stat: -rw-r--r-- 1,546 bytes parent folder | download | duplicates (4)
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
import re


explicitnumber = {
    '0x010100f0': '1.1.1',   # bugfix release, no change in hex version
    '0x010200f0': '1.2',
    '0x010300f0': '1.3',
    '0x010400f0': '1.4',
    '0x010500f0': '1.5',
    '0x010501f0': '1.5.1',
    '0x010502f0': '1.5.2',
    '0x010600f0': '1.6',
    }

FILES = {
    'Python/pyver.h': re.compile(r'PSYCO_VERSION_HEX\s+(0x[0-9a-fA-F]+)'),
    '../py-support/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.]+)\"'),
    '../../www/dist/Makefile': re.compile(r'version\s*=\s*([0-9.]+)'),
    '../../www/content/index.rst': re.compile(r'`Psyco ([0-9.]+)@'),
    '../../www/content/download.rst': re.compile(r'Current version is ([0-9.]+)'),
    '../../www/content/./download.rst': re.compile(r'[dD]ownload Release ([0-9.]+)'),
    '../../www/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"

import files; files.main()