From 7f0f0aa95474b22f750a903007665b21ca9c921b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Gr=C3=A4uler?= Date: Sat, 29 Jul 2017 18:43:30 +0200 Subject: [PATCH] Initialize config_dir in Config constructor --- syncrypt/config.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/syncrypt/config.py b/syncrypt/config.py index 29a638d..1c55504 100644 --- a/syncrypt/config.py +++ b/syncrypt/config.py @@ -18,8 +18,10 @@ class Config(object): default_config = {} - def __init__(self, config_path): + def __init__(self, config_path=None): self._config = configparser.ConfigParser() + if config_path is None: + config_path = os.path.join(self.config_dir, 'config') self._config_path = config_path # set defaults for k in self.default_config.keys(): @@ -71,7 +73,8 @@ def update(self, section, dct): @property def config_dir(self): - if 'app' in self._config and 'directory' in self._config['app']: + if hasattr(self, '_config') and 'app' in self._config \ + and 'directory' in self._config['app']: return self._config['app']['directory'] else: return os.path.join(os.path.expanduser('~'), '.config', 'syncrypt') @@ -168,7 +171,7 @@ class AppConfig(Config, BackendConfigMixin): } def __init__(self, config_file=None): - super(AppConfig, self).__init__(config_file or os.path.join(self.config_dir, 'config')) + super(AppConfig, self).__init__(config_file) logger.info('Syncrypt config has %d vault(s).', len(self.vault_dirs)) @property