Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/pypi/loader.py
Show All 21 Lines | from swh.model.model import ( | ||||
MetadataAuthority, | MetadataAuthority, | ||||
MetadataAuthorityType, | MetadataAuthorityType, | ||||
Person, | Person, | ||||
Revision, | Revision, | ||||
RevisionType, | RevisionType, | ||||
Sha1Git, | Sha1Git, | ||||
TimestampWithTimezone, | TimestampWithTimezone, | ||||
) | ) | ||||
from swh.storage.interface import StorageInterface | |||||
logger = logging.getLogger(__name__) | logger = logging.getLogger(__name__) | ||||
@attr.s | @attr.s | ||||
class PyPIPackageInfo(BasePackageInfo): | class PyPIPackageInfo(BasePackageInfo): | ||||
raw_info = attr.ib(type=Dict[str, Any]) | raw_info = attr.ib(type=Dict[str, Any]) | ||||
Show All 20 Lines | |||||
class PyPILoader(PackageLoader[PyPIPackageInfo]): | class PyPILoader(PackageLoader[PyPIPackageInfo]): | ||||
"""Load pypi origin's artifact releases into swh archive. | """Load pypi origin's artifact releases into swh archive. | ||||
""" | """ | ||||
visit_type = "pypi" | visit_type = "pypi" | ||||
def __init__(self, url): | def __init__( | ||||
super().__init__(url=url) | self, | ||||
storage: StorageInterface, | |||||
url: str, | |||||
max_content_size: Optional[int] = None, | |||||
): | |||||
super().__init__(storage=storage, url=url, max_content_size=max_content_size) | |||||
self.provider_url = pypi_api_url(self.url) | self.provider_url = pypi_api_url(self.url) | ||||
@cached_method | @cached_method | ||||
def _raw_info(self) -> bytes: | def _raw_info(self) -> bytes: | ||||
return api_info(self.provider_url) | return api_info(self.provider_url) | ||||
@cached_method | @cached_method | ||||
def info(self) -> Dict: | def info(self) -> Dict: | ||||
▲ Show 20 Lines • Show All 209 Lines • Show Last 20 Lines |