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) | |
225 return None | |
226 | |
213 def GetAvailability(self): | 227 def GetAvailability(self): |
214 '''Returns availability information for this node. | 228 '''Returns availability information for this node. |
215 ''' | 229 ''' |
216 if self._GetCategory() in self._ignored_categories: | 230 if self._GetCategory() in self._ignored_categories: |
217 return None | 231 return None |
218 node_availability = self._LookupAvailability(self._lookup_path) | 232 node_availability = self._LookupAvailability(self._lookup_path) |
219 if node_availability is None: | 233 if node_availability is None: |
220 logging.warning('No availability found for: %s' % self) | 234 logging.warning('No availability found for: %s' % self) |
221 return None | 235 return None |
222 | 236 |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
548 # if they share the same 'title' attribute. | 562 # if they share the same 'title' attribute. |
549 row_titles = [row['title'] for row in intro_rows] | 563 row_titles = [row['title'] for row in intro_rows] |
550 for misc_row in self._GetMiscIntroRows(): | 564 for misc_row in self._GetMiscIntroRows(): |
551 if misc_row['title'] in row_titles: | 565 if misc_row['title'] in row_titles: |
552 intro_rows[row_titles.index(misc_row['title'])] = misc_row | 566 intro_rows[row_titles.index(misc_row['title'])] = misc_row |
553 else: | 567 else: |
554 intro_rows.append(misc_row) | 568 intro_rows.append(misc_row) |
555 | 569 |
556 return intro_rows | 570 return intro_rows |
557 | 571 |
558 def _GetAvailabilityTemplate(self, status=None, version=None, scheduled=None): | 572 def _CreateAvailabilityTemplate(self, status, scheduled, version): |
559 '''Returns an object that the templates use to display availability | 573 '''Returns an object suitable for use in templates to display availability |
560 information. | 574 information. |
561 ''' | 575 ''' |
562 if status is None: | |
563 availability_info = self._current_node.GetAvailability() | |
564 if availability_info is None: | |
565 return None | |
566 status = availability_info.channel | |
567 version = availability_info.version | |
568 return { | 576 return { |
569 'partial': self._template_cache.GetFromFile( | 577 'partial': self._template_cache.GetFromFile( |
570 '%sintro_tables/%s_message.html' % (PRIVATE_TEMPLATES, status)).Get(), | 578 '%sintro_tables/%s_message.html' % (PRIVATE_TEMPLATES, status)).Get(), |
571 'scheduled': scheduled, | 579 'scheduled': scheduled, |
572 'version': version | 580 'version': version |
573 } | 581 } |
574 | 582 |
583 def _GetAvailabilityTemplate(self): | |
584 '''Gets availability for the current node and returns an appropriate | |
585 template object. | |
586 ''' | |
587 # Displaying deprecated status takes precedence over when the API | |
588 # became stable. | |
589 availability_info = self._current_node.GetDeprecated() | |
590 if availability_info is not None: | |
591 status = 'deprecated' | |
592 else: | |
593 availability_info = self._current_node.GetAvailability() | |
594 if availability_info is None: | |
595 return None | |
596 status = availability_info.channel_info.channel | |
597 scheduled = availability_info.scheduled | |
598 version = availability_info.channel_info.version | |
not at google - send to devlin
2014/07/17 21:39:21
inline |scheduled| and |version| ?
| |
599 return self._CreateAvailabilityTemplate(status, scheduled, version) | |
600 | |
575 def _GetIntroDescriptionRow(self): | 601 def _GetIntroDescriptionRow(self): |
576 ''' Generates the 'Description' row data for an API intro table. | 602 ''' Generates the 'Description' row data for an API intro table. |
577 ''' | 603 ''' |
578 return { | 604 return { |
579 'title': 'Description', | 605 'title': 'Description', |
580 'content': [ | 606 'content': [ |
581 { 'text': self._namespace.description } | 607 { 'text': self._namespace.description } |
582 ] | 608 ] |
583 } | 609 } |
584 | 610 |
585 def _GetIntroAvailabilityRow(self): | 611 def _GetIntroAvailabilityRow(self): |
586 ''' Generates the 'Availability' row data for an API intro table. | 612 ''' Generates the 'Availability' row data for an API intro table. |
587 ''' | 613 ''' |
588 if self._IsExperimental(): | 614 if self._IsExperimental(): |
589 status = 'experimental' | 615 status = 'experimental' |
616 scheduled = None | |
590 version = None | 617 version = None |
591 scheduled = None | |
592 else: | 618 else: |
593 status = self._availability.channel_info.channel | 619 status = self._availability.channel_info.channel |
620 scheduled = self._availability.scheduled | |
594 version = self._availability.channel_info.version | 621 version = self._availability.channel_info.version |
595 scheduled = self._availability.scheduled | |
596 return { | 622 return { |
597 'title': 'Availability', | 623 'title': 'Availability', |
598 'content': [ | 624 'content': [ |
599 self._GetAvailabilityTemplate(status=status, | 625 self._CreateAvailabilityTemplate(status, scheduled, version) |
600 version=version, | |
601 scheduled=scheduled) | |
602 ] | 626 ] |
603 } | 627 } |
604 | 628 |
605 def _GetIntroDependencyRows(self): | 629 def _GetIntroDependencyRows(self): |
606 # Devtools aren't in _api_features. If we're dealing with devtools, bail. | 630 # Devtools aren't in _api_features. If we're dealing with devtools, bail. |
607 if 'devtools' in self._namespace.name: | 631 if 'devtools' in self._namespace.name: |
608 return [] | 632 return [] |
609 | 633 |
610 api_feature = self._api_features.Get().get(self._namespace.name) | 634 api_feature = self._api_features.Get().get(self._namespace.name) |
611 if not api_feature: | 635 if not api_feature: |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
768 getter = lambda: 0 | 792 getter = lambda: 0 |
769 getter.get = lambda api_name: self._GetImpl(platform, api_name).Get() | 793 getter.get = lambda api_name: self._GetImpl(platform, api_name).Get() |
770 return getter | 794 return getter |
771 | 795 |
772 def Cron(self): | 796 def Cron(self): |
773 futures = [] | 797 futures = [] |
774 for platform in GetPlatforms(): | 798 for platform in GetPlatforms(): |
775 futures += [self._GetImpl(platform, name) | 799 futures += [self._GetImpl(platform, name) |
776 for name in self._platform_bundle.GetAPIModels(platform).GetNames()] | 800 for name in self._platform_bundle.GetAPIModels(platform).GetNames()] |
777 return Collect(futures, except_pass=FileNotFoundError) | 801 return Collect(futures, except_pass=FileNotFoundError) |
OLD | NEW |