From fa21f2096cc2f9b5304174cb47542f62edcf1eca Mon Sep 17 00:00:00 2001 From: Alexander Dietrich Date: Fri, 28 Oct 2016 22:12:24 +0200 Subject: [PATCH] Remove garbage "function:" items from node data --- lib/validate.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/validate.py b/lib/validate.py index eb6c11f..0b1bfd6 100644 --- a/lib/validate.py +++ b/lib/validate.py @@ -5,12 +5,25 @@ def validate_nodeinfos(nodeinfos): result = [] for nodeinfo in nodeinfos: + nodeinfo = remove_garbage(nodeinfo) if validate_nodeinfo(nodeinfo): result.append(nodeinfo) 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): if 'location' in nodeinfo: if 'latitude' not in nodeinfo['location'] or 'longitude' not in nodeinfo['location']: