Import Hooks (xonsh.imphooks
)
Import hooks for importing xonsh source files.
This module registers the hooks it defines when it is imported.
-
class
xonsh.imphooks.
XonshImportEventHook
(*args, **kwargs)[source]
Implements the import hook for firing xonsh events on import.
-
append_stack
(fullname)[source]
A context manager for appending and then removing a name from the
fullname stack.
-
find_spec
(fullname, path, target=None)[source]
Finds the spec for a xonsh module if it exists.
-
class
xonsh.imphooks.
XonshImportEventLoader
(loader)[source]
A class that dispatches loader calls to another loader and fires relevant
xonsh events.
-
create_module
(spec)[source]
Creates and returns the module object.
-
exec_module
(module)[source]
Executes the module in its own namespace.
-
load_module
(fullname)[source]
Legacy module loading, provided for backwards compatibility.
-
module_repr
(module)[source]
Legacy module repr, provided for backwards compatibility.
-
class
xonsh.imphooks.
XonshImportHook
(*args, **kwargs)[source]
Implements the import hook for xonsh source files.
-
create_module
(spec)[source]
Create a xonsh module with the appropriate attributes.
-
find_spec
(fullname, path, target=None)[source]
Finds the spec for a xonsh module if it exists.
-
get_code
(fullname)[source]
Gets the code object for a xonsh file.
-
get_data
(path)[source]
Gets the bytes for a path.
-
get_filename
(fullname)[source]
Returns the filename for a module’s fullname.
-
get_source
(fullpath)[source]
Concrete implementation of InspectLoader.get_source.
-
execer
-
xonsh.imphooks.
find_source_encoding
(src)[source]
Finds the source encoding given bytes representing a file. If
no encoding is found, UTF-8 will be returned as per the docs
https://docs.python.org/3/howto/unicode.html#unicode-literals-in-python-source-code
-
xonsh.imphooks.
install_hook
()
Install Xonsh import hooks in sys.meta_path
in order for .xsh
files
to be importable and import events to be fired.
Can safely be called many times, will be no-op if xonsh import hooks are
already present.
-
xonsh.imphooks.
install_import_hooks
()[source]
Install Xonsh import hooks in sys.meta_path
in order for .xsh
files
to be importable and import events to be fired.
Can safely be called many times, will be no-op if xonsh import hooks are
already present.