Capabilities¶
Capability
¶
Bases: Enum
Operations a backend may support.
Most values gate one or more Store methods; some are quality
flags that inform callers about backend behaviour without gating a
specific method (see ATOMIC_MOVE, SEEKABLE_READ, LAZY_READ).
Use Store.supports() to query at runtime.
Values:
Core I/O
READ-- Stream or bulk-read file content. GatesStore.read()andStore.read_bytes().WRITE-- Create or overwrite files. GatesStore.write().DELETE-- Remove files and folders. GatesStore.delete()andStore.delete_folder().
Navigation
LIST-- Enumerate files and subfolders. GatesStore.list_files()andStore.list_folders().GLOB-- Native pattern matching against file paths. GatesStore.glob(). Not all backends support this — useext.glob.glob_files()as a portable fallback.
File operations
MOVE-- Rename or relocate a file within the same backend. GatesStore.move().COPY-- Duplicate a file within the same backend. GatesStore.copy().
Atomic variants
ATOMIC_WRITE-- Write via temp-file-and-rename so readers never see partial content. GatesStore.write_atomic()andStore.open_atomic().ATOMIC_MOVE-- Quality flag:move()is guaranteed atomic under concurrent access (e.g. Local viaos.rename, Memory under lock, SQL in a transaction). Does not gate a method — callstore.supports(Capability.ATOMIC_MOVE)before relying on atomic rename semantics. Backends that implement move as copy-then-delete (e.g. S3, Azure non-HNS) do not declare this capability.
Metadata
METADATA-- Retrieve file or folder metadata. GatesStore.get_file_info()andStore.get_folder_info().USER_METADATA-- Store user-supplied key/value pairs alongside a file. Strict gate on themetadata=kwarg inStore.write(),Store.write_text(), andStore.write_atomic(): passing a non-empty mapping to a backend that does not declare this capability raisesCapabilityNotSupportedbefore any I/O.metadata=Noneandmetadata={}are always allowed.
Quality flags
SEEKABLE_READ--Store.read()always returns a seekable stream (stream.seekable()isTrue). Backends that declare this capability return seekable streams from bothread()andread_seekable()with zero overhead. Backends without this capability still supportread_seekable()via an optimized override or spool fallback.LAZY_READ--read()fetches data lazily on demand from the native source rather than loading the entire file into memory before returning. Backends that pre-load the full file contents (e.g. in-memory backends, SQL blob stores) do not declare this flag. Callers can usestore.supports(Capability.LAZY_READ)to know whether partial reads avoid loading the entire file.WRITE_RESULT_NATIVE-- Quality flag: the backend populates the rich fields of the returnedWriteResult(etag,last_modified,version_id, and where applicabledigest) directly from its write response. Does not gate any method —Store.write*()works on every backend. Backends without this flag return aWriteResultwith onlypathandsizepopulated (source == "basic");metadatais governed independently by theUSER_METADATAcapability and is not subject to this flag. Usestore.supports(Capability.WRITE_RESULT_NATIVE)to decide whether to callstore.get_file_info()after a write if you need the full metadata set.
Quality flags vs. method gates
Two kinds of capabilities exist. Method gates (e.g. READ, WRITE,
DELETE) guard specific Store or Backend methods — calling a gated
method on a backend that does not declare the capability raises
CapabilityNotSupported. Quality flags (e.g. SEEKABLE_READ,
WRITE_RESULT_NATIVE) are informational only — they describe behaviour
the backend provides but do not guard any method call. Check the class
docstring for the full categorisation.
CapabilitySet
¶
CapabilitySet(capabilities: set[Capability])
Immutable set of capabilities declared by a backend.
Parameters:
-
capabilities(set[Capability]) –The set of supported capabilities.
require
¶
require(cap: Capability, *, backend: str = '') -> None
Raise if a capability is not supported.
Raises:
-
CapabilityNotSupported–If the capability is missing.
See also¶
- Capabilities Matrix — per-backend capability comparison
- Capabilities & Errors example — checking capabilities at runtime