Handle possible lack of extensions

This commit is contained in:
Roland Hedberg
2014-04-08 17:37:56 +02:00
parent 3740d80810
commit 69c5e078e0

View File

@@ -815,14 +815,18 @@ class MetadataStore(object):
:type entity_id: string
:rtype: dict
"""
ext = self.__getitem__(entity_id)["extensions"]
res = {}
try:
ext = self.__getitem__(entity_id)["extensions"]
except KeyError:
return res
for elem in ext["extension_elements"]:
if elem["__class__"] == ENTITYATTRIBUTES:
for attr in elem["attribute"]:
if attr["name"] not in res:
res[attr["name"]] = []
res[attr["name"]] += [v["text"] for v in attr["attribute_value"]]
res[attr["name"]] += [v["text"] for v in attr[
"attribute_value"]]
return res
def bindings(self, entity_id, typ, service):