Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/deposit/loader.py
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | class DepositPackageInfo(BasePackageInfo): | ||||
"""codemeta:datePublished if any, deposit completed_date otherwise""" | """codemeta:datePublished if any, deposit completed_date otherwise""" | ||||
client = attr.ib(type=str) | client = attr.ib(type=str) | ||||
id = attr.ib(type=int) | id = attr.ib(type=int) | ||||
"""Internal ID of the deposit in the deposit DB""" | """Internal ID of the deposit in the deposit DB""" | ||||
collection = attr.ib(type=str) | collection = attr.ib(type=str) | ||||
"""The collection in the deposit; see SWORD specification.""" | """The collection in the deposit; see SWORD specification.""" | ||||
author = attr.ib(type=Person) | author = attr.ib(type=Person) | ||||
committer = attr.ib(type=Person) | committer = attr.ib(type=Person) | ||||
release_notes = attr.ib(type=Optional[str]) | |||||
@classmethod | @classmethod | ||||
def from_metadata( | def from_metadata( | ||||
cls, metadata: Dict[str, Any], url: str, filename: str, version: str | cls, metadata: Dict[str, Any], url: str, filename: str, version: str | ||||
) -> "DepositPackageInfo": | ) -> "DepositPackageInfo": | ||||
# Note: | # Note: | ||||
# `date` and `committer_date` are always transmitted by the deposit read api | # `date` and `committer_date` are always transmitted by the deposit read api | ||||
# which computes itself the values. The loader needs to use those to create the | # which computes itself the values. The loader needs to use those to create the | ||||
Show All 15 Lines | ) -> "DepositPackageInfo": | ||||
version=version, | version=version, | ||||
author_date=depo["author_date"], | author_date=depo["author_date"], | ||||
commit_date=depo["committer_date"], | commit_date=depo["committer_date"], | ||||
client=depo["client"], | client=depo["client"], | ||||
id=depo["id"], | id=depo["id"], | ||||
collection=depo["collection"], | collection=depo["collection"], | ||||
author=parse_author(depo["author"]), | author=parse_author(depo["author"]), | ||||
committer=parse_author(depo["committer"]), | committer=parse_author(depo["committer"]), | ||||
release_notes=depo["release_notes"], | |||||
raw_info=raw_info, | raw_info=raw_info, | ||||
directory_extrinsic_metadata=[ | directory_extrinsic_metadata=[ | ||||
RawExtrinsicMetadataCore( | RawExtrinsicMetadataCore( | ||||
discovery_date=now(), | discovery_date=now(), | ||||
metadata=raw_metadata.encode(), | metadata=raw_metadata.encode(), | ||||
format="sword-v2-atom-codemeta-v2", | format="sword-v2-atom-codemeta-v2", | ||||
) | ) | ||||
for raw_metadata in all_metadata_raw | for raw_metadata in all_metadata_raw | ||||
▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | ) -> List[Tuple[str, Mapping]]: | ||||
""" | """ | ||||
return [self.client.archive_get(self.deposit_id, tmpdir, p_info.filename)] | return [self.client.archive_get(self.deposit_id, tmpdir, p_info.filename)] | ||||
def build_release( | def build_release( | ||||
self, p_info: DepositPackageInfo, uncompressed_path: str, directory: Sha1Git, | self, p_info: DepositPackageInfo, uncompressed_path: str, directory: Sha1Git, | ||||
) -> Optional[Release]: | ) -> Optional[Release]: | ||||
message = ( | message = ( | ||||
f"{p_info.client}: Deposit {p_info.id} in collection {p_info.collection}\n" | f"{p_info.client}: Deposit {p_info.id} in collection {p_info.collection}" | ||||
).encode("utf-8") | ) | ||||
if p_info.release_notes: | |||||
message += "\n\n" + p_info.release_notes | |||||
if not message.endswith("\n"): | |||||
message += "\n" | |||||
ardumont: do we want to keep that crafted message at all?
If there is a release note already mentioned… | |||||
Done Inline ActionsI'd rather keep it for consistency between deposits vlorentz: I'd rather keep it for consistency between deposits | |||||
return Release( | return Release( | ||||
name=p_info.version.encode(), | name=p_info.version.encode(), | ||||
message=message, | message=message.encode(), | ||||
author=p_info.author, | author=p_info.author, | ||||
date=TimestampWithTimezone.from_dict(p_info.author_date), | date=TimestampWithTimezone.from_dict(p_info.author_date), | ||||
target=directory, | target=directory, | ||||
target_type=ObjectType.DIRECTORY, | target_type=ObjectType.DIRECTORY, | ||||
synthetic=True, | synthetic=True, | ||||
) | ) | ||||
def get_extrinsic_origin_metadata(self) -> List[RawExtrinsicMetadataCore]: | def get_extrinsic_origin_metadata(self) -> List[RawExtrinsicMetadataCore]: | ||||
▲ Show 20 Lines • Show All 174 Lines • Show Last 20 Lines |
do we want to keep that crafted message at all?
If there is a release note already mentioned, shan't we just keep it as is?