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

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

Issue 2601333002: Update json_schema_compiler to handle the Automation extension API (Closed)
Patch Set: Fix select_to_speak Created 3 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 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 import os.path 5 import os.path
6 6
7 from json_parse import OrderedDict 7 from json_parse import OrderedDict
8 from memoize import memoize 8 from memoize import memoize
9 9
10 10
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 self.supports_listeners = options.get('supportsListeners', True) 310 self.supports_listeners = options.get('supportsListeners', True)
311 self.supports_rules = options.get('supportsRules', False) 311 self.supports_rules = options.get('supportsRules', False)
312 self.supports_dom = options.get('supportsDom', False) 312 self.supports_dom = options.get('supportsDom', False)
313 313
314 def GeneratePropertyFromParam(p): 314 def GeneratePropertyFromParam(p):
315 return Property(self, p['name'], p, namespace, origin) 315 return Property(self, p['name'], p, namespace, origin)
316 316
317 self.filters = [GeneratePropertyFromParam(filter_instance) 317 self.filters = [GeneratePropertyFromParam(filter_instance)
318 for filter_instance in json.get('filters', [])] 318 for filter_instance in json.get('filters', [])]
319 callback_param = None 319 callback_param = None
320 for param in json.get('parameters', []): 320 params = json.get('parameters', [])
321 if param.get('type') == 'function': 321 for i in range(len(params)):
Dan Beam 2017/01/10 22:54:43 for i, param in enumerate(params):
dmazzoni 2017/01/11 22:20:42 Done.
322 param = params[i]
323 if param.get('type') == 'function' and i == len(params) - 1:
322 if callback_param: 324 if callback_param:
323 # No ParseException because the webstore has this. 325 # No ParseException because the webstore has this.
324 # Instead, pretend all intermediate callbacks are properties. 326 # Instead, pretend all intermediate callbacks are properties.
325 self.params.append(GeneratePropertyFromParam(callback_param)) 327 self.params.append(GeneratePropertyFromParam(callback_param))
326 callback_param = param 328 callback_param = param
327 else: 329 else:
328 self.params.append(GeneratePropertyFromParam(param)) 330 self.params.append(GeneratePropertyFromParam(param))
329 331
330 if callback_param: 332 if callback_param:
331 self.callback = Function(self, 333 self.callback = Function(self,
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 # Sanity check: platforms should not be an empty list. 610 # Sanity check: platforms should not be an empty list.
609 if not json['platforms']: 611 if not json['platforms']:
610 raise ValueError('"platforms" cannot be an empty list') 612 raise ValueError('"platforms" cannot be an empty list')
611 platforms = [] 613 platforms = []
612 for platform_name in json['platforms']: 614 for platform_name in json['platforms']:
613 for platform_enum in _Enum.GetAll(Platforms): 615 for platform_enum in _Enum.GetAll(Platforms):
614 if platform_name == platform_enum.name: 616 if platform_name == platform_enum.name:
615 platforms.append(platform_enum) 617 platforms.append(platform_enum)
616 break 618 break
617 return platforms 619 return platforms
OLDNEW
« tools/json_schema_compiler/js_util.py ('K') | « tools/json_schema_compiler/js_util.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698