Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/nixguix/loader.py
Show All 28 Lines | |||||
from swh.storage.interface import StorageInterface | from swh.storage.interface import StorageInterface | ||||
logger = logging.getLogger(__name__) | logger = logging.getLogger(__name__) | ||||
EXTID_TYPE = "subresource-integrity" | EXTID_TYPE = "subresource-integrity" | ||||
"""The ExtID is an ASCII string, as defined by | """The ExtID is an ASCII string, as defined by | ||||
https://w3c.github.io/webappsec-subresource-integrity/""" | https://w3c.github.io/webappsec-subresource-integrity/""" | ||||
EXTID_VERSION = 0 | |||||
@attr.s | @attr.s | ||||
class NixGuixPackageInfo(BasePackageInfo): | class NixGuixPackageInfo(BasePackageInfo): | ||||
raw_info = attr.ib(type=Dict[str, Any]) | raw_info = attr.ib(type=Dict[str, Any]) | ||||
integrity = attr.ib(type=str) | integrity = attr.ib(type=str) | ||||
"""Hash of the archive, formatted as in the Subresource Integrity | """Hash of the archive, formatted as in the Subresource Integrity | ||||
specification.""" | specification.""" | ||||
@classmethod | @classmethod | ||||
def from_metadata( | def from_metadata( | ||||
cls, metadata: Dict[str, Any], version: str | cls, metadata: Dict[str, Any], version: str | ||||
) -> "NixGuixPackageInfo": | ) -> "NixGuixPackageInfo": | ||||
return cls( | return cls( | ||||
url=metadata["url"], | url=metadata["url"], | ||||
filename=None, | filename=None, | ||||
version=version, | version=version, | ||||
integrity=metadata["integrity"], | integrity=metadata["integrity"], | ||||
raw_info=metadata, | raw_info=metadata, | ||||
) | ) | ||||
def extid(self) -> PartialExtID: | def extid(self) -> PartialExtID: | ||||
return (EXTID_TYPE, self.integrity.encode("ascii")) | return (EXTID_TYPE, EXTID_VERSION, self.integrity.encode("ascii")) | ||||
class NixGuixLoader(PackageLoader[NixGuixPackageInfo]): | class NixGuixLoader(PackageLoader[NixGuixPackageInfo]): | ||||
"""Load sources from a sources.json file. This loader is used to load | """Load sources from a sources.json file. This loader is used to load | ||||
sources used by functional package manager (eg. Nix and Guix). | sources used by functional package manager (eg. Nix and Guix). | ||||
""" | """ | ||||
▲ Show 20 Lines • Show All 215 Lines • Show Last 20 Lines |