httk.core.datastream.textstream_file_view

Classes

TextstreamFileView

A view presenting an underlying data streaming backend via the full io.TextIOBase API, which is a superset of TextstreamAPI.

Module Contents

class httk.core.datastream.textstream_file_view.TextstreamFileView(obj, **hints)

Bases: httk.core.datastream.textstream_view.TextstreamView, io.TextIOBase, httk.core.datastream.textstream_api.TextstreamAPI

A view presenting an underlying data streaming backend via the full io.TextIOBase API, which is a superset of TextstreamAPI.

Parameters:
unwrap()

Return the raw representation of the wrapped backend.

Returns:

The backend’s most raw available representation.

Return type:

Any

property name: str | None

Return the backend’s source name when one exists.

property closed: bool

Report whether the backend is closed.

close()

Close the underlying backend.

readable()

Report that the view supports reading.

Returns:

Always True.

Return type:

bool

writable()

Report that the view does not support writing.

Returns:

Always False.

Return type:

bool

seekable()

Report whether the backend supports seeking and telling.

Returns:

Whether both operations are available.

Return type:

bool

flush()

Flush the backend when it provides flushing.

Raises:

ValueError – If the view is closed.

read(size=-1)

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

Parameters:

size (int | None) – Maximum number of characters to read; None also means all remaining characters.

Returns:

The text read from the stream.

Raises:

ValueError – If the view is closed.

Return type:

str

readline(size=-1)

Read one line, optionally limited to size characters.

Parameters:

size (int | None) – Maximum number of characters to read; None means no limit.

Returns:

The line read, including its newline when present.

Raises:

ValueError – If the view is closed.

Return type:

str

readlines(hint=-1)

Read lines until EOF or until the accumulated size reaches hint.

Parameters:

hint (int) – Approximate minimum number of characters to collect, or a negative value for no limit.

Returns:

The lines read from the stream.

Raises:

ValueError – If the view is closed.

Return type:

list[str]

seek(offset, whence=io.SEEK_SET)

Move the stream position and discard buffered line data.

Parameters:
  • offset (int) – Position adjustment interpreted according to whence.

  • whence (int) – Reference point for offset.

Returns:

The resulting absolute stream position.

Raises:
Return type:

int

tell()

Return the logical stream position before buffered line data.

Returns:

The logical absolute stream position.

Raises:
Return type:

int

detach()

Reject detaching because the view owns its backend interface.

Raises:

io.UnsupportedOperation – Always, because detaching is unsupported.

property encoding: str | None

Return the backend’s text encoding when available.

property errors: str | None

Return the backend’s error handling mode when available.

property newlines: str | tuple[str, Ellipsis] | None

Return the newline conventions observed by the backend when available.