config.py: store config path in runtime conf and log file load
This commit is contained in:
parent
32fbc7529b
commit
ba7043b654
1 changed files with 3 additions and 1 deletions
|
@ -31,6 +31,7 @@ def parse_file(config_file: str, base: dict=CONFIG_DEFAULTS) -> dict:
|
||||||
`base` itself is NOT checked for invalid keys.
|
`base` itself is NOT checked for invalid keys.
|
||||||
"""
|
"""
|
||||||
_conf_file = config_file if config_file != None else CONFIG_DEFAULT_PATH
|
_conf_file = config_file if config_file != None else CONFIG_DEFAULT_PATH
|
||||||
|
logging.debug(f'Trying to load config file: {_conf_file}')
|
||||||
loaded_conf = toml.load(_conf_file)
|
loaded_conf = toml.load(_conf_file)
|
||||||
parsed = deepcopy(base)
|
parsed = deepcopy(base)
|
||||||
|
|
||||||
|
@ -97,7 +98,7 @@ class ConfigStateHolder:
|
||||||
# config options that are persisted to file
|
# config options that are persisted to file
|
||||||
file: dict = {}
|
file: dict = {}
|
||||||
# runtime config not persisted anywhere
|
# runtime config not persisted anywhere
|
||||||
runtime: dict = {'verbose': False}
|
runtime: dict = {'verbose': False, 'config_file': None}
|
||||||
|
|
||||||
def __init__(self, runtime_conf = {}, file_conf_path: str = None, file_conf_base: dict = {}):
|
def __init__(self, runtime_conf = {}, file_conf_path: str = None, file_conf_base: dict = {}):
|
||||||
"""init a stateholder, optionally loading `file_conf_path`"""
|
"""init a stateholder, optionally loading `file_conf_path`"""
|
||||||
|
@ -108,6 +109,7 @@ class ConfigStateHolder:
|
||||||
|
|
||||||
def try_load_file(self, config_file=None, base=CONFIG_DEFAULTS):
|
def try_load_file(self, config_file=None, base=CONFIG_DEFAULTS):
|
||||||
_conf_file = config_file if config_file != None else CONFIG_DEFAULT_PATH
|
_conf_file = config_file if config_file != None else CONFIG_DEFAULT_PATH
|
||||||
|
self.runtime['config_file'] = _conf_file
|
||||||
try:
|
try:
|
||||||
self.file = parse_file(config_file=_conf_file, base=base)
|
self.file = parse_file(config_file=_conf_file, base=base)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue