From 96020cf92853f11eb77ae19a97841c8591294050 Mon Sep 17 00:00:00 2001 From: gryf Date: Tue, 1 Sep 2020 22:09:11 +0200 Subject: [PATCH] Added ability to load configuration from external file --- wicd/config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wicd/config.py b/wicd/config.py index 3117e37..01d665f 100644 --- a/wicd/config.py +++ b/wicd/config.py @@ -20,7 +20,7 @@ DEFAULTS = {'bin': '/usr/bin', 'varlib': '/var/lib/wicd', 'wicdgroup': 'users'} SECTION = 'wicd' -CFG_FILE = 'wicd.conf' +CFG_FILE = os.path.join(DEFAULTS['etc'], 'wicd.conf') class Config(dict): @@ -35,14 +35,14 @@ class Config(dict): for name, path in DEFAULTS.items(): self.parser.set(self.parser.default_section, name, path) - def load(self): + def load(self, cfg_file=CFG_FILE): """ Try to load config from hardcoded location. At least, on proper installation, we need to have an entry point to look at. Most of the time distro package maintainers rely on defaults, since they are sane and mostly tested. Let's keep it up. """ - self.parser.read(os.path.join(self.etc, CFG_FILE)) + self.parser.read(cfg_file) if SECTION in self.parser.sections(): for opt in self.parser.options(SECTION): self[opt] = self.parser.get(SECTION, opt)