MCPcopy Index your code
hub / github.com/RustPython/RustPython / _get_code_from_file

Function _get_code_from_file

Lib/runpy.py:250–260  ·  view source on GitHub ↗
(fname)

Source from the content-addressed store, hash-verified

248
249
250def _get_code_from_file(fname):
251 # Check for a compiled file first
252 from pkgutil import read_code
253 code_path = os.path.abspath(fname)
254 with io.open_code(code_path) as f:
255 code = read_code(f)
256 if code is None:
257 # That didn't work, so try it as normal source code
258 with io.open_code(code_path) as f:
259 code = compile(f.read(), fname, 'exec')
260 return code
261
262def run_path(path_name, init_globals=None, run_name=None):
263 """Execute code located at the specified filesystem location.

Callers 1

run_pathFunction · 0.85

Calls 3

read_codeFunction · 0.90
compileFunction · 0.70
readMethod · 0.45

Tested by

no test coverage detected