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.
- class xonsh.built_ins.DynamicAccessProxy(refname, objname)[source]#
Proxies access dynamically.
- Parameters
- refnamestr
‘.’-separated string that represents the new, reference name that the user will access.
- objnamestr
‘.’-separated string that represents the name where the target object actually lives that refname points to.
- property obj#
Dynamically grabs object
- class xonsh.built_ins.XonshSession[source]#
All components defining a xonsh session.
- load(execer=None, ctx=None, **kwargs)[source]#
Loads the session with default values.
- Parameters
- execerExecer, optional
Xonsh execution object, may be None to start
- ctxMapping, optional
Context to start xonsh session with.
- property aliases#
- xonsh.built_ins.call_macro(f, raw_args, glbs, locs)[source]#
Calls a function as a macro, returning its result.
- Parameters
- fcallable object
The function that is called as
f(*args)
.- raw_argstuple of str
The str representation of arguments of that were passed into the macro. These strings will be parsed, compiled, evaled, or left as a string depending on the annotations of f.
- glbsMapping
The globals from the call site.
- locsMapping 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_argstr
The str representation of the macro argument.
- kindobject
A flag or type representing how to convert the argument.
- glbsMapping
The globals from the call site.
- locsMapping or None
The locals from the call site.
- namestr, optional
The macro argument name.
- macronamestr, 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
- objcontext manager
The object that is about to be entered via a with-statement.
- raw_blockstr
The str of the block that is the context body. This string will be parsed, compiled, evaled, or left as a string depending on the return annotation of obj.__enter__.
- glbsMapping
The globals from the context site.
- locsMapping or None
The locals from the context site.
- Returns
- objcontext manager
The same context manager but with the new macro information applied.
- xonsh.built_ins.in_macro_call(f, glbs, locs)[source]#
Attaches macro globals and locals temporarily to function as a context manager.
- Parameters
- fcallable object
The function that is called as
f(*args)
.- glbsMapping
The globals from the call site.
- locsMapping or None
The locals from the call site.
- xonsh.built_ins.list_of_list_of_strs_outer_product(x)[source]#
Takes an outer product of a list of strings
- xonsh.built_ins.list_of_strs_or_callables(x)[source]#
Ensures that x is a list of strings or functions. This is called when using the
@()
operator to expand it’s content.
- xonsh.built_ins.pathsearch(func, s, pymode=False, pathobj=False)[source]#
Takes a string and returns a list of file paths that match (regex, glob, or arbitrary search function). If pathobj=True, the return is a list of pathlib.Path objects instead of strings.
- 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.
Runs a subprocess, capturing the output. Returns an instance of HiddenCommandPipeline representing the completed command.
- xonsh.built_ins.subproc_captured_inject(*cmds, envs=None)[source]#
Runs a subprocess, capturing the output. Returns a list of whitespace-separated strings of the stdout that was produced. The string is split using xonsh’s lexer, rather than Python’s str.split() or shlex.split().
- xonsh.built_ins.subproc_captured_object(*cmds, envs=None)[source]#
Runs a subprocess, capturing the output. Returns an instance of CommandPipeline representing the completed command.
- xonsh.built_ins.subproc_captured_stdout(*cmds, envs=None)[source]#
Runs a subprocess, capturing the output. Returns the stdout that was produced as a str.