replace-bot/configs/configure.py

29 lines
669 B
Python
Raw Normal View History

2022-02-16 18:13:44 +03:00
from configparser import ConfigParser
from easydict import EasyDict as edict
2022-02-16 18:13:44 +03:00
CONFIG_FILE = 'config.ini'
class Configure:
2022-02-16 18:13:44 +03:00
def __init__(self):
config = ConfigParser()
config.read(CONFIG_FILE)
2022-02-16 18:13:44 +03:00
self.data = dict()
for section in config.sections():
2022-02-16 18:13:44 +03:00
self.data[section] = dict()
for key, value in config.items(section):
2022-02-16 18:13:44 +03:00
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!")