summaryrefslogtreecommitdiffstats
path: root/tools/json_schema_compiler/json_schema.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/json_schema_compiler/json_schema.py')
-rw-r--r--tools/json_schema_compiler/json_schema.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/tools/json_schema_compiler/json_schema.py b/tools/json_schema_compiler/json_schema.py
index 46ca487..240a168 100644
--- a/tools/json_schema_compiler/json_schema.py
+++ b/tools/json_schema_compiler/json_schema.py
@@ -48,9 +48,28 @@ def StripJSONComments(stream):
return result
+def DeleteNocompileNodes(item):
+ def HasNocompile(thing):
+ return type(thing) == dict and thing.get('nocompile', False)
+
+ if type(item) == dict:
+ toDelete = []
+ for key, value in item.items():
+ if HasNocompile(value):
+ toDelete.append(key)
+ else:
+ DeleteNocompileNodes(value)
+ for key in toDelete:
+ del item[key]
+ elif type(item) == list:
+ item[:] = [DeleteNocompileNodes(thing)
+ for thing in item if not HasNocompile(thing)]
+
+ return item
+
def Load(filename):
with open(filename, 'r') as handle:
- return json.loads(StripJSONComments(handle.read()))
+ return DeleteNocompileNodes(json.loads(StripJSONComments(handle.read())))
# A dictionary mapping |filename| to the object resulting from loading the JSON