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: httk.core.datastream.bytestream_like.BytestreamLike, **hints: Any)[source]

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.

unwrap() Any[source]

Return the most raw representation possible of this view, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.

property name: str | None[source]
property closed: bool[source]
close() None[source]

Flush and close the IO object.

This method has no effect if the file is already closed.

readable() bool[source]

Return whether object was opened for reading.

If False, read() will raise OSError.

writable() bool[source]

Return whether object was opened for writing.

If False, write() will raise OSError.

seekable() bool[source]

Return whether object supports random access.

If False, seek(), tell() and truncate() will raise OSError. This method may need to do a test seek().

flush() None[source]

Flush write buffers, if applicable.

This is not implemented for read-only and non-blocking streams.

read(size: int | None = -1) bytes[source]
readline(size: int | None = -1) bytes[source]

Read and return a line from the stream.

If size is specified, at most size bytes will be read.

The line terminator is always b’n’ for binary files; for text files, the newlines argument to open can be used to select the line terminator(s) recognized.

readlines(hint: int = -1) list[bytes][source]

Return a list of lines from the stream.

hint can be specified to control the number of lines read: no more lines will be read if the total size (in bytes/characters) of all lines so far exceeds hint.

seek(offset: int, whence: int = io.SEEK_SET) int[source]

Change the stream position to the given byte offset.

offset

The stream position, relative to ‘whence’.

whence

The relative position to seek from.

The offset is interpreted relative to the position indicated by whence. Values for whence are:

  • os.SEEK_SET or 0 – start of stream (the default); offset should be zero or positive

  • os.SEEK_CUR or 1 – current stream position; offset may be negative

  • os.SEEK_END or 2 – end of stream; offset is usually negative

Return the new absolute position.

tell() int[source]

Return current stream position.

detach() NoReturn[source]