pyrelacs/pyrelacs/config/config_loader.py

27 lines
703 B
Python

from dataclasses import dataclass
import pathlib
import yaml
from IPython import embed
from pyrelacs.util.logging import config_logging
log = config_logging()
@dataclass
class Config:
# Path: str
@classmethod
def load_config(cls):
pyrelacs_config_path = pathlib.Path(__file__).parent / "config.yaml"
log.debug(pyrelacs_config_path)
if not pyrelacs_config_path.is_file():
log.error("Config File was not found")
with open(pyrelacs_config_path, "r") as config_file:
try:
return yaml.full_load(config_file)
except yaml.YAMLError as e:
raise yaml.YAMLError(f"Error parsing YAML file: {e}")