use venv etc/userconfig2.conf if it exists

This commit is contained in:
Marcus Stoegbauer 2024-03-30 09:19:38 +01:00
parent d8bb56cb7b
commit ac41bc7fb6

View File

@ -1,5 +1,6 @@
import configparser
import os
import sys
class Conf(object):
@ -14,7 +15,10 @@ class Conf(object):
if filename:
filenames.append(filename)
if not force_filename:
filenames.append(f'{os.environ.get("HOME")}/etc/userconfig2.conf')
if os.path.isfile(f'{os.environ.get("HOME")}/etc/userconfig2.conf'):
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')
ret = self.set_filenames(filenames)
if not ret:
raise ValueError(f'Cannot open either configuration file: {",".join(filenames)}')