swh.loader.package.debian.loader module

class swh.loader.package.debian.loader.DebianLoader(url: str, date: str, packages: Mapping[str, Any])[source]

Bases: swh.loader.package.loader.PackageLoader

Load debian origins into swh archive.

visit_type = 'deb'
get_versions() → Sequence[str][source]

Returns the keys of the packages input (e.g. stretch/contrib/0.7.2-3, etc…)

get_package_info(version: str) → Generator[Tuple[str, Mapping[str, Any]], None, None][source]
Given a release version of a package, retrieve the associated

package information for such version.


version – Package version


(branch name, package metadata)

resolve_revision_from(known_package_artifacts: Mapping, artifact_metadata: Mapping) → Optional[bytes][source]

Resolve the revision from a snapshot and an artifact metadata dict.

If the artifact has already been downloaded, this will return the existing revision targeting that uncompressed artifact directory. Otherwise, this returns None.

  • snapshot – Snapshot

  • artifact_metadata – Information dict


None or revision identifier

download_package(p_info: Mapping[str, Any], tmpdir: str) → List[Tuple[str, Mapping]][source]

Contrary to other package loaders (1 package, 1 artifact), a_metadata represents the package’s datafiles set to fetch: - <package-version>.orig.tar.gz - <package-version>.dsc - <package-version>.diff.gz

This is delegated to the download_package function.

uncompress(dl_artifacts: List[Tuple[str, Mapping[str, Any]]], dest: str) → str[source]

Uncompress the artifact(s) in the destination folder dest.

Optionally, this could need to use the p_info dict for some more information (debian).

build_revision(a_metadata: Mapping[str, Any], uncompressed_path: str, directory: bytes) → Optional[swh.model.model.Revision][source]

Build the revision from the archive metadata (extrinsic artifact metadata) and the intrinsic metadata.

  • a_metadata – Artifact metadata

  • uncompressed_path – Artifact uncompressed path on disk


SWH data dict

swh.loader.package.debian.loader.resolve_revision_from(known_package_artifacts: Mapping, artifact_metadata: Mapping) → Optional[bytes][source]

Given known package artifacts (resolved from the snapshot of previous visit) and the new artifact to fetch, try to solve the corresponding revision.

swh.loader.package.debian.loader.uid_to_person(uid: str) → Mapping[str, str][source]

Convert an uid to a person suitable for insertion.


uid – an uid of the form “Name <email@ddress>”


  • name: the name associated to the uid

  • email: the mail associated to the uid

  • fullname: the actual uid input

Return type

a dictionary with the following keys

swh.loader.package.debian.loader.prepare_person(person: Mapping[str, str])swh.model.model.Person[source]

Prepare person for swh serialization…


person dict (A) –


A person ready for storage

swh.loader.package.debian.loader.download_package(package: Mapping[str, Any], tmpdir: Any) → Mapping[str, Any][source]

Fetch a source package in a temporary directory and check the checksums for all files.

  • package – Dict defining the set of files representing a debian package

  • tmpdir – Where to download and extract the files to ingest


Dict of swh hashes per filename key

swh.loader.package.debian.loader.dsc_information(package: Mapping[str, Any]) → Tuple[Optional[str], Optional[str]][source]

Retrieve dsc information from a package.


package – Package metadata information


Tuple of dsc file’s uri, dsc’s full disk path

swh.loader.package.debian.loader.extract_package(dl_artifacts: List[Tuple[str, Mapping]], dest: str) → str[source]

Extract a Debian source package to a given directory.

Note that after extraction the target directory will be the root of the extracted package, rather than containing it.

  • package – package information dictionary

  • dest – directory where the package files are stored


Package extraction directory

swh.loader.package.debian.loader.get_package_metadata(package: Mapping[str, Any], dsc_path: str, extracted_path: str) → Mapping[str, Any][source]

Get the package metadata from the source package at dsc_path, extracted in extracted_path.

  • package – the package dict (with a dsc_path key)

  • dsc_path – path to the package’s dsc file

  • extracted_path – the path where the package got extracted


a dictionary with the following keys:

  • history: list of (package_name, package_version) tuples parsed from the package changelog

Return type