Skip to content

tinker_cookbook.stores.Storage

class tinker_cookbook.stores.Storage(Protocol)

Sync byte-level file I/O.

url(path)

Return a human-readable URI for a path.

Parameters:

  • path (str)

read(path)

Read entire file. Raises FileNotFoundError if missing.

Parameters:

  • path (str)

write(path, data)

Write data, creating parent dirs. Overwrites if exists.

Parameters:

  • path (str)
  • data (bytes)

append(path, data)

Append data to a file, creating if needed.

Parameters:

  • path (str)
  • data (bytes)

exists(path)

Return True if the file exists.

Parameters:

  • path (str)

stat(path)

Get file size and mtime, or None if missing.

Parameters:

  • path (str)

read_range(path, offset, length)

Read bytes from offset. If length is None, read to end.

Parameters:

  • path (str)
  • offset (int)
  • length (int | None)

list_dir(prefix)

List immediate children under prefix. Returns names only.

Parameters:

  • prefix (str)

remove(path)

Delete a file. No error if missing.

Parameters:

  • path (str)

remove_dir(path)

Remove an empty directory. No error if missing or non-empty.

Parameters:

  • path (str)

flush()

Flush any buffered data to the backend.