Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/interface.py
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | class RelationData: | ||||
""" | """ | ||||
dst: Sha1Git | dst: Sha1Git | ||||
path: Optional[bytes] | path: Optional[bytes] | ||||
@runtime_checkable | @runtime_checkable | ||||
class ProvenanceStorageInterface(Protocol): | class ProvenanceStorageInterface(Protocol): | ||||
@remote_api_endpoint("close") | |||||
def close(self) -> None: | |||||
"""Close connection to the storage and release resources.""" | |||||
... | |||||
@remote_api_endpoint("content_add") | @remote_api_endpoint("content_add") | ||||
def content_add( | def content_add( | ||||
self, cnts: Union[Iterable[Sha1Git], Dict[Sha1Git, Optional[datetime]]] | self, cnts: Union[Iterable[Sha1Git], Dict[Sha1Git, Optional[datetime]]] | ||||
) -> bool: | ) -> bool: | ||||
"""Add blobs identified by sha1 ids, with an optional associated date (as paired | """Add blobs identified by sha1 ids, with an optional associated date (as paired | ||||
in `cnts`) to the provenance storage. Return a boolean stating whether the | in `cnts`) to the provenance storage. Return a boolean stating whether the | ||||
information was successfully stored. | information was successfully stored. | ||||
""" | """ | ||||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | class ProvenanceStorageInterface(Protocol): | ||||
def with_path(self) -> bool: | def with_path(self) -> bool: | ||||
... | ... | ||||
@runtime_checkable | @runtime_checkable | ||||
class ProvenanceInterface(Protocol): | class ProvenanceInterface(Protocol): | ||||
storage: ProvenanceStorageInterface | storage: ProvenanceStorageInterface | ||||
def close(self) -> None: | |||||
"""Close connection to the underlying `storage` and release resources.""" | |||||
... | |||||
def flush(self) -> None: | def flush(self) -> None: | ||||
"""Flush internal cache to the underlying `storage`.""" | """Flush internal cache to the underlying `storage`.""" | ||||
... | ... | ||||
def content_add_to_directory( | def content_add_to_directory( | ||||
self, directory: DirectoryEntry, blob: FileEntry, prefix: bytes | self, directory: DirectoryEntry, blob: FileEntry, prefix: bytes | ||||
) -> None: | ) -> None: | ||||
"""Associate `blob` with `directory` in the provenance model. `prefix` is the | """Associate `blob` with `directory` in the provenance model. `prefix` is the | ||||
▲ Show 20 Lines • Show All 123 Lines • Show Last 20 Lines |