35 lines
1.2 KiB
Python
35 lines
1.2 KiB
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
|
|
|
|
config_folder = config.get("Docs_Settings", "Config_folder").rstrip("/")
|
|
self.data["documentid"] = config.get("Docs_Settings", 'Document_ID')
|
|
self.data["data_file"] = config_folder + "/" + config.get("Docs_Settings", "data_file")
|
|
self.data["credentials_file"] = config_folder + "/" + config.get("Docs_Settings", "credentials_file")
|
|
self.data["token_file"] = self.config_folder + "/" + self.data['Docs_Settings']['token_file']
|
|
|
|
def __getattr__(self, name):
|
|
if name in ["documentid", "data_file", "credentials_file", "token_file"]:
|
|
return self.data[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!")
|