Index: tools/json_schema_compiler/compiler.py |
diff --git a/tools/json_schema_compiler/compiler.py b/tools/json_schema_compiler/compiler.py |
index 7965d18d40f003000fee5d454c6aef514c002409..87e840179a5d16f7fb69879c274ea8de1d4e9ec6 100644 |
--- a/tools/json_schema_compiler/compiler.py |
+++ b/tools/json_schema_compiler/compiler.py |
@@ -25,6 +25,14 @@ import optparse |
import os.path |
import sys |
+# We need to get json_minify from the third_party directory. |
+# This is similar to what is done in chrome/common/extensions/docs/build.py |
+third_party_path = os.path.dirname(os.path.realpath(__file__)) + \ |
+ '/../../third_party/' |
not at google - send to devlin
2012/03/02 02:15:08
Won't this cause problems on Windows? os.path.join
|
+if third_party_path not in sys.path: |
+ sys.path.insert(0, third_party_path) |
+import json_minify as minify |
+ |
if __name__ == '__main__': |
parser = optparse.OptionParser( |
description='Generates a C++ model of an API from JSON schema', |
@@ -50,7 +58,7 @@ if __name__ == '__main__': |
# Actually generate for source file. |
with open(schema, 'r') as schema_file: |
- api_defs = json.loads(schema_file.read()) |
+ api_defs = json.loads(minify.json_minify(schema_file.read())) |
for target_namespace in api_defs: |
referenced_schemas = target_namespace.get('dependencies', []) |
@@ -59,7 +67,8 @@ if __name__ == '__main__': |
referenced_schema_path = os.path.join( |
os.path.dirname(schema), referenced_schema + '.json') |
with open(referenced_schema_path, 'r') as referenced_schema_file: |
- referenced_api_defs = json.loads(referenced_schema_file.read()) |
+ referenced_api_defs = json.loads(minify.json_minify( |
+ referenced_schema_file.read())) |
for namespace in referenced_api_defs: |
api_model.AddNamespace(namespace, |