From a07b77b31abf5f232098fc0b5dbceb933e67026c Mon Sep 17 00:00:00 2001 From: henryruhs Date: Thu, 6 Mar 2025 14:08:12 +0100 Subject: [PATCH] Change naming of config parser --- facefusion/config.py | 30 +++++++++++++++--------------- tests/test_config.py | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/facefusion/config.py b/facefusion/config.py index a1161fb..4a794f2 100644 --- a/facefusion/config.py +++ b/facefusion/config.py @@ -4,22 +4,22 @@ from typing import Any, List, Optional from facefusion import state_manager from facefusion.common_helper import cast_float, cast_int -CONFIG = None +CONFIG_PARSER = None -def get_config() -> ConfigParser: - global CONFIG +def get_config_parser() -> ConfigParser: + global CONFIG_PARSER - if CONFIG is None: - CONFIG = ConfigParser() - CONFIG.read(state_manager.get_item('config_path'), encoding = 'utf-8') - return CONFIG + if CONFIG_PARSER is None: + CONFIG_PARSER = ConfigParser() + CONFIG_PARSER.read(state_manager.get_item('config_path'), encoding = 'utf-8') + return CONFIG_PARSER -def clear_config() -> None: - global CONFIG +def clear_config_parser() -> None: + global CONFIG_PARSER - CONFIG = None + CONFIG_PARSER = None def get_str_value(key : str, fallback : Optional[str] = None) -> Optional[str]: @@ -81,12 +81,12 @@ def get_float_list(key : str, fallback : Optional[str] = None) -> Optional[List[ def get_value_by_notation(key : str) -> Optional[Any]: - config = get_config() + config_parser = get_config_parser() if '.' in key: section, name = key.split('.') - if section in config and name in config[section]: - return config[section][name] - if key in config: - return config[key] + if section in config_parser and name in config_parser[section]: + return config_parser[section].get(name) + if key in config_parser: + return config_parser.get(key) return None diff --git a/tests/test_config.py b/tests/test_config.py index 88550e5..43d000c 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -7,8 +7,8 @@ from facefusion import config @pytest.fixture(scope = 'module', autouse = True) def before_all() -> None: - config.CONFIG = ConfigParser() - config.CONFIG.read_dict( + config.CONFIG_PARSER = ConfigParser() + config.CONFIG_PARSER.read_dict( { 'str': {