| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 import posixpath | 5 import posixpath |
| 6 | 6 |
| 7 from api_schema_graph import APISchemaGraph | 7 from api_schema_graph import APISchemaGraph |
| 8 from branch_utility import BranchUtility, ChannelInfo | 8 from branch_utility import BranchUtility, ChannelInfo |
| 9 from extensions_paths import API_PATHS, JSON_TEMPLATES | 9 from extensions_paths import API_PATHS, JSON_TEMPLATES |
| 10 from features_bundle import FeaturesBundle | 10 from features_bundle import FeaturesBundle |
| 11 from file_system import FileNotFoundError | 11 from file_system import FileNotFoundError |
| 12 from third_party.json_schema_compiler.memoize import memoize | 12 from third_party.json_schema_compiler.memoize import memoize |
| 13 from third_party.json_schema_compiler.model import UnixName | 13 from third_party.json_schema_compiler.model import UnixName |
| 14 | 14 |
| 15 | 15 |
| 16 _DEVTOOLS_API = 'devtools_api.json' | 16 _DEVTOOLS_API = 'devtools_api.json' |
| 17 _EXTENSION_API = 'extension_api.json' | 17 _EXTENSION_API = 'extension_api.json' |
| 18 # The version where api_features.json is first available. | 18 # The version where api_features.json is first available. |
| 19 _API_FEATURES_MIN_VERSION = 28 | 19 _API_FEATURES_MIN_VERSION = 28 |
| 20 # The version where permission_ and manifest_features.json are available and | 20 # The version where permission_ and manifest_features.json are available and |
| 21 # presented in the current format. | 21 # presented in the current format. |
| 22 _ORIGINAL_FEATURES_MIN_VERSION = 20 | 22 _ORIGINAL_FEATURES_MIN_VERSION = 20 |
| 23 # API schemas are aggregated in extension_api.json up to this version. | 23 # API schemas are aggregated in extension_api.json up to this version. |
| 24 _EXTENSION_API_MAX_VERSION = 17 | 24 _EXTENSION_API_MAX_VERSION = 17 |
| 25 # The earliest version for which we have SVN data. | 25 # The earliest version for which we have SVN data. |
| 26 _SVN_MIN_VERSION = 5 | 26 _SVN_MIN_VERSION = 5 |
| 27 | 27 |
| 28 | 28 |
| 29 def _GetNamespaceFromFilename(api_name): | |
| 30 '''API names passed in from the templates follow a different naming | |
| 31 convention than the actual API namespace names. Convert |api_name| | |
| 32 to its proper namespace name. | |
| 33 ''' | |
| 34 # Devtools APIs are located in a devtools/ directory | |
| 35 # (e.g. devtools/panels.json). The namespace will be devtools.panels. | |
| 36 if 'devtools/' in api_name: | |
| 37 api_name = api_name.replace('/', '.') | |
| 38 # Experimental API filenames have a 'experimental_' prefixed to them (e.g. | |
| 39 # devtools/experimental_audits.json). The namespace always has | |
| 40 # 'experimental.' prefixed to it (e.g. experimental.devtools.audits). | |
| 41 if 'experimental_' in api_name: | |
| 42 api_name = 'experimental.' + api_name.replace('experimental_', '') | |
| 43 # API filenames use '_'s as separators; the separator for namespaces is | |
| 44 # always a '.'. | |
| 45 api_name = api_name.replace('_', '.') | |
| 46 return api_name | |
| 47 | |
| 48 | |
| 49 def _GetChannelFromFeatures(api_name, features): | 29 def _GetChannelFromFeatures(api_name, features): |
| 50 '''Finds API channel information for |api_name| from |features|. | 30 '''Finds API channel information for |api_name| from |features|. |
| 51 Returns None if channel information for the API cannot be located. | 31 Returns None if channel information for the API cannot be located. |
| 52 ''' | 32 ''' |
| 53 feature = features.Get().get(api_name) | 33 feature = features.Get().get(api_name) |
| 54 return feature.get('channel') if feature else None | 34 return feature.get('channel') if feature else None |
| 55 | 35 |
| 56 | 36 |
| 57 def _GetChannelFromAPIFeatures(api_name, features_bundle): | 37 def _GetChannelFromAPIFeatures(api_name, features_bundle): |
| 58 return _GetChannelFromFeatures(api_name, features_bundle.GetAPIFeatures()) | 38 return _GetChannelFromFeatures(api_name, features_bundle.GetAPIFeatures()) |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 292 |
| 313 availability = AvailabilityInfo(channel_info, scheduled=scheduled) | 293 availability = AvailabilityInfo(channel_info, scheduled=scheduled) |
| 314 | 294 |
| 315 self._top_level_object_store.Set(api_name, availability) | 295 self._top_level_object_store.Set(api_name, availability) |
| 316 return availability | 296 return availability |
| 317 | 297 |
| 318 def GetAPINodeAvailability(self, api_name): | 298 def GetAPINodeAvailability(self, api_name): |
| 319 '''Returns an APISchemaGraph annotated with each node's availability (the | 299 '''Returns an APISchemaGraph annotated with each node's availability (the |
| 320 ChannelInfo at the oldest channel it's available in). | 300 ChannelInfo at the oldest channel it's available in). |
| 321 ''' | 301 ''' |
| 322 api_name = _GetNamespaceFromFilename(api_name) | |
| 323 availability_graph = self._node_level_object_store.Get(api_name).Get() | 302 availability_graph = self._node_level_object_store.Get(api_name).Get() |
| 324 if availability_graph is not None: | 303 if availability_graph is not None: |
| 325 return availability_graph | 304 return availability_graph |
| 326 | 305 |
| 327 def assert_not_none(value): | 306 def assert_not_none(value): |
| 328 assert value is not None | 307 assert value is not None |
| 329 return value | 308 return value |
| 330 | 309 |
| 331 availability_graph = APISchemaGraph() | 310 availability_graph = APISchemaGraph() |
| 332 host_fs = self._host_file_system | 311 host_fs = self._host_file_system |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 # Continue looping until there are no longer differences between this | 356 # Continue looping until there are no longer differences between this |
| 378 # version and trunk. | 357 # version and trunk. |
| 379 return version_stat != trunk_stat | 358 return version_stat != trunk_stat |
| 380 | 359 |
| 381 self._file_system_iterator.Ascending( | 360 self._file_system_iterator.Ascending( |
| 382 self.GetAPIAvailability(api_name).channel_info, | 361 self.GetAPIAvailability(api_name).channel_info, |
| 383 update_availability_graph) | 362 update_availability_graph) |
| 384 | 363 |
| 385 self._node_level_object_store.Set(api_name, availability_graph) | 364 self._node_level_object_store.Set(api_name, availability_graph) |
| 386 return availability_graph | 365 return availability_graph |
| OLD | NEW |