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

Function good_file

Tools/c-analyzer/c_parser/source.py:23–32  ·  view source on GitHub ↗
(filename, alt=None)

Source from the content-addressed store, hash-verified

21
22@contextlib.contextmanager
23def good_file(filename, alt=None):
24 if not _looks_like_filename(filename):
25 raise ValueError(f'expected a filename, got {filename}')
26 filename, _ = _resolve_filename(filename, alt)
27 try:
28 yield filename
29 except Exception:
30 if not os.path.exists(filename):
31 raise FileNotFoundError(f'file not found: {filename}')
32 raise # re-raise
33
34
35def _looks_like_filename(value):

Callers

nothing calls this directly

Calls 3

_looks_like_filenameFunction · 0.85
_resolve_filenameFunction · 0.85
existsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…