Made config relative paths and include files expansion more robust
This commit is contained in:
parent
949d9cd619
commit
6a9ddb9e53
1 changed files with 5 additions and 2 deletions
|
@ -116,9 +116,9 @@ class Config(object):
|
||||||
|
|
||||||
|
|
||||||
def _read_config_file(self, cfgfile):
|
def _read_config_file(self, cfgfile):
|
||||||
|
cfgfile_dir = os.path.expanduser(os.path.dirname(self._cfgfile))
|
||||||
if not os.path.isabs(cfgfile):
|
if not os.path.isabs(cfgfile):
|
||||||
cfgfile = os.path.join(os.path.expanduser(
|
cfgfile = os.path.join(cfgfile_dir, os.path.basename(cfgfile))
|
||||||
os.path.dirname(self._cfgfile)), cfgfile)
|
|
||||||
|
|
||||||
config = {}
|
config = {}
|
||||||
|
|
||||||
|
@ -132,6 +132,9 @@ class Config(object):
|
||||||
else [file_config[section]]
|
else [file_config[section]]
|
||||||
|
|
||||||
for include_file in include_files:
|
for include_file in include_files:
|
||||||
|
if not os.path.isabs(include_file):
|
||||||
|
include_file = os.path.join(cfgfile_dir, include_file)
|
||||||
|
|
||||||
included_config = self._read_config_file(include_file)
|
included_config = self._read_config_file(include_file)
|
||||||
for incl_section in included_config.keys():
|
for incl_section in included_config.keys():
|
||||||
config[incl_section] = included_config[incl_section]
|
config[incl_section] = included_config[incl_section]
|
||||||
|
|
Loading…
Reference in a new issue