Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/storage/archive.py
from typing import Any, Dict, Iterable, Set | from typing import Any, Dict, Iterable, Set | ||||
from swh.model.model import ObjectType, Revision, Sha1Git, TargetType | from swh.model.model import ObjectType, Sha1Git, TargetType | ||||
from swh.storage.interface import StorageInterface | from swh.storage.interface import StorageInterface | ||||
class ArchiveStorage: | class ArchiveStorage: | ||||
def __init__(self, storage: StorageInterface): | def __init__(self, storage: StorageInterface): | ||||
self.storage = storage | self.storage = storage | ||||
def directory_ls(self, id: Sha1Git) -> Iterable[Dict[str, Any]]: | def directory_ls(self, id: Sha1Git) -> Iterable[Dict[str, Any]]: | ||||
# TODO: filter unused fields | # TODO: filter unused fields | ||||
yield from self.storage.directory_ls(id) | yield from self.storage.directory_ls(id) | ||||
def revision_get(self, ids: Iterable[Sha1Git]) -> Iterable[Revision]: | def revision_get_parents(self, id: Sha1Git) -> Iterable[Sha1Git]: | ||||
# TODO: filter unused fields | rev = self.storage.revision_get([id])[0] | ||||
yield from ( | if rev is not None: | ||||
rev for rev in self.storage.revision_get(list(ids)) if rev is not None | yield from rev.parents | ||||
) | |||||
vlorentz: why not yield entries directly? | |||||
Done Inline ActionsWell, the documentation (in the definition of the ArchiveInterface) states that each Dict should have only these three keys, and we use that to test that both implementation (ArchiveStorage and ArchivePostgreSQL) behave in the same way. aeviso: Well, the documentation (in the definition of the `ArchiveInterface`) states that each `Dict`… | |||||
def snapshot_get_heads(self, id: Sha1Git) -> Iterable[Sha1Git]: | def snapshot_get_heads(self, id: Sha1Git) -> Iterable[Sha1Git]: | ||||
from swh.core.utils import grouper | from swh.core.utils import grouper | ||||
from swh.storage.algos.snapshot import snapshot_get_all_branches | from swh.storage.algos.snapshot import snapshot_get_all_branches | ||||
snapshot = snapshot_get_all_branches(self.storage, id) | snapshot = snapshot_get_all_branches(self.storage, id) | ||||
assert snapshot is not None | assert snapshot is not None | ||||
targets_set = set() | targets_set = set() | ||||
Show All 25 Lines |
why not yield entries directly?