almanac.hooks
¶
-
assert_async_callback
(candidate: Any) → None[source]¶ Assert that the candidate is a valid asynchronous.
-
assert_sync_callback
(candidate: Any) → None[source]¶ Assert that the candidate is a valid synchronous callback.
-
class
ExceptionHookDispatchTable
[source]¶ Bases:
object
A table for storing and dispatching exception hooks.
-
get_hook_for_exc_type
(exc_type: Type[Exception]) → Optional[almanac.hooks.types.AsyncExceptionHookCallback][source]¶ Return all matching hooks for the specified exception type.
-
-
class
HookProxy
(app: Application)[source]¶ Bases:
object
A simple proxy for hooking events.
Command hook callbacks will be called with the same arguments as the command that they are hooking.
Exception hook callbacks will be called with the raised exception.
-
after
(*command_names: Union[str, FrozenCommand]) → Callable[[AsyncHookCallback], AsyncHookCallback][source]¶ A decorator to add a callback to fire after commands execute.
-
before
(*command_names: Union[str, FrozenCommand]) → Callable[[AsyncHookCallback], AsyncHookCallback][source]¶ A decorator to add a callback to fire before commands execute.
-
property
command_engine
¶
-
property
exception
¶ A decorator to add a callback to fire when a matching exception occurs.
-
-
class
AsyncExceptionHookCallback
(*args, **kwds)[source]¶ Bases:
typing.Protocol
-
class
AsyncNoArgsCallback
(*args, **kwds)[source]¶ Bases:
typing.Protocol
-
class
PromoterFunction
(*args, **kwds)[source]¶ Bases:
typing.Protocol
-
PromptCallback
¶ The central part of internal API.
This represents a generic version of type ‘origin’ with type arguments ‘params’. There are two kind of these aliases: user defined and special. The special ones are wrappers around builtin collections and ABCs in collections.abc. These must have ‘name’ always set. If ‘inst’ is False, then the alias can’t be instantiated, this is used by e.g. typing.List and typing.Dict.
alias of almanac.hooks.types.SyncNoArgsCallback[Union[str, prompt_toolkit.formatted_text.base.FormattedText]]
-
class
SyncNoArgsCallback
(*args, **kwds)[source]¶ Bases:
typing.Protocol