Utilities.

async_debounce(wait=DEFAULT_DEBOUNCE_WAIT_SECONDS, immediate=False, queue=True)

Debounce decorator for async functions.

NOTE: only works for functions returning None!

Ensures that the decorated function is only executed once after the specified wait time, resetting if called again.

When 'immediate' is True the first call is executed immediatally. When queue is True subsequent calls are still debounced normally. 'queue' does nothing when 'immediate' is False.

sha256_hexdigest(source)

Calculate sha256 checksum from input string.

Parameters:
  • source (str) –

    input data to calculate checksum

Returns:
  • str

    sha256 checksum of source string

to_iso8601(dt)

Convert a datetime object to an ISO 8601 string.

  • Adds 'Z' if datetime is UTC.
  • Converts naive datetimes to UTC before formatting.