filename supplied in __init__ will be read last, so it has highest priority

This commit is contained in:
Marcus Stoegbauer 2024-03-30 20:49:42 +01:00
parent c6405e9c2a
commit 4640a5edc3

View File

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