MCPcopy Create free account
hub / github.com/nodejs/node / get_source

Method get_source

deps/v8/third_party/jinja2/loaders.py:192–218  ·  view source on GitHub ↗
(
        self, environment: "Environment", template: str
    )

Source from the content-addressed store, hash-verified

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()

Callers

nothing calls this directly

Calls 7

split_template_pathFunction · 0.70
open_if_existsFunction · 0.70
TemplateNotFoundClass · 0.70
decodeMethod · 0.65
closeMethod · 0.65
joinMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected