mirror of https://github.com/docker/docker-py.git
Avoid an additional level of indentation
This commit is contained in:
parent
2e66ca8a6c
commit
1345da7972
|
|
@ -108,26 +108,28 @@ def load_config(root=None):
|
||||||
if not os.path.exists(config_file):
|
if not os.path.exists(config_file):
|
||||||
return config
|
return config
|
||||||
|
|
||||||
with open(config_file) as f:
|
f = open(config_file)
|
||||||
try:
|
try:
|
||||||
config['Configs'] = json.load(f)
|
config['Configs'] = json.load(f)
|
||||||
for k, conf in six.iteritems(config['Configs']):
|
for k, conf in six.iteritems(config['Configs']):
|
||||||
conf['Username'], conf['Password'] = decode_auth(conf['auth'])
|
conf['Username'], conf['Password'] = decode_auth(conf['auth'])
|
||||||
del conf['auth']
|
del conf['auth']
|
||||||
config['Configs'][k] = conf
|
config['Configs'][k] = conf
|
||||||
except Exception:
|
except Exception:
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
buf = []
|
buf = []
|
||||||
for line in f:
|
for line in f:
|
||||||
k, v = line.split(' = ')
|
k, v = line.split(' = ')
|
||||||
buf.append(v)
|
buf.append(v)
|
||||||
if len(buf) < 2:
|
if len(buf) < 2:
|
||||||
raise Exception("The Auth config file is empty")
|
raise Exception("The Auth config file is empty")
|
||||||
user, pwd = decode_auth(buf[0])
|
user, pwd = decode_auth(buf[0])
|
||||||
config['Configs'][INDEX_URL] = {
|
config['Configs'][INDEX_URL] = {
|
||||||
'Username': user,
|
'Username': user,
|
||||||
'Password': pwd,
|
'Password': pwd,
|
||||||
'Email': buf[1]
|
'Email': buf[1]
|
||||||
}
|
}
|
||||||
|
finally:
|
||||||
|
f.close()
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue