mate_common.utils module

Miscellaneous helpers for MATE.

mate_common.utils.grouper(n: int, iterable: Iterable[Any]) Iterator[Iterable[Any]]

Group iterable into chunks of n, truncating the last group if there aren’t enough elements.

Parameters
  • n (int) –

  • iterable (Iterable[Any]) –

Return type

Iterator[Iterable[Any]]

mate_common.utils.stateless_io(io: IO) Iterator[IO]

A context manager for presenting a “stateless” view of some IO object.

The object is reset to its starting position before and after the managed context, allowing operations within the context to consume the IO without producing side effects in other places that use it.

Parameters

io (IO) –

Return type

Iterator[IO]

mate_common.utils.tarball(src: pathlib.Path) Iterator[pathlib.Path]

Create a temporary tarball (.tar.gz) for the given path and yield it.

Parameters

src (pathlib.Path) –

Return type

Iterator[pathlib.Path]

mate_common.utils.unreachable(x: NoReturn) NoReturn

A hint to the typechecker that a branch can never occur.

Parameters

x (NoReturn) –

Return type

NoReturn