| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 mimetypes | 5 import mimetypes |
| 6 import posixpath | 6 import posixpath |
| 7 | 7 |
| 8 from compiled_file_system import SingleFile | 8 from compiled_file_system import SingleFile |
| 9 from directory_zipper import DirectoryZipper | 9 from directory_zipper import DirectoryZipper |
| 10 from docs_server_utils import ToUnicode | 10 from docs_server_utils import ToUnicode |
| 11 from file_system import FileNotFoundError | 11 from file_system import FileNotFoundError |
| 12 from future import Gettable, Future | 12 from future import Gettable, Future |
| 13 from path_canonicalizer import PathCanonicalizer | 13 from path_canonicalizer import PathCanonicalizer |
| 14 from path_util import AssertIsValid, ToDirectory | 14 from path_util import AssertIsValid, Join, ToDirectory |
| 15 from special_paths import SITE_VERIFICATION_FILE | 15 from special_paths import SITE_VERIFICATION_FILE |
| 16 from third_party.handlebar import Handlebar | 16 from third_party.handlebar import Handlebar |
| 17 from third_party.markdown import markdown | 17 from third_party.markdown import markdown |
| 18 | 18 |
| 19 | 19 |
| 20 _MIMETYPE_OVERRIDES = { | 20 _MIMETYPE_OVERRIDES = { |
| 21 # SVG is not supported by mimetypes.guess_type on AppEngine. | 21 # SVG is not supported by mimetypes.guess_type on AppEngine. |
| 22 '.svg': 'image/svg+xml', | 22 '.svg': 'image/svg+xml', |
| 23 } | 23 } |
| 24 | 24 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 if self.file_system.Exists(path + default_ext).Get(): | 146 if self.file_system.Exists(path + default_ext).Get(): |
| 147 path += default_ext | 147 path += default_ext |
| 148 break | 148 break |
| 149 | 149 |
| 150 return self._content_cache.GetFromFile(path) | 150 return self._content_cache.GetFromFile(path) |
| 151 | 151 |
| 152 def Cron(self): | 152 def Cron(self): |
| 153 futures = [self._path_canonicalizer.Cron()] | 153 futures = [self._path_canonicalizer.Cron()] |
| 154 for root, _, files in self.file_system.Walk(''): | 154 for root, _, files in self.file_system.Walk(''): |
| 155 for f in files: | 155 for f in files: |
| 156 futures.append(self.GetContentAndType(posixpath.join(root, f))) | 156 futures.append(self.GetContentAndType(Join(root, f))) |
| 157 # Also cache the extension-less version of the file if needed. | 157 # Also cache the extension-less version of the file if needed. |
| 158 base, ext = posixpath.splitext(f) | 158 base, ext = posixpath.splitext(f) |
| 159 if f != SITE_VERIFICATION_FILE and ext in self._default_extensions: | 159 if f != SITE_VERIFICATION_FILE and ext in self._default_extensions: |
| 160 futures.append(self.GetContentAndType(posixpath.join(root, base))) | 160 futures.append(self.GetContentAndType(Join(root, base))) |
| 161 # TODO(kalman): Cache .zip files for each directory (if supported). | 161 # TODO(kalman): Cache .zip files for each directory (if supported). |
| 162 return Future(delegate=Gettable(lambda: [f.Get() for f in futures])) | 162 return Future(delegate=Gettable(lambda: [f.Get() for f in futures])) |
| 163 | 163 |
| 164 def __repr__(self): | 164 def __repr__(self): |
| 165 return 'ContentProvider of <%s>' % repr(self.file_system) | 165 return 'ContentProvider of <%s>' % repr(self.file_system) |
| OLD | NEW |