From 4640a5edc330b414d480c9aa7faa38a955f95345 Mon Sep 17 00:00:00 2001 From: Marcus Stoegbauer Date: Sat, 30 Mar 2024 20:49:42 +0100 Subject: [PATCH] filename supplied in __init__ will be read last, so it has highest priority --- userconfig/cfgfile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/userconfig/cfgfile.py b/userconfig/cfgfile.py index 395f9f3..db95c76 100644 --- a/userconfig/cfgfile.py +++ b/userconfig/cfgfile.py @@ -12,8 +12,6 @@ class Conf(object): if debug: self.set_debug(debug) filenames = [] - if filename: - filenames.append(filename) if not force_filename: # default config files are $HOME/etc/userconfig2.conf and # {sys.prefix}/etc/userconfig2.conf @@ -21,6 +19,9 @@ class Conf(object): filenames.append(f'{os.environ.get("HOME")}/etc/userconfig2.conf') if os.path.isfile(f'{sys.prefix}/etc/userconfig2.conf'): filenames.append(f'{sys.prefix}/etc/userconfig2.conf') + # supplied filename will be read last, has highest priority + if filename: + filenames.append(filename) ret = self.set_filenames(filenames) if not ret: raise ValueError(f'Cannot open either configuration file: {",".join(filenames)}')