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

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

Issue 14125010: Docserver: Add support for viewing docs with a codereview patch applied (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: 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
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 import traceback 6 import traceback
7 7
8 from branch_utility import BranchUtility 8 from branch_utility import BranchUtility
9 from docs_server_utils import FormatKey 9 from docs_server_utils import FormatKey
10 from file_system import FileNotFoundError 10 from file_system import FileNotFoundError
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 channel_name, 44 channel_name,
45 api_data_source_factory, 45 api_data_source_factory,
46 api_list_data_source_factory, 46 api_list_data_source_factory,
47 intro_data_source_factory, 47 intro_data_source_factory,
48 samples_data_source_factory, 48 samples_data_source_factory,
49 sidenav_data_source_factory, 49 sidenav_data_source_factory,
50 compiled_fs_factory, 50 compiled_fs_factory,
51 ref_resolver_factory, 51 ref_resolver_factory,
52 manifest_data_source, 52 manifest_data_source,
53 public_template_path, 53 public_template_path,
54 private_template_path): 54 private_template_path,
55 static_path):
55 self._branch_info = _MakeChannelDict(channel_name) 56 self._branch_info = _MakeChannelDict(channel_name)
56 self._api_data_source_factory = api_data_source_factory 57 self._api_data_source_factory = api_data_source_factory
57 self._api_list_data_source_factory = api_list_data_source_factory 58 self._api_list_data_source_factory = api_list_data_source_factory
58 self._intro_data_source_factory = intro_data_source_factory 59 self._intro_data_source_factory = intro_data_source_factory
59 self._samples_data_source_factory = samples_data_source_factory 60 self._samples_data_source_factory = samples_data_source_factory
60 self._sidenav_data_source_factory = sidenav_data_source_factory 61 self._sidenav_data_source_factory = sidenav_data_source_factory
61 self._cache = compiled_fs_factory.Create(self._CreateTemplate, 62 self._cache = compiled_fs_factory.Create(self._CreateTemplate,
62 TemplateDataSource) 63 TemplateDataSource)
63 self._ref_resolver = ref_resolver_factory.Create() 64 self._ref_resolver = ref_resolver_factory.Create()
64 self._public_template_path = public_template_path 65 self._public_template_path = public_template_path
65 self._private_template_path = private_template_path 66 self._private_template_path = private_template_path
66 self._static_resources = '/%s/static' % channel_name 67 self._static_resources = static_path
67 self._manifest_data_source = manifest_data_source 68 self._manifest_data_source = manifest_data_source
68 69
69 def _CreateTemplate(self, template_name, text): 70 def _CreateTemplate(self, template_name, text):
70 return Handlebar(self._ref_resolver.ResolveAllLinks(text)) 71 return Handlebar(self._ref_resolver.ResolveAllLinks(text))
71 72
72 def Create(self, request, path): 73 def Create(self, request, path):
73 """Returns a new TemplateDataSource bound to |request|. 74 """Returns a new TemplateDataSource bound to |request|.
74 """ 75 """
75 return TemplateDataSource( 76 return TemplateDataSource(
76 self._branch_info, 77 self._branch_info,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 def get(self, key): 151 def get(self, key):
151 return self.GetTemplate(self._private_template_path, key) 152 return self.GetTemplate(self._private_template_path, key)
152 153
153 def GetTemplate(self, base_path, template_name): 154 def GetTemplate(self, base_path, template_name):
154 try: 155 try:
155 return self._cache.GetFromFile( 156 return self._cache.GetFromFile(
156 '/'.join((base_path, FormatKey(template_name)))) 157 '/'.join((base_path, FormatKey(template_name))))
157 except FileNotFoundError: 158 except FileNotFoundError:
158 logging.warning(traceback.format_exc()) 159 logging.warning(traceback.format_exc())
159 return None 160 return None
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698