Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: chrome/common/extensions/docs/server2/availability_finder.py

Issue 491653002: Docserver: Use GitilesFileSystem instead of SubversionFileSystem (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_models import GetNodeCategories 7 from api_models import GetNodeCategories
8 from api_schema_graph import APISchemaGraph 8 from api_schema_graph import APISchemaGraph
9 from branch_utility import BranchUtility, ChannelInfo 9 from branch_utility import BranchUtility, ChannelInfo
10 from compiled_file_system import CompiledFileSystem, SingleFile, Unicode 10 from compiled_file_system import CompiledFileSystem, SingleFile, Unicode
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 return _GetChannelFromFeatures(api_name, 52 return _GetChannelFromFeatures(api_name,
53 features_bundle.GetPermissionFeatures()) 53 features_bundle.GetPermissionFeatures())
54 54
55 55
56 def _GetAPISchemaFilename(api_name, file_system, version): 56 def _GetAPISchemaFilename(api_name, file_system, version):
57 '''Gets the name of the file which may contain the schema for |api_name| in 57 '''Gets the name of the file which may contain the schema for |api_name| in
58 |file_system|, or None if the API is not found. Note that this may be the 58 |file_system|, or None if the API is not found. Note that this may be the
59 single _EXTENSION_API file which all APIs share in older versions of Chrome, 59 single _EXTENSION_API file which all APIs share in older versions of Chrome,
60 in which case it is unknown whether the API actually exists there. 60 in which case it is unknown whether the API actually exists there.
61 ''' 61 '''
62 if version == 'trunk' or version > _ORIGINAL_FEATURES_MIN_VERSION: 62 if version == 'master' or version > _ORIGINAL_FEATURES_MIN_VERSION:
63 # API schema filenames switch format to unix_hacker_style. 63 # API schema filenames switch format to unix_hacker_style.
64 api_name = UnixName(api_name) 64 api_name = UnixName(api_name)
65 65
66 # Devtools API names have 'devtools.' prepended to them. 66 # Devtools API names have 'devtools.' prepended to them.
67 # The corresponding filenames do not. 67 # The corresponding filenames do not.
68 if 'devtools_' in api_name: 68 if 'devtools_' in api_name:
69 api_name = api_name.replace('devtools_', '') 69 api_name = api_name.replace('devtools_', '')
70 70
71 for api_path in API_PATHS: 71 for api_path in API_PATHS:
72 try: 72 try:
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 self._top_level_object_store.Set(api_name, availability) 359 self._top_level_object_store.Set(api_name, availability)
360 return availability 360 return availability
361 361
362 def check_api_availability(file_system, channel_info): 362 def check_api_availability(file_system, channel_info):
363 return self._CheckAPIAvailability(api_name, file_system, channel_info) 363 return self._CheckAPIAvailability(api_name, file_system, channel_info)
364 364
365 channel_info = self._file_system_iterator.Descending( 365 channel_info = self._file_system_iterator.Descending(
366 self._branch_utility.GetChannelInfo('dev'), 366 self._branch_utility.GetChannelInfo('dev'),
367 check_api_availability) 367 check_api_availability)
368 if channel_info is None: 368 if channel_info is None:
369 # The API wasn't available on 'dev', so it must be a 'trunk'-only API. 369 # The API wasn't available on 'dev', so it must be a 'master'-only API.
370 channel_info = self._branch_utility.GetChannelInfo('trunk') 370 channel_info = self._branch_utility.GetChannelInfo('master')
371 371
372 # If the API is not stable, check when it will be scheduled to be stable. 372 # If the API is not stable, check when it will be scheduled to be stable.
373 if channel_info.channel == 'stable': 373 if channel_info.channel == 'stable':
374 scheduled = None 374 scheduled = None
375 else: 375 else:
376 scheduled = self._FindScheduled(api_name) 376 scheduled = self._FindScheduled(api_name)
377 377
378 availability = AvailabilityInfo(channel_info, scheduled=scheduled) 378 availability = AvailabilityInfo(channel_info, scheduled=scheduled)
379 379
380 self._top_level_object_store.Set(api_name, availability) 380 self._top_level_object_store.Set(api_name, availability)
381 return availability 381 return availability
382 382
383 def GetAPINodeAvailability(self, api_name): 383 def GetAPINodeAvailability(self, api_name):
384 '''Returns an APISchemaGraph annotated with each node's availability (the 384 '''Returns an APISchemaGraph annotated with each node's availability (the
385 ChannelInfo at the oldest channel it's available in). 385 ChannelInfo at the oldest channel it's available in).
386 ''' 386 '''
387 availability_graph = self._node_level_object_store.Get(api_name).Get() 387 availability_graph = self._node_level_object_store.Get(api_name).Get()
388 if availability_graph is not None: 388 if availability_graph is not None:
389 return availability_graph 389 return availability_graph
390 390
391 def assert_not_none(value): 391 def assert_not_none(value):
392 assert value is not None 392 assert value is not None
393 return value 393 return value
394 394
395 availability_graph = APISchemaGraph() 395 availability_graph = APISchemaGraph()
396 host_fs = self._host_file_system 396 host_fs = self._host_file_system
397 trunk_stat = assert_not_none(host_fs.Stat(_GetAPISchemaFilename( 397 master_stat = assert_not_none(host_fs.Stat(_GetAPISchemaFilename(
398 api_name, host_fs, 'trunk'))) 398 api_name, host_fs, 'master')))
399 399
400 # Weird object thing here because nonlocal is Python 3. 400 # Weird object thing here because nonlocal is Python 3.
401 previous = type('previous', (object,), {'stat': None, 'graph': None}) 401 previous = type('previous', (object,), {'stat': None, 'graph': None})
402 402
403 def update_availability_graph(file_system, channel_info): 403 def update_availability_graph(file_system, channel_info):
404 # If we can't find a filename, skip checking at this branch. 404 # If we can't find a filename, skip checking at this branch.
405 # For example, something could have a predetermined availability of 23, 405 # For example, something could have a predetermined availability of 23,
406 # but it doesn't show up in the file system until 26. 406 # but it doesn't show up in the file system until 26.
407 # We know that the file will become available at some point. 407 # We know that the file will become available at some point.
408 # 408 #
(...skipping 28 matching lines...) Expand all
437 return self._CheckAPINodeAvailability('%s.%s' % (api_name, node_name), 437 return self._CheckAPINodeAvailability('%s.%s' % (api_name, node_name),
438 channel_info) 438 channel_info)
439 439
440 availability_graph.Update(version_graph.Subtract(availability_graph), 440 availability_graph.Update(version_graph.Subtract(availability_graph),
441 annotator) 441 annotator)
442 442
443 previous.stat = version_stat 443 previous.stat = version_stat
444 previous.graph = version_graph 444 previous.graph = version_graph
445 445
446 # Continue looping until there are no longer differences between this 446 # Continue looping until there are no longer differences between this
447 # version and trunk. 447 # version and master.
448 return version_stat != trunk_stat 448 return version_stat != master_stat
449 449
450 self._file_system_iterator.Ascending( 450 self._file_system_iterator.Ascending(
451 self.GetAPIAvailability(api_name).channel_info, 451 self.GetAPIAvailability(api_name).channel_info,
452 update_availability_graph) 452 update_availability_graph)
453 453
454 self._node_level_object_store.Set(api_name, availability_graph) 454 self._node_level_object_store.Set(api_name, availability_graph)
455 return availability_graph 455 return availability_graph
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698