(
self, environment: "Environment", template: str
)
| 190 | self.followlinks = followlinks |
| 191 | |
| 192 | def get_source( |
| 193 | self, environment: "Environment", template: str |
| 194 | ) -> t.Tuple[str, str, t.Callable[[], bool]]: |
| 195 | pieces = split_template_path(template) |
| 196 | for searchpath in self.searchpath: |
| 197 | # Use posixpath even on Windows to avoid "drive:" or UNC |
| 198 | # segments breaking out of the search directory. |
| 199 | filename = posixpath.join(searchpath, *pieces) |
| 200 | f = open_if_exists(filename) |
| 201 | if f is None: |
| 202 | continue |
| 203 | try: |
| 204 | contents = f.read().decode(self.encoding) |
| 205 | finally: |
| 206 | f.close() |
| 207 | |
| 208 | mtime = os.path.getmtime(filename) |
| 209 | |
| 210 | def uptodate() -> bool: |
| 211 | try: |
| 212 | return os.path.getmtime(filename) == mtime |
| 213 | except OSError: |
| 214 | return False |
| 215 | |
| 216 | # Use normpath to convert Windows altsep to sep. |
| 217 | return contents, os.path.normpath(filename), uptodate |
| 218 | raise TemplateNotFound(template) |
| 219 | |
| 220 | def list_templates(self) -> t.List[str]: |
| 221 | found = set() |
nothing calls this directly
no test coverage detected