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)}')