Skip to content

Commit

Permalink
Initialize config_dir in Config constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
lordi committed Jul 29, 2017
1 parent d6a20a9 commit 7f0f0aa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions syncrypt/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7f0f0aa

Please sign in to comment.