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. Absence of the flag means only thatread()is forward-only -- not that seekable reads are unavailable. On the syncStore,read_seekable()is gated onREADalone, so it is served on every backend: a backend without the flag serves it either through a native override as cheap as the passthrough (the sync Azure backend issues one ranged download perread(), with no temp-file spill) or through aSpooledTemporaryFilethat copies the object first (HTTP, and any async backend bridged to sync). The async API has noread_seekable()-- an async-native backend that omits the flag (AsyncAzureBackend,GraphBackend) has no seekable read until bridged to sync. The flag does not distinguish the native and spooled costs; the Azure backend guide's "Streaming and seekable reads" section documents the sync Azure range reader in full.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 fills each rich field of the returnedWriteResult(etag,version_id,last_modified,digest) directly from its write response, but only when that response carries the field — which fields are filled depends on the backend. Some native backends fill none: SFTP's write response has no metadata at all, so it returns onlypath/size/sourceand leaves every rich fieldNone(callget_file_info()for the metadata). 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.store.supports(Capability.WRITE_RESULT_NATIVE)tells you whether the rich fields may be populated, not that any given one is: a native backend can still leave an individual fieldNone(SFTP leaves all of them). Check the specific field you need, or callstore.get_file_info()when you must have it.
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. For example, a
backend that omits SEEKABLE_READ is still served by the sync
Store.read_seekable() — the flag reports only whether read() itself is
seekable, not whether read_seekable() is native or spooled (the async API
has no read_seekable()). 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