httk.core.datastream.bytestream_file_view

Classes

BytestreamFileView

A view presenting an underlying data streaming backend via an io.IOBase-like API.

Module Contents

class httk.core.datastream.bytestream_file_view.BytestreamFileView(obj, **hints)

Bases: httk.core.datastream.bytestream_view.BytestreamView, io.IOBase, httk.core.datastream.bytestream_api.BytestreamAPI

A view presenting an underlying data streaming backend via an io.IOBase-like API.

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 bytes, or all remaining bytes when size is negative.

Parameters:

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

Returns:

The bytes read from the stream.

Raises:

ValueError – If the view is closed.

Return type:

bytes

readline(size=-1)

Read one line, optionally limited to size bytes.

Parameters:

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

Returns:

The line read, including its newline when present.

Raises:

ValueError – If the view is closed.

Return type:

bytes

readlines(hint=-1)

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

Parameters:

hint (int) – Approximate minimum number of bytes 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[bytes]

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.