Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/opam/loader.py
Show All 25 Lines | |||||
) | ) | ||||
from swh.storage.interface import StorageInterface | from swh.storage.interface import StorageInterface | ||||
@attr.s | @attr.s | ||||
class OpamPackageInfo(BasePackageInfo): | class OpamPackageInfo(BasePackageInfo): | ||||
author = attr.ib(type=Person) | author = attr.ib(type=Person) | ||||
committer = attr.ib(type=Person) | committer = attr.ib(type=Person) | ||||
version = attr.ib(type=str) | |||||
def opam_read( | def opam_read( | ||||
cmd: List[str], init_error_msg_if_any: Optional[str] = None | cmd: List[str], init_error_msg_if_any: Optional[str] = None | ||||
) -> Optional[str]: | ) -> Optional[str]: | ||||
"""This executes an opam command and returns the first line of the output. | """This executes an opam command and returns the first line of the output. | ||||
Args: | Args: | ||||
▲ Show 20 Lines • Show All 194 Lines • ▼ Show 20 Lines | def get_package_info(self, version: str) -> Iterator[Tuple[str, OpamPackageInfo]]: | ||||
directory_extrinsic_metadata=[ | directory_extrinsic_metadata=[ | ||||
RawExtrinsicMetadataCore( | RawExtrinsicMetadataCore( | ||||
metadata=metadata, format="opam-package-definition", | metadata=metadata, format="opam-package-definition", | ||||
) | ) | ||||
], | ], | ||||
) | ) | ||||
def build_release( | def build_release( | ||||
self, | self, p_info: OpamPackageInfo, uncompressed_path: str, directory: Sha1Git, | ||||
version: str, | |||||
p_info: OpamPackageInfo, | |||||
uncompressed_path: str, | |||||
directory: Sha1Git, | |||||
) -> Optional[Release]: | ) -> Optional[Release]: | ||||
return Release( | return Release( | ||||
name=version.encode(), | name=p_info.version.encode(), | ||||
author=p_info.author, | author=p_info.author, | ||||
message=str.encode(p_info.version), | message=str.encode(p_info.version), | ||||
date=None, | date=None, | ||||
target=directory, | target=directory, | ||||
target_type=ObjectType.DIRECTORY, | target_type=ObjectType.DIRECTORY, | ||||
synthetic=True, | synthetic=True, | ||||
) | ) |