swh.loader.package.cpan.loader module#

class swh.loader.package.cpan.loader.CpanPackageInfo(url: str, filename: str | None, name: str, version: str, last_modified: datetime, author: Person, sha256sum: str, *, directory_extrinsic_metadata: List[RawExtrinsicMetadataCore] = [], checksums: Dict[str, str] = {})[source]#

Bases: BasePackageInfo

Method generated by attrs for class CpanPackageInfo.

EXTID_TYPE: str = 'cpan-manifest-sha256'#
EXTID_VERSION: int = 0#
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.

name#

Name of the package

version#

Current version

last_modified#

File last modified date as release date.

author#

Author

sha256sum#

sha256 checksum of package tarball

class swh.loader.package.cpan.loader.CpanLoader(storage: StorageInterface, url: str, api_base_url: str, artifacts: List[Dict[str, Any]], module_metadata: List[Dict[str, Any]], **kwargs)[source]#

Bases: PackageLoader[CpanPackageInfo]

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 = 'cpan'#
EXTRINSIC_METADATA_URL_PATTERN = '{api_base_url}/release/{author}/{release_name}'#
get_metadata_authority()[source]#

For package loaders that get extrinsic metadata, returns the authority the metadata are coming from.

get_versions() Sequence[str][source]#

Get all released versions of a Perl package

Returns:

A sequence of versions

Example:

["0.1.1", "0.10.2"]

get_default_version() str[source]#

Get the newest release version of a Perl package

Returns:

A string representing a version

Example:

"0.10.2"

get_package_info(version: str) Iterator[Tuple[str, CpanPackageInfo]][source]#

Get release name and package information from version

Parameters:

version – Package version (e.g: “0.1.0”)

Returns:

Iterator of tuple (release_name, p_info)

build_release(p_info: CpanPackageInfo, 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