azuredol.base#
Close-to-metal Mapping stores over Azure Blob Storage.
Three concrete classes:
ContainerStore— the primary store. Mapping of blob name → bytes within one container.AccountStore— mapping of container name →ContainerStorewithin one account.BlobHandle— non-Mapping escape hatch for one blob with the full Azure surface.
See misc/docs/architecture.md Layer B. Codec / convenience layers live in
azuredol.recipes; the connection layer lives in azuredol.connection.
Classes
|
Mapping over container names in an account (iter / contains / len). |
|
Adds |
|
Read-write Mapping over containers in an account. |
|
Thin facade over one |
|
Iteration / membership / cardinality ( |
|
Adds |
|
The primary read-write Mapping over an Azure container. |
- class azuredol.base.AccountCollection(connection=None, *, container_store_cls=None, container_store_kwargs=None)[source]#
Bases:
_AccountStoreBase,KvReaderMapping over container names in an account (iter / contains / len).
- class azuredol.base.AccountReader(connection=None, *, container_store_cls=None, container_store_kwargs=None)[source]#
Bases:
AccountCollectionAdds
__getitem__returning aContainerStore(or configured subclass).
- class azuredol.base.AccountStore(connection=None, *, container_store_cls=None, container_store_kwargs=None)[source]#
Bases:
AccountReader,KvPersisterRead-write Mapping over containers in an account.
__setitem__creates a container; the value is ignored except when it’s a Mapping (in which case it is treated as an initial bulk-load).__delitem__refuses non-empty containers — callazuredol.ops.delete_container(store, name, force=True)to acknowledge a cascading delete. Seemisc/docs/design_decisions.md§12.
- class azuredol.base.BlobHandle(container, blob, *, connection=None)[source]#
Bases:
objectThin facade over one
BlobClient. Not a Mapping.Use when you need the full Azure-blob surface for a single blob: metadata, properties, conditional writes, leases, copy, append, SAS URL generation, streaming downloads.
- Parameters:
container (
Union[str,ContainerClient]) – An existingContainerClientor a container name string.blob (
str) – The blob name (relative to the container root; full path including ‘/’).connection (
Union[AzureConnection,BlobServiceClient,str,dict,None]) – Ignored ifcontaineris aContainerClient. Otherwise resolved viaAzureConnection.from_anything.
- acquire_lease(lease_duration=-1)[source]#
Acquire a lease (15-60s, or -1 for infinite). Returns a
BlobLeaseClient.
- copy_from(source_url, *, requires_sync=None)[source]#
Server-side copy from a URL. Same-account = sync; cross-account = async (poll).
- create(data, *, overwrite=False, **kwargs)[source]#
Strict-create variant of
write; raisesBlobAlreadyExistsErroron conflict.- Return type:
- download_stream(*, chunk_size=None)[source]#
Return a streaming downloader. Iterate chunks via
.chunks()or.readinto(fp).
- properties()[source]#
Return
BlobProperties(size, last_modified, etag, content_settings, metadata, …).
- read(*, offset=None, length=None)[source]#
Download (possibly a range) and return bytes.
- Return type:
- class azuredol.base.ContainerCollection(container, *, prefix='', connection=None, create_container_if_missing=False, blob_type=BlobType.BLOCKBLOB, upload_kwargs=None, download_kwargs=None)[source]#
Bases:
_ContainerStoreBase,KvReaderIteration / membership / cardinality (
__len__deliberately omitted) over a container.__len__is intentionally NOT implemented — seemisc/docs/design_decisions.md§2. Pagination cost is unbounded; users wanting a count callsum(1 for _ in store).- walk_ids(delimiter='/')[source]#
Hierarchical walk of the leaf’s prefix, yielding
BlobProperties/BlobPrefixnodes.Thin pass-through to
ContainerClient.walk_blobs. The scope is the leaf’s ownprefixand each node’s.nameis an absolute blob id (never a store key), so under adolkey codec it disagrees with__iter__. For a scope that follows the caller’s (possibly wrapped) store useazuredol.ops.walk(store).
- class azuredol.base.ContainerReader(container, *, prefix='', connection=None, create_container_if_missing=False, blob_type=BlobType.BLOCKBLOB, upload_kwargs=None, download_kwargs=None)[source]#
Bases:
ContainerCollectionAdds
__getitem__(returns bytes) overContainerCollection.The trailing-slash sub-store convention lives here:
store['sub/']returns a newContainerReaderwith extended prefix and zero round-trips. This works on a bare store and on typed-store classes, but not through every wrapper stack (adolwrapper placed on an instance is not carried into the sub-store);azuredol.substore()is the portable form and should be preferred (i2mint/azuredol#9).
- class azuredol.base.ContainerStore(container, *, prefix='', connection=None, create_container_if_missing=False, blob_type=BlobType.BLOCKBLOB, upload_kwargs=None, download_kwargs=None)[source]#
Bases:
ContainerReader,KvPersisterThe primary read-write Mapping over an Azure container.
Doctest below requires Azurite (or live Azure). It is shown but not auto-run.
Example (requires Azurite):
>>> from azuredol import ContainerStore >>> s = ContainerStore( ... 'my-test-container', ... connection='UseDevelopmentStorage=true', ... create_container_if_missing=True, ... ) >>> s['k1'] = b'v1' >>> s['k1'] b'v1' >>> 'k1' in s True >>> del s['k1']
For unit tests without Azurite, prototype with
dol’s in-memory pattern:wrap_kvs(dict(), ...).