-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversion_switcher.py
More file actions
25 lines (21 loc) · 961 Bytes
/
version_switcher.py
File metadata and controls
25 lines (21 loc) · 961 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
import json
import sys
def main():
replace_from = "master" if sys.argv[1] == "test" else "test"
replace_to = "test" if sys.argv[1] == "test" else "test"
with open('config.json', 'r+') as config_file:
config_data = json.load(config_file)
config_new_urls = []
for version_file_url in config_data["updates"]["versions_files"]:
replace_from = "master"
replace_to = "test"
new_url = version_file_url.replace(replace_from, replace_to)
config_new_urls.append(new_url)
config_data["updates"]["versions_files"] = config_new_urls
config_file.truncate(0)
json.dump(config_file, config_data)
with open('versions.json', 'r+') as versions_file:
versions_data = json.load(versions_file)
for file_name, file_data in versions_data.items():
for url in file_data["urls"]:
new_url = url.replace(replace_from, replace_to)