alkaid_release_platform/database/__init__.py

31 lines
1.1 KiB
Python
Raw Normal View History

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