Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Unified Diff: tools/json_schema_compiler/json_schema.py

Issue 12041098: Initial commit of the Dart Chrome Extension APIs generators (Closed) Base URL: http://git.chromium.org/chromium/src.git@file_path_bugfix
Patch Set: Kalman fixes 2 (nocompile ignored in bundle mode) Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/json_schema_compiler/idl_schema.py ('k') | tools/json_schema_compiler/json_schema_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8ee53a8dc03b633759edbc44c74ee4b55dd9b784..0fa1ba57e9669379d75f1909215dc751816fe54d 100644
--- a/tools/json_schema_compiler/json_schema.py
+++ b/tools/json_schema_compiler/json_schema.py
@@ -9,22 +9,25 @@ import sys
import json_parse
import schema_util
-def DeleteNocompileNodes(item):
- def HasNocompile(thing):
- return json_parse.IsDict(thing) and thing.get('nocompile', False)
+def DeleteNodes(item, delete_key):
+ """Deletes the given nodes in item, recursively, that have |delete_key| as
+ an attribute.
+ """
+ def HasKey(thing):
+ return json_parse.IsDict(thing) and thing.get(delete_key, False)
if json_parse.IsDict(item):
toDelete = []
for key, value in item.items():
- if HasNocompile(value):
+ if HasKey(value):
toDelete.append(key)
else:
- DeleteNocompileNodes(value)
+ DeleteNodes(value, delete_key)
for key in toDelete:
del item[key]
elif type(item) == list:
- item[:] = [DeleteNocompileNodes(thing)
- for thing in item if not HasNocompile(thing)]
+ item[:] = [DeleteNodes(thing, delete_key)
+ for thing in item if not HasKey(thing)]
return item
@@ -44,3 +47,4 @@ def CachedLoad(filename):
# Return a copy of the object so that any changes a caller makes won't affect
# the next caller.
return copy.deepcopy(_cache[filename])
+
« no previous file with comments | « tools/json_schema_compiler/idl_schema.py ('k') | tools/json_schema_compiler/json_schema_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698