33 lines
807 B
Python
33 lines
807 B
Python
|
from configparser import ConfigParser
|
||
|
|
||
|
from easydict import EasyDict as edict
|
||
|
|
||
|
|
||
|
CONFIG_FILE = 'config.ini'
|
||
|
|
||
|
data = ConfigParser()
|
||
|
data.read(CONFIG_FILE)
|
||
|
|
||
|
config = edict()
|
||
|
config["cert"] = edict()
|
||
|
|
||
|
for section in data.sections():
|
||
|
config[section] = edict()
|
||
|
|
||
|
for key, value in data.items(section):
|
||
|
config[section][key] = value
|
||
|
|
||
|
config["cert"] = {
|
||
|
"cert": f"{config.webhook.cert_folder}/{config.webhook.cert}",
|
||
|
"key": f"{config.webhook.cert_folder}/{config.webhook.key}"
|
||
|
}
|
||
|
config["data_file"] = f"{config.parser.folder}/{config.parser.file}"
|
||
|
|
||
|
def parse_bool(section=None, key=None, text=None):
|
||
|
if text is not None:
|
||
|
return text.lower() in ['yes', 'true']
|
||
|
|
||
|
|
||
|
if section is not None and key is not None:
|
||
|
return config[section][key].lower() in ['yes', 'true']
|