refactor: filter和ignore独立成新的cntfilter包

This commit is contained in:
RockChinQ
2024-01-25 15:28:23 +08:00
parent f4ae9df3bf
commit a9a798b19d
17 changed files with 440 additions and 146 deletions
+27
View File
@@ -1,5 +1,6 @@
from . import model as file_model
from ..utils import context
from .impls import pymodule, json as json_file
class ConfigManager:
@@ -20,3 +21,29 @@ class ConfigManager:
async def dump_config(self):
await self.file.save(self.data)
async def load_python_module_config(config_name: str, template_name: str) -> ConfigManager:
"""加载Python模块配置文件"""
cfg_inst = pymodule.PythonModuleConfigFile(
config_name,
template_name
)
cfg_mgr = ConfigManager(cfg_inst)
await cfg_mgr.load_config()
return cfg_mgr
async def load_json_config(config_name: str, template_name: str) -> ConfigManager:
"""加载JSON配置文件"""
cfg_inst = json_file.JSONConfigFile(
config_name,
template_name
)
cfg_mgr = ConfigManager(cfg_inst)
await cfg_mgr.load_config()
return cfg_mgr