WIP: default config replacement for (#12)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from os import kill
|
||||
from os import kill, path
|
||||
from os import name as osname
|
||||
from os import sep
|
||||
from sys import exit
|
||||
@@ -73,9 +73,20 @@ def configGet(key: str, *args: str):
|
||||
* any: Value of provided key
|
||||
"""
|
||||
this_dict = jsonLoad("config.json")
|
||||
this_key = this_dict
|
||||
for dict_key in args:
|
||||
this_key = this_key[dict_key]
|
||||
try:
|
||||
this_key = this_dict
|
||||
for dict_key in args:
|
||||
this_key = this_key[dict_key]
|
||||
except KeyError:
|
||||
print(
|
||||
f"Could not find config key '{key}' under path {args}: falling back to default config",
|
||||
flush=True,
|
||||
)
|
||||
fallback_dict = jsonLoad(path.join("modules", "default_config.json"))
|
||||
this_key = fallback_dict
|
||||
for dict_key in args:
|
||||
this_key = this_key[dict_key]
|
||||
configSet(key, this_key[key], args)
|
||||
return this_key[key]
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user