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

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

Issue 10878056: Extensions Docs Server: Fix samples page and ExampleZipper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 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 json 5 import json
6 import logging 6 import logging
7 import re 7 import re
8 8
9 import compiled_file_system as compiled_fs 9 import compiled_file_system as compiled_fs
10 import third_party.json_schema_compiler.json_comment_eater as json_comment_eater 10 import third_party.json_schema_compiler.json_comment_eater as json_comment_eater
11 import third_party.json_schema_compiler.model as model 11 import third_party.json_schema_compiler.model as model
12 import url_constants 12 import url_constants
13 13
14 DEFAULT_ICON_PATH = '/images/sample-default-icon.png' 14 DEFAULT_ICON_PATH = '/images/sample-default-icon.png'
15 15
16 class SamplesDataSource(object): 16 class SamplesDataSource(object):
17 """Constructs a list of samples and their respective files and api calls. 17 """Constructs a list of samples and their respective files and api calls.
18 """ 18 """
19 19
20 class Factory(object): 20 class Factory(object):
21 """A factory to create SamplesDataSource instances bound to individual 21 """A factory to create SamplesDataSource instances bound to individual
22 Requests. 22 Requests.
23 """ 23 """
24 def __init__(self, 24 def __init__(self,
25 branch, 25 channel,
26 file_system, 26 file_system,
27 github_file_system, 27 github_file_system,
28 cache_factory, 28 cache_factory,
29 github_cache_factory, 29 github_cache_factory,
30 samples_path): 30 samples_path):
31 self._file_system = file_system 31 self._file_system = file_system
32 self._github_file_system = github_file_system 32 self._github_file_system = github_file_system
33 self._static_path = ((('/' + branch) if branch != 'local' else '') + 33 self._static_path = ((('/' + channel) if channel != 'local' else '') +
34 '/static') 34 '/static')
35 self._extensions_cache = cache_factory.Create(self._MakeSamplesList, 35 self._extensions_cache = cache_factory.Create(self._MakeSamplesList,
36 compiled_fs.EXTENSIONS) 36 compiled_fs.EXTENSIONS)
37 self._apps_cache = github_cache_factory.Create( 37 self._apps_cache = github_cache_factory.Create(
38 lambda x: self._MakeSamplesList(x, is_apps=True), 38 lambda x: self._MakeSamplesList(x, is_apps=True),
39 compiled_fs.APPS) 39 compiled_fs.APPS)
40 self._samples_path = samples_path 40 self._samples_path = samples_path
41 41
42 def Create(self, request): 42 def Create(self, request):
43 """Returns a new SamplesDataSource bound to |request|. 43 """Returns a new SamplesDataSource bound to |request|.
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 return return_list 203 return return_list
204 204
205 def __getitem__(self, key): 205 def __getitem__(self, key):
206 return self.get(key) 206 return self.get(key)
207 207
208 def get(self, key): 208 def get(self, key):
209 return { 209 return {
210 'apps': lambda: self._CreateSamplesDict('apps'), 210 'apps': lambda: self._CreateSamplesDict('apps'),
211 'extensions': lambda: self._CreateSamplesDict('extensions') 211 'extensions': lambda: self._CreateSamplesDict('extensions')
212 }.get(key, lambda: {})() 212 }.get(key, lambda: {})()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698