tugboat.utils module

tugboat.utils.find_duplicate_names(items: Sequence[NamedModel]) Iterator[tuple[int, str]]

Find and yield the indices and names of duplicate items in a sequence.

tugboat.utils.join_with_and(items: Iterable[Any], *, quote: bool = True, sort: bool = True, fallback_string: str = '(none)') str

Join items with “and” as the last joiner. On empty input, returns the fallback string.

Parameters:
  • items (Iterable[Any]) – The items to join.

  • quote (bool) – Whether to quote the items.

  • sort (bool) – Whether to sort the items.

  • fallback_string (str) – The string to return if there are no items.

tugboat.utils.join_with_or(items: Iterable[Any], *, quote: bool = True, sort: bool = True, fallback_string: str = '(none)') str

Join items with “or” as the last joiner. On empty input, returns the fallback string.

Parameters:
  • items (Iterable[Any]) – The items to join.

  • quote (bool) – Whether to quote the items.

  • sort (bool) – Whether to sort the items.

  • fallback_string (str) – The string to return if there are no items.

class tugboat.utils.prepend_loc(prefix: Sequence[str | int], items: Iterable[Diagnosis] = ())

Prepend path to the location of each diagnosis in an iterable.