MCPcopy Create free account
hub / github.com/alephdata/aleph / _normalize_data

Function _normalize_data

aleph/tests/test_entitysets_api.py:19–34  ·  view source on GitHub ↗

Turn entities in properties into entity ids

(data)

Source from the content-addressed store, hash-verified

17
18
19def _normalize_data(data):
20 """Turn entities in properties into entity ids"""
21 entities = data["layout"]["entities"]
22 for obj in entities:
23 schema = model.get(obj.get("schema"))
24 if schema is None:
25 raise InvalidData("Invalid schema %s" % obj.get("schema"))
26 properties = obj.get("properties", {})
27 for name, values in list(properties.items()):
28 prop = schema.get(name)
29 if prop.type == registry.entity:
30 properties[prop.name] = []
31 for value in ensure_list(values):
32 entity_id = get_entity_id(value)
33 properties[prop.name].append(entity_id)
34 return data
35
36
37class EntitySetAPITest(TestCase):

Callers

nothing calls this directly

Calls 2

getMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected