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 |
11 from docs_server_utils import StringIdentity | 11 from docs_server_utils import StringIdentity |
12 from environment import IsPreviewServer | 12 from environment import IsPreviewServer, IsReleaseServer |
13 from extensions_paths import JSON_TEMPLATES, PRIVATE_TEMPLATES | 13 from extensions_paths import JSON_TEMPLATES, PRIVATE_TEMPLATES |
14 from file_system import FileNotFoundError | 14 from file_system import FileNotFoundError |
15 from future import Future, Collect | 15 from future import Future, Collect |
16 from platform_util import GetPlatforms | 16 from platform_util import GetPlatforms |
17 import third_party.json_schema_compiler.json_parse as json_parse | 17 import third_party.json_schema_compiler.json_parse as json_parse |
18 import third_party.json_schema_compiler.model as model | 18 import third_party.json_schema_compiler.model as model |
19 from environment import IsPreviewServer | |
20 from third_party.json_schema_compiler.memoize import memoize | 19 from third_party.json_schema_compiler.memoize import memoize |
21 | 20 |
22 | 21 |
23 # The set of possible categories a node may belong to. | 22 # The set of possible categories a node may belong to. |
24 _NODE_CATEGORIES = ('types', 'functions', 'events', 'properties') | 23 _NODE_CATEGORIES = ('types', 'functions', 'events', 'properties') |
25 | 24 |
26 | 25 |
27 def _CreateId(node, prefix): | 26 def _CreateId(node, prefix): |
28 if node.parent is not None and not isinstance(node.parent, model.Namespace): | 27 if node.parent is not None and not isinstance(node.parent, model.Namespace): |
29 return '-'.join([prefix, node.parent.simple_name, node.simple_name]) | 28 return '-'.join([prefix, node.parent.simple_name, node.simple_name]) |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 return 'properties' | 210 return 'properties' |
212 raise AssertionError('Could not classify node %s' % self) | 211 raise AssertionError('Could not classify node %s' % self) |
213 | 212 |
214 def GetAvailability(self): | 213 def GetAvailability(self): |
215 '''Returns availability information for this node. | 214 '''Returns availability information for this node. |
216 ''' | 215 ''' |
217 if self._GetCategory() in self._ignored_categories: | 216 if self._GetCategory() in self._ignored_categories: |
218 return None | 217 return None |
219 node_availability = self._LookupAvailability(self._lookup_path) | 218 node_availability = self._LookupAvailability(self._lookup_path) |
220 if node_availability is None: | 219 if node_availability is None: |
221 logging.warning('No availability found for: %s' % self) | 220 if not IsReleaseServer(): |
| 221 # Bad, and happens a lot :( |
| 222 logging.warning('No availability found for: %s' % self) |
222 return None | 223 return None |
223 | 224 |
224 parent_node_availability = self._LookupAvailability(self._GetParentPath()) | 225 parent_node_availability = self._LookupAvailability(self._GetParentPath()) |
225 # If the parent node availability couldn't be found, something | 226 # If the parent node availability couldn't be found, something |
226 # is very wrong. | 227 # is very wrong. |
227 assert parent_node_availability is not None | 228 assert parent_node_availability is not None |
228 | 229 |
229 # Only render this node's availability if it differs from the parent | 230 # Only render this node's availability if it differs from the parent |
230 # node's availability. | 231 # node's availability. |
231 if node_availability == parent_node_availability: | 232 if node_availability == parent_node_availability: |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 getter = lambda: 0 | 770 getter = lambda: 0 |
770 getter.get = lambda api_name: self._GetImpl(platform, api_name).Get() | 771 getter.get = lambda api_name: self._GetImpl(platform, api_name).Get() |
771 return getter | 772 return getter |
772 | 773 |
773 def Cron(self): | 774 def Cron(self): |
774 futures = [] | 775 futures = [] |
775 for platform in GetPlatforms(): | 776 for platform in GetPlatforms(): |
776 futures += [self._GetImpl(platform, name) | 777 futures += [self._GetImpl(platform, name) |
777 for name in self._platform_bundle.GetAPIModels(platform).GetNames()] | 778 for name in self._platform_bundle.GetAPIModels(platform).GetNames()] |
778 return Collect(futures, except_pass=FileNotFoundError) | 779 return Collect(futures, except_pass=FileNotFoundError) |
OLD | NEW |