cobra_db.scripts.utils

Module Contents

Functions

batcher(→ Generator[List, None, None])

Create a batched generator out of a generator

add_args_to_iterable(→ Generator[Tuple, None, None])

Create a generator where some args are repeated every time.

cobra_db.scripts.utils.batcher(iterable: Iterable, batch_size: int) Generator[List, None, None][source]

Create a batched generator out of a generator

Parameters:
  • generator – the iterable that will be batched.

  • batch_size – The max size of the list

Yield:

a list with batch_size number of items in iterable. If there is a residual at the end, the last list will be shorter.

cobra_db.scripts.utils.add_args_to_iterable(iterable: Iterable, *args: Any) Generator[Tuple, None, None][source]

Create a generator where some args are repeated every time.

Parameters:

iterable – the variable that will change in every iteration

Yield:

a generator that will look like (iterable[i], args[0], args[1], …)