httk.core.datastream.textstream_api

Classes

TextstreamAPI

Abstract base class for a bare minimum API for streamable text data.

Module Contents

class httk.core.datastream.textstream_api.TextstreamAPI

Bases: abc.ABC

Abstract base class for a bare minimum API for streamable text data.

Supports: * read, close, name, and closed with the meanings defined by io.IOBase

Since it is a minimal streaming data API it deliberately omits: seek, tell, etc.; there should be no assumption that the underlying data source is seekable. However, many backend implementations may chose to support them.

abstractmethod read(size=-1)

Read up to size characters, or all remaining characters when size is negative.

Parameters:

size (int) – Maximum number of characters to read.

Returns:

The text read from the stream.

Return type:

str

abstractmethod close()

Close the stream.

property name: str | None
Abstractmethod:

Expose the source name when one exists.

property closed: bool
Abstractmethod:

Report whether the stream is closed.