Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/cpan/loader.py
Show First 20 Lines • Show All 160 Lines • ▼ Show 20 Lines | ) -> Optional[Release]: | ||||
Path(uncompressed_path) / f"{p_info.name}-{p_info.version}" | Path(uncompressed_path) / f"{p_info.name}-{p_info.version}" | ||||
) | ) | ||||
name: str = intrinsic_metadata["name"] | name: str = intrinsic_metadata["name"] | ||||
assert name == p_info.name | assert name == p_info.name | ||||
version: str = str(intrinsic_metadata["version"]) | version: str = str(intrinsic_metadata["version"]) | ||||
assert version == p_info.version | assert version == p_info.version | ||||
description = intrinsic_metadata["abstract"] | |||||
# author data from http endpoint are less complete than from META | # author data from http endpoint are less complete than from META | ||||
if "author" in intrinsic_metadata: | if "author" in intrinsic_metadata: | ||||
author_data = intrinsic_metadata["author"] | author_data = intrinsic_metadata["author"] | ||||
if type(author_data) is list: | if type(author_data) is list: | ||||
author = author_data[0] | author = author_data[0] | ||||
else: | else: | ||||
author = author_data | author = author_data | ||||
author = Person.from_fullname(author.encode()) | author = Person.from_fullname(author.encode()) | ||||
else: | else: | ||||
author = p_info.author | author = p_info.author | ||||
message = ( | message = ( | ||||
f"Synthetic release for Perl source package {name} " | f"Synthetic release for Perl source package {name} version {version}\n" | ||||
f"version {version}\n\n" | |||||
f"{description}\n" | |||||
) | ) | ||||
return Release( | return Release( | ||||
name=version.encode(), | name=version.encode(), | ||||
author=author, | author=author, | ||||
date=TimestampWithTimezone.from_datetime(p_info.last_modified), | date=TimestampWithTimezone.from_datetime(p_info.last_modified), | ||||
message=message.encode(), | message=message.encode(), | ||||
target_type=ObjectType.DIRECTORY, | target_type=ObjectType.DIRECTORY, | ||||
target=directory, | target=directory, | ||||
synthetic=True, | synthetic=True, | ||||
) | ) |