mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2026-12-04 03:55:23 +03:00
Fix deep_get not returning the correct on success
I forgot to actually return the given data if we manage to index to the requested depth
This commit is contained in:
1 parent
2403ed1d2f
commit
b6482878f0
1 file changed
+7
-5
@@ -49,16 +49,18 @@ def versioncmp(versionstring):
|
||||
|
||||
|
||||
def deep_get(target: dict, *args: str, default=None) -> Any:
|
||||
if not hasattr(target, 'get'):
|
||||
raise ValueError("Cannot call get on {} ({})".format(target, type(target)))
|
||||
|
||||
current = target
|
||||
for arg in args:
|
||||
res = current.get(arg)
|
||||
if res is not None:
|
||||
current = res
|
||||
if res is None:
|
||||
return default
|
||||
|
||||
else:
|
||||
break
|
||||
current = res
|
||||
|
||||
return default
|
||||
return current
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in new issue
Block a user