xonsh.xontribs

Tools for helping manage xontributions.

exception xonsh.xontribs.XontribNotInstalled[source]

raised when the requested xontrib is not found

add_note()

Exception.add_note(note) – add a note to the exception

with_traceback()

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

args
class xonsh.xontribs.ExitCode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
as_integer_ratio(/)

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count(/)

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length(/)

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

from_bytes(/, bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

to_bytes(/, length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

INIT_FAILED = 2
NOT_FOUND = 1
OK = 0
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

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

add_note()

Exception.add_note(note) – add a note to the exception

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) ArgParser

create root parser

err(*args, **kwargs)

Write text to error stream

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, 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, _stdout=None)[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: ~typing.Annotated[~typing.Sequence[str], ((), (('nargs', '+'), ('completer', <function xontrib_names_completer at 0x7f1075f72520>)))] = (), verbose=False, full_module=False, suppress_warnings=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

suppress_warnings-s, –suppress-warnings

no warnings about missing xontribs and return code 0

xonsh.xontribs.xontribs_loaded()[source]

Returns list of loaded xontribs.

xonsh.xontribs.xontribs_reload(names: ~typing.Annotated[~typing.Sequence[str], ((), (('nargs', '+'), ('completer', <function xontrib_unload_completer at 0x7f1075f725c0>)))] = (), verbose=False)[source]

Reload the given xontribs

Parameters:
names

name of xontribs to reload

xonsh.xontribs.xontribs_unload(names: ~typing.Annotated[~typing.Sequence[str], ((), (('nargs', '+'), ('completer', <function xontrib_unload_completer at 0x7f1075f725c0>)))] = (), 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].