Config file: relative to home
This commit is contained in:
parent
c86a4bb1b9
commit
223108004f
|
@ -1,4 +1,5 @@
|
||||||
import yaml
|
import yaml
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
class BadConfig(Exception):
|
class BadConfig(Exception):
|
||||||
|
@ -11,9 +12,11 @@ class Configuration:
|
||||||
The configuration is a YAML file.
|
The configuration is a YAML file.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
BASE_CONFIG_PATH = Path.home() / "config.yml"
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
try:
|
try:
|
||||||
with open("./config.yml", "r") as handle:
|
with self.BASE_CONFIG_PATH.open("r") as handle:
|
||||||
self.raw = yaml.safe_load(handle)
|
self.raw = yaml.safe_load(handle)
|
||||||
except yaml.YAMLError as exn:
|
except yaml.YAMLError as exn:
|
||||||
raise BadConfig("Cannot parse yaml") from exn
|
raise BadConfig("Cannot parse yaml") from exn
|
||||||
|
|
Loading…
Reference in a new issue