mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-11 00:06:04 +00:00
feat: 实现配置文件管理器并适配main.py中的引用
This commit is contained in:
23
pkg/config/manager.py
Normal file
23
pkg/config/manager.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from . import model as file_model
|
||||
from ..utils import context
|
||||
|
||||
|
||||
class ConfigManager:
|
||||
"""配置文件管理器"""
|
||||
|
||||
file: file_model.ConfigFile = None
|
||||
"""配置文件实例"""
|
||||
|
||||
data: dict = None
|
||||
"""配置数据"""
|
||||
|
||||
def __init__(self, cfg_file: file_model.ConfigFile) -> None:
|
||||
self.file = cfg_file
|
||||
self.data = {}
|
||||
context.set_config_manager(self)
|
||||
|
||||
async def load_config(self):
|
||||
self.data = await self.file.load()
|
||||
|
||||
async def dump_config(self):
|
||||
await self.file.save(self.data)
|
||||
Reference in New Issue
Block a user