OLD | NEW |
---|---|
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 from copy import copy | 5 from copy import copy |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import posixpath | 8 import posixpath |
9 | 9 |
10 from data_source import DataSource | 10 from data_source import DataSource |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 assert self._lookup_path[-3] == 'events' | 120 assert self._lookup_path[-3] == 'events' |
121 return self._lookup_path[:-1] | 121 return self._lookup_path[:-1] |
122 # This is a function parameter. | 122 # This is a function parameter. |
123 assert self._lookup_path[-2] == 'parameters' | 123 assert self._lookup_path[-2] == 'parameters' |
124 return self._lookup_path[:-2] | 124 return self._lookup_path[:-2] |
125 # This is a regular node, so lookup_path[-2] should | 125 # This is a regular node, so lookup_path[-2] should |
126 # be a node category. | 126 # be a node category. |
127 self._AssertIsValidCategory(self._lookup_path[-2]) | 127 self._AssertIsValidCategory(self._lookup_path[-2]) |
128 return self._lookup_path[:-2] | 128 return self._lookup_path[:-2] |
129 | 129 |
130 def _LookupNodeAvailability(self): | 130 def _LookupNodeAvailability(self, lookup_path): |
131 '''Returns the ChannelInfo object for this node. | 131 '''Returns the ChannelInfo object for this node. |
132 ''' | 132 ''' |
133 return self._node_availabilities.Lookup(self._namespace_name, | 133 return self._node_availabilities.Lookup(self._namespace_name, |
134 *self._lookup_path).annotation | 134 *lookup_path).annotation |
135 | 135 |
136 def _LookupParentNodeAvailability(self): | 136 def _LookupParentNodeAvailability(self): |
137 '''Returns the ChannelInfo object for this node's parent. | 137 '''Returns the ChannelInfo object for this node's parent. |
138 ''' | 138 ''' |
139 return self._node_availabilities.Lookup(self._namespace_name, | 139 return self._LookupNodeAvailability(self._GetParentPath()) |
not at google - send to devlin
2014/07/02 22:14:34
could you make a bunch of these @classmethod-s to
ahernandez
2014/07/02 22:25:47
I don't understand what you mean.
ahernandez
2014/07/02 22:27:22
Actually, my confusion has ended.
| |
140 *self._GetParentPath()).annotation | |
141 | 140 |
142 def _CheckNamespacePrefix(self): | 141 def _CheckNamespacePrefix(self, lookup_path): |
143 '''API schemas may prepend the namespace name to top-level types | 142 '''API schemas may prepend the namespace name to top-level types |
144 (e.g. declarativeWebRequest > types > declarativeWebRequest.IgnoreRules), | 143 (e.g. declarativeWebRequest > types > declarativeWebRequest.IgnoreRules), |
145 but just the base name (here, 'IgnoreRules') will be in the |lookup_path|. | 144 but just the base name (here, 'IgnoreRules') will be in the |lookup_path|. |
146 Try creating an alternate |lookup_path| by adding the namespace name. | 145 Try creating an alternate |lookup_path| by adding the namespace name. |
147 ''' | 146 ''' |
148 # lookup_path[0] is always the node category (e.g. types, functions, etc.). | 147 # lookup_path[0] is always the node category (e.g. types, functions, etc.). |
149 # Thus, lookup_path[1] is always the top-level node name. | 148 # Thus, lookup_path[1] is always the top-level node name. |
150 self._AssertIsValidCategory(self._lookup_path[0]) | 149 self._AssertIsValidCategory(lookup_path[0]) |
151 base_name = self._lookup_path[1] | 150 base_name = lookup_path[1] |
152 self._lookup_path[1] = '%s.%s' % (self._namespace_name, base_name) | 151 lookup_path[1] = '%s.%s' % (self._namespace_name, base_name) |
153 try: | 152 try: |
154 node_availability = self._LookupNodeAvailability() | 153 node_availability = self._LookupNodeAvailability(lookup_path) |
155 if node_availability is not None: | 154 if node_availability is not None: |
156 return node_availability | 155 return node_availability |
157 finally: | 156 finally: |
158 # Restore lookup_path. | 157 # Restore lookup_path. |
159 self._lookup_path[1] = base_name | 158 lookup_path[1] = base_name |
160 return None | 159 return None |
161 | 160 |
162 def _CheckEventCallback(self): | 161 def _CheckEventCallback(self, lookup_path): |
163 '''Within API schemas, an event has a list of 'properties' that the event's | 162 '''Within API schemas, an event has a list of 'properties' that the event's |
164 callback expects. The callback itself is not explicitly represented in the | 163 callback expects. The callback itself is not explicitly represented in the |
165 schema. However, when creating an event node in _JSCModel, a callback node | 164 schema. However, when creating an event node in _JSCModel, a callback node |
166 is generated and acts as the parent for the event's properties. | 165 is generated and acts as the parent for the event's properties. |
167 Modify |lookup_path| to check the original schema format. | 166 Modify |lookup_path| to check the original schema format. |
168 ''' | 167 ''' |
169 if 'events' in self._lookup_path: | 168 if 'events' in lookup_path: |
170 assert 'callback' in self._lookup_path | 169 assert 'callback' in lookup_path |
171 callback_index = self._lookup_path.index('callback') | 170 callback_index = lookup_path.index('callback') |
172 try: | 171 try: |
173 self._lookup_path.pop(callback_index) | 172 lookup_path.pop(callback_index) |
174 node_availability = self._LookupNodeAvailability() | 173 node_availability = self._LookupNodeAvailability(lookup_path) |
175 finally: | 174 finally: |
176 self._lookup_path.insert(callback_index, 'callback') | 175 lookup_path.insert(callback_index, 'callback') |
177 return node_availability | 176 return node_availability |
178 return None | 177 return None |
179 | 178 |
180 def _LookupAvailability(self): | 179 def _LookupAvailability(self, lookup_path): |
181 '''Runs all the lookup checks on self._lookup_path and | 180 '''Runs all the lookup checks on self._lookup_path and |
182 returns the node availability if found, None otherwise. | 181 returns the node availability if found, None otherwise. |
183 ''' | 182 ''' |
184 for lookup in (self._LookupNodeAvailability, | 183 for lookup in (self._LookupNodeAvailability, |
185 self._CheckEventCallback, | 184 self._CheckEventCallback, |
186 self._CheckNamespacePrefix): | 185 self._CheckNamespacePrefix): |
187 node_availability = lookup() | 186 node_availability = lookup(lookup_path) |
188 if node_availability is not None: | 187 if node_availability is not None: |
189 return node_availability | 188 return node_availability |
190 return None | 189 return None |
191 | 190 |
192 def GetAvailability(self): | 191 def GetAvailability(self): |
193 '''Returns availability information for this node. | 192 '''Returns availability information for this node. |
194 ''' | 193 ''' |
195 node_availability = self._LookupAvailability() | 194 node_availability = self._LookupAvailability(self._lookup_path) |
196 if node_availability is None: | 195 if node_availability is None: |
197 logging.warning('No availability found for: %s > %s' % | 196 logging.warning('No availability found for: %s > %s' % |
198 (self._namespace_name, ' > '.join(self._lookup_path))) | 197 (self._namespace_name, ' > '.join(self._lookup_path))) |
199 return None | 198 return None |
200 | 199 |
201 try: | 200 parent_node_availability = self._LookupAvailability(self._GetParentPath()) |
202 current_path = self._lookup_path | |
203 self._lookup_path = self._GetParentPath() | |
204 parent_node_availability = self._LookupAvailability() | |
205 finally: | |
206 self._lookup_path = current_path | |
207 # If the parent node availability couldn't be found, something | 201 # If the parent node availability couldn't be found, something |
208 # is very wrong. | 202 # is very wrong. |
209 assert parent_node_availability is not None | 203 assert parent_node_availability is not None |
210 | 204 |
211 # Only render this node's availability if it differs from the parent | 205 # Only render this node's availability if it differs from the parent |
212 # node's availability. | 206 # node's availability. |
213 if node_availability == parent_node_availability: | 207 if node_availability == parent_node_availability: |
214 return None | 208 return None |
215 return node_availability | 209 return node_availability |
216 | 210 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
280 def _GetChannelWarning(self): | 274 def _GetChannelWarning(self): |
281 if not self._IsExperimental(): | 275 if not self._IsExperimental(): |
282 return { | 276 return { |
283 self._availability.channel_info.channel: True | 277 self._availability.channel_info.channel: True |
284 } | 278 } |
285 return None | 279 return None |
286 | 280 |
287 def _IsExperimental(self): | 281 def _IsExperimental(self): |
288 return self._namespace.name.startswith('experimental') | 282 return self._namespace.name.startswith('experimental') |
289 | 283 |
290 def _GenerateTypes(self, types): | 284 def _GenerateTypes(self, types, no_gen=False): |
291 with self._current_node.Descend('types'): | 285 with self._current_node.Descend('types'): |
292 return [self._GenerateType(t) for t in types] | 286 return [self._GenerateType(t, no_gen=no_gen) for t in types] |
293 | 287 |
294 def _GenerateType(self, type_): | 288 def _GenerateType(self, type_, no_gen=False): |
295 with self._current_node.Descend(type_.simple_name): | 289 with self._current_node.Descend(type_.simple_name): |
296 type_dict = { | 290 type_dict = { |
297 'name': type_.simple_name, | 291 'name': type_.simple_name, |
298 'description': type_.description, | 292 'description': type_.description, |
299 'properties': self._GenerateProperties(type_.properties), | 293 'properties': self._GenerateProperties(type_.properties, no_gen=no_gen), |
ahernandez
2014/07/03 02:04:14
I think eliminating the no_gen passing will make t
not at google - send to devlin
2014/07/07 15:10:31
What about if no_gen took a tuple of properties to
ahernandez
2014/07/07 20:04:56
Doing that cleans up a good portion of the code, b
| |
300 'functions': self._GenerateFunctions(type_.functions), | 294 'functions': self._GenerateFunctions(type_.functions), |
301 'events': self._GenerateEvents(type_.events), | 295 'events': self._GenerateEvents(type_.events), |
302 'id': _CreateId(type_, 'type'), | 296 'id': _CreateId(type_, 'type'), |
297 'availability': None if no_gen else self._GetAvailabilityTemplate() | |
not at google - send to devlin
2014/07/02 22:14:34
why do you need to do this no_gen stuff?
in any c
ahernandez
2014/07/02 22:25:47
Certain nodes shouldn't have availability generate
| |
303 } | 298 } |
304 self._RenderTypeInformation(type_, type_dict) | 299 self._RenderTypeInformation(type_, type_dict) |
305 return type_dict | 300 return type_dict |
306 | 301 |
307 def _GenerateFunctions(self, functions): | 302 def _GenerateFunctions(self, functions): |
308 with self._current_node.Descend('functions'): | 303 with self._current_node.Descend('functions'): |
309 return [self._GenerateFunction(f) for f in functions.values()] | 304 return [self._GenerateFunction(f) for f in functions.values()] |
310 | 305 |
311 def _GenerateFunction(self, function): | 306 def _GenerateFunction(self, function): |
312 with self._current_node.Descend(function.simple_name): | 307 with self._current_node.Descend(function.simple_name): |
313 function_dict = { | 308 function_dict = { |
314 'name': function.simple_name, | 309 'name': function.simple_name, |
315 'description': function.description, | 310 'description': function.description, |
316 'callback': self._GenerateCallback(function.callback), | 311 'callback': self._GenerateCallback(function.callback), |
317 'parameters': [], | 312 'parameters': [], |
318 'returns': None, | 313 'returns': None, |
319 'id': _CreateId(function, 'method'), | 314 'id': _CreateId(function, 'method'), |
320 'availability': self._GetAvailabilityTemplate() | 315 'availability': self._GetAvailabilityTemplate() |
321 } | 316 } |
322 self._AddCommonProperties(function_dict, function) | 317 self._AddCommonProperties(function_dict, function) |
323 if function.returns: | 318 if function.returns: |
324 function_dict['returns'] = self._GenerateType(function.returns) | 319 function_dict['returns'] = self._GenerateType(function.returns, |
325 for param in function.params: | 320 no_gen=True) |
326 function_dict['parameters'].append(self._GenerateProperty(param)) | 321 with self._current_node.Descend('parameters'): |
322 for param in function.params: | |
323 function_dict['parameters'].append(self._GenerateProperty(param)) | |
327 if function.callback is not None: | 324 if function.callback is not None: |
328 # Show the callback as an extra parameter. | 325 # Show the callback as an extra parameter. |
329 function_dict['parameters'].append( | 326 function_dict['parameters'].append( |
330 self._GenerateCallbackProperty(function.callback)) | 327 self._GenerateCallbackProperty(function.callback)) |
331 if len(function_dict['parameters']) > 0: | 328 if len(function_dict['parameters']) > 0: |
332 function_dict['parameters'][-1]['last'] = True | 329 function_dict['parameters'][-1]['last'] = True |
333 return function_dict | 330 return function_dict |
334 | 331 |
335 def _GenerateEvents(self, events): | 332 def _GenerateEvents(self, events): |
336 with self._current_node.Descend('events'): | 333 with self._current_node.Descend('events'): |
337 return [self._GenerateEvent(e) for e in events.values() | 334 return [self._GenerateEvent(e) for e in events.values() |
338 if not e.supports_dom] | 335 if not e.supports_dom] |
339 | 336 |
340 def _GenerateDomEvents(self, events): | 337 def _GenerateDomEvents(self, events): |
341 with self._current_node.Descend('events'): | 338 with self._current_node.Descend('events'): |
342 return [self._GenerateEvent(e) for e in events.values() | 339 return [self._GenerateEvent(e) for e in events.values() |
343 if e.supports_dom] | 340 if e.supports_dom] |
344 | 341 |
345 def _GenerateEvent(self, event): | 342 def _GenerateEvent(self, event): |
346 with self._current_node.Descend(event.simple_name): | 343 with self._current_node.Descend(event.simple_name): |
347 event_dict = { | 344 event_dict = { |
348 'name': event.simple_name, | 345 'name': event.simple_name, |
349 'description': event.description, | 346 'description': event.description, |
350 'filters': [self._GenerateProperty(f) for f in event.filters], | 347 'filters': [self._GenerateProperty(f, no_gen=True) |
348 for f in event.filters], | |
351 'conditions': [self._GetLink(condition) | 349 'conditions': [self._GetLink(condition) |
352 for condition in event.conditions], | 350 for condition in event.conditions], |
353 'actions': [self._GetLink(action) for action in event.actions], | 351 'actions': [self._GetLink(action) for action in event.actions], |
354 'supportsRules': event.supports_rules, | 352 'supportsRules': event.supports_rules, |
355 'supportsListeners': event.supports_listeners, | 353 'supportsListeners': event.supports_listeners, |
356 'properties': [], | 354 'properties': [], |
357 'id': _CreateId(event, 'event'), | 355 'id': _CreateId(event, 'event'), |
358 'byName': {}, | 356 'byName': {}, |
357 'availability': self._GetAvailabilityTemplate() | |
359 } | 358 } |
360 self._AddCommonProperties(event_dict, event) | 359 self._AddCommonProperties(event_dict, event) |
361 # Add the Event members to each event in this object. | 360 # Add the Event members to each event in this object. |
362 if self._event_byname_future: | 361 if self._event_byname_future: |
363 event_dict['byName'].update(self._event_byname_future.Get()) | 362 event_dict['byName'].update(self._event_byname_future.Get()) |
364 # We need to create the method description for addListener based on the | 363 # We need to create the method description for addListener based on the |
365 # information stored in |event|. | 364 # information stored in |event|. |
366 if event.supports_listeners: | 365 if event.supports_listeners: |
367 callback_object = model.Function(parent=event, | 366 callback_object = model.Function(parent=event, |
368 name='callback', | 367 name='callback', |
369 json={}, | 368 json={}, |
370 namespace=event.parent, | 369 namespace=event.parent, |
371 origin='') | 370 origin='') |
372 callback_object.params = event.params | 371 callback_object.params = event.params |
373 if event.callback: | 372 if event.callback: |
374 callback_object.callback = event.callback | 373 callback_object.callback = event.callback |
375 callback_parameters = self._GenerateCallbackProperty(callback_object) | 374 callback_parameters = self._GenerateCallbackProperty(callback_object) |
376 callback_parameters['last'] = True | 375 callback_parameters['last'] = True |
377 event_dict['byName']['addListener'] = { | 376 event_dict['byName']['addListener'] = { |
378 'name': 'addListener', | 377 'name': 'addListener', |
379 'callback': self._GenerateFunction(callback_object), | 378 'callback': self._GenerateFunction(callback_object), |
380 'parameters': [callback_parameters] | 379 'parameters': [callback_parameters] |
381 } | 380 } |
382 if event.supports_dom: | 381 if event.supports_dom: |
383 # Treat params as properties of the custom Event object associated with | 382 # Treat params as properties of the custom Event object associated with |
384 # this DOM Event. | 383 # this DOM Event. |
385 event_dict['properties'] += [self._GenerateProperty(param) | 384 event_dict['properties'] += [self._GenerateProperty(param, no_gen=True) |
386 for param in event.params] | 385 for param in event.params] |
387 return event_dict | 386 return event_dict |
388 | 387 |
389 def _GenerateCallback(self, callback): | 388 def _GenerateCallback(self, callback): |
390 if not callback: | 389 if not callback: |
391 return None | 390 return None |
392 callback_dict = { | 391 callback_dict = { |
393 'name': callback.simple_name, | 392 'name': callback.simple_name, |
394 'simple_type': {'simple_type': 'function'}, | 393 'simple_type': {'simple_type': 'function'}, |
395 'optional': callback.optional, | 394 'optional': callback.optional, |
396 'parameters': [] | 395 'parameters': [] |
397 } | 396 } |
398 for param in callback.params: | 397 with self._current_node.Descend('parameters', |
399 callback_dict['parameters'].append(self._GenerateProperty(param)) | 398 callback.simple_name, |
399 'parameters'): | |
400 for param in callback.params: | |
401 callback_dict['parameters'].append(self._GenerateProperty(param)) | |
400 if (len(callback_dict['parameters']) > 0): | 402 if (len(callback_dict['parameters']) > 0): |
401 callback_dict['parameters'][-1]['last'] = True | 403 callback_dict['parameters'][-1]['last'] = True |
402 return callback_dict | 404 return callback_dict |
403 | 405 |
404 def _GenerateProperties(self, properties): | 406 def _GenerateProperties(self, properties, no_gen=False): |
405 return [self._GenerateProperty(v) for v in properties.values()] | 407 with self._current_node.Descend('properties'): |
408 return [self._GenerateProperty(v, no_gen=no_gen) | |
409 for v in properties.values()] | |
406 | 410 |
407 def _GenerateProperty(self, property_): | 411 def _GenerateProperty(self, property_, no_gen=False): |
408 if not hasattr(property_, 'type_'): | 412 with self._current_node.Descend(property_.simple_name): |
409 for d in dir(property_): | 413 if not hasattr(property_, 'type_'): |
410 if not d.startswith('_'): | 414 for d in dir(property_): |
411 print ('%s -> %s' % (d, getattr(property_, d))) | 415 if not d.startswith('_'): |
412 type_ = property_.type_ | 416 print ('%s -> %s' % (d, getattr(property_, d))) |
417 type_ = property_.type_ | |
413 | 418 |
414 # Make sure we generate property info for arrays, too. | 419 # Make sure we generate property info for arrays, too. |
415 # TODO(kalman): what about choices? | 420 # TODO(kalman): what about choices? |
416 if type_.property_type == model.PropertyType.ARRAY: | 421 if type_.property_type == model.PropertyType.ARRAY: |
417 properties = type_.item_type.properties | 422 properties = type_.item_type.properties |
418 else: | 423 else: |
419 properties = type_.properties | 424 properties = type_.properties |
420 | 425 |
421 property_dict = { | 426 property_dict = { |
422 'name': property_.simple_name, | 427 'name': property_.simple_name, |
423 'optional': property_.optional, | 428 'optional': property_.optional, |
424 'description': property_.description, | 429 'description': property_.description, |
425 'properties': self._GenerateProperties(type_.properties), | 430 'properties': self._GenerateProperties(type_.properties, no_gen=True), |
426 'functions': self._GenerateFunctions(type_.functions), | 431 'functions': self._GenerateFunctions(type_.functions), |
427 'parameters': [], | 432 'parameters': [], |
428 'returns': None, | 433 'returns': None, |
429 'id': _CreateId(property_, 'property'), | 434 'id': _CreateId(property_, 'property'), |
430 } | 435 'availability': None if no_gen else self._GetAvailabilityTemplate() |
431 self._AddCommonProperties(property_dict, property_) | 436 } |
437 self._AddCommonProperties(property_dict, property_) | |
432 | 438 |
433 if type_.property_type == model.PropertyType.FUNCTION: | 439 if type_.property_type == model.PropertyType.FUNCTION: |
434 function = type_.function | 440 function = type_.function |
435 for param in function.params: | 441 with self._current_node.Descend('parameters'): |
436 property_dict['parameters'].append(self._GenerateProperty(param)) | 442 for param in function.params: |
437 if function.returns: | 443 property_dict['parameters'].append(self._GenerateProperty(param)) |
438 property_dict['returns'] = self._GenerateType(function.returns) | 444 if function.returns: |
445 property_dict['returns'] = self._GenerateType(function.returns, | |
446 no_gen=True) | |
439 | 447 |
440 value = property_.value | 448 value = property_.value |
441 if value is not None: | 449 if value is not None: |
442 if isinstance(value, int): | 450 if isinstance(value, int): |
443 property_dict['value'] = _FormatValue(value) | 451 property_dict['value'] = _FormatValue(value) |
452 else: | |
453 property_dict['value'] = value | |
444 else: | 454 else: |
445 property_dict['value'] = value | 455 self._RenderTypeInformation(type_, property_dict) |
446 else: | |
447 self._RenderTypeInformation(type_, property_dict) | |
448 | 456 |
449 return property_dict | 457 return property_dict |
450 | 458 |
451 def _GenerateCallbackProperty(self, callback): | 459 def _GenerateCallbackProperty(self, callback): |
452 property_dict = { | 460 property_dict = { |
453 'name': callback.simple_name, | 461 'name': callback.simple_name, |
454 'description': callback.description, | 462 'description': callback.description, |
455 'optional': callback.optional, | 463 'optional': callback.optional, |
456 'is_callback': True, | 464 'is_callback': True, |
457 'id': _CreateId(callback, 'property'), | 465 'id': _CreateId(callback, 'property'), |
458 'simple_type': 'function', | 466 'simple_type': 'function', |
459 } | 467 } |
460 if (callback.parent is not None and | 468 if (callback.parent is not None and |
461 not isinstance(callback.parent, model.Namespace)): | 469 not isinstance(callback.parent, model.Namespace)): |
462 property_dict['parentName'] = callback.parent.simple_name | 470 property_dict['parentName'] = callback.parent.simple_name |
463 return property_dict | 471 return property_dict |
464 | 472 |
465 def _RenderTypeInformation(self, type_, dst_dict): | 473 def _RenderTypeInformation(self, type_, dst_dict): |
466 dst_dict['is_object'] = type_.property_type == model.PropertyType.OBJECT | 474 dst_dict['is_object'] = type_.property_type == model.PropertyType.OBJECT |
467 if type_.property_type == model.PropertyType.CHOICES: | 475 if type_.property_type == model.PropertyType.CHOICES: |
468 dst_dict['choices'] = self._GenerateTypes(type_.choices) | 476 dst_dict['choices'] = self._GenerateTypes(type_.choices, no_gen=True) |
469 # We keep track of which == last for knowing when to add "or" between | 477 # We keep track of which == last for knowing when to add "or" between |
470 # choices in templates. | 478 # choices in templates. |
471 if len(dst_dict['choices']) > 0: | 479 if len(dst_dict['choices']) > 0: |
472 dst_dict['choices'][-1]['last'] = True | 480 dst_dict['choices'][-1]['last'] = True |
473 elif type_.property_type == model.PropertyType.REF: | 481 elif type_.property_type == model.PropertyType.REF: |
474 dst_dict['link'] = self._GetLink(type_.ref_type) | 482 dst_dict['link'] = self._GetLink(type_.ref_type) |
475 elif type_.property_type == model.PropertyType.ARRAY: | 483 elif type_.property_type == model.PropertyType.ARRAY: |
476 dst_dict['array'] = self._GenerateType(type_.item_type) | 484 dst_dict['array'] = self._GenerateType(type_.item_type, no_gen=True) |
477 elif type_.property_type == model.PropertyType.ENUM: | 485 elif type_.property_type == model.PropertyType.ENUM: |
478 dst_dict['enum_values'] = [ | 486 dst_dict['enum_values'] = [ |
479 {'name': value.name, 'description': value.description} | 487 {'name': value.name, 'description': value.description} |
480 for value in type_.enum_values] | 488 for value in type_.enum_values] |
481 if len(dst_dict['enum_values']) > 0: | 489 if len(dst_dict['enum_values']) > 0: |
482 dst_dict['enum_values'][-1]['last'] = True | 490 dst_dict['enum_values'][-1]['last'] = True |
483 elif type_.instance_of is not None: | 491 elif type_.instance_of is not None: |
484 dst_dict['simple_type'] = type_.instance_of | 492 dst_dict['simple_type'] = type_.instance_of |
485 else: | 493 else: |
486 dst_dict['simple_type'] = type_.property_type.name | 494 dst_dict['simple_type'] = type_.property_type.name |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
718 getter = lambda: 0 | 726 getter = lambda: 0 |
719 getter.get = lambda api_name: self._GetImpl(platform, api_name).Get() | 727 getter.get = lambda api_name: self._GetImpl(platform, api_name).Get() |
720 return getter | 728 return getter |
721 | 729 |
722 def Cron(self): | 730 def Cron(self): |
723 futures = [] | 731 futures = [] |
724 for platform in GetPlatforms(): | 732 for platform in GetPlatforms(): |
725 futures += [self._GetImpl(platform, name) | 733 futures += [self._GetImpl(platform, name) |
726 for name in self._platform_bundle.GetAPIModels(platform).GetNames()] | 734 for name in self._platform_bundle.GetAPIModels(platform).GetNames()] |
727 return Collect(futures, except_pass=FileNotFoundError) | 735 return Collect(futures, except_pass=FileNotFoundError) |
OLD | NEW |