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 # Check for this before calling CheckEventCallback to avoid | |
| 224 # unnecessary AssertionErrors. | |
|
not at google - send to devlin
2014/07/15 21:51:15
comment is unnecessary, code is clear enough
| |
| 225 if 'callback' in self._lookup_path: | |
| 226 return self._CheckEventCallback(deprecated_path) | |
| 227 | |
| 213 def GetAvailability(self): | 228 def GetAvailability(self): |
| 214 '''Returns availability information for this node. | 229 '''Returns availability information for this node. |
| 215 ''' | 230 ''' |
| 216 if self._GetCategory() in self._ignored_categories: | 231 if self._GetCategory() in self._ignored_categories: |
| 217 return None | 232 return None |
| 218 node_availability = self._LookupAvailability(self._lookup_path) | 233 node_availability = self._LookupAvailability(self._lookup_path) |
| 219 if node_availability is None: | 234 if node_availability is None: |
| 220 if not IsReleaseServer(): | 235 if not IsReleaseServer(): |
| 221 # Bad, and happens a lot :( | 236 # Bad, and happens a lot :( |
| 222 logging.warning('No availability found for: %s' % self) | 237 logging.warning('No availability found for: %s' % self) |
| 223 return None | 238 return None |
| 224 | 239 |
| 240 # Check this before checking parent availability; we always want | |
|
not at google - send to devlin
2014/07/15 21:51:15
I'd rather that the callers worry about this rathe
| |
| 241 # to see when an API became deprecated. | |
| 242 deprecated_availability = self.GetDeprecated() | |
| 243 if deprecated_availability is not None: | |
| 244 # The same annotation object is used for multiple nodes. | |
| 245 deprecated_info = copy(deprecated_availability) | |
| 246 deprecated_info.channel = 'deprecated' | |
| 247 return deprecated_info | |
| 248 | |
| 225 parent_node_availability = self._LookupAvailability(self._GetParentPath()) | 249 parent_node_availability = self._LookupAvailability(self._GetParentPath()) |
| 226 # If the parent node availability couldn't be found, something | 250 # If the parent node availability couldn't be found, something |
| 227 # is very wrong. | 251 # is very wrong. |
| 228 assert parent_node_availability is not None | 252 assert parent_node_availability is not None |
| 229 | 253 |
| 230 # Only render this node's availability if it differs from the parent | 254 # Only render this node's availability if it differs from the parent |
| 231 # node's availability. | 255 # node's availability. |
| 232 if node_availability == parent_node_availability: | 256 if node_availability == parent_node_availability: |
| 233 return None | 257 return None |
| 234 return node_availability | 258 return node_availability |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 550 # if they share the same 'title' attribute. | 574 # if they share the same 'title' attribute. |
| 551 row_titles = [row['title'] for row in intro_rows] | 575 row_titles = [row['title'] for row in intro_rows] |
| 552 for misc_row in self._GetMiscIntroRows(): | 576 for misc_row in self._GetMiscIntroRows(): |
| 553 if misc_row['title'] in row_titles: | 577 if misc_row['title'] in row_titles: |
| 554 intro_rows[row_titles.index(misc_row['title'])] = misc_row | 578 intro_rows[row_titles.index(misc_row['title'])] = misc_row |
| 555 else: | 579 else: |
| 556 intro_rows.append(misc_row) | 580 intro_rows.append(misc_row) |
| 557 | 581 |
| 558 return intro_rows | 582 return intro_rows |
| 559 | 583 |
| 560 def _GetAvailabilityTemplate(self, status=None, version=None, scheduled=None): | 584 def _GetAvailabilityTemplate(self, status=None, version=None, scheduled=None): |
|
not at google - send to devlin
2014/07/15 21:51:15
a thought: does the function/event level availabil
ahernandez
2014/07/15 22:09:51
It can't say "deprecated in dev channel"; deprecat
| |
| 561 '''Returns an object that the templates use to display availability | 585 '''Returns an object that the templates use to display availability |
| 562 information. | 586 information. |
| 563 ''' | 587 ''' |
| 564 if status is None: | 588 if status is None: |
| 565 availability_info = self._current_node.GetAvailability() | 589 availability_info = self._current_node.GetAvailability() |
|
not at google - send to devlin
2014/07/15 21:51:14
put that logic down here:
availability_info = sel
| |
| 566 if availability_info is None: | 590 if availability_info is None: |
| 567 return None | 591 return None |
| 568 status = availability_info.channel | 592 status = availability_info.channel |
| 569 version = availability_info.version | 593 version = availability_info.version |
| 570 return { | 594 return { |
| 571 'partial': self._template_cache.GetFromFile( | 595 'partial': self._template_cache.GetFromFile( |
| 572 '%sintro_tables/%s_message.html' % (PRIVATE_TEMPLATES, status)).Get(), | 596 '%sintro_tables/%s_message.html' % (PRIVATE_TEMPLATES, status)).Get(), |
| 573 'scheduled': scheduled, | 597 'scheduled': scheduled, |
| 574 'version': version | 598 'version': version |
| 575 } | 599 } |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 770 getter = lambda: 0 | 794 getter = lambda: 0 |
| 771 getter.get = lambda api_name: self._GetImpl(platform, api_name).Get() | 795 getter.get = lambda api_name: self._GetImpl(platform, api_name).Get() |
| 772 return getter | 796 return getter |
| 773 | 797 |
| 774 def Cron(self): | 798 def Cron(self): |
| 775 futures = [] | 799 futures = [] |
| 776 for platform in GetPlatforms(): | 800 for platform in GetPlatforms(): |
| 777 futures += [self._GetImpl(platform, name) | 801 futures += [self._GetImpl(platform, name) |
| 778 for name in self._platform_bundle.GetAPIModels(platform).GetNames()] | 802 for name in self._platform_bundle.GetAPIModels(platform).GetNames()] |
| 779 return Collect(futures, except_pass=FileNotFoundError) | 803 return Collect(futures, except_pass=FileNotFoundError) |
| OLD | NEW |