Built-Ins (xonsh.built_ins
)¶
The xonsh built-ins.
Note that this module is named ‘built_ins’ so as not to be confused with the special Python builtins module.
-
xonsh.built_ins.
call_macro
(f, raw_args, glbs, locs)[source]¶ Calls a function as a macro, returning its result.
Parameters: f : callable object
The function that is called as
f(*args)
.raw_args : tuple of str
The str reprensetaion of arguments of that were passed into the macro. These strings will be parsed, compiled, evaled, or left as a string dependending on the annotations of f.
glbs : Mapping
The globals from the call site.
locs : Mapping or None
The locals from the call site.
-
xonsh.built_ins.
convert_macro_arg
(raw_arg, kind, glbs, locs, *, name='<arg>', macroname='<macro>')[source]¶ Converts a string macro argument based on the requested kind.
Parameters: raw_arg : str
The str reprensetaion of the macro argument.
kind : object
A flag or type representing how to convert the argument.
glbs : Mapping
The globals from the call site.
locs : Mapping or None
The locals from the call site.
name : str, optional
The macro argument name.
macroname : str, optional
The name of the macro itself.
Returns: The converted argument.
-
xonsh.built_ins.
enter_macro
(obj, raw_block, glbs, locs)[source]¶ Prepares to enter a context manager macro by attaching the contents of the macro block, globals, and locals to the object. These modifications are made in-place and the original object is returned.
Parameters: obj : context manager
The object that is about to be entered via a with-statement.
raw_block : str
The str of the block that is the context body. This string will be parsed, compiled, evaled, or left as a string dependending on the return annotation of obj.__enter__.
glbs : Mapping
The globals from the context site.
locs : Mapping or None
The locals from the context site.
Returns: obj : context manager
The same context manager but with the new macro information applied.
-
xonsh.built_ins.
expand_path
(s)[source]¶ Takes a string path and expands ~ to home and environment vars.
-
xonsh.built_ins.
get_script_subproc_command
(fname, args)[source]¶ Given the name of a script outside the path, returns a list representing an appropriate subprocess command to execute the script. Raises PermissionError if the script is not executable.
-
xonsh.built_ins.
in_macro_call
(f, glbs, locs)[source]¶ Attaches macro globals and locals temporarily to function as a context manager.
Parameters: f : callable object
The function that is called as
f(*args)
.glbs : Mapping
The globals from the call site.
locs : Mapping or None
The locals from the call site.
-
xonsh.built_ins.
list_of_strs_or_callables
(x)[source]¶ Ensures that x is a list of strings or functions
-
xonsh.built_ins.
load_builtins
(execer=None, config=None, login=False, ctx=None)[source]¶ Loads the xonsh builtins into the Python builtins. Sets the BUILTINS_LOADED variable to True.
-
xonsh.built_ins.
pathsearch
(func, s, pymode=False)[source]¶ Takes a string and returns a list of file paths that match (regex, glob, or arbitrary search function).
-
xonsh.built_ins.
resetting_signal_handle
(sig, f)[source]¶ Sets a new signal handle that will automatically restore the old value once the new handle is finished.
-
xonsh.built_ins.
run_subproc
(cmds, captured=False)[source]¶ Runs a subprocess, in its many forms. This takes a list of ‘commands,’ which may be a list of command line arguments or a string, representing a special connecting character. For example:
$ ls | grep wakka
is represented by the following cmds:
[['ls'], '|', ['grep', 'wakka']]
Lastly, the captured argument affects only the last real command.
Runs a subprocess, capturing the output. Returns an instance of
HiddenCompletedCommand
representing the completed command.
-
xonsh.built_ins.
subproc_captured_inject
(*cmds)[source]¶ Runs a subprocess, capturing the output. Returns a list of whitespace-separated strings in the stdout that was produced.
-
xonsh.built_ins.
subproc_captured_object
(*cmds)[source]¶ Runs a subprocess, capturing the output. Returns an instance of
CompletedCommand
representing the completed command.
-
xonsh.built_ins.
subproc_captured_stdout
(*cmds)[source]¶ Runs a subprocess, capturing the output. Returns the stdout that was produced as a str.
-
xonsh.built_ins.
subproc_uncaptured
(*cmds)[source]¶ Runs a subprocess, without capturing the output. Returns the stdout that was produced as a str.