Index: tools/json_schema_compiler/json_schema.py |
diff --git a/tools/json_schema_compiler/json_schema.py b/tools/json_schema_compiler/json_schema.py |
index 46ca4874c57486e55dcebfd00eed29ed393b0726..240a1685f70db8a7319f0e2520e8ff40f66a8b39 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 |