Files
yu-zhi-ran/config/__init__.py
T

32 lines
863 B
Python

#!/usr/bin/env python3
"""
配置加载模块
"""
import yaml
from pathlib import Path
CONFIG_DIR = Path(__file__).parent
def load_wecom_config():
"""加载企业微信和内容配置"""
config_path = CONFIG_DIR / "wecom_config.yaml"
with open(config_path, 'r', encoding='utf-8') as f:
return yaml.safe_load(f)
def load_sources_config():
"""加载信息源配置"""
config_path = CONFIG_DIR / "sources.yaml"
with open(config_path, 'r', encoding='utf-8') as f:
return yaml.safe_load(f)
def load_app_config():
"""加载应用主配置"""
config_path = CONFIG_DIR / "app_config.yaml"
if config_path.exists():
with open(config_path, 'r', encoding='utf-8') as f:
return yaml.safe_load(f)
return {}
# 便捷导入
__all__ = ['load_wecom_config', 'load_sources_config', 'load_app_config']