From b2a34d22158beae7833c2f82b4db7b88eda42f8e Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Fri, 15 Mar 2024 21:40:35 +0100 Subject: [PATCH] refactor: unify preset loading methods in config --- modules/config.py | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/modules/config.py b/modules/config.py index 996cd29..132e17f 100644 --- a/modules/config.py +++ b/modules/config.py @@ -128,22 +128,6 @@ def try_get_preset_content(preset): print(e) return {} -def try_load_preset_global(preset): - global config_dict - - if isinstance(preset, str): - preset_path = os.path.abspath(f'./presets/{preset}.json') - try: - if os.path.exists(preset_path): - with open(preset_path, "r", encoding="utf-8") as json_file: - config_dict.update(json.load(json_file)) - print(f'Loaded preset: {preset_path}') - else: - raise FileNotFoundError - except Exception as e: - print(f'Load preset [{preset_path}] failed') - print(e) - try: with open(os.path.abspath(f'./presets/default.json'), "r", encoding="utf-8") as json_file: config_dict.update(json.load(json_file)) @@ -152,7 +136,7 @@ except Exception as e: print(e) preset = args_manager.args.preset -try_load_preset_global(preset) +config_dict.update(try_get_preset_content(preset)) def get_path_output() -> str: """