Initial commit
This commit is contained in:
commit
6c02075a57
5 changed files with 574 additions and 0 deletions
models
25
models/config.py
Normal file
25
models/config.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
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)
|
Loading…
Add table
Add a link
Reference in a new issue