From ac41bc7fb60d50462bbff1da96c9d92982db6336 Mon Sep 17 00:00:00 2001 From: Marcus Stoegbauer Date: Sat, 30 Mar 2024 09:19:38 +0100 Subject: [PATCH] use venv etc/userconfig2.conf if it exists --- userconfig/cfgfile.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/userconfig/cfgfile.py b/userconfig/cfgfile.py index 2b99f24..df9f847 100644 --- a/userconfig/cfgfile.py +++ b/userconfig/cfgfile.py @@ -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)}')