Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/nixguix/loader.py
Show First 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | ) -> Dict[Sha1Git, Optional[ImmutableDict[str, object]]]: | ||||
ret = {} | ret = {} | ||||
for revision in known_revisions: | for revision in known_revisions: | ||||
if not revision: # revision_get can return None | if not revision: # revision_get can return None | ||||
continue | continue | ||||
ret[revision.id] = revision.metadata | ret[revision.id] = revision.metadata | ||||
return ret | return ret | ||||
@staticmethod | |||||
def known_artifact_to_extid(known_artifact: Dict) -> Optional[PartialExtID]: | |||||
try: | |||||
value = known_artifact["extrinsic"]["raw"]["integrity"].encode("ascii") | |||||
except KeyError as e: | |||||
logger.exception( | |||||
"Unexpected metadata revision structure detected: %(context)s", | |||||
{"context": {"reason": str(e), "known_artifact": known_artifact,}}, | |||||
) | |||||
# metadata field for the revision is not as expected by the loader | |||||
# nixguix. We consider this not the right revision and continue checking | |||||
# the other revisions | |||||
return None | |||||
return (EXTID_TYPE, value) | |||||
def extra_branches(self) -> Dict[bytes, Mapping[str, Any]]: | def extra_branches(self) -> Dict[bytes, Mapping[str, Any]]: | ||||
"""We add a branch to the snapshot called 'evaluation' pointing to the | """We add a branch to the snapshot called 'evaluation' pointing to the | ||||
revision used to generate the sources.json file. This revision | revision used to generate the sources.json file. This revision | ||||
is specified in the sources.json file itself. For the nixpkgs | is specified in the sources.json file itself. For the nixpkgs | ||||
origin, this revision is coming from the | origin, this revision is coming from the | ||||
github.com/nixos/nixpkgs repository. | github.com/nixos/nixpkgs repository. | ||||
Note this repository is not loaded explicitly. So, this | Note this repository is not loaded explicitly. So, this | ||||
Show All 24 Lines | ) -> Optional[Revision]: | ||||
message=b"", | message=b"", | ||||
author=EMPTY_AUTHOR, | author=EMPTY_AUTHOR, | ||||
date=None, | date=None, | ||||
committer=EMPTY_AUTHOR, | committer=EMPTY_AUTHOR, | ||||
committer_date=None, | committer_date=None, | ||||
parents=(), | parents=(), | ||||
directory=directory, | directory=directory, | ||||
synthetic=True, | synthetic=True, | ||||
metadata={ | |||||
"extrinsic": { | |||||
"provider": self.provider_url, | |||||
"when": self.visit_date.isoformat(), | |||||
"raw": p_info.raw_info, | |||||
}, | |||||
}, | |||||
) | ) | ||||
def retrieve_sources(url: str) -> bytes: | def retrieve_sources(url: str) -> bytes: | ||||
"""Retrieve sources. Potentially raise NotFound error.""" | """Retrieve sources. Potentially raise NotFound error.""" | ||||
return api_info(url, allow_redirects=True) | return api_info(url, allow_redirects=True) | ||||
▲ Show 20 Lines • Show All 106 Lines • Show Last 20 Lines |