Chromium Code Reviews| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 callback_index = lookup_path.index('callback') | 164 callback_index = lookup_path.index('callback') |
| 165 try: | 165 try: |
| 166 lookup_path.pop(callback_index) | 166 lookup_path.pop(callback_index) |
| 167 node_availability = self._LookupNodeAvailability(lookup_path) | 167 node_availability = self._LookupNodeAvailability(lookup_path) |
| 168 finally: | 168 finally: |
| 169 lookup_path.insert(callback_index, 'callback') | 169 lookup_path.insert(callback_index, 'callback') |
| 170 return node_availability | 170 return node_availability |
| 171 return None | 171 return None |
| 172 | 172 |
| 173 def _LookupAvailability(self, lookup_path): | 173 def _LookupAvailability(self, lookup_path): |
| 174 '''Runs all the lookup checks on self._lookup_path and | 174 '''Runs all the lookup checks on |lookup_path| and |
| 175 returns the node availability if found, None otherwise. | 175 returns the node availability if found, None otherwise. |
| 176 ''' | 176 ''' |
| 177 for lookup in (self._LookupNodeAvailability, | 177 for lookup in (self._LookupNodeAvailability, |
| 178 self._CheckEventCallback, | 178 self._CheckEventCallback, |
| 179 self._CheckNamespacePrefix): | 179 self._CheckNamespacePrefix): |
| 180 node_availability = lookup(lookup_path) | 180 node_availability = lookup(lookup_path) |
| 181 if node_availability is not None: | 181 if node_availability is not None: |
| 182 return node_availability | 182 return node_availability |
| 183 return None | 183 return None |
| 184 | 184 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 203 # lookup paths like | 203 # lookup paths like |
| 204 # 'events > types > Rule > properties > tags > tagsType'. | 204 # 'events > types > Rule > properties > tags > tagsType'. |
| 205 # These nodes are treated as properties. | 205 # These nodes are treated as properties. |
| 206 return 'properties' | 206 return 'properties' |
| 207 if self._lookup_path[0] == 'events': | 207 if self._lookup_path[0] == 'events': |
| 208 # HACK(ahernandez.miralles): This catches a few edge cases, | 208 # HACK(ahernandez.miralles): This catches a few edge cases, |
| 209 # such as 'webviewTag > events > consolemessage > level'. | 209 # such as 'webviewTag > events > consolemessage > level'. |
| 210 return 'properties' | 210 return 'properties' |
| 211 raise AssertionError('Could not classify node %s' % self) | 211 raise AssertionError('Could not classify node %s' % self) |
| 212 | 212 |
| 213 def GetDeprecated(self): | |
| 214 '''Returns when this node became deprecated, or None if it | |
| 215 is not deprecated. | |
| 216 ''' | |
| 217 deprecated_path = self._lookup_path + ['deprecated'] | |
| 218 for lookup in (self._LookupNodeAvailability, | |
| 219 self._CheckNamespacePrefix): | |
| 220 node_availability = lookup(deprecated_path) | |
| 221 if node_availability is not None: | |
| 222 return node_availability | |
| 223 if 'callback' in self._lookup_path: | |
| 224 return self._CheckEventCallback(deprecated_path) | |
|
not at google - send to devlin
2014/07/17 20:30:06
'return None' at end.
| |
| 225 | |
| 213 def GetAvailability(self): | 226 def GetAvailability(self): |
| 214 '''Returns availability information for this node. | 227 '''Returns availability information for this node. |
| 215 ''' | 228 ''' |
| 216 if self._GetCategory() in self._ignored_categories: | 229 if self._GetCategory() in self._ignored_categories: |
| 217 return None | 230 return None |
| 218 node_availability = self._LookupAvailability(self._lookup_path) | 231 node_availability = self._LookupAvailability(self._lookup_path) |
| 219 if node_availability is None: | 232 if node_availability is None: |
| 220 logging.warning('No availability found for: %s' % self) | 233 logging.warning('No availability found for: %s' % self) |
| 221 return None | 234 return None |
| 222 | 235 |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 548 # if they share the same 'title' attribute. | 561 # if they share the same 'title' attribute. |
| 549 row_titles = [row['title'] for row in intro_rows] | 562 row_titles = [row['title'] for row in intro_rows] |
| 550 for misc_row in self._GetMiscIntroRows(): | 563 for misc_row in self._GetMiscIntroRows(): |
| 551 if misc_row['title'] in row_titles: | 564 if misc_row['title'] in row_titles: |
| 552 intro_rows[row_titles.index(misc_row['title'])] = misc_row | 565 intro_rows[row_titles.index(misc_row['title'])] = misc_row |
| 553 else: | 566 else: |
| 554 intro_rows.append(misc_row) | 567 intro_rows.append(misc_row) |
| 555 | 568 |
| 556 return intro_rows | 569 return intro_rows |
| 557 | 570 |
| 558 def _GetAvailabilityTemplate(self, status=None, version=None, scheduled=None): | 571 def _GetAvailabilityTemplate(self, status=None, version=None, scheduled=None): |
|
not at google - send to devlin
2014/07/17 20:30:06
mm I didn't notice these arguments here, with the
| |
| 559 '''Returns an object that the templates use to display availability | 572 '''Returns an object that the templates use to display availability |
| 560 information. | 573 information. |
| 561 ''' | 574 ''' |
| 562 if status is None: | 575 if status is None: |
| 563 availability_info = self._current_node.GetAvailability() | 576 availability_info = self._current_node.GetDeprecated() |
|
not at google - send to devlin
2014/07/17 20:30:06
please add a comment like 'Displaying deprecated s
| |
| 564 if availability_info is None: | 577 if availability_info is not None: |
| 565 return None | 578 status = 'deprecated' |
| 566 status = availability_info.channel | 579 else: |
| 567 version = availability_info.version | 580 availability_info = self._current_node.GetAvailability() |
| 581 if availability_info is None: | |
| 582 return None | |
| 583 status = availability_info.channel_info.channel | |
| 584 version = availability_info.channel_info.version | |
| 585 scheduled = availability_info.scheduled | |
| 568 return { | 586 return { |
| 569 'partial': self._template_cache.GetFromFile( | 587 'partial': self._template_cache.GetFromFile( |
| 570 '%sintro_tables/%s_message.html' % (PRIVATE_TEMPLATES, status)).Get(), | 588 '%sintro_tables/%s_message.html' % (PRIVATE_TEMPLATES, status)).Get(), |
| 571 'scheduled': scheduled, | 589 'scheduled': scheduled, |
| 572 'version': version | 590 'version': version |
| 573 } | 591 } |
| 574 | 592 |
| 575 def _GetIntroDescriptionRow(self): | 593 def _GetIntroDescriptionRow(self): |
| 576 ''' Generates the 'Description' row data for an API intro table. | 594 ''' Generates the 'Description' row data for an API intro table. |
| 577 ''' | 595 ''' |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 768 getter = lambda: 0 | 786 getter = lambda: 0 |
| 769 getter.get = lambda api_name: self._GetImpl(platform, api_name).Get() | 787 getter.get = lambda api_name: self._GetImpl(platform, api_name).Get() |
| 770 return getter | 788 return getter |
| 771 | 789 |
| 772 def Cron(self): | 790 def Cron(self): |
| 773 futures = [] | 791 futures = [] |
| 774 for platform in GetPlatforms(): | 792 for platform in GetPlatforms(): |
| 775 futures += [self._GetImpl(platform, name) | 793 futures += [self._GetImpl(platform, name) |
| 776 for name in self._platform_bundle.GetAPIModels(platform).GetNames()] | 794 for name in self._platform_bundle.GetAPIModels(platform).GetNames()] |
| 777 return Collect(futures, except_pass=FileNotFoundError) | 795 return Collect(futures, except_pass=FileNotFoundError) |
| OLD | NEW |