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

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

Issue 239283008: Add global presubmit that JSON and IDL files can be parsed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 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
« no previous file with comments | « chrome/common/extensions/api/test_presubmit/valid_json.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 idl = idl_parser.IDLParser().ParseData(contents, filename) 462 idl = idl_parser.IDLParser().ParseData(contents, filename)
463 idl_schema = IDLSchema(idl) 463 idl_schema = IDLSchema(idl)
464 return idl_schema.process() 464 return idl_schema.process()
465 465
466 466
467 def Main(): 467 def Main():
468 ''' 468 '''
469 Dump a json serialization of parse result for the IDL files whose names 469 Dump a json serialization of parse result for the IDL files whose names
470 were passed in on the command line. 470 were passed in on the command line.
471 ''' 471 '''
472 for filename in sys.argv[1:]: 472 if len(sys.argv) > 1:
473 schema = Load(filename) 473 for filename in sys.argv[1:]:
474 schema = Load(filename)
475 print json.dumps(schema, indent=2)
476 else:
477 contents = sys.stdin.read()
478 idl = idl_parser.IDLParser().ParseData(contents, '<stdin>')
479 schema = IDLSchema(idl).process()
474 print json.dumps(schema, indent=2) 480 print json.dumps(schema, indent=2)
475 481
476 482
477 if __name__ == '__main__': 483 if __name__ == '__main__':
478 Main() 484 Main()
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/test_presubmit/valid_json.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698