swh.loader.package.utils module

swh.loader.package.utils.api_info(url: str) → Dict[source]
Basic api client to retrieve information on project. This deals with

fetching json metadata about pypi projects.


url (str) – The api url (e.g PyPI, npm, etc…)


ValueError in case of query failures (for some reasons – 404, …)


The associated response’s information dict

swh.loader.package.utils.download(url: str, dest: str, hashes: Dict = {}, filename: Optional[str] = None, auth: Optional[Tuple[str, str]] = None) → Tuple[str, Dict][source]
Download a remote tarball from url, uncompresses and computes swh hashes

on it.

  • url – Artifact uri to fetch, uncompress and hash

  • dest – Directory to write the archive to

  • hashes – Dict of expected hashes (key is the hash algo) for the artifact to download (those hashes are expected to be hex string)

  • auth – Optional tuple of login/password (for http authentication service, e.g. deposit)

  • ValueError in case of any error when fetching/computing (length,

  • checksums mismatched...)


Tuple of local (filepath, hashes of filepath)

swh.loader.package.utils.release_name(version: str, filename: Optional[str] = None) → str[source]
swh.loader.package.utils.artifact_identity(d: Mapping[str, Any], id_keys: Sequence[str]) → List[Any][source]
Compute the primary key for a dict using the id_keys as primary key


  • d – A dict entry to compute the primary key on

  • id_keys – Sequence of keys to use as primary key


The identity for that dict entry