-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_file.py
42 lines (37 loc) · 1.49 KB
/
config_file.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
import json
from color import Color
class configFile:
"""
This class is used to parse the config file.
"""
def __init__(
self,
filepath: str,
*args,
) -> None:
"""
This function is used to parse the config file.
You can define a language to be used by passing it as an argument, otherwise it will be determined automatically.
"""
with open(filepath, "r") as f:
data = json.loads(f.read())
if args:
self.language = args[0]
else:
self.language = next(iter(data))
self.show_errors = data[self.language]["showErrors"]
self.remove_comments = data[self.language]["showComments"]
self.keyword = Color(data[self.language]["style"]["keywords"])
self.identifier = Color(data[self.language]["style"]["identifiers"])
self.operator = Color(data[self.language]["style"]["operators"])
self.seperator = Color(data[self.language]["style"]["seperators"])
self.comment = Color(data[self.language]["style"]["comments"])
self.background = Color(data[self.language]["style"]["background"])
self.literal = type(
"literal",
(),
{
"string": Color(data[self.language]["style"]["literals"]["string"]),
"number": Color(data[self.language]["style"]["literals"]["number"]),
},
)