Fix writer and load folder
This commit is contained in:
@@ -1,23 +1,33 @@
|
||||
import dataclasses
|
||||
from ..modules.toml_parser import TomlConfig
|
||||
from ..modules.writer import WriteTomlConfig
|
||||
from typing import Dict, Any
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class __HiddenStorage:
|
||||
nekomata_folder: str = ''
|
||||
|
||||
|
||||
_storage = __HiddenStorage()
|
||||
|
||||
|
||||
class ConfigParserInterface:
|
||||
@staticmethod
|
||||
def parse_config(config_path: str = 'config.neko.toml') -> TomlConfig:
|
||||
def parse_config(config_path: str = None) -> TomlConfig:
|
||||
"""
|
||||
Get toml configuration in our handy representation
|
||||
:param config_path:
|
||||
:return:
|
||||
"""
|
||||
return TomlConfig(config_path)
|
||||
return TomlConfig(config_path if config_path
|
||||
else _storage.nekomata_folder + '/config.neko.toml')
|
||||
|
||||
@staticmethod
|
||||
def ensure_config(
|
||||
partition: str,
|
||||
module_config: Dict[str, Any],
|
||||
config_path: str = 'config.neko.toml'
|
||||
config_path: str = None
|
||||
) -> None:
|
||||
"""
|
||||
Validates your module config and adds values if needed
|
||||
@@ -27,4 +37,14 @@ class ConfigParserInterface:
|
||||
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})
|
||||
WriteTomlConfig(
|
||||
config_path if config_path
|
||||
else _storage.nekomata_folder + '/config.neko.toml'
|
||||
).ensure({partition: module_config})
|
||||
|
||||
@staticmethod
|
||||
def get_nekomata_folder():
|
||||
return _storage.nekomata_folder
|
||||
|
||||
|
||||
__all__ = [ConfigParserInterface]
|
||||
|
||||
Reference in New Issue
Block a user