alkaid_release_platform/database/__init__.py
ekko.bao 0a0f6a6054 初次创建仓库提交代码
1. 已经构建好了架子了。
2. 添加了示例的插件
2025-04-21 06:37:06 +00:00

31 lines
1.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from .base import *
from .dirs import *
from .configs import *
from .options import *
from .common import *
from .customer import *
from .black import *
def load_from_file(config_path:str=None):
"""从文件加载customer配置
"""
if not os.path.exists(config_path):
log.warning(f"{config_path} doesn't exists")
return
with open(config_path, 'r') as f:
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from thirdparty import yaml
obj = yaml.safe_load(f.read())
# 遍历该package下的所有数据如果是 BaseConfig 类型的实例则进行更新操作
for class_name in globals():
instance = globals()[class_name]
if isinstance(instance, BaseConfig):
class_name = instance.__class__.__name__
if class_name not in obj:
log.debug(f"No Customer Config update ==> {class_name}")
continue
log.info(f"Update Customer Config Cnt: {len(obj[class_name]):3d} ==> {class_name}")
instance = instance.update_from_extra(obj[class_name])
globals()[class_name] = instance