mirror of
https://github.com/Nighthawk42/mOrpheus.git
synced 2026-08-30 09:22:26 +00:00
21 lines
632 B
Python
21 lines
632 B
Python
# modules/config.py
|
|
import os
|
|
import yaml
|
|
from modules.logging import logger
|
|
|
|
class ConfigError(Exception):
|
|
pass
|
|
|
|
_config_cache = None
|
|
|
|
def load_config(config_file="settings.yml"):
|
|
global _config_cache
|
|
if _config_cache is None:
|
|
if not os.path.exists(config_file):
|
|
logger.error("Configuration file %s not found.", config_file)
|
|
raise ConfigError(f"Configuration file {config_file} not found.")
|
|
with open(config_file, "r", encoding="utf-8") as f:
|
|
_config_cache = yaml.safe_load(f)
|
|
logger.info("Configuration loaded from %s", config_file)
|
|
return _config_cache
|