diff options
author | shin- <joffrey@dotcloud.com> | 2013-11-08 20:43:50 +0100 |
---|---|---|
committer | shin- <joffrey@dotcloud.com> | 2013-11-08 20:43:50 +0100 |
commit | 1345da797234ae8df22a444607a56e0d02b2ff82 (patch) | |
tree | dd42bd8443b6dfb4df9b21fc399443bb1f6c2b4c /docker/auth | |
parent | 2e66ca8a6cf567f8ec43d207179f6580a13f9878 (diff) | |
download | docker-py-1345da797234ae8df22a444607a56e0d02b2ff82.tar.gz |
Avoid an additional level of indentation
Diffstat (limited to 'docker/auth')
-rw-r--r-- | docker/auth/auth.py | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/docker/auth/auth.py b/docker/auth/auth.py index fc27559..92a7193 100644 --- a/docker/auth/auth.py +++ b/docker/auth/auth.py @@ -108,26 +108,28 @@ def load_config(root=None): if not os.path.exists(config_file): return config - with open(config_file) as f: - try: - config['Configs'] = json.load(f) - for k, conf in six.iteritems(config['Configs']): - conf['Username'], conf['Password'] = decode_auth(conf['auth']) - del conf['auth'] - config['Configs'][k] = conf - except Exception: - f.seek(0) - buf = [] - for line in f: - k, v = line.split(' = ') - buf.append(v) - if len(buf) < 2: - raise Exception("The Auth config file is empty") - user, pwd = decode_auth(buf[0]) - config['Configs'][INDEX_URL] = { - 'Username': user, - 'Password': pwd, - 'Email': buf[1] - } + f = open(config_file) + try: + config['Configs'] = json.load(f) + for k, conf in six.iteritems(config['Configs']): + conf['Username'], conf['Password'] = decode_auth(conf['auth']) + del conf['auth'] + config['Configs'][k] = conf + except Exception: + f.seek(0) + buf = [] + for line in f: + k, v = line.split(' = ') + buf.append(v) + if len(buf) < 2: + raise Exception("The Auth config file is empty") + user, pwd = decode_auth(buf[0]) + config['Configs'][INDEX_URL] = { + 'Username': user, + 'Password': pwd, + 'Email': buf[1] + } + finally: + f.close() return config |