decorators
Main module containing the decorator definition.
This module and class should be imported and used to create a new decorator instance.
Typical usage example:
from herald.decorators import Herald
herald = Herald(".env")
@herald(...)
def my_function():
pass
Classes
Class for creating a decorator instance. |
- class Herald(env='.env')[source]
Bases:
object
Class for creating a decorator instance.
This class is used to set up the decorator with the .env file. The resulting decorator can be used to decorate long-running functions.
- Parameters:
secrets – Secrets object containing the secrets from the .env file.
env (str) –
- __init__(env='.env')[source]
Initializes the instance with the .env file.
- Parameters:
env (str) – String containing the path to the .env file.
- __call__(messengers, message=None, send_result=True, send_function=True, send_args=True)[source]
Creates a decorator instance with the given messengers.
- Parameters:
messengers (Messenger | List[Messenger]) – Messenger, or list of Messenger, to send the messages.
message (str | None) – String containing a custom message to send.
send_result (bool) – Boolean indicating whether to send the result of the function.
send_function (bool) – Boolean indicating whether to send the name of the original calling function.
send_args (bool) – Boolean indicating whether to send the args and kwargs that were passed to the function.
- Returns:
A decorator instance that can be used to wrap functions.
- Return type:
Callable