[config] adding dataclass for config

This commit is contained in:
wendtalexander 2024-10-14 08:40:52 +02:00
parent 0e0aaf9f04
commit 38123cdff3

View File

@ -0,0 +1,26 @@
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}")