From 4790429f246397e1927cd07b81b7728edae5738b Mon Sep 17 00:00:00 2001 From: Marcus Stoegbauer Date: Sat, 30 Mar 2024 00:24:55 +0100 Subject: [PATCH] introduce force_filename to set filename exclusively --- userconfig/cfgfile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/userconfig/cfgfile.py b/userconfig/cfgfile.py index 7817780..2b99f24 100644 --- a/userconfig/cfgfile.py +++ b/userconfig/cfgfile.py @@ -7,13 +7,14 @@ class Conf(object): _cfgfiles = [] debug = None - def __init__(self, filename=None, debug=None): + def __init__(self, filename=None, debug=None, force_filename=False): if debug: self.set_debug(debug) filenames = [] if filename: filenames.append(filename) - filenames.append(f'{os.environ.get("HOME")}/etc/userconfig2.conf') + if not force_filename: + filenames.append(f'{os.environ.get("HOME")}/etc/userconfig2.conf') ret = self.set_filenames(filenames) if not ret: raise ValueError(f'Cannot open either configuration file: {",".join(filenames)}')