Giter Site home page Giter Site logo

ocamlpro / swhid Goto Github PK

View Code? Open in Web Editor NEW
2.0 5.0 2.0 319 KB

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

Home Page: https://ocamlpro.github.io/swhid/

License: ISC License

OCaml 100.00%
swhid ocaml persistent identifiers software

swhid's Introduction

swhid Actions Status coverage percentage

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

swhid's People

Contributors

radiopotin avatar zapashcanon avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

swhid's Issues

provide a CLI tool to compute SWHIDs easily

Would provide two sub-commands: swhid compute and swhid download. The compute sub-command should also let the user specify which kind of content is being worked on (directory, cnt, directory_deep etc.).

cc @kit-ty-kate

@rjbou I remember you wrote a one-liner to allow computing the swhid of a directory by calling directory_identifier_deep. For some reason I can't find it again, could you post it here ? It could be useful to others until I write the CLI tool.

proper error handling in the parser

you should raise an exception in the parser and catch it in Parser.ml (which is different of Menhir_parser.ml)

then, you'll change all functions in Parser to return a Result.t

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.