hd2api.util package

Submodules

hd2api.util.utils module

hd2api.util.utils.changeformatif(value: str | None) str

Return formatted string if value is not None or empty.

hd2api.util.utils.default_fdt(dt: datetime, *args, **kwargs) str

Return the ISO 8601 string representation of a datetime object.

hd2api.util.utils.extract_timestamp(timestamp: str) datetime

Extract datetime object from a given timestamp string.

hd2api.util.utils.format_datetime(*args, **kwargs) str

Format datetime using the currently set callable.

hd2api.util.utils.hdml_parse(input_str: str) str

Parse a given string to replace custom HTML-like tags.

hd2api.util.utils.human_format(num: float) str

Format a large number with appropriate suffixes.

hd2api.util.utils.seconds_to_time_stamp(seconds_init: int | float) str

Convert seconds into a timestamp string of format d:h:m:s.

hd2api.util.utils.select_emoji(key: str) str

Select an emoji from the status emoji dictionary.

hd2api.util.utils.set_fdt(func: Callable) None

Set a custom formatting function for datetime objects.

hd2api.util.utils.set_fdt_callable(dt: datetime, *args, **kwargs) str

Return the ISO 8601 string representation of a datetime object.

hd2api.util.utils.set_status_emoji(new)

hd2api.util.find module

hd2api.util.find.get_item(target: Iterable, /, **attrs: Any) Any | None

Look for the first item in iterable that matches the traits in attrs.

Usage:

get_item(target, attr1=value1, attr2=value2, …)

Parameters:
  • target – An iterable collection of items to search through.

  • attrs – Keyword arguments representing attribute-value pairs to match.

Returns:

The first item in the target that matches the specified attributes, or None if no match is found.

Module contents