forked from molmod/yaff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateversion.py
executable file
·57 lines (50 loc) · 2.02 KB
/
updateversion.py
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
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# YAFF is yet another force-field code
# Copyright (C) 2011 - 2013 Toon Verstraelen <[email protected]>,
# Louis Vanduyfhuys <[email protected]>, Center for Molecular Modeling
# (CMM), Ghent University, Ghent, Belgium; all rights reserved unless otherwise
# stated.
#
# This file is part of YAFF.
#
# YAFF is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# YAFF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>
#
#--
#!/usr/bin/env python
import re, sys
rules = [
('setup.py', '^ version=\'(...+)\',$'),
('yaff/__init__.py', '^__version__ = \'(...+)\'$'),
('doc/conf.py', '^version = \'(...+)\'$'),
('doc/conf.py', '^release = \'(...+)\'$'),
('doc/ug_install.rst', '^ http://users.ugent.be/~tovrstra/yaff/yaff-(...+).tar.gz.$'),
('doc/ug_install.rst', '^ wget http://users.ugent.be/~tovrstra/yaff/yaff-(...+).tar.gz$'),
('doc/ug_install.rst', '^ tar -xvzf yaff-(...+).tar.gz$'),
('doc/ug_install.rst', '^ cd yaff-(...+)$'),
('yaff/log.py', '^ *Welcome to Yaff (...+) - Yet another force field'),
]
if __name__ == '__main__':
newversion = sys.argv[1]
for fn, regex in rules:
r = re.compile(regex)
with open(fn) as f:
lines = f.readlines()
for i in xrange(len(lines)):
line = lines[i]
m = r.match(line)
if m is not None:
lines[i] = line[:m.start(1)] + newversion + line[m.end(1):]
with open(fn, 'w') as f:
f.writelines(lines)