added config file and parser

This commit is contained in:
Mikhail Tergoev
2025-03-07 01:55:38 +03:00
parent ce9feceb52
commit 3a57048f49
2 changed files with 21 additions and 0 deletions

14
modules/config_parser.py Normal file
View File

@ -0,0 +1,14 @@
import json
from .log import *
from .env_var import *
def var(var_name):
py_work_path = get_env_var("PYTHON_WORK_PATH")
# Читаем конфигурационный файл
with open(py_work_path + "/config.json", "r") as file:
config = json.load(file)
if config[var_name]:
return config[var_name]
else:
log.critical(f"в config.json нет значения переменной: {var_name}")