swh.loader.package.cran.loader module

class swh.loader.package.cran.loader.CRANLoader(url: str, artifacts: List[Dict])[source]

Bases: swh.loader.package.loader.PackageLoader

visit_type = 'cran'
get_versions() → List[str][source]

Return the list of all 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) → Generator[Tuple[str, Dict[str, Any]], None, None][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)

resolve_revision_from(known_artifacts: Mapping[bytes, Mapping], artifact_metadata: Mapping[str, Any]) → Optional[bytes][source]

Given known_artifacts per revision, try to determine the revision for artifact_metadata

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.

Parameters
  • a_metadata – Artifact metadata

  • uncompressed_path – Artifact uncompressed path on disk

Returns

SWH data dict

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: Optional[str]) → Optional[swh.model.model.TimestampWithTimezone][source]

Parse a date into a datetime