-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
config.py
47 lines (35 loc) · 1.07 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from typing import Optional
from automate.config.reader import read_config
from automate.config.sections import ConfigFile
__all__ = [
'get_global_config',
'force_reload',
'switch_config',
'ConfigFile',
'OVERRIDE_FILENAME',
'LOGGING_FILENAME',
'HIERARCHY_FILENAME',
'ROOT_LOGGER',
]
CONFIG_FILENAME = 'config/config.ini'
OVERRIDE_FILENAME = 'config/overrides.yaml'
LOGGING_FILENAME = 'config/logging.yaml'
HIERARCHY_FILENAME = 'config/hierarchy.yaml'
ROOT_LOGGER = ''
config: Optional[ConfigFile] = None
def get_global_config() -> ConfigFile:
_ensure_loaded()
assert config is not None
return config
def force_reload():
global config # pylint: disable=global-statement
config = None
_ensure_loaded()
def switch_config(filename: str):
global config # pylint: disable=global-statement
config = read_config(filename)
return config
def _ensure_loaded():
global config # pylint: disable=global-statement
if not config:
config = read_config(CONFIG_FILENAME)