summaryrefslogtreecommitdiffstats
path: root/tools/json_schema_compiler
diff options
context:
space:
mode:
authoryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-02 17:26:54 +0000
committeryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-02 17:26:54 +0000
commit836a7e224691d75571f754e1749f434d76f1692d (patch)
tree3ddbba7f87161af43f106011f37ea191fed54212 /tools/json_schema_compiler
parent7ec7ecbf9f9223c1c27c88f49aac863a28903ca3 (diff)
downloadchromium_src-836a7e224691d75571f754e1749f434d76f1692d.zip
chromium_src-836a7e224691d75571f754e1749f434d76f1692d.tar.gz
chromium_src-836a7e224691d75571f754e1749f434d76f1692d.tar.bz2
Revert 124660 - Allow comments in extension config files.
Added a script to remove comments from the extension api JSON files before processing for the extension docs. We will now be able to comment in the JSON files, and they should be much easier to read. Also added the license header to all the JSON files. BUG=114233 TEST=Put comments in one of the JSON files and remake the docs. They will make with no problems. Review URL: http://codereview.chromium.org/9447090 TBR=cduvall@chromium.org Review URL: https://chromiumcodereview.appspot.com/9582013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124675 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/json_schema_compiler')
-rw-r--r--tools/json_schema_compiler/compiler.py8
-rw-r--r--tools/json_schema_compiler/cpp_type_generator_test.py8
-rw-r--r--tools/json_schema_compiler/json_schema.py19
-rw-r--r--tools/json_schema_compiler/model_test.py8
-rwxr-xr-xtools/json_schema_compiler/previewserver.py8
5 files changed, 18 insertions, 33 deletions
diff --git a/tools/json_schema_compiler/compiler.py b/tools/json_schema_compiler/compiler.py
index fb84a6c..54ab62f 100644
--- a/tools/json_schema_compiler/compiler.py
+++ b/tools/json_schema_compiler/compiler.py
@@ -19,7 +19,7 @@ Usage example:
import cc_generator
import cpp_type_generator
import h_generator
-from json_schema import LoadJSON
+import json
import model
import optparse
import os.path
@@ -49,7 +49,8 @@ if __name__ == '__main__':
# Actually generate for source file.
- api_defs = LoadJSON(schema)
+ with open(schema, 'r') as schema_file:
+ api_defs = json.loads(schema_file.read())
for target_namespace in api_defs:
referenced_schemas = target_namespace.get('dependencies', [])
@@ -57,7 +58,8 @@ if __name__ == '__main__':
for referenced_schema in referenced_schemas:
referenced_schema_path = os.path.join(
os.path.dirname(schema), referenced_schema + '.json')
- referenced_api_defs = LoadJSON(referenced_schema_path)
+ with open(referenced_schema_path, 'r') as referenced_schema_file:
+ referenced_api_defs = json.loads(referenced_schema_file.read())
for namespace in referenced_api_defs:
api_model.AddNamespace(namespace,
diff --git a/tools/json_schema_compiler/cpp_type_generator_test.py b/tools/json_schema_compiler/cpp_type_generator_test.py
index e58dbac..ac16262 100644
--- a/tools/json_schema_compiler/cpp_type_generator_test.py
+++ b/tools/json_schema_compiler/cpp_type_generator_test.py
@@ -3,22 +3,22 @@
# found in the LICENSE file.
from cpp_type_generator import CppTypeGenerator
-from json_schema import LoadJSON
+import json
import model
import unittest
class CppTypeGeneratorTest(unittest.TestCase):
def setUp(self):
self.model = model.Model()
- self.permissions_json = LoadJSON('test/permissions.json')
+ self.permissions_json = json.loads(open('test/permissions.json').read())
self.model.AddNamespace(self.permissions_json[0],
'path/to/permissions.json')
self.permissions = self.model.namespaces.get('permissions')
- self.windows_json = LoadJSON('test/windows.json')
+ self.windows_json = json.loads(open('test/windows.json').read())
self.model.AddNamespace(self.windows_json[0],
'path/to/window.json')
self.windows = self.model.namespaces.get('windows')
- self.tabs_json = LoadJSON('test/tabs.json')
+ self.tabs_json = json.loads(open('test/tabs.json').read())
self.model.AddNamespace(self.tabs_json[0],
'path/to/tabs.json')
self.tabs = self.model.namespaces.get('tabs')
diff --git a/tools/json_schema_compiler/json_schema.py b/tools/json_schema_compiler/json_schema.py
deleted file mode 100644
index aa192c0..0000000
--- a/tools/json_schema_compiler/json_schema.py
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright (c) 2012 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import json
-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.join(os.path.dirname(os.path.realpath(__file__)),
- os.pardir, os.pardir, 'third_party/')
-if third_party_path not in sys.path:
- sys.path.insert(0, third_party_path)
-import json_minify as minify
-
-def LoadJSON(filename):
- with open(filename, 'r') as handle:
- return json.loads(minify.json_minify(handle.read()))
diff --git a/tools/json_schema_compiler/model_test.py b/tools/json_schema_compiler/model_test.py
index a588968..3217498 100644
--- a/tools/json_schema_compiler/model_test.py
+++ b/tools/json_schema_compiler/model_test.py
@@ -2,22 +2,22 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-from json_schema import LoadJSON
+import json
import model
import unittest
class ModelTest(unittest.TestCase):
def setUp(self):
self.model = model.Model()
- self.permissions_json = LoadJSON('test/permissions.json')
+ self.permissions_json = json.loads(open('test/permissions.json').read())
self.model.AddNamespace(self.permissions_json[0],
'path/to/permissions.json')
self.permissions = self.model.namespaces.get('permissions')
- self.windows_json = LoadJSON('test/windows.json')
+ self.windows_json = json.loads(open('test/windows.json').read())
self.model.AddNamespace(self.windows_json[0],
'path/to/window.json')
self.windows = self.model.namespaces.get('windows')
- self.tabs_json = LoadJSON('test/tabs.json')
+ self.tabs_json = json.loads(open('test/tabs.json').read())
self.model.AddNamespace(self.tabs_json[0],
'path/to/tabs.json')
self.tabs = self.model.namespaces.get('tabs')
diff --git a/tools/json_schema_compiler/previewserver.py b/tools/json_schema_compiler/previewserver.py
index 8a6f6ab..384171e 100755
--- a/tools/json_schema_compiler/previewserver.py
+++ b/tools/json_schema_compiler/previewserver.py
@@ -11,7 +11,7 @@ import code
import cpp_type_generator
import cpp_util
import h_generator
-from json_schema import LoadJSON
+import json
import model
import optparse
import os
@@ -188,7 +188,8 @@ updateEverything();
try:
# Get main json file
- api_defs = LoadJSON(json_file_path)
+ with open(json_file_path) as json_file:
+ api_defs = json.loads(json_file.read())
namespace = api_model.AddNamespace(api_defs[0], json_file_path)
if not namespace:
body.Append("<pre>Target file %s is marked nocompile</pre>" %
@@ -200,7 +201,8 @@ updateEverything();
# Get json file depedencies
for dependency in api_defs[0].get('dependencies', []):
json_file_path = os.path.join(filedir, dependency + '.json')
- api_defs = LoadJSON(json_file_path)
+ with open(json_file_path) as json_file:
+ api_defs = json.loads(json_file.read())
referenced_namespace = api_model.AddNamespace(api_defs[0],
json_file_path)
if referenced_namespace: