opendata-nm-exporter/src/settings.py

20 lines
474 B
Python

import os
import yaml
from pathlib import Path
class Settings:
db = {}
def __init__(self):
home = str(Path.home())
config_file = os.environ.get(
"CONFIGPATH", f"{home}/.config/opendata_nm/config.yml"
)
with open(f"{config_file}", "r") as stream:
try:
config = yaml.safe_load(stream)
self.db = config["db"]
except yaml.YAMLError as exc:
print(exc)