Skip to content

Commit 7f0f0aa

Browse files
committed
Initialize config_dir in Config constructor
1 parent d6a20a9 commit 7f0f0aa

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

syncrypt/config.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ class Config(object):
1818

1919
default_config = {}
2020

21-
def __init__(self, config_path):
21+
def __init__(self, config_path=None):
2222
self._config = configparser.ConfigParser()
23+
if config_path is None:
24+
config_path = os.path.join(self.config_dir, 'config')
2325
self._config_path = config_path
2426
# set defaults
2527
for k in self.default_config.keys():
@@ -71,7 +73,8 @@ def update(self, section, dct):
7173

7274
@property
7375
def config_dir(self):
74-
if 'app' in self._config and 'directory' in self._config['app']:
76+
if hasattr(self, '_config') and 'app' in self._config \
77+
and 'directory' in self._config['app']:
7578
return self._config['app']['directory']
7679
else:
7780
return os.path.join(os.path.expanduser('~'), '.config', 'syncrypt')
@@ -168,7 +171,7 @@ class AppConfig(Config, BackendConfigMixin):
168171
}
169172

170173
def __init__(self, config_file=None):
171-
super(AppConfig, self).__init__(config_file or os.path.join(self.config_dir, 'config'))
174+
super(AppConfig, self).__init__(config_file)
172175
logger.info('Syncrypt config has %d vault(s).', len(self.vault_dirs))
173176

174177
@property

0 commit comments

Comments
 (0)