utils

Helper functions used throughout the package.

truncate(input, length)[source]

Truncate an input value to custom typed representation.

Parameters:
  • input (T) – Value to be truncated. Can be of any type.

  • length (int) – Length to truncate the value to.

Returns:

Truncated representation of the input.

Return type:

T | str

build_arg_string(args, truncate_length=10)[source]

Create string representation of an args tuple.

Parameters:
  • args (tuple) – Tuple of arguments to be converted to a string.

  • truncate_length (int) – Length to truncate the string to.

Returns:

String representation of the args.

Return type:

str

build_kwarg_string(kwargs, truncate_length=10)[source]

Create string representation of a kwargs dict.

Parameters:
  • kwargs (dict) – Dictionary of keyword arguments to be converted to a string.

  • truncate_length (int) – Length to truncate the string to.

Returns:

String representation of the kwargs dict.

Return type:

str

load_secrets(env='.env')[source]

Load secrets from a .env file.

The contents of the .env file are stored in a Secrets object.

Parameters:

env (str) – Path to the .env file.

Return type:

Secrets

send_notification(messengers, info, env='.env')[source]

Send notification without using a decorator.

This function can be used to send a notification without using a decorator. This allows you to send a notification at any point, without tying it to a specific function.

Parameters:
  • messengers (Messenger | List[Messenger]) – Messenger, or list of Messenger, that will send the notification.

  • info (TaskInfo) – TaskInfo object containing information to send in the notification.

  • env (str) – Path to the .env file containing the secrets to use.

Return type:

None