Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/api/private/deposit_read.py
Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | |||||
class APIReadArchives(APIPrivateView, APIGet, DepositReadMixin): | class APIReadArchives(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. | ||||
""" | """ | ||||
ADDITIONAL_CONFIG = { | |||||
"extraction_dir": ("str", "/tmp/swh-deposit/archive/"), | |||||
} | |||||
def __init__(self): | def __init__(self): | ||||
super().__init__() | super().__init__() | ||||
self.extraction_dir = self.config["extraction_dir"] | self.extraction_dir = self.config["extraction_dir"] | ||||
if not os.path.exists(self.extraction_dir): | if not os.path.exists(self.extraction_dir): | ||||
os.makedirs(self.extraction_dir) | os.makedirs(self.extraction_dir) | ||||
def process_get(self, request, collection_name, deposit_id): | def process_get(self, request, collection_name, deposit_id): | ||||
"""Build a unique tarball from the multiple received and stream that | """Build a unique tarball from the multiple received and stream that | ||||
Show All 20 Lines | def process_get(self, request, collection_name, deposit_id): | ||||
) | ) | ||||
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. | ||||
""" | """ | ||||
ADDITIONAL_CONFIG = { | |||||
"provider": ( | |||||
"dict", | |||||
{ | |||||
# 'provider_name': '', # those are not set since read from the | |||||
# 'provider_url': '', # deposit's client | |||||
"provider_type": "deposit_client", | |||||
"metadata": {}, | |||||
}, | |||||
), | |||||
"tool": ( | |||||
"dict", | |||||
{ | |||||
"name": "swh-deposit", | |||||
"version": "0.0.1", | |||||
"configuration": {"sword_version": "2"}, | |||||
}, | |||||
), | |||||
} | |||||
def __init__(self): | def __init__(self): | ||||
super().__init__() | super().__init__() | ||||
self.provider = self.config["provider"] | self.provider = self.config["provider"] | ||||
self.tool = self.config["tool"] | self.tool = self.config["tool"] | ||||
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. | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |