swh.loader.package.archive.loader module#

class swh.loader.package.archive.loader.ArchivePackageInfo(url: str, filename: Optional[str], version: str, raw_info: Dict[str, Any], length: int, time: Union[str, datetime], *, directory_extrinsic_metadata: List[RawExtrinsicMetadataCore] = [], checksums: Dict[str, str] = {})[source]#

Bases: BasePackageInfo

Method generated by attrs for class ArchivePackageInfo.


Size of the archive file


Timestamp of the archive file on the server

MANIFEST_FORMAT: Optional[Template] = <string.Template object>#

If not None, used by the default extid() implementation to format a manifest, before hashing it to produce an ExtID.

extid(manifest_format: Optional[Template] = None) Tuple[str, int, bytes][source]#

Returns a unique intrinsic identifier of this package info

manifest_format allows overriding the class’ default MANIFEST_FORMAT

classmethod from_metadata(a_metadata: Dict[str, Any]) ArchivePackageInfo[source]#
class swh.loader.package.archive.loader.ArchiveLoader(storage: StorageInterface, url: str, artifacts: Sequence[Dict[str, Any]], extid_manifest_format: Optional[str] = None, snapshot_append: bool = False, **kwargs: Any)[source]#

Bases: PackageLoader[ArchivePackageInfo]

Load archive origin’s artifact files into swh archive

Loader’s constructor. This raises exception if the minimal required

configuration is missing (cf. fn:check method).

  • storage – Storage instance

  • url – Origin url to load data from

visit_type: str = 'tar'#
get_versions() Sequence[str][source]#

Return the list of all published package versions.


classswh.loader.exception.NotFound error when failing to read the published package versions.


Sequence of published versions

get_default_version() str[source]#

Retrieve the latest release version if any.


Latest version

get_package_info(version: str) Iterator[Tuple[str, ArchivePackageInfo]][source]#
Given a release version of a package, retrieve the associated

package information for such version.


version – Package version


(branch name, package metadata)

new_packageinfo_to_extid(p_info: ArchivePackageInfo) Optional[Tuple[str, int, bytes]][source]#
build_release(p_info: ArchivePackageInfo, uncompressed_path: str, directory: bytes) Optional[Release][source]#

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

  • p_info – Package information

  • uncompressed_path – Artifact uncompressed path on disk

origin: Origin#
loaded_snapshot_id: Optional[bytes]#
parent_origins: Optional[List[Origin]]#

If the given origin is a “forge fork” (ie. created with the “Fork” button of GitHub-like forges), build_extrinsic_origin_metadata() sets this to a list of origins it was forked from; closest parent first.

extra_branches() Dict[bytes, Mapping[str, Any]][source]#

Return an extra dict of branches that are used to update the set of branches.