From c061fb9215cdb95d8e61e5cb83b6c4db1286536b Mon Sep 17 00:00:00 2001 From: vky Date: Mon, 24 Jan 2022 22:09:01 +0100 Subject: [PATCH] started work --- modules/config.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/modules/config.py b/modules/config.py index d123fe7..355399e 100644 --- a/modules/config.py +++ b/modules/config.py @@ -1 +1,24 @@ -# Interprets config files \ No newline at end of file +# Interprets config files + +import yaml +class ConfigLoader(): + """ + Reads config files. + """ + + def __init__(self, configfile): + with open(configfile, "r") as f: + self.loadedconf = yaml.safe_load(f) + def __getitem__(self, item): + return self.loadedconf[item] + +class UserConfig(ConfigLoader): + def __init__(self, configfile): + super().__init__(configfile) + +class GlobalConfig(ConfigLoader): + def __init__(self, configfile): + super().__init__(configfile) + + +conf = ConfigLoader("./example_userfiles/config/aliases.yml") \ No newline at end of file