swhid

OCaml library to work with Software Heritage identifiers
README

swhid is an OCaml library to work with persistent identifiers found in Software Heritage, also known as swhid. It provides:

  • a parser and a printer for swhid (Swhid_core.Object module)

  • functions to compute a swhid for a given object of any kind : content, directory, revision, release or snapshot (Swhid.Compute)

  • functions to query the swh API in order to get an URL from which you can download a given object (Swhid.Download)

Installation

swhid can be installed with opam:

opam install swhid

If you don't have opam, you can install it following the how to install opam guide.

If you can't or don't want to use opam, consult the opam file for build instructions.

Quickstart

let id = "swh:1:rev:db21f0afdb54c16b265754ca599869fda0ca4bfc"

let url =
  match Swhid_core.Object.of_string id with
  | Error e -> Error e
  | Ok id -> Swhid.Download.revision id

let () =
  match url with
  | Error e -> Format.eprintf "can't get download URL: `%s`@." e
  | Ok url ->
    Format.printf "you can download the revision at the URL: `%s`@." url

For more, have a look at the example folder, at the documentation or at the test suite.

About

Install
Published
21 Jun 2022
Sources
0.2.tar.gz
sha256=c766eabb38217946195f506ff570aa19fd0e3b81a5c210d7c15b3df4cd39d1f7
sha512=77dd69bded58920963dcbbde7d3e61b68e05e7a12e2a5eaf821ba1e5fe8d076dfe2695303d5bed182b075f333dffa9f6e8638bd89ede3db2bdeaf7098d613479
Dependencies
odoc
with-doc
bisect_ppx
with-test & >= "2.6" & dev
bos
>= "0.2.0"
ezcurl
>= "0.1"
jsonm
>= "1.0.1"
digestif
>= "1.0.0"
ocaml
>= "4.08"
dune
>= "2.8"
Reverse Dependencies