filedb.structfile module

Classes

class whoosh.filedb.structfile.StructFile(fileobj: BinaryIO, name: str | None = None, onclose: Callable[[StructFile], None] | None = None)[source]

Returns a “structured file” object that wraps the given file object and provides numerous additional methods for writing structured data, such as “write_varint” and “write_long”.

close() → None[source]

Closes the wrapped file.

flush() → None[source]

Flushes the buffer of the wrapped file. This is a no-op if the wrapped file does not have a flush method.

read_pickle() → Any[source]

Reads a pickled object from the wrapped file.

read_string() → bytes[source]

Reads a string from the wrapped file.

read_svarint() → int[source]

Reads a variable-length encoded signed integer from the wrapped file.

read_tagint() → int[source]

Reads a sometimes-compressed unsigned integer from the wrapped file. This is similar to the varint methods but uses a less compressed but faster format.

read_varint() → int[source]

Reads a variable-length encoded unsigned integer from the wrapped file.

write_byte(n: int) → None[source]

Writes a single byte to the wrapped file, shortcut for file.write(chr(n)).

write_pickle(obj: Any, protocol: int = -1) → None[source]

Writes a pickled representation of obj to the wrapped file.

write_string(s: bytes) → None[source]

Writes a string to the wrapped file. This method writes the length of the string first, so you can read the string back without having to know how long it was.

write_svarint(i: int) → None[source]

Writes a variable-length signed integer to the wrapped file.

write_tagint(i: int) → None[source]

Writes a sometimes-compressed unsigned integer to the wrapped file. This is similar to the varint methods but uses a less compressed but faster format.

write_varint(i: int) → None[source]

Writes a variable-length unsigned integer to the wrapped file.

class whoosh.filedb.structfile.BufferFile(buf: bytes | bytearray | memoryview, name: str | None = None, onclose: Callable[[StructFile], None] | None = None)[source]
class whoosh.filedb.structfile.ChecksumFile(*args: Any, **kwargs: Any)[source]