MCPcopy Index your code
hub / github.com/pre-commit/pre-commit / normexe

Function normexe

pre_commit/parse_shebang.py:46–62  ·  view source on GitHub ↗
(orig: str, *, env: Mapping[str, str] | None = None)

Source from the content-addressed store, hash-verified

44
45
46def normexe(orig: str, *, env: Mapping[str, str] | None = None) -> str:
47 def _error(msg: str) -> NoReturn:
48 raise ExecutableNotFoundError(f'Executable `{orig}` {msg}')
49
50 if os.sep not in orig and (not os.altsep or os.altsep not in orig):
51 exe = find_executable(orig, env=env)
52 if exe is None:
53 _error('not found')
54 return exe
55 elif os.path.isdir(orig):
56 _error('is a directory')
57 elif not os.path.isfile(orig):
58 _error('not found')
59 elif not os.access(orig, os.X_OK): # pragma: win32 no cover
60 _error('is not executable')
61 else:
62 return orig
63
64
65def normalize_cmd(

Callers 1

normalize_cmdFunction · 0.85

Calls 2

find_executableFunction · 0.85
_errorFunction · 0.85

Tested by

no test coverage detected