OLD | NEW |
---|---|
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 from HTMLParser import HTMLParser | 5 from HTMLParser import HTMLParser |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import re | 8 import re |
9 | 9 |
10 from extensions_paths import INTROS_TEMPLATES, ARTICLES_TEMPLATES | 10 from extensions_paths import INTROS_TEMPLATES, ARTICLES_TEMPLATES |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 self._request = request | 87 self._request = request |
88 self._cache = server_instance.compiled_fs_factory.Create( | 88 self._cache = server_instance.compiled_fs_factory.Create( |
89 server_instance.host_file_system_provider.GetTrunk(), | 89 server_instance.host_file_system_provider.GetTrunk(), |
90 self._MakeIntro, | 90 self._MakeIntro, |
91 IntroDataSource) | 91 IntroDataSource) |
92 self._ref_resolver = server_instance.ref_resolver_factory.Create() | 92 self._ref_resolver = server_instance.ref_resolver_factory.Create() |
93 | 93 |
94 def _MakeIntro(self, intro_path, intro): | 94 def _MakeIntro(self, intro_path, intro): |
95 # Guess the name of the API from the path to the intro. | 95 # Guess the name of the API from the path to the intro. |
96 api_name = os.path.splitext(intro_path.split('/')[-1])[0] | 96 api_name = os.path.splitext(intro_path.split('/')[-1])[0] |
97 request_path = '' | |
98 if self._request: | |
99 request_path = self._request.path | |
not at google - send to devlin
2013/11/22 20:16:10
nit: ternary:
request_path = self._request.path i
benwells
2013/11/25 01:12:37
I was thinking it might be better to make sure tha
benwells
2013/11/27 07:28:31
Removed the code by making sure self._request was
| |
97 intro_with_links = self._ref_resolver.ResolveAllLinks( | 100 intro_with_links = self._ref_resolver.ResolveAllLinks( |
98 intro, namespace=api_name) | 101 intro, requestPath=request_path, namespace=api_name) |
not at google - send to devlin
2013/11/22 20:16:10
python style requires request_path not requestPath
benwells
2013/11/27 07:28:31
Done.
| |
99 | 102 |
100 # TODO(kalman): In order to pick up every header tag, and therefore make a | 103 # TODO(kalman): In order to pick up every header tag, and therefore make a |
101 # complete TOC, the render context of the Handlebar needs to be passed | 104 # complete TOC, the render context of the Handlebar needs to be passed |
102 # through to here. Even if there were a mechanism to do this it would | 105 # through to here. Even if there were a mechanism to do this it would |
103 # break caching; we'd need to do the TOC parsing *after* rendering the full | 106 # break caching; we'd need to do the TOC parsing *after* rendering the full |
104 # template, and that would probably be expensive. | 107 # template, and that would probably be expensive. |
105 intro_parser = _IntroParser() | 108 intro_parser = _IntroParser() |
106 intro_parser.feed( | 109 intro_parser.feed( |
107 self._template_renderer.Render(Handlebar(intro_with_links), | 110 self._template_renderer.Render(Handlebar(intro_with_links), |
108 self._request, | 111 self._request, |
(...skipping 22 matching lines...) Expand all Loading... | |
131 except FileNotFoundError: | 134 except FileNotFoundError: |
132 continue | 135 continue |
133 # Not found. Do the first operation again so that we get a stack trace - we | 136 # Not found. Do the first operation again so that we get a stack trace - we |
134 # know that it'll fail. | 137 # know that it'll fail. |
135 get_from_base_path(base_paths[0]) | 138 get_from_base_path(base_paths[0]) |
136 raise AssertionError() | 139 raise AssertionError() |
137 | 140 |
138 def Cron(self): | 141 def Cron(self): |
139 # TODO(kalman): Walk through the intros and articles directory. | 142 # TODO(kalman): Walk through the intros and articles directory. |
140 return Future(value=()) | 143 return Future(value=()) |
OLD | NEW |