update_revnum.py
23 lines
| 569 B
| text/x-python
|
PythonLexer
/ tools / update_revnum.py
ville
|
r988 | #!/usr/bin/env python | ||
""" Change the revision number in Release.py """ | ||||
import os | ||||
Ville M. Vainio
|
r1072 | import re,pprint | ||
ville
|
r988 | |||
Ville M. Vainio
|
r1072 | def verinfo(): | ||
out = os.popen('bzr version-info') | ||||
pairs = (l.split(':',1) for l in out) | ||||
d = dict(((k,v.strip()) for (k,v) in pairs)) | ||||
return d | ||||
ville
|
r988 | |||
Ville M. Vainio
|
r1072 | ver = verinfo() | ||
pprint.pprint(ver) | ||||
ville
|
r988 | |||
Ville M. Vainio
|
r1052 | rfile = open('../IPython/Release.py','rb').read() | ||
Ville M. Vainio
|
r1072 | newcont = re.sub(r'revision\s*=.*', "revision = '%s'" % ver['revno'], rfile) | ||
newcont = re.sub(r'^branch\s*=[^=].*', "branch = '%s'" % ver['branch-nick'], newcont ) | ||||
Ville M. Vainio
|
r1052 | open('../IPython/Release.py','wb').write(newcont) | ||