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

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

Issue 1151283007: Docserver overhaul: Gitiles away from me. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 (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 import logging 5 import logging
6 6
7 from data_source import DataSource 7 from data_source import DataSource
8 from docs_server_utils import StringIdentity 8 from docs_server_utils import StringIdentity
9 from environment import IsPreviewServer 9 from environment import IsPreviewServer
10 from file_system import FileNotFoundError 10 from file_system import FileNotFoundError
11 from future import Future, All 11 from future import All, Future
12 from jsc_view import CreateJSCView, GetEventByNameFromEvents 12 from jsc_view import CreateJSCView, GetEventByNameFromEvents
13 from platform_util import GetPlatforms 13 from platform_util import GetPlatforms
14 from third_party.json_schema_compiler.model import UnixName 14 from third_party.json_schema_compiler.model import UnixName
15 15
16 16
17 class APIDataSource(DataSource): 17 class APIDataSource(DataSource):
18 '''This class fetches and loads JSON APIs from the FileSystem passed in with 18 '''This class fetches and loads JSON APIs from the FileSystem passed in with
19 |compiled_fs_factory|, so the APIs can be plugged into templates. 19 |compiled_fs_factory|, so the APIs can be plugged into templates.
20 ''' 20 '''
21 def __init__(self, server_instance, request): 21 def __init__(self, server_instance, request):
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 return Future(callback=resolve) 78 return Future(callback=resolve)
79 79
80 def get(self, platform): 80 def get(self, platform):
81 '''Return a getter object so that templates can perform lookups such 81 '''Return a getter object so that templates can perform lookups such
82 as apis.extensions.runtime. 82 as apis.extensions.runtime.
83 ''' 83 '''
84 getter = lambda: 0 84 getter = lambda: 0
85 getter.get = lambda api_name: self._GetSchemaView(platform, api_name).Get() 85 getter.get = lambda api_name: self._GetSchemaView(platform, api_name).Get()
86 return getter 86 return getter
87 87
88 def GetRefreshPaths(self): 88 def Refresh(self):
Ken Rockot(use gerrit already) 2015/05/26 00:26:22 Nothing interesting here, just merging all refresh
89 tasks = [] 89 def get_api_schema(platform, api):
90 for platform in GetPlatforms(): 90 return self._GetSchemaView(platform, api)
91 tasks += ['%s/%s' % (platform, UnixName(api))
92 for api in
93 self._platform_bundle.GetAPIModels(platform).GetNames()]
94 return tasks
95 91
96 def Refresh(self, path): 92 def get_platform_schemas(platform):
97 platform, api = path.split('/') 93 return All([get_api_schema(platform, api)
98 logging.info('Refreshing %s/%s' % (platform, api)) 94 for api in self._platform_bundle.GetAPIModels(platform)
99 future = self._GetSchemaView(platform, api) 95 .GetNames()],
100 return All([future], except_pass=FileNotFoundError) 96 except_pass=FileNotFoundError)
97
98 return All([get_platform_schemas(platform) for platform in GetPlatforms()])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698