Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/api/private/deposit_read.py
# Copyright (C) 2017-2020 The Software Heritage developers | # Copyright (C) 2017-2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from contextlib import contextmanager | from contextlib import contextmanager | ||||
import os | import os | ||||
import shutil | import shutil | ||||
import tempfile | import tempfile | ||||
from typing import Any, Dict, Tuple | from typing import Any, Dict, Tuple | ||||
from rest_framework import status | from rest_framework import status | ||||
from swh.core import tarball | from swh.core import tarball | ||||
from swh.deposit.api import __version__ | |||||
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 . 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 | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | ) -> Tuple[int, Any, str]: | ||||
) | ) | ||||
class APIReadMetadata(APIPrivateView, APIGet, DepositReadMixin): | class APIReadMetadata(APIPrivateView, APIGet, DepositReadMixin): | ||||
"""Class in charge of aggregating metadata on a deposit. | """Class in charge of aggregating metadata on a deposit. | ||||
""" | """ | ||||
def __init__(self): | |||||
super().__init__() | |||||
self.provider = self.config["provider"] | |||||
self.tool = { | |||||
"name": "swh-deposit", | |||||
"version": __version__, | |||||
"configuration": {"sword_version": "2"}, | |||||
} | |||||
def _normalize_dates(self, deposit, metadata): | def _normalize_dates(self, deposit, metadata): | ||||
"""Normalize the date to use as a tuple of author date, committer date | """Normalize the date to use as a tuple of author date, committer date | ||||
from the incoming metadata. | from the incoming metadata. | ||||
Args: | Args: | ||||
deposit (Deposit): Deposit model representation | deposit (Deposit): Deposit model representation | ||||
metadata (Dict): Metadata dict representation | metadata (Dict): Metadata dict representation | ||||
▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines |