import os import yaml SERVICES_DIR = "services" CONFIG_DIR = "configs" def load_services(): services = [] for filename in os.listdir(SERVICES_DIR): if not filename.endswith(".yaml"): continue path = os.path.join(SERVICES_DIR, filename) with open(path, "r", encoding="utf-8") as f: cfg = yaml.safe_load(f) if not cfg.get("enabled", True): continue services.append(cfg) return services def load_app_config(): config = {} if not os.path.isdir(CONFIG_DIR): return config for filename in os.listdir(CONFIG_DIR): if not filename.endswith((".yml", ".yaml")): continue path = os.path.join(CONFIG_DIR, filename) with open(path, "r", encoding="utf-8") as f: data = yaml.safe_load(f) or {} # merge config config.update(data) return config