adgtk.utils.processing

Common, often used patterns.

adgtk.utils.processing.get_pair_from_iterable(data: Iterator, default: Any = None) tuple

Gets first two entries

Parameters:
  • data (Iterable) – The iterable data

  • default (Any, optional) – if unable to get Next, defaults to None

Returns:

The first and second item

Return type:

Any

adgtk.utils.processing.get_sample_from_iterable(data: Iterator, default: Any = None) Any

Gets a sample from an iterable.

Parameters:
  • data (Iterable) – The iterable data

  • default (Any, optional) – if unable to get Next, defaults to None

Returns:

The first item

Return type:

Any

adgtk.utils.processing.string_to_bool(source: str | bool) bool

Converts a string into a boolean. also considers when a bool is passed. this keeps the invoking code cleaner.

Parameters:

source (Union[str, bool]) – the source string

Raises:

ValueError – Unable to transform

Returns:

the boolean value T/F.

Return type:

bool