Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/nixguix/loader.py
Show All 22 Lines | from swh.model.model import ( | ||||
MetadataAuthority, | MetadataAuthority, | ||||
MetadataAuthorityType, | MetadataAuthorityType, | ||||
Revision, | Revision, | ||||
RevisionType, | RevisionType, | ||||
Sha1Git, | Sha1Git, | ||||
Snapshot, | Snapshot, | ||||
TargetType, | TargetType, | ||||
) | ) | ||||
from swh.storage.interface import StorageInterface | |||||
logger = logging.getLogger(__name__) | logger = logging.getLogger(__name__) | ||||
@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]) | ||||
Show All 14 Lines | |||||
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). | ||||
""" | """ | ||||
visit_type = "nixguix" | visit_type = "nixguix" | ||||
def __init__(self, url): | def __init__( | ||||
super().__init__(url=url) | self, | ||||
storage: StorageInterface, | |||||
url: str, | |||||
unsupported_file_extensions: List[str] = [], | |||||
): | |||||
super().__init__(storage=storage, url=url) | |||||
self.provider_url = url | self.provider_url = url | ||||
self.unsupported_file_extensions = unsupported_file_extensions | |||||
# Note: this could be renamed get_artifacts in the PackageLoader | # Note: this could be renamed get_artifacts in the PackageLoader | ||||
# base class. | # base class. | ||||
@cached_method | @cached_method | ||||
def raw_sources(self): | def raw_sources(self): | ||||
return retrieve_sources(self.url) | return retrieve_sources(self.url) | ||||
@cached_method | @cached_method | ||||
def supported_sources(self): | def supported_sources(self): | ||||
raw_sources = self.raw_sources() | raw_sources = self.raw_sources() | ||||
unsupported_file_extensions = self.config.get("unsupported_file_extensions", []) | return clean_sources( | ||||
return clean_sources(parse_sources(raw_sources), unsupported_file_extensions) | parse_sources(raw_sources), self.unsupported_file_extensions | ||||
) | |||||
@cached_method | @cached_method | ||||
def integrity_by_url(self) -> Dict[str, Any]: | def integrity_by_url(self) -> Dict[str, Any]: | ||||
sources = self.supported_sources() | sources = self.supported_sources() | ||||
return {s["urls"][0]: s["integrity"] for s in sources["sources"]} | return {s["urls"][0]: s["integrity"] for s in sources["sources"]} | ||||
def get_versions(self) -> List[str]: | def get_versions(self) -> List[str]: | ||||
"""The first mirror of the mirror list is used as branch name in the | """The first mirror of the mirror list is used as branch name in the | ||||
▲ Show 20 Lines • Show All 244 Lines • Show Last 20 Lines |