Change naming of config parser
This commit is contained in:
@@ -4,22 +4,22 @@ from typing import Any, List, Optional
|
|||||||
from facefusion import state_manager
|
from facefusion import state_manager
|
||||||
from facefusion.common_helper import cast_float, cast_int
|
from facefusion.common_helper import cast_float, cast_int
|
||||||
|
|
||||||
CONFIG = None
|
CONFIG_PARSER = None
|
||||||
|
|
||||||
|
|
||||||
def get_config() -> ConfigParser:
|
def get_config_parser() -> ConfigParser:
|
||||||
global CONFIG
|
global CONFIG_PARSER
|
||||||
|
|
||||||
if CONFIG is None:
|
if CONFIG_PARSER is None:
|
||||||
CONFIG = ConfigParser()
|
CONFIG_PARSER = ConfigParser()
|
||||||
CONFIG.read(state_manager.get_item('config_path'), encoding = 'utf-8')
|
CONFIG_PARSER.read(state_manager.get_item('config_path'), encoding = 'utf-8')
|
||||||
return CONFIG
|
return CONFIG_PARSER
|
||||||
|
|
||||||
|
|
||||||
def clear_config() -> None:
|
def clear_config_parser() -> None:
|
||||||
global CONFIG
|
global CONFIG_PARSER
|
||||||
|
|
||||||
CONFIG = None
|
CONFIG_PARSER = None
|
||||||
|
|
||||||
|
|
||||||
def get_str_value(key : str, fallback : Optional[str] = None) -> Optional[str]:
|
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]:
|
def get_value_by_notation(key : str) -> Optional[Any]:
|
||||||
config = get_config()
|
config_parser = get_config_parser()
|
||||||
|
|
||||||
if '.' in key:
|
if '.' in key:
|
||||||
section, name = key.split('.')
|
section, name = key.split('.')
|
||||||
if section in config and name in config[section]:
|
if section in config_parser and name in config_parser[section]:
|
||||||
return config[section][name]
|
return config_parser[section].get(name)
|
||||||
if key in config:
|
if key in config_parser:
|
||||||
return config[key]
|
return config_parser.get(key)
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ from facefusion import config
|
|||||||
|
|
||||||
@pytest.fixture(scope = 'module', autouse = True)
|
@pytest.fixture(scope = 'module', autouse = True)
|
||||||
def before_all() -> None:
|
def before_all() -> None:
|
||||||
config.CONFIG = ConfigParser()
|
config.CONFIG_PARSER = ConfigParser()
|
||||||
config.CONFIG.read_dict(
|
config.CONFIG_PARSER.read_dict(
|
||||||
{
|
{
|
||||||
'str':
|
'str':
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user