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

Unified Diff: chrome/common/extensions/docs/server2/api_models.py

Issue 522183002: Docserver: Rename CompiledFileSystem's GetFileVersion/GetFileListingVersion to (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unnecessary change Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/app.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/docs/server2/api_models.py
diff --git a/chrome/common/extensions/docs/server2/api_models.py b/chrome/common/extensions/docs/server2/api_models.py
index ac164fb4e6d331288c797e0449ee424df649d9b3..21d9329a3dd62f2b37cfed2c01caaf49ff4ebf6c 100644
--- a/chrome/common/extensions/docs/server2/api_models.py
+++ b/chrome/common/extensions/docs/server2/api_models.py
@@ -8,8 +8,9 @@ from compiled_file_system import SingleFile, Unicode
from extensions_paths import API_PATHS
from features_bundle import HasParent, GetParentName
from file_system import FileNotFoundError
-from future import All, Future
+from future import All, Future, Race
from operator import itemgetter
+from path_util import Join
from platform_util import PlatformToExtensionType
from schema_util import ProcessSchema
from third_party.json_schema_compiler.json_schema import DeleteNodes
@@ -86,7 +87,10 @@ class APIModels(object):
return [name for name, feature in api_features.iteritems()
if not HasParent(name, feature, api_features)]
- def GetModel(self, api_name):
+ def _GetPotentialPathsForModel(self, api_name):
+ '''Returns the list of file system paths that the model for |api_name|
+ might be located at.
+ '''
# By default |api_name| is assumed to be given without a path or extension,
# so combinations of known paths and extension types will be searched.
api_extensions = ('.json', '.idl')
@@ -116,19 +120,13 @@ class APIModels(object):
'devtools', file_name.replace(basename,
basename.replace('devtools_' , '')))
- futures = [self._model_cache.GetFromFile(
- posixpath.join(path, '%s%s' % (file_name, ext)))
- for ext in api_extensions
- for path in api_paths]
- def resolve():
- for future in futures:
- try:
- return future.Get()
- # Either the file wasn't found or there was no schema for the file
- except (FileNotFoundError, ValueError): pass
- # Propagate the first error if neither were found.
- futures[0].Get()
- return Future(callback=resolve)
+ return [Join(path, file_name + ext) for ext in api_extensions
+ for path in api_paths]
+
+ def GetModel(self, api_name):
+ futures = [self._model_cache.GetFromFile(path)
+ for path in self._GetPotentialPathsForModel(api_name)]
+ return Race(futures, except_pass=(FileNotFoundError, ValueError))
def GetContentScriptAPIs(self):
'''Creates a dict of APIs and nodes supported by content scripts in
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/app.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698