From 6a9ddb9e5309732f67265ec4ec1275d17ebd5180 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 19 Dec 2018 09:19:58 +0100 Subject: [PATCH] Made config relative paths and include files expansion more robust --- platypush/config/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platypush/config/__init__.py b/platypush/config/__init__.py index cc2cede904..921e322f2a 100644 --- a/platypush/config/__init__.py +++ b/platypush/config/__init__.py @@ -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]