MCPcopy Index your code
hub / github.com/python/cpython / sourcehook

Method sourcehook

Lib/shlex.py:277–285  ·  view source on GitHub ↗

Hook called on a filename to be sourced.

(self, newfile)

Source from the content-addressed store, hash-verified

275 return result
276
277 def sourcehook(self, newfile):
278 "Hook called on a filename to be sourced."
279 import os.path
280 if newfile[0] == '"':
281 newfile = newfile[1:-1]
282 # This implements cpp-like semantics for relative-path inclusion.
283 if isinstance(self.infile, str) and not os.path.isabs(newfile):
284 newfile = os.path.join(os.path.dirname(self.infile), newfile)
285 return (newfile, open(newfile, "r"))
286
287 def error_leader(self, infile=None, lineno=None):
288 "Emit a C-compiler-like, Emacs-friendly error-message leader."

Callers 1

get_tokenMethod · 0.95

Calls 4

openFunction · 0.70
isabsMethod · 0.45
joinMethod · 0.45
dirnameMethod · 0.45

Tested by

no test coverage detected