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

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

Issue 1038993002: Docserver: Fix API refresh task names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/app.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 Future, All
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 15
15 16
16 class APIDataSource(DataSource): 17 class APIDataSource(DataSource):
17 '''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
18 |compiled_fs_factory|, so the APIs can be plugged into templates. 19 |compiled_fs_factory|, so the APIs can be plugged into templates.
19 ''' 20 '''
20 def __init__(self, server_instance, request): 21 def __init__(self, server_instance, request):
21 file_system = server_instance.host_file_system_provider.GetMaster() 22 file_system = server_instance.host_file_system_provider.GetMaster()
22 self._json_cache = server_instance.compiled_fs_factory.ForJson(file_system) 23 self._json_cache = server_instance.compiled_fs_factory.ForJson(file_system)
23 self._template_cache = server_instance.compiled_fs_factory.ForTemplates( 24 self._template_cache = server_instance.compiled_fs_factory.ForTemplates(
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 '''Return a getter object so that templates can perform lookups such 81 '''Return a getter object so that templates can perform lookups such
81 as apis.extensions.runtime. 82 as apis.extensions.runtime.
82 ''' 83 '''
83 getter = lambda: 0 84 getter = lambda: 0
84 getter.get = lambda api_name: self._GetSchemaView(platform, api_name).Get() 85 getter.get = lambda api_name: self._GetSchemaView(platform, api_name).Get()
85 return getter 86 return getter
86 87
87 def GetRefreshPaths(self): 88 def GetRefreshPaths(self):
88 tasks = [] 89 tasks = []
89 for platform in GetPlatforms(): 90 for platform in GetPlatforms():
90 tasks += ['%s/%s' % (platform, api) 91 tasks += ['%s/%s' % (platform, UnixName(api))
91 for api in 92 for api in
92 self._platform_bundle.GetAPIModels(platform).GetNames()] 93 self._platform_bundle.GetAPIModels(platform).GetNames()]
93 return tasks 94 return tasks
94 95
95 def Refresh(self, path): 96 def Refresh(self, path):
96 platform, api = path.split('/') 97 platform, api = path.split('/')
97 logging.info('Refreshing %s/%s' % (platform, api)) 98 logging.info('Refreshing %s/%s' % (platform, api))
98 future = self._GetSchemaView(platform, api) 99 future = self._GetSchemaView(platform, api)
99 return All([future], except_pass=FileNotFoundError) 100 return All([future], except_pass=FileNotFoundError)
OLDNEW
« 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