Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/api/private/deposit_read.py
Show All 13 Lines | |||||
from swh.core import tarball | from swh.core import tarball | ||||
from swh.deposit.utils import normalize_date | from swh.deposit.utils import normalize_date | ||||
from swh.model import identifiers | from swh.model import identifiers | ||||
from swh.model.model import MetadataAuthorityType | from swh.model.model import MetadataAuthorityType | ||||
from . import APIPrivateView, DepositReadMixin | from . import APIPrivateView, DepositReadMixin | ||||
from ...config import ARCHIVE_TYPE, SWH_PERSON | from ...config import ARCHIVE_TYPE, SWH_PERSON | ||||
from ...models import Deposit | from ...models import Deposit | ||||
from ..common import APIGet | from ..common import APIGet, get_deposit_by_id | ||||
@contextmanager | @contextmanager | ||||
def aggregate_tarballs(extraction_dir, archive_paths): | def aggregate_tarballs(extraction_dir, archive_paths): | ||||
"""Aggregate multiple tarballs into one and returns this new archive's | """Aggregate multiple tarballs into one and returns this new archive's | ||||
path. | path. | ||||
Args: | Args: | ||||
▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | def metadata_read(self, deposit: Deposit) -> Dict[str, Any]: | ||||
"committer_date": commit_date, | "committer_date": commit_date, | ||||
"revision_parents": parents, | "revision_parents": parents, | ||||
}, | }, | ||||
} | } | ||||
def process_get( | def process_get( | ||||
self, request, collection_name: str, deposit_id: int | self, request, collection_name: str, deposit_id: int | ||||
) -> Tuple[int, Dict, str]: | ) -> Tuple[int, Dict, str]: | ||||
deposit = Deposit.objects.get(pk=deposit_id) | deposit = get_deposit_by_id(deposit_id) | ||||
data = self.metadata_read(deposit) | data = self.metadata_read(deposit) | ||||
return status.HTTP_200_OK, data if data else {}, "application/json" | return status.HTTP_200_OK, data if data else {}, "application/json" |