This commit is contained in:
hhh
2024-02-02 21:53:35 +02:00
commit 90ed21c4a5
9 changed files with 158 additions and 0 deletions

View File

@@ -0,0 +1 @@
pass

View File

@@ -0,0 +1,30 @@
from ..modules.toml_parser import TomlConfig
from ..modules.writer import WriteTomlConfig
from typing import Dict, Any
class ConfigParserInterface:
@staticmethod
def parse_config(config_path: str = 'config.neko.toml') -> TomlConfig:
"""
Get toml configuration in our handy representation
:param config_path:
:return:
"""
return TomlConfig(config_path)
@staticmethod
def ensure_config(
partition: str,
module_config: Dict[str, Any],
config_path: str = 'config.neko.toml'
) -> None:
"""
Validates your module config and adds values if needed
:param partition: Your module name or any name under which you want to see this
key-value configuration table
:param module_config: Dictionary of default config keys and values, so they will
be added and verified in config
:param config_path: Path of config, if you want to use custom
"""
WriteTomlConfig(config_path).ensure({partition: module_config})