(orig: str, *, env: Mapping[str, str] | None = None)
| 44 | |
| 45 | |
| 46 | def 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 | |
| 65 | def normalize_cmd( |
no test coverage detected