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

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

Issue 15087006: Docserver: there is only one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better redirects Created 7 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 | Annotate | Revision Log
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 hashlib 5 import hashlib
6 import json 6 import json
7 import logging 7 import logging
8 import re 8 import re
9 9
10 from compiled_file_system import CompiledFileSystem 10 from compiled_file_system import CompiledFileSystem
11 from file_system import FileNotFoundError 11 from file_system import FileNotFoundError
12 import third_party.json_schema_compiler.json_comment_eater as json_comment_eater 12 import third_party.json_schema_compiler.json_comment_eater as json_comment_eater
13 import third_party.json_schema_compiler.model as model 13 import third_party.json_schema_compiler.model as model
14 import url_constants 14 import url_constants
15 15
16 DEFAULT_ICON_PATH = '/images/sample-default-icon.png' 16 DEFAULT_ICON_PATH = '/images/sample-default-icon.png'
17 17
18 class SamplesDataSource(object): 18 class SamplesDataSource(object):
19 '''Constructs a list of samples and their respective files and api calls. 19 '''Constructs a list of samples and their respective files and api calls.
20 ''' 20 '''
21 class Factory(object): 21 class Factory(object):
22 '''A factory to create SamplesDataSource instances bound to individual 22 '''A factory to create SamplesDataSource instances bound to individual
23 Requests. 23 Requests.
24 ''' 24 '''
25 def __init__(self, 25 def __init__(self,
26 channel,
27 host_file_system, 26 host_file_system,
28 compiled_host_fs_factory, 27 compiled_host_fs_factory,
29 app_samples_file_system, 28 app_samples_file_system,
30 compiled_app_samples_fs_factory, 29 compiled_app_samples_fs_factory,
31 ref_resolver_factory, 30 ref_resolver_factory,
32 extension_samples_path): 31 extension_samples_path):
33 self._host_file_system = host_file_system 32 self._host_file_system = host_file_system
34 self._app_samples_file_system = app_samples_file_system 33 self._app_samples_file_system = app_samples_file_system
35 self._static_path = '/%s/static' % channel 34 self._static_path = '/static'
36 self._ref_resolver = ref_resolver_factory.Create() 35 self._ref_resolver = ref_resolver_factory.Create()
37 self._extension_samples_path = extension_samples_path 36 self._extension_samples_path = extension_samples_path
38 self._extensions_cache = compiled_host_fs_factory.Create( 37 self._extensions_cache = compiled_host_fs_factory.Create(
39 self._MakeSamplesList, 38 self._MakeSamplesList,
40 SamplesDataSource, 39 SamplesDataSource,
41 category='extensions') 40 category='extensions')
42 self._apps_cache = compiled_app_samples_fs_factory.Create( 41 self._apps_cache = compiled_app_samples_fs_factory.Create(
43 lambda *args: self._MakeSamplesList(*args, is_apps=True), 42 lambda *args: self._MakeSamplesList(*args, is_apps=True),
44 SamplesDataSource, 43 SamplesDataSource,
45 category='apps') 44 category='apps')
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 return_list.append(sample_data) 244 return_list.append(sample_data)
246 else: 245 else:
247 return_list.append(dict_) 246 return_list.append(dict_)
248 return return_list 247 return return_list
249 248
250 def get(self, key): 249 def get(self, key):
251 return { 250 return {
252 'apps': lambda: self._CreateSamplesDict('apps'), 251 'apps': lambda: self._CreateSamplesDict('apps'),
253 'extensions': lambda: self._CreateSamplesDict('extensions') 252 'extensions': lambda: self._CreateSamplesDict('extensions')
254 }.get(key, lambda: {})() 253 }.get(key, lambda: {})()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698