dissertation/where_fi/config/__init__.py
Christos Falas 4f7a9d2e70
Make into package
Add CLI to bin, allow for tab-completions
2025-01-27 15:55:17 +00:00

25 lines
494 B
Python

import logging
import sys
import pydantic
import yaml
from . import models
logger = logging.getLogger(__name__)
try:
config = yaml.safe_load(open("config.yaml"))
except FileNotFoundError:
logger.error(
"No config.yaml file found. Make sure to copy the "
"config.example.yaml file to config.yaml"
)
sys.exit(1)
try:
config = models.Config(**config)
except pydantic.ValidationError as e:
logger.error(f"Invalid config.yaml file: {e}")
sys.exit(1)