feat: добавил конфиг

This commit is contained in:
Андрей Скирченко 2024-11-13 23:43:45 +03:00
parent 5e430fad6e
commit 78fa10d897
3 changed files with 24 additions and 0 deletions

4
config/config.json Normal file
View File

@ -0,0 +1,4 @@
{
"trace_storage_path": "/home/andrei/Desktop/bla",
"monitor_update_period": 100
}

6
src/cfg/schema.py Normal file
View File

@ -0,0 +1,6 @@
from typing import NamedTuple
class ConfigSchema(NamedTuple):
trace_storage_path: str
monitor_update_period: int

View File

@ -1,10 +1,24 @@
import sys
from PyQt5 import QtWidgets
import json
from os import path
from gui.mainGui import MainWindow
from cfg.schema import ConfigSchema
def read_json(filepath: str) -> dict:
if not path.exists(filepath):
raise FileNotFoundError(f"JSON file {filepath} not found!")
with open(filepath, 'r') as json_file:
content = json.load(json_file)
return content
def main():
app = QtWidgets.QApplication(sys.argv)
config = ConfigSchema(**read_json("config/config.json"))
window = MainWindow()
window.show()