Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/debian/loader.py
Show First 20 Lines • Show All 172 Lines • ▼ Show 20 Lines | def get_versions(self) -> Sequence[str]: | ||||
""" | """ | ||||
return list(self.packages.keys()) | return list(self.packages.keys()) | ||||
def get_package_info(self, version: str) -> Iterator[Tuple[str, DebianPackageInfo]]: | def get_package_info(self, version: str) -> Iterator[Tuple[str, DebianPackageInfo]]: | ||||
meta = self.packages[version] | meta = self.packages[version] | ||||
p_info = DebianPackageInfo.from_metadata(meta, url=self.url) | p_info = DebianPackageInfo.from_metadata(meta, url=self.url) | ||||
yield release_name(version), p_info | yield release_name(version), p_info | ||||
def known_artifact_to_extid(self, known_artifact: Dict) -> Optional[PartialExtID]: | |||||
sha256 = _artifact_to_dsc_sha256(known_artifact, url=self.url) | |||||
if sha256 is None: | |||||
return None | |||||
return (EXTID_TYPE, hash_to_bytes(sha256)) | |||||
def resolve_revision_from_artifacts( | |||||
self, known_artifacts: Dict, p_info: DebianPackageInfo, | |||||
) -> Optional[bytes]: | |||||
try: | |||||
return super().resolve_revision_from_artifacts(known_artifacts, p_info) | |||||
except DscCountError: | |||||
# known_artifacts are corrupted, ignore them instead of crashing | |||||
return None | |||||
def download_package( | def download_package( | ||||
self, p_info: DebianPackageInfo, tmpdir: str | self, p_info: DebianPackageInfo, tmpdir: str | ||||
) -> List[Tuple[str, Mapping]]: | ) -> List[Tuple[str, Mapping]]: | ||||
"""Contrary to other package loaders (1 package, 1 artifact), | """Contrary to other package loaders (1 package, 1 artifact), | ||||
`p_info.files` represents the package's datafiles set to fetch: | `p_info.files` represents the package's datafiles set to fetch: | ||||
- <package-version>.orig.tar.gz | - <package-version>.orig.tar.gz | ||||
- <package-version>.dsc | - <package-version>.dsc | ||||
- <package-version>.diff.gz | - <package-version>.diff.gz | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | ) -> Optional[Revision]: | ||||
message=msg.encode("utf-8"), | message=msg.encode("utf-8"), | ||||
author=author, | author=author, | ||||
date=date, | date=date, | ||||
committer=author, | committer=author, | ||||
committer_date=date, | committer_date=date, | ||||
parents=(), | parents=(), | ||||
directory=directory, | directory=directory, | ||||
synthetic=True, | synthetic=True, | ||||
metadata={ | |||||
"intrinsic": {"tool": "dsc", "raw": attr.asdict(intrinsic_metadata),}, | |||||
"extrinsic": { | |||||
"provider": dsc_url, | |||||
"when": self.visit_date.isoformat(), | |||||
"raw": p_info.raw_info, | |||||
}, | |||||
}, | |||||
) | ) | ||||
def _artifact_to_dsc_sha256(known_artifacts: Dict, url: str) -> Optional[str]: | def _artifact_to_dsc_sha256(known_artifacts: Dict, url: str) -> Optional[str]: | ||||
extrinsic = known_artifacts.get("extrinsic") | extrinsic = known_artifacts.get("extrinsic") | ||||
if not extrinsic: | if not extrinsic: | ||||
return None | return None | ||||
▲ Show 20 Lines • Show All 230 Lines • Show Last 20 Lines |