swh.loader.package.archive.loader module#

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

Bases: BasePackageInfo

Method generated by attrs for class ArchivePackageInfo.

length#

Size of the archive file

time#

Timestamp of the archive file on the server

MANIFEST_FORMAT: Template | None = <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: Template | None = 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: str | None = 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).

Parameters:
  • 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.

Raises:

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

Returns:

Sequence of published versions

get_default_version() str[source]#

Retrieve the latest release version if any.

Returns:

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.

Parameters:

version – Package version

Returns:

(branch name, package metadata)

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

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

Parameters:
  • p_info – Package information

  • uncompressed_path – Artifact uncompressed path on disk

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

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