swh.loader.package.cran.loader module

class swh.loader.package.cran.loader.CRANPackageInfo(url: str, filename: Optional[str], raw_info: Dict[str, Any], version: str, *, directory_extrinsic_metadata: List[swh.loader.package.loader.RawExtrinsicMetadataCore] = [])[source]

Bases: swh.loader.package.loader.BasePackageInfo

Method generated by attrs for class CRANPackageInfo.

EXTID_TYPE: str = 'cran-sha256'
MANIFEST_FORMAT: Optional[string.Template] = <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]) swh.loader.package.cran.loader.CRANPackageInfo[source]
class swh.loader.package.cran.loader.CRANLoader(storage: swh.storage.interface.StorageInterface, url: str, artifacts: List[Dict], max_content_size: Optional[int] = None)[source]

Bases: swh.loader.package.loader.PackageLoader[swh.loader.package.cran.loader.CRANPackageInfo]

Loader constructor.

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

  • artifacts – List of associated artifact for the origin url

visit_type: Optional[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, swh.loader.package.cran.loader.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_revision(p_info: swh.loader.package.cran.loader.CRANPackageInfo, 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
  • p_info – Package information

  • uncompressed_path – Artifact uncompressed path on disk

Returns

Revision object

visit_date: datetime.datetime
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