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

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

Issue 11827026: Overhaul JSON Schema Compiler to support a number of features required to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 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 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import itertools 6 import itertools
7 import json 7 import json
8 import os.path 8 import os.path
9 import re 9 import re
10 import sys 10 import sys
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 if node.name == 'nodoc': 345 if node.name == 'nodoc':
346 nodoc = bool(node.value) 346 nodoc = bool(node.value)
347 elif node.name == 'permissions': 347 elif node.name == 'permissions':
348 permission = node.value.split(',') 348 permission = node.value.split(',')
349 elif node.name == 'internal': 349 elif node.name == 'internal':
350 internal = bool(node.value) 350 internal = bool(node.value)
351 else: 351 else:
352 continue 352 continue
353 else: 353 else:
354 sys.exit('Did not process %s %s' % (node.cls, node)) 354 sys.exit('Did not process %s %s' % (node.cls, node))
355 schema_util.PrefixSchemasWithNamespace(namespaces)
356 return namespaces 355 return namespaces
357 356
358 def Load(filename): 357 def Load(filename):
359 ''' 358 '''
360 Given the filename of an IDL file, parses it and returns an equivalent 359 Given the filename of an IDL file, parses it and returns an equivalent
361 Python dictionary in a format that the JSON schema compiler expects to see. 360 Python dictionary in a format that the JSON schema compiler expects to see.
362 ''' 361 '''
363 362
364 f = open(filename, 'r') 363 f = open(filename, 'r')
365 contents = f.read() 364 contents = f.read()
366 f.close() 365 f.close()
367 366
368 idl = idl_parser.IDLParser().ParseData(contents, filename) 367 idl = idl_parser.IDLParser().ParseData(contents, filename)
369 idl_schema = IDLSchema(idl) 368 idl_schema = IDLSchema(idl)
370 return idl_schema.process() 369 return idl_schema.process()
371 370
372 def Main(): 371 def Main():
373 ''' 372 '''
374 Dump a json serialization of parse result for the IDL files whose names 373 Dump a json serialization of parse result for the IDL files whose names
375 were passed in on the command line. 374 were passed in on the command line.
376 ''' 375 '''
377 for filename in sys.argv[1:]: 376 for filename in sys.argv[1:]:
378 schema = Load(filename) 377 schema = Load(filename)
379 print json.dumps(schema, indent=2) 378 print json.dumps(schema, indent=2)
380 379
381 if __name__ == '__main__': 380 if __name__ == '__main__':
382 Main() 381 Main()
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/h_generator.py ('k') | tools/json_schema_compiler/idl_schema_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698