25 lines
701 B
Python
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)
|