Merge pull request #11194 from ic4f/dev_api_script_fix_bug

Fix bug: code expects dictionary, but value can be string
This commit is contained in:
Marius van den Beek
2021-01-22 11:16:16 +01:00
committed by GitHub
+11 -8
View File
@@ -86,14 +86,17 @@ def display(api_key, url, return_formatted=True):
print('Collection Members')
print('------------------')
for n, i in enumerate(r):
# All collection members should have a name in the response.
# url is optional
if 'url' in i:
print('#%d: %s' % (n + 1, i.pop('url')))
if 'name' in i:
print(' name: %s' % i.pop('name'))
for k, v in i.items():
print(f' {k}: {v}')
if isinstance(i, str):
print(' %s' % i)
else:
# All collection members should have a name in the response.
# url is optional
if 'url' in i:
print('#%d: %s' % (n + 1, i.pop('url')))
if 'name' in i:
print(' name: %s' % i.pop('name'))
for k, v in i.items():
print(' %s: %s' % (k, v))
print('')
print('%d element(s) in collection' % len(r))
elif type(r) == dict: