-
Notifications
You must be signed in to change notification settings - Fork 2
/
parser.py
47 lines (40 loc) · 1.7 KB
/
parser.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
import json
import sys
scheme = sys.argv[1]
schemes = ""
with open("colorschemes.json", "r", encoding="utf-8") as file:
schemes = json.loads(file.read())
template_extended = ""
with open("template_extended.json", "r", encoding="utf-8") as file:
template_extended = json.loads(file.read())
template_simplified = ""
with open("template_simplified.json", "r", encoding="utf-8") as file:
template_simplified = json.loads(file.read())
for c in template_extended["columns"]:
if "color" in c:
if c["color"] in schemes[scheme]:
c["color"] = schemes[scheme][c["color"]]
if "header" in c:
if not c["header"] == None:
c["header"] = c["header"].replace(
"color_6", schemes[scheme]["color_6"])
for k in template_extended:
if "color" in str(template_extended[k]):
if "color_" in str(template_extended[k]):
template_extended[k] = schemes[scheme][template_extended[k]]
for c in template_simplified["columns"]:
if "color" in c:
if c["color"] in schemes[scheme]:
c["color"] = schemes[scheme][c["color"]]
if "header" in c:
if not c["header"] == None:
c["header"] = c["header"].replace(
"color_6", schemes[scheme]["color_6"])
for k in template_simplified:
if "color" in str(template_simplified[k]):
if "color_" in str(template_simplified[k]):
template_simplified[k] = schemes[scheme][template_simplified[k]]
with open(scheme + "_extended.json", "w", encoding="utf-8") as file:
file.write(json.dumps(template_extended, indent=4))
with open(scheme + "_simplified.json", "w", encoding="utf-8") as file:
file.write(json.dumps(template_simplified, indent=4))