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

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

Issue 849103005: Cleanup most pylint errors in json_schema_compiler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 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 """Generator for C++ features from json files. 5 """Generator for C++ features from json files.
6 6
7 Usage example: 7 Usage example:
8 features_compiler.py --destdir gen --root /home/Work/src _permissions.json 8 features_compiler.py --destdir gen --root /home/Work/src _permissions.json
9 """ 9 """
10 10
11 import optparse 11 import optparse
12 import os 12 import os
13 13
14 from schema_loader import SchemaLoader 14 from schema_loader import SchemaLoader
15 from features_cc_generator import CCGenerator 15 from features_cc_generator import CCGenerator
16 from features_h_generator import HGenerator 16 from features_h_generator import HGenerator
17 from model import CreateFeature 17 from model import CreateFeature
18 18
19 19
20 def _GenerateSchema(filename, root, destdir, namespace): 20 def _GenerateSchema(filename, root, destdir, namespace):
21 """Generates C++ features files from the json file |filename|. 21 """Generates C++ features files from the json file |filename|.
22 """ 22 """
23 # Load in the feature permissions from the JSON file. 23 # Load in the feature permissions from the JSON file.
24 schema = os.path.normpath(filename) 24 schema = os.path.normpath(filename)
25 schema_loader = SchemaLoader(os.path.dirname(os.path.relpath(schema, root)), 25 schema_loader = SchemaLoader(os.path.dirname(os.path.relpath(schema, root)),
26 os.path.dirname(schema)) 26 os.path.dirname(schema),
27 [],
28 None)
27 schema_filename = os.path.splitext(schema)[0] 29 schema_filename = os.path.splitext(schema)[0]
28 feature_defs = schema_loader.LoadSchema(schema) 30 feature_defs = schema_loader.LoadSchema(schema)
29 31
30 # Generate a list of the features defined and a list of their models. 32 # Generate a list of the features defined and a list of their models.
31 feature_list = [] 33 feature_list = []
32 for feature_def, feature in feature_defs.iteritems(): 34 for feature_def, feature in feature_defs.iteritems():
33 feature_list.append(CreateFeature(feature_def, feature)) 35 feature_list.append(CreateFeature(feature_def, feature))
34 36
35 source_file_dir, _ = os.path.split(schema) 37 source_file_dir, _ = os.path.split(schema)
36 relpath = os.path.relpath(os.path.normpath(source_file_dir), root) 38 relpath = os.path.relpath(os.path.normpath(source_file_dir), root)
(...skipping 30 matching lines...) Expand all
67 (opts, filenames) = parser.parse_args() 69 (opts, filenames) = parser.parse_args()
68 70
69 # Only one file is currently specified. 71 # Only one file is currently specified.
70 if len(filenames) != 1: 72 if len(filenames) != 1:
71 raise ValueError('One (and only one) file is required (for now).') 73 raise ValueError('One (and only one) file is required (for now).')
72 74
73 result = _GenerateSchema(filenames[0], opts.root, opts.destdir, 75 result = _GenerateSchema(filenames[0], opts.root, opts.destdir,
74 opts.namespace) 76 opts.namespace)
75 if not opts.destdir: 77 if not opts.destdir:
76 print result 78 print result
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698