-
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathupdate.py
More file actions
23 lines (22 loc) · 657 Bytes
/
update.py
File metadata and controls
23 lines (22 loc) · 657 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import re
if __name__ == '__main__':
setupFile = 'setup.py'
outLines = []
# read and update old version
with open(setupFile, 'r') as f:
for line in f:
regex = r".+version.+'(.+)',"
match = re.match(regex, line)
if match != None:
items = list(match.groups())
version = items[0]
major, middle, minor = [int(x) for x in version.split('.')]
minor += 1
newVersion = '{}.{}.{}'.format(major, middle, minor)
print('{} -> {}'.format(version, newVersion))
line = "\tversion = '{}',\n".format(newVersion)
outLines.append(line)
# write updated lines
with open(setupFile, 'w') as f:
s = ''.join(outLines)
f.write(s)