Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/api/private/deposit_check.py
Show All 9 Lines | |||||
from itertools import chain | from itertools import chain | ||||
from shutil import get_unpack_formats | from shutil import get_unpack_formats | ||||
from rest_framework import status | from rest_framework import status | ||||
from swh.scheduler.utils import create_oneshot_task_dict | from swh.scheduler.utils import create_oneshot_task_dict | ||||
from . import DepositReadMixin, SWHPrivateAPIView | from . import DepositReadMixin, APIPrivateView | ||||
from ..common import APIGet | from ..common import APIGet | ||||
from ...config import DEPOSIT_STATUS_VERIFIED, DEPOSIT_STATUS_REJECTED | from ...config import DEPOSIT_STATUS_VERIFIED, DEPOSIT_STATUS_REJECTED | ||||
from ...config import ARCHIVE_TYPE | from ...config import ARCHIVE_TYPE | ||||
from ...models import Deposit | from ...models import Deposit | ||||
MANDATORY_FIELDS_MISSING = "Mandatory fields are missing" | MANDATORY_FIELDS_MISSING = "Mandatory fields are missing" | ||||
ALTERNATE_FIELDS_MISSING = "Mandatory alternate fields are missing" | ALTERNATE_FIELDS_MISSING = "Mandatory alternate fields are missing" | ||||
MANDATORY_ARCHIVE_UNREADABLE = ( | MANDATORY_ARCHIVE_UNREADABLE = ( | ||||
Show All 23 Lines | |||||
def known_archive_format(filename): | def known_archive_format(filename): | ||||
return any( | return any( | ||||
filename.endswith(t) for t in chain(*(x[1] for x in get_unpack_formats())) | filename.endswith(t) for t in chain(*(x[1] for x in get_unpack_formats())) | ||||
) | ) | ||||
class SWHChecksDeposit(SWHPrivateAPIView, APIGet, DepositReadMixin): | class APIChecks(APIPrivateView, APIGet, DepositReadMixin): | ||||
"""Dedicated class to read a deposit's raw archives content. | """Dedicated class to read a deposit's raw archives content. | ||||
Only GET is supported. | Only GET is supported. | ||||
""" | """ | ||||
def _check_deposit_archives(self, deposit): | def _check_deposit_archives(self, deposit): | ||||
"""Given a deposit, check each deposit request of type archive. | """Given a deposit, check each deposit request of type archive. | ||||
▲ Show 20 Lines • Show All 164 Lines • Show Last 20 Lines |