From 04ee93fc8b8a33df711696756e12e33ce9db9c3f Mon Sep 17 00:00:00 2001 From: Artem30801 Date: Tue, 7 Jan 2020 17:23:45 +0300 Subject: [PATCH] Fixed configspec loading for dicts --- config.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/config.py b/config.py index 95539d3..824d280 100644 --- a/config.py +++ b/config.py @@ -265,10 +265,11 @@ class ConfigManager: if isinstance(configspec, dict): kwargs.update({'configspec': configspec}) elif isinstance(configspec, str): - if not self._config_exists(configspec): - configspec = self._get_spec_path(configspec) - if self._config_exists(configspec): - kwargs.update({'configspec': configspec}) + spec_path = self._get_spec_path(configspec) # check for /spec, then for config + if not self._config_exists(spec_path): + spec_path = configspec + if self._config_exists(spec_path): + kwargs.update({'configspec': spec_path}) config = ConfigObj(**kwargs) config.filename = configspec if isinstance(configspec, str) else None @@ -321,7 +322,7 @@ if __name__ == '__main__': #pprint.pprint(cfg2.full_dict) cfg.merge(cfg2) #pprint.pprint(cfg.full_dict) - print(cfg.config) + print(cfg.full_dict) print(dict(cfg.config.configspec)) #print(dict(ConfigManager(cfg.config.configspec).config))