xonsh.xontribs#

Tools for helping manage xontributions.

exception xonsh.xontribs.XontribNotInstalled[source]#

raised when the requested xontrib is not found

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args#
class xonsh.xontribs.ExitCode(value)[source]#

An enumeration.

INIT_FAILED = 2#
NOT_FOUND = 1#
OK = 0#
class xonsh.xontribs.Xontrib(module: str, distribution: tp.Optional[Distribution] = None)[source]#

Meta class that is used to describe a xontrib

Create new instance of Xontrib(module, distribution)

count(value, /)#

Return number of occurrences of value.

get_description()[source]#
index(value, start=0, stop=sys.maxsize, /)#

Return first index of value.

Raises ValueError if the value is not present.

distribution: tp.Optional[Distribution]#

short description about the xontrib.

property is_auto_loaded#
property is_loaded#
property license#
module: str#

path to the xontrib module

property url#
class xonsh.xontribs.XontribAlias(threadable=True, **kwargs)[source]#

Manage xonsh extensions

exception Error(message: str, errno=1)#

Special case, when raised, the traceback will not be shown. Instead the process with exit with error code and message

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args#
build()[source]#

Sub-classes should return constructed ArgumentParser

create_parser(func=None, has_args=False, allowed_params=None, **kwargs)#

create root parser

err(*args, **kwargs)#

Write text to error stream

hook_post_add_argument(*, parser: ArgParser | ap.ArgumentParser, action: ap.Action, param: str, func: tp.Callable)#

Hook into parser.add_argument step.

Can be used to update action’s attributes

hook_pre_add_argument(param: str, func, flags, kwargs)#

Hook to update arguments that are passed to parser.add_argument

out(*args, **kwargs)#

Write text to output stream

write_to(stream: str, *args, **kwargs)#
xonsh_complete(command, **kwargs)#
property parser#
xonsh.xontribs.auto_load_xontribs_from_entrypoints(blocked: Sequence[str] = (), verbose=False)[source]#

Load xontrib modules exposed via setuptools’s entrypoints

xonsh.xontribs.find_xontrib(name, full_module=False)[source]#

Finds a xontribution from its name.

xonsh.xontribs.get_module_docstring(module: str)str[source]#

Find the module and return its docstring without actual import

xonsh.xontribs.get_xontribs()Dict[str, xonsh.xontribs.Xontrib][source]#

Return xontrib definitions lazily.

xonsh.xontribs.prompt_xontrib_install(names: List[str])[source]#

Returns a formatted string with name of xontrib package to prompt user

xonsh.xontribs.update_context(name, ctx: dict, full_module=False)[source]#

Updates a context in place from a xontrib.

xonsh.xontribs.xontrib_context(name, full_module=False)[source]#

Return a context dictionary for a xontrib of a given name.

xonsh.xontribs.xontrib_data()[source]#

Collects and returns the data about installed xontribs.

xonsh.xontribs.xontrib_names_completer(**_)[source]#
xonsh.xontribs.xontrib_unload_completer(**_)[source]#
xonsh.xontribs.xontribs_list(to_json=False)[source]#

List installed xontribs and show whether they are loaded or not

Parameters
to_json-j, –json

reports results as json

xonsh.xontribs.xontribs_load(names: Sequence[str] = (), verbose=False, full_module=False)[source]#

Load xontribs from a list of names

Parameters
names

names of xontribs

verbose-v, –verbose

verbose output

full_module-f, –full

indicates that the names are fully qualified module paths and not inside xontrib package

xonsh.xontribs.xontribs_loaded()[source]#

Returns list of loaded xontribs.

xonsh.xontribs.xontribs_reload(names: Sequence[str] = (), verbose=False)[source]#

Reload the given xontribs

Parameters
names

name of xontribs to reload

xonsh.xontribs.xontribs_unload(names: Sequence[str] = (), verbose=False)[source]#

Unload the given xontribs

Parameters
names

name of xontribs to unload

Notes

Proper cleanup can be implemented by the xontrib. The default is equivalent to del sys.modules[module].