From 223108004f6b83c02d96af8aa07d88ae1e3b2b9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Fri, 15 Apr 2022 20:00:05 +0200 Subject: [PATCH] Config file: relative to home --- gitea_hooks/conf.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gitea_hooks/conf.py b/gitea_hooks/conf.py index 630a6e5..1082705 100644 --- a/gitea_hooks/conf.py +++ b/gitea_hooks/conf.py @@ -1,4 +1,5 @@ import yaml +from pathlib import Path class BadConfig(Exception): @@ -11,9 +12,11 @@ class Configuration: The configuration is a YAML file. """ + BASE_CONFIG_PATH = Path.home() / "config.yml" + def __init__(self): try: - with open("./config.yml", "r") as handle: + with self.BASE_CONFIG_PATH.open("r") as handle: self.raw = yaml.safe_load(handle) except yaml.YAMLError as exn: raise BadConfig("Cannot parse yaml") from exn