Allow main to switch back from yaml to json config files

This commit is contained in:
cmdr2 2023-06-30 15:53:54 +05:30 committed by GitHub
parent 656acafed3
commit cf87c34bef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -100,7 +100,22 @@ def init():
def getConfig(default_val=APP_CONFIG_DEFAULTS):
try:
config_json_path = os.path.join(CONFIG_DIR, "config.json")
if not os.path.exists(config_json_path):
# compatibility with upcoming yaml changes, switching from beta to main
config_yaml_path = os.path.join(CONFIG_DIR, "config.yaml")
if os.path.exists(config_yaml_path):
try:
import yaml
with open(config_yaml_path, "r", encoding="utf-8") as f:
config = yaml.safe_load(f)
setConfig(config) # save to config.json
os.remove(config_yaml_path) # delete the yaml file
except:
log.warn(traceback.format_exc())
config = default_val
elif not os.path.exists(config_json_path):
config = default_val
else:
with open(config_json_path, "r", encoding="utf-8") as f: