diff --git a/userconfig/cfgfile.py b/userconfig/cfgfile.py index df9f847..395f9f3 100644 --- a/userconfig/cfgfile.py +++ b/userconfig/cfgfile.py @@ -4,7 +4,7 @@ import sys class Conf(object): - _confobj = configparser.ConfigParser(os.environ) + _confobj = configparser.ConfigParser(dict(HOME=os.environ.get('HOME'))) _cfgfiles = [] debug = None @@ -15,6 +15,8 @@ class Conf(object): if filename: filenames.append(filename) if not force_filename: + # default config files are $HOME/etc/userconfig2.conf and + # {sys.prefix}/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'): @@ -30,6 +32,7 @@ class Conf(object): ret = self._confobj.read(filenames) if len(ret) == 0: return None + self._cfgfiles = ret if self.debug: self.debug.stdout("Read config files: %s" % ", ".join(filenames), 2) return ret