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

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

Issue 2677603002: Revert of Convert make_qualified_names and make_element_factory to use JSON5. (Closed)
Patch Set: 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
158 entry["name"] = item.pop("name") 155 entry["name"] = item.pop("name")
159 # Validate parameters if it's specified.
160 for key, value in item.items(): 156 for key, value in item.items():
161 if key not in self.parameters: 157 if key not in self.parameters:
162 raise Exception( 158 raise Exception(
163 "Unknown parameter: '%s'\nKnown params: %s" % 159 "Unknown parameter: '%s'\nKnown params: %s" %
164 (key, self.parameters.keys())) 160 (key, self.parameters.keys()))
165 if self.parameters[key]: 161 if self.parameters[key]:
166 self._validate_parameter(self.parameters[key], value) 162 self._validate_parameter(self.parameters[key], value)
167 entry[key] = value 163 entry[key] = value
168 return entry 164 return entry
169 165
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 parser.add_argument("--developer_dir", help="Path to Xcode.") 237 parser.add_argument("--developer_dir", help="Path to Xcode.")
242 parser.add_argument("--output_dir", default=os.getcwd()) 238 parser.add_argument("--output_dir", default=os.getcwd())
243 args = parser.parse_args() 239 args = parser.parse_args()
244 240
245 if args.developer_dir: 241 if args.developer_dir:
246 os.environ["DEVELOPER_DIR"] = args.developer_dir 242 os.environ["DEVELOPER_DIR"] = args.developer_dir
247 243
248 writer = self._writer_class(args.files) 244 writer = self._writer_class(args.files)
249 writer.set_gperf_path(args.gperf) 245 writer.set_gperf_path(args.gperf)
250 writer.write_files(args.output_dir) 246 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