step-ca-inspector/models/config.py
2025-01-07 09:50:19 +01:00

25 lines
701 B
Python

import os
import sys
import yaml
class config:
@classmethod
def __init__(self):
for config_path in (
os.path.expanduser("~/.config/step-ca-inspector"),
os.environ.get("STEP_CA_INSPECTOR_CONF"),
):
if config_path is None:
continue
try:
with open(os.path.join(config_path, "config.yaml")) as ymlfile:
cfg = yaml.load(ymlfile, Loader=yaml.FullLoader)
break
except IOError:
pass
else:
print("No configuration file found")
sys.exit(1)
for k, v in cfg.items():
setattr(self, k, v)