-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
40 lines (32 loc) · 1.03 KB
/
config.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
from dataclasses import dataclass
import toml
@dataclass
class Application:
name: str
input_type: str
path: str
class Config:
def __init__(self, target_file):
self.file = target_file
self.application = []
self.loadTomlConfigs()
def loadTomlConfigs(self):
with open(self.file, 'r') as file:
self.config = toml.load(file)
print(self.config)
def parseConfigs(self):
self.application = []
self.name = self.config['app']['name']
if len(self.config['applications']) > 0:
for app in self.config['applications']:
self.application.append(Application(name = app['name'], input_type=app['input_type'], path=app['path']))
def __str__(self):
toReturn = f"Name: {self.name}"
toReturn += f"Application: {self.application}"
return toReturn
def main():
target_file = ""
config = Config(target_file)
config.parseConfigs()
if __name__=="__main__":
main()