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

Function _find_executable

Lib/_osx_support.py:29–52  ·  view source on GitHub ↗

Tries to find 'executable' in the directories listed in 'path'. A string listing directories separated by 'os.pathsep'; defaults to os.environ['PATH']. Returns the complete filename or None if not found.

(executable, path=None)

Source from the content-addressed store, hash-verified

27
28
29def _find_executable(executable, path=None):
30 """Tries to find 'executable' in the directories listed in 'path'.
31
32 A string listing directories separated by 'os.pathsep'; defaults to
33 os.environ['PATH']. Returns the complete filename or None if not found.
34 """
35 if path is None:
36 path = os.environ['PATH']
37
38 paths = path.split(os.pathsep)
39 base, ext = os.path.splitext(executable)
40
41 if (sys.platform == 'win32') and (ext != '.exe'):
42 executable = executable + '.exe'
43
44 if not os.path.isfile(executable):
45 for p in paths:
46 f = os.path.join(p, executable)
47 if os.path.isfile(f):
48 # the file exists, we have a shot at spawn working
49 return f
50 return None
51 else:
52 return executable
53
54
55def _read_output(commandstring, capture_stderr=False):

Callers 2

_find_build_toolFunction · 0.85

Calls 4

splitextMethod · 0.80
splitMethod · 0.45
isfileMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected