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

Side by Side Diff: third_party/WebKit/Source/build/scripts/json5_generator.py

Issue 2645283006: Convert make_qualified_names and make_element_factory to use JSON5. (Closed)
Patch Set: fix typo __majson5__ -> __main__ in make_qualified_names.py Created 3 years, 10 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/build/scripts/make_element_factory.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2017 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2017 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Generic generator for configuration files in JSON5 format. 5 """Generic generator for configuration files in JSON5 format.
6 6
7 The configuration file is expected to contain either a data array or a data map, 7 The configuration file is expected to contain either a data array or a data map,
8 an optional parameters validation map, and an optional metdata map. Examples: 8 an optional parameters validation map, and an optional metdata map. Examples:
9 { 9 {
10 data: [ 10 data: [
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 else: 145 else:
146 self._defaults[key] = None 146 self._defaults[key] = None
147 147
148 def _get_entry(self, item): 148 def _get_entry(self, item):
149 entry = copy.deepcopy(self._defaults) 149 entry = copy.deepcopy(self._defaults)
150 if type(item) is not dict: 150 if type(item) is not dict:
151 entry["name"] = item 151 entry["name"] = item
152 return entry 152 return entry
153 if "name" not in item: 153 if "name" not in item:
154 raise Exception("Missing name in item: %s" % item) 154 raise Exception("Missing name in item: %s" % item)
155 if not self.parameters:
156 entry.update(item)
157 return entry
155 entry["name"] = item.pop("name") 158 entry["name"] = item.pop("name")
159 # Validate parameters if it's specified.
156 for key, value in item.items(): 160 for key, value in item.items():
157 if key not in self.parameters: 161 if key not in self.parameters:
158 raise Exception( 162 raise Exception(
159 "Unknown parameter: '%s'\nKnown params: %s" % 163 "Unknown parameter: '%s'\nKnown params: %s" %
160 (key, self.parameters.keys())) 164 (key, self.parameters.keys()))
161 if self.parameters[key]: 165 if self.parameters[key]:
162 self._validate_parameter(self.parameters[key], value) 166 self._validate_parameter(self.parameters[key], value)
163 entry[key] = value 167 entry[key] = value
164 return entry 168 return entry
165 169
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 parser.add_argument("--developer_dir", help="Path to Xcode.") 241 parser.add_argument("--developer_dir", help="Path to Xcode.")
238 parser.add_argument("--output_dir", default=os.getcwd()) 242 parser.add_argument("--output_dir", default=os.getcwd())
239 args = parser.parse_args() 243 args = parser.parse_args()
240 244
241 if args.developer_dir: 245 if args.developer_dir:
242 os.environ["DEVELOPER_DIR"] = args.developer_dir 246 os.environ["DEVELOPER_DIR"] = args.developer_dir
243 247
244 writer = self._writer_class(args.files) 248 writer = self._writer_class(args.files)
245 writer.set_gperf_path(args.gperf) 249 writer.set_gperf_path(args.gperf)
246 writer.write_files(args.output_dir) 250 writer.write_files(args.output_dir)
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/build/scripts/make_element_factory.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698