Remove garbage "function:" items from node data

This commit is contained in:
Alexander Dietrich 2016-10-28 22:12:24 +02:00
parent 4b5bad262c
commit fa21f2096c

View file

@ -5,12 +5,25 @@ def validate_nodeinfos(nodeinfos):
result = [] result = []
for nodeinfo in nodeinfos: for nodeinfo in nodeinfos:
nodeinfo = remove_garbage(nodeinfo)
if validate_nodeinfo(nodeinfo): if validate_nodeinfo(nodeinfo):
result.append(nodeinfo) result.append(nodeinfo)
return result return result
def remove_garbage(nodeinfo):
garbage_keys = []
for k, v in nodeinfo.items():
if k.startswith('function:'):
garbage_keys.append(k)
elif isinstance(v, dict):
remove_garbage(v)
for k in garbage_keys:
del nodeinfo[k]
return nodeinfo
def validate_nodeinfo(nodeinfo): def validate_nodeinfo(nodeinfo):
if 'location' in nodeinfo: if 'location' in nodeinfo:
if 'latitude' not in nodeinfo['location'] or 'longitude' not in nodeinfo['location']: if 'latitude' not in nodeinfo['location'] or 'longitude' not in nodeinfo['location']: