xonsh.xoreutils.xcontext¶
The xontext command.
- class xonsh.xoreutils.xcontext.Resolved(path: object = None, bad: bool = False, version: str = '')[source]¶
A resolved binary path probed by
XContext.pathmay be a string (resolved file path), a list (alias args wherepath[0]is the executable), orNone(not found / no such alias).badis True when the entry is unusable: symlink loop, missing file, not a regular file, lacks+x, or its--versionprobe failed (Windows Storepython.exealias).versionis the trimmed--versionoutput, populated only for python-family entries.The
displayproperty renders the entry as a single string — list paths are space-joined the way the CLI shows them, plain strings pass through, andNonebecomesNoneso callers can detect “not found” without re-checkingpath.- bad: bool = False¶
- property display¶
- path: object = None¶
- version: str = ''¶
- class xonsh.xoreutils.xcontext.XContext(resolve=True, cache=False)[source]¶
Lazy collector of every value displayed by
xcontext.Each
get_*method computes its value and returns aResolved(or, for env getters, a plain string /None). Construct withresolve=Falseto skip symlink resolution — the accessibility /+xcheck still runs, matching the--no-resolveCLI flag.Caching is off by default so a long-lived instance always reflects the current
$PATHand alias state — callers that read a getter twice after mutating the environment get the new value, not a stale snapshot. Passcache=Trueto enable per-instance memoization for the lifetime of the report;xcontext_maindoes this so each--versionsubprocess runs at most once per invocation.- get_commands_python() Resolved[source]¶
Return the
pythonbinary on$PATH, with version probed.The version probe doubles as a spawn check — a Windows Store
python.exeApp Execution Alias can be located on$PATHbut raises WinError 1920 on execution. Such entries getbad=Trueso the row renders red.
- xonsh.xoreutils.xcontext.xcontext_main(no_resolve: bool = False, as_json: bool = False, _stdout=None)[source]¶
Report information about the current xonsh environment.
By default, all displayed binary paths (xxonsh, xpython, xpip and the
$PATH-resolvedxonsh/python/pip/pytest) have their symlinks followed to the real underlying files. This also makes the match check that decides the label color (GREEN for match, BLUE for mismatch) more accurate, because two paths that ultimately point to the same file compare equal after resolution.- Parameters:
- no_resolve-n, –no-resolve
Show raw paths as-is without following symlinks (turns off the default resolution).
- as_json-j, –json
Emit the resolved paths as a JSON object on stdout instead of the colored text report. Top-level keys mirror the text sections (
session,commands,env);commandsalways includes every probed name withnullfor entries not on$PATH;envonly contains variables that are set.