swh.loader.package.cran.loader module#

class swh.loader.package.cran.loader.CRANPackageInfo(url: str, filename: str | None, version: str, raw_info: Dict[str, Any], name: str, *, directory_extrinsic_metadata: List[RawExtrinsicMetadataCore] = [], checksums: Dict[str, str] = {})[source]#

Bases: BasePackageInfo

Method generated by attrs for class CRANPackageInfo.

EXTID_TYPE: str = 'cran-sha256'#
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.

classmethod from_metadata(a_metadata: Dict[str, Any]) CRANPackageInfo[source]#
class swh.loader.package.cran.loader.CRANLoader(storage: StorageInterface, url: str, artifacts: List[Dict], **kwargs: Any)[source]#

Bases: PackageLoader[CRANPackageInfo]

Loader constructor.

Parameters:
  • url – Origin url to retrieve cran artifact(s) from

  • artifacts – List of associated artifact for the origin url

visit_type: str = 'cran'#
get_versions() List[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, CRANPackageInfo]][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)

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

swh.loader.package.cran.loader.parse_debian_control(filepath: str) Dict[str, Any][source]#

Parse debian control at filepath

swh.loader.package.cran.loader.extract_intrinsic_metadata(dir_path: str) Dict[str, Any][source]#
Given an uncompressed path holding the DESCRIPTION file, returns a

DESCRIPTION parsed structure as a dict.

Cran origins describes their intrinsic metadata within a DESCRIPTION file at the root tree of a tarball. This DESCRIPTION uses a simple file format called DCF, the Debian control format.

The release artifact contains at their root one folder. For example: $ tar tvf zprint-0.0.6.tar.gz drwxr-xr-x root/root 0 2018-08-22 11:01 zprint-0.0.6/ …

Parameters:

dir_path (str) – Path to the uncompressed directory representing a release artifact from pypi.

Returns:

the DESCRIPTION parsed structure as a dict (or empty dict if missing)

swh.loader.package.cran.loader.parse_date(date: str | None) TimestampWithTimezone | None[source]#

Parse a date into a datetime