Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/deposit/loader.py
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | ) -> List[Tuple[str, Mapping]]: | ||||
"""Override to allow use of the dedicated deposit client | """Override to allow use of the dedicated deposit client | ||||
""" | """ | ||||
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_revision( | def build_revision( | ||||
self, a_metadata: Dict, uncompressed_path: str, directory: Sha1Git | self, a_metadata: Dict, uncompressed_path: str, directory: Sha1Git | ||||
) -> Optional[Revision]: | ) -> Optional[Revision]: | ||||
# FIXME: the deposit read api should no longer need to build the revision entry | depo = a_metadata.pop("deposit") | ||||
# as this would avoid unnecessary indirection. This would also align with what | |||||
# other package loaders do | |||||
revision_data = a_metadata.pop("revision") | |||||
# 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 | ||||
# revision. | # revision. | ||||
# date: codemeta:dateCreated if any, deposit completed_date otherwise | # date: codemeta:dateCreated if any, deposit completed_date otherwise | ||||
date = TimestampWithTimezone.from_dict(revision_data["date"]) | date = TimestampWithTimezone.from_dict(depo["author_date"]) | ||||
# commit_date: codemeta:datePublished if any, deposit completed_date otherwise | # commit_date: codemeta:datePublished if any, deposit completed_date otherwise | ||||
commit_date = TimestampWithTimezone.from_dict(revision_data["committer_date"]) | commit_date = TimestampWithTimezone.from_dict(depo["committer_date"]) | ||||
client, id, collection = [depo[k] for k in ["client", "id", "collection"]] | |||||
vlorentz: why this instead of `a_metadata["revision"]["message"]`? | |||||
Done Inline ActionsIt's no longer part of the a_metadata any more (see D3047 ;) ardumont: It's no longer part of the a_metadata any more (see D3047 ;) | |||||
message = f"{client}: Deposit {id} in collection {collection}".encode("utf-8") | |||||
author = parse_author(depo["author"]) | |||||
committer = parse_author(depo["committer"]) | |||||
return Revision( | return Revision( | ||||
type=RevisionType.TAR, | type=RevisionType.TAR, | ||||
message=revision_data["message"].encode("utf-8"), | message=message, | ||||
author=parse_author(revision_data["author"]), | author=author, | ||||
date=date, | date=date, | ||||
committer=parse_author(revision_data["committer"]), | committer=committer, | ||||
Not Done Inline ActionsHere the author and committer is the same. moranegg: Here the author and committer is the same.
Which is what we have done with HAL. but we should… | |||||
Done Inline ActionsSo that means we should update the other diff with both author and committer. author, publisher, author_date, publisher_date or something. ardumont: So that means we should update the other diff with both author and committer.
Tell me if we… | |||||
Done Inline ActionsDiff updated. Added a new entry "committer". ardumont: Diff updated. Added a new entry "committer". | |||||
Not Done Inline Actionsthat's good. moranegg: that's good.
no need for more "metada" like:-) | |||||
committer_date=commit_date, | committer_date=commit_date, | ||||
parents=[hash_to_bytes(p) for p in revision_data.get("parents", [])], | parents=[hash_to_bytes(p) for p in depo["revision_parents"]], | ||||
directory=directory, | directory=directory, | ||||
synthetic=True, | synthetic=True, | ||||
metadata={ | metadata={ | ||||
"extrinsic": { | "extrinsic": { | ||||
"provider": self.client.metadata_url(self.deposit_id), | "provider": self.client.metadata_url(self.deposit_id), | ||||
"when": self.visit_date.isoformat(), | "when": self.visit_date.isoformat(), | ||||
"raw": a_metadata, | "raw": a_metadata, | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 157 Lines • Show Last 20 Lines |
why this instead of a_metadata["revision"]["message"]?