Made config relative paths and include files expansion more robust

This commit is contained in:
Fabio Manganiello 2018-12-19 09:19:58 +01:00
parent 949d9cd619
commit 6a9ddb9e53
1 changed files with 5 additions and 2 deletions

View File

@ -116,9 +116,9 @@ class Config(object):
def _read_config_file(self, cfgfile):
cfgfile_dir = os.path.expanduser(os.path.dirname(self._cfgfile))
if not os.path.isabs(cfgfile):
cfgfile = os.path.join(os.path.expanduser(
os.path.dirname(self._cfgfile)), cfgfile)
cfgfile = os.path.join(cfgfile_dir, os.path.basename(cfgfile))
config = {}
@ -132,6 +132,9 @@ class Config(object):
else [file_config[section]]
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)
for incl_section in included_config.keys():
config[incl_section] = included_config[incl_section]