replace-bot/configs/configure.py
tema 42a0579f2e
Изменён парсинг конфига
Добавлена обратная связь
2023-03-28 09:54:21 +03:00

29 lines
669 B
Python

from configparser import ConfigParser
from easydict import EasyDict as edict
CONFIG_FILE = 'config.ini'
class Configure:
def __init__(self):
config = ConfigParser()
config.read(CONFIG_FILE)
self.data = dict()
for section in config.sections():
self.data[section] = dict()
for key, value in config.items(section):
self.data[section][key] = value
def __getattr__(self, name):
for key in self.data.keys():
if name not in self.data[key]:
continue
return self.data[key][name]
raise NameError("Config options not found!")