Skip to content

Commit

Permalink
Fix config loading
Browse files Browse the repository at this point in the history
  • Loading branch information
wohlgejm committed Nov 13, 2016
1 parent e832f25 commit 962d1ff
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions accountable/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,21 @@ class Config(object):
'co': 'checkout'}

def __init__(self, **kwargs):
if kwargs.get('create_config'):
self._initial_setup(kwargs)
self.config = self._load_config()
self.kwargs = kwargs
self._config = None
self.username, self.password, self.domain, self.issue_fields = \
itemgetter(
'username', 'password', 'domain', 'issue_fields'
)(self.config)
self.auth = HTTPBasicAuth(self.username, self.password)

@property
def config(self):
if self.kwargs.get('create_config'):
self._initial_setup(self.kwargs)
self._config = self._load_config()
return self._config

def _load_config(self):
with open(self.CONFIG_FILE, 'r') as f:
config = yaml.load(f)
Expand Down Expand Up @@ -60,6 +66,6 @@ def _config_dict(self, username, password, domain):

def _create_config(self, config_dict):
self._create_config_dir()
with open(self.CONFIG_FILE, 'w') as f:
with open(self.CONFIG_FILE, 'w+') as f:
f.write(yaml.dump(config_dict, default_flow_style=False))
click.echo('Configuration file written to {}'.format(self.CONFIG_FILE))

0 comments on commit 962d1ff

Please sign in to comment.