minimalkv.fsspecstore module

class minimalkv.fsspecstore.FSSpecStore(prefix: str = '', mkdir_prefix: bool = True, write_kwargs: dict | None = None, custom_fs: AbstractFileSystem | None = None)

Bases: KeyValueStore

A KeyValueStore that uses an fsspec AbstractFileSystem to store the key-value pairs.

iter_keys(prefix: str = '') Iterator[str]

Iterate over all keys in the store starting with prefix.

Parameters

prefix: str, optional, default = ‘’

Only iterate over keys starting with prefix. Iterate over all keys if empty.

Raises

IOError

If there was an error accessing the store.

property mkdir_prefix

Whether to create the prefix if it does not exist.

Note

Deprecated in 2.0.0.

property prefix

Get the prefix used on the fsspec FileSystem when storing keys.

Note

Deprecated in 2.0.0.

class minimalkv.fsspecstore.FSSpecStoreEntry(file: AbstractBufferedFile)

Bases: BufferedIOBase

A file-like object for reading from an entry in an FSSpecStore.

read(size: int | None = -1) bytes

Return first size bytes of data.

If no size is given all data is returned.

Parameters

sizeint, optional, default = -1

Number of bytes to be returned.

readable() bool

Whether the file is readable.

seek(loc: int, whence: int = 0) int

Set current file location.

Parameters

loc: int

byte location

whence: {0, 1, 2}

from start of file, current location or end of file, respectively.

seekable() bool

Whether the file is seekable.

tell() int

Return the current offset as int. Always >= 0.