|
|
|
|
@@ -66,7 +66,12 @@ class SettingsLoader:
|
|
|
|
|
self._check_settings_abort: bool = False
|
|
|
|
|
|
|
|
|
|
# MARK: load settings
|
|
|
|
|
def load_settings(self, config_id: str, config_validate: dict[str, list[str]]) -> dict[str, str]:
|
|
|
|
|
def load_settings(
|
|
|
|
|
self,
|
|
|
|
|
config_id: str,
|
|
|
|
|
config_validate: dict[str, list[str]],
|
|
|
|
|
allow_not_exist: bool = False
|
|
|
|
|
) -> dict[str, str]:
|
|
|
|
|
"""
|
|
|
|
|
neutral settings loader
|
|
|
|
|
|
|
|
|
|
@@ -84,9 +89,12 @@ class SettingsLoader:
|
|
|
|
|
- convert: convert to int, float -> if element is number convert, else leave as is
|
|
|
|
|
- empty: convert empty to, if nothing set on the right side then convert to None type
|
|
|
|
|
|
|
|
|
|
TODO: there should be a config/options argument for general settings
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
config_id (str): what block to load
|
|
|
|
|
config_allowed (list[str]): list of allowed entries sets
|
|
|
|
|
config_validate (dict[str, list[str]]): list of allowed entries sets
|
|
|
|
|
allow_not_exist (bool): If set to True, does not throw an error, but returns empty set
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
dict[str, str]: key = value list
|
|
|
|
|
@@ -99,6 +107,8 @@ class SettingsLoader:
|
|
|
|
|
# load all data as is, validation is done afterwards
|
|
|
|
|
settings[config_id] = dict(self.config_parser[config_id])
|
|
|
|
|
except KeyError as e:
|
|
|
|
|
if allow_not_exist is True:
|
|
|
|
|
return {}
|
|
|
|
|
self.__print(
|
|
|
|
|
f"[!] Cannot read [{config_id}] block in the {self.config_file}: {e}",
|
|
|
|
|
'CRITICAL', raise_exception=True
|
|
|
|
|
|