pydatatask.utils module#

Various utility classes and functions that are used throughout the codebase but don’t belong anywhere in particular.

class pydatatask.utils.AReadStream(*args, **kwargs)[source]#

Bases: Protocol, AbstractAsyncContextManager

A protocol for reading data from an asynchronous stream.

async read(n: int | None = None) bytes[source]#

Read and return up to n bytes, or if unspecified, the rest of the stream.

async close() None[source]#

Close and release the stream.

class pydatatask.utils.AWriteStream(*args, **kwargs)[source]#

Bases: Protocol, AbstractAsyncContextManager

A protocol for writing data to an asynchronous stream.

async write(data: bytes)[source]#

Write data to the stream.

async close() None[source]#

Close and release the stream.

async pydatatask.utils.async_copyfile(copyfrom: AReadStream, copyto: AWriteStream, blocksize=1048576)[source]#

Stream data from copyfrom to copyto.

class pydatatask.utils.AReadText(base: AReadStream, encoding: str = 'utf-8', errors='strict', chunksize=4096)[source]#

Bases: object

An async version of io.TextIOWrapper which can only handle reading.

async read(n: int | None = None) str[source]#

Read up to n chars from the string, or the rest of the stream if not provided.

async close()[source]#

Close and release the stream.

class pydatatask.utils.AWriteText(base: AWriteStream, encoding='utf-8', errors='strict')[source]#

Bases: object

An async version of io.TextIOWrapper which can only handle writing.

async write(data: str)[source]#

Write data to the stream.

async close()[source]#

Close and release the stream.

async pydatatask.utils.async_copyfile_str(copyfrom: AReadText, copyto: AWriteText, blocksize=1048576)[source]#

Stream text from copyfrom to copyto.

async pydatatask.utils.roundrobin(iterables: List)[source]#

An async version of the itertools roundrobin recipe.

roundrobin(‘ABC’, ‘D’, ‘EF’) –> A D E B F C