Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/archive.py
from typing import Any, Dict, Iterable | from typing import Any, Dict, Iterable | ||||
from typing_extensions import Protocol, runtime_checkable | from typing_extensions import Protocol, runtime_checkable | ||||
from swh.model.model import Revision, Sha1Git | from swh.model.model import Sha1Git | ||||
@runtime_checkable | @runtime_checkable | ||||
class ArchiveInterface(Protocol): | class ArchiveInterface(Protocol): | ||||
def directory_ls(self, id: Sha1Git) -> Iterable[Dict[str, Any]]: | def directory_ls(self, id: Sha1Git) -> Iterable[Dict[str, Any]]: | ||||
"""List entries for one directory. | """List entries for one directory. | ||||
Args: | Args: | ||||
id: sha1 id of the directory to list entries from. | id: sha1 id of the directory to list entries from. | ||||
Yields: | Yields: | ||||
directory entries for such directory. | dictionary of entries in such directory containing only the keys "name", | ||||
"target" and "type". | |||||
""" | """ | ||||
... | ... | ||||
def revision_get(self, ids: Iterable[Sha1Git]) -> Iterable[Revision]: | def revision_get_parents(self, id: Sha1Git) -> Iterable[Sha1Git]: | ||||
"""Given a list of sha1, return the revisions' information | """List parents of one revision. | ||||
Args: | Args: | ||||
revisions: list of sha1s for the revisions to be retrieved | revisions: sha1 id of the revision to list parents from. | ||||
Yields: | Yields: | ||||
revisions matching the identifiers. If a revision does | sha1 ids for the parents of such revision. | ||||
not exist, the provided sha1 is simply ignored. | |||||
""" | """ | ||||
... | ... | ||||
def snapshot_get_heads(self, id: Sha1Git) -> Iterable[Sha1Git]: | def snapshot_get_heads(self, id: Sha1Git) -> Iterable[Sha1Git]: | ||||
"""List all revisions pointed by one snapshot. | """List all revisions targeted by one snapshot. | ||||
Args: | Args: | ||||
id: sha1 id of the snapshot. | id: sha1 id of the snapshot. | ||||
Yields: | Yields: | ||||
sha1 ids of found revisions. | sha1 ids of revisions that a target of such snapshot. | ||||
""" | """ | ||||
... | ... |