xonsh.procs.executables¶
Interfaces to locate executable files on file system.
- xonsh.procs.executables.clear_paths(paths)[source]¶
Remove duplicates and nonexistent directories from paths.
- xonsh.procs.executables.get_paths(env=None)[source]¶
Return tuple with deduplicated and existent paths from
$PATH.
- xonsh.procs.executables.get_possible_names(name, env=None)[source]¶
Expand name to all possible variants based on PATHEXT.
PATHEXT is a Windows convention containing extensions to be considered when searching for an executable file.
Conserves order of any extensions found and gives precedence to the bare name.
- xonsh.procs.executables.is_executable(filepath, check_file_exist=True)¶
Check the file is executable in POSIX.
- Parameters:
- filepathstr
Path to file.
- check_file_existbool
If
Falsedo not check that file exists. This made to consistency withis_executable_in_windows.
- xonsh.procs.executables.is_executable_in_posix(filepath, check_file_exist=True)[source]¶
Check the file is executable in POSIX.
- Parameters:
- filepathstr
Path to file.
- check_file_existbool
If
Falsedo not check that file exists. This made to consistency withis_executable_in_windows.
- xonsh.procs.executables.is_executable_in_windows(filepath, check_file_exist=True, env=None)[source]¶
Check the file is executable in Windows.
- Parameters:
- filepathstr
Path to file.
- check_file_existbool
If
Falsedo not check that file exists. This helps to disable double checking in case the file already checked in upstream code. This is important for Windows where checking can take a long time.
- xonsh.procs.executables.is_explicit_path(name)[source]¶
Return whether
nameis written as a path rather than a bare name.This follows the rule used by other shells: if the command name contains a path separator (
/, or\on Windows) it is an explicit path — resolved against the file system, relative to the current directory or as an absolute path, and never looked up in$PATH. This covers./name,../name,~/name,sub/nameand absolute paths alike.A bare name with no separator (e.g.
"binfile") is not an explicit path: it is resolved through$PATHand, for security reasons, never against the current working directory.
- xonsh.procs.executables.locate_executable(name, env=None)[source]¶
Search executable binary name in
$PATHand return full path.
- xonsh.procs.executables.locate_file(name, env=None, check_executable=False, use_pathext=False)[source]¶
Search file name in the current working directory and in
$PATHand return full path.A name containing a path separator (
./name,../name,~/name,sub/nameor an absolute path) is an explicit path and is resolved only against the location it points at. If the file is not there the result isNone— we must not fall back to a$PATHsearch, otherwise a command such as./nameorsub/namewould be located in$PATHeven though it does not exist in the current directory (see gh-6532). Only a bare name with no separator is looked up in$PATH.
- xonsh.procs.executables.locate_file_in_path_env(name, env=None, check_executable=False, use_pathext=False)[source]¶
Search file name in
$PATHand return full path.Compromise. There is no way to get case sensitive file name without listing all files. If the file name is
CaMeL.exeand we found thatcamel.EXEexists there is no way to get back the case sensitive name. We don’t want to read the list of files in all$PATHdirectories because of performance reasons. So we’re ok to get existent but case insensitive (or different) result from resolver. May be in the future file systems as well as Python Path will be smarter to get the case sensitive name. The task for reading and returning case sensitive filename we give to completer in interactive mode withcommands_cache.
- xonsh.procs.executables.locate_relative_path(name, env=None, check_executable=False, use_pathext=False)[source]¶
Return absolute path for a name written as a path (containing a separator).
We should not locate files without a separator (e.g.
"binfile") for security reasons, like other shells. If the current directory has “binfile” it can be called only by providing a path such as “./binfile” explicitly.