forked from MerginMaps/python-api-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_version.py
More file actions
29 lines (21 loc) · 845 Bytes
/
update_version.py
File metadata and controls
29 lines (21 loc) · 845 Bytes
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
import os
import re
import argparse
def replace_in_file(filepath, regex, sub):
with open(filepath, 'r') as f:
content = f.read()
content_new = re.sub(regex, sub, content, flags=re.M)
with open(filepath, "w") as f:
f.write(content_new)
dir_path = os.path.dirname(os.path.realpath(__file__))
parser = argparse.ArgumentParser()
parser.add_argument('--version', help='version to replace')
args = parser.parse_args()
ver = args.version
print("using version " + ver)
about_file = os.path.join(dir_path, os.pardir, "mergin", "version.py")
print("patching " + about_file)
replace_in_file(about_file, "__version__\s=\s\".*", "__version__ = \"" + ver + "\"")
setup_file = os.path.join(dir_path, os.pardir, "setup.py")
print("patching " + setup_file)
replace_in_file(setup_file, "version='.*", "version='" + ver + "',")