Commit 6dd71f50 authored by Lukas Jelonek's avatar Lukas Jelonek
Browse files

Fix bug: info command lists some providers multiple times

parent a7a6c443
...@@ -10,7 +10,10 @@ def _load_providers(path): ...@@ -10,7 +10,10 @@ def _load_providers(path):
data = [] data = []
with open(path) as data_file: with open(path) as data_file:
data = yaml.load(data_file) data = yaml.load(data_file)
return normalize_index(index_providers(data)) return data
def load_indexed_providers():
return normalize_index(index_providers(load_providers()))
def index_providers(providers): def index_providers(providers):
index = {} index = {}
...@@ -24,10 +27,10 @@ def normalize_index(index): ...@@ -24,10 +27,10 @@ def normalize_index(index):
return {k.lower():v for (k,v) in index.items()} return {k.lower():v for (k,v) in index.items()}
def has_provider(provider): def has_provider(provider):
return _has_provider(load_providers(), provider) return _has_provider(load_indexed_providers(), provider)
def _has_provider(providers, provider): def _has_provider(providers, provider):
return provider.lower() in providers return provider.lower() in providers
def get_provider(provider): def get_provider(provider):
return load_providers()[provider.lower()] return load_indexed_providers()[provider.lower()]
...@@ -43,8 +43,7 @@ def info(args, cfg): ...@@ -43,8 +43,7 @@ def info(args, cfg):
print ('') print ('')
print ('Supported dbxref databases:') print ('Supported dbxref databases:')
providers = config.load_providers() providers = config.load_providers()
for key in providers: for provider in providers:
provider = providers[key]
print (' ' + provider['name']) print (' ' + provider['name'])
print (' Prefixes: ' + str.join(', ', [x for x in provider['prefixes']])) print (' Prefixes: ' + str.join(', ', [x for x in provider['prefixes']]))
print (' Formats : ' + str.join(', ', [x for x in provider['resources']])) print (' Formats : ' + str.join(', ', [x for x in provider['resources']]))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment