Merge pull request #352 from martenson/scripts-api-display-optional-url

fix common API scripts so they dont fail when response has no url param
This commit is contained in:
John Chilton
2015-06-16 15:03:10 -04:00
2 changed files with 8 additions and 4 deletions
+4 -2
View File
@@ -94,8 +94,10 @@ def display( url, api_key=None, return_formatted=True ):
print 'Collection Members'
print '------------------'
for n, i in enumerate(r):
# All collection members should have a name and url in the response.
print '#%d: %s' % (n+1, i.pop( 'url' ) )
# 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():
+4 -2
View File
@@ -89,8 +89,10 @@ 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 and url in the response.
print '#%d: %s' % (n+1, i.pop( 'url' ) )
# 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():