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

Side by Side Diff: tools/json_schema_compiler/previewserver.py

Issue 10108005: Make json_schema_compiler remove 'nocompile' nodes from JSON at the JSON level (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 """Server for viewing the compiled C++ code from tools/json_schema_compiler. 6 """Server for viewing the compiled C++ code from tools/json_schema_compiler.
7 """ 7 """
8 8
9 import cc_generator 9 import cc_generator
10 import code 10 import code
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 183
184 request_path = self._GetRequestPath(parsed_url) 184 request_path = self._GetRequestPath(parsed_url)
185 (file_root, file_ext) = os.path.splitext(request_path) 185 (file_root, file_ext) = os.path.splitext(request_path)
186 (filedir, filename) = os.path.split(file_root) 186 (filedir, filename) = os.path.split(file_root)
187 json_file_path = os.path.normpath(file_root + '.json') 187 json_file_path = os.path.normpath(file_root + '.json')
188 188
189 try: 189 try:
190 # Get main json file 190 # Get main json file
191 api_defs = json_schema.Load(json_file_path) 191 api_defs = json_schema.Load(json_file_path)
192 namespace = api_model.AddNamespace(api_defs[0], json_file_path) 192 namespace = api_model.AddNamespace(api_defs[0], json_file_path)
193 if not namespace:
194 body.Append("<pre>Target file %s is marked nocompile</pre>" %
195 json_file_path)
196 return
197 type_generator = cpp_type_generator.CppTypeGenerator( 193 type_generator = cpp_type_generator.CppTypeGenerator(
198 'preview::api', namespace, namespace.unix_name) 194 'previewserver::api', namespace, namespace.unix_name)
199 195
200 # Get json file depedencies 196 # Get json file depedencies
201 for dependency in api_defs[0].get('dependencies', []): 197 for dependency in api_defs[0].get('dependencies', []):
202 json_file_path = os.path.join(filedir, dependency + '.json') 198 json_file_path = os.path.join(filedir, dependency + '.json')
203 api_defs = json_schema.Load(json_file_path) 199 api_defs = json_schema.Load(json_file_path)
204 referenced_namespace = api_model.AddNamespace(api_defs[0], 200 referenced_namespace = api_model.AddNamespace(api_defs[0],
205 json_file_path) 201 json_file_path)
206 if referenced_namespace: 202 if referenced_namespace:
207 type_generator.AddNamespace(referenced_namespace, 203 type_generator.AddNamespace(referenced_namespace,
208 cpp_util.Classname(referenced_namespace.name).lower()) 204 cpp_util.Classname(referenced_namespace.name).lower())
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 print('') 323 print('')
328 server = PreviewHTTPServer(('', int(opts.port)), CompilerHandler, 324 server = PreviewHTTPServer(('', int(opts.port)), CompilerHandler,
329 { 325 {
330 'pygments': pygments_highlighter.PygmentsHighlighter(), 326 'pygments': pygments_highlighter.PygmentsHighlighter(),
331 'hilite': hilite_me_highlighter.HiliteMeHighlighter(), 327 'hilite': hilite_me_highlighter.HiliteMeHighlighter(),
332 'none': none_highlighter.NoneHighlighter(), 328 'none': none_highlighter.NoneHighlighter(),
333 }) 329 })
334 server.serve_forever() 330 server.serve_forever()
335 except KeyboardInterrupt: 331 except KeyboardInterrupt:
336 server.socket.close() 332 server.socket.close()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698