only add HOME from environ to ConfigParser, set _cfgfiles on loading, add comment on default ocnfig file locations
This commit is contained in:
parent
015ea337f2
commit
7684033903
@ -4,7 +4,7 @@ import sys
|
|||||||
|
|
||||||
|
|
||||||
class Conf(object):
|
class Conf(object):
|
||||||
_confobj = configparser.ConfigParser(os.environ)
|
_confobj = configparser.ConfigParser(dict(HOME=os.environ.get('HOME')))
|
||||||
_cfgfiles = []
|
_cfgfiles = []
|
||||||
debug = None
|
debug = None
|
||||||
|
|
||||||
@ -15,6 +15,8 @@ class Conf(object):
|
|||||||
if filename:
|
if filename:
|
||||||
filenames.append(filename)
|
filenames.append(filename)
|
||||||
if not force_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'):
|
if os.path.isfile(f'{os.environ.get("HOME")}/etc/userconfig2.conf'):
|
||||||
filenames.append(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'):
|
if os.path.isfile(f'{sys.prefix}/etc/userconfig2.conf'):
|
||||||
@ -30,6 +32,7 @@ class Conf(object):
|
|||||||
ret = self._confobj.read(filenames)
|
ret = self._confobj.read(filenames)
|
||||||
if len(ret) == 0:
|
if len(ret) == 0:
|
||||||
return None
|
return None
|
||||||
|
self._cfgfiles = ret
|
||||||
if self.debug:
|
if self.debug:
|
||||||
self.debug.stdout("Read config files: %s" % ", ".join(filenames), 2)
|
self.debug.stdout("Read config files: %s" % ", ".join(filenames), 2)
|
||||||
return ret
|
return ret
|
||||||
|
Loading…
Reference in New Issue
Block a user