Use an if/else for returning the client in get_client
Attempting to do something more fancy lead the method to instanciate both clients, let's not do that. Change-Id: I0c8abc48ce146fe7dec592779b4cd07dedcc3bd8
This commit is contained in:
parent
4a3f2b4418
commit
bb45af0f98
@ -23,12 +23,9 @@ def get_client(client="offline", endpoint="http://127.0.0.1:8000", timeout=30):
|
|||||||
"""
|
"""
|
||||||
Returns a specified client configuration or one with sane defaults.
|
Returns a specified client configuration or one with sane defaults.
|
||||||
"""
|
"""
|
||||||
try:
|
if client == "offline":
|
||||||
# fmt: off
|
return AraOfflineClient()
|
||||||
return {
|
elif client == "http":
|
||||||
"offline": AraOfflineClient(),
|
return AraHttpClient(endpoint=endpoint, timeout=timeout)
|
||||||
"http": AraHttpClient(endpoint=endpoint, timeout=timeout)
|
else:
|
||||||
}[client]
|
|
||||||
# fmt: on
|
|
||||||
except KeyError:
|
|
||||||
raise ValueError(f"Unsupported API client: {client} (use 'http' or 'offline')")
|
raise ValueError(f"Unsupported API client: {client} (use 'http' or 'offline')")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user