Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Show materials - Python
def show_materials(materials, location):
""" show what's in the materials catalog """
key_superset = []
key_commonset = []
#
key = materials['key']
count = materials['count']
catalog = materials['materials']
if count != len(catalog):
# something not right
print "Expecting count to be same as length of catalog"
print "Failing..."
else: # good
print "Location: %s" % (location)
print " %s materials found" % (count)
for c in catalog:
keys = c.keys()
keys.sort()
# collect superset of all keys
for k in keys:
if k not in key_superset:
key_superset.append(k)
#
print " ", c['name']
if c['name'] == 'Cork':
print c['key'], c['weight'], c['thickness']
## if u'weight' in keys:
## print c['name']
## print " ", c
## #print " ",c['type']
## #print " ",c['kind']
## #print " ",c['updated_at']
## #print " ", keys
## if u'type' not in keys:
## print c['name']
## print " ", c
# Find common set of keys
key_commonset = deepcopy(key_superset)
for c in catalog:
keys = c.keys()
for k in key_commonset:
if k not in keys:
key_commonset.remove(k)
#
print "Superset of all keys found is:", key_superset
print "Common set of keys is:", key_commonset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.