Metadata-Version: 2.4
Name: oais_utils
Version: 0.2.0
Summary: OAIS utilities
Home-page: https://gitlab.cern.ch/digitalmemory/utils
Author: CERN Digital Memory
Author-email: digitalmemory-support@cern.ch
License: GPLv3
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: AUTHORS
Requires-Dist: jsonschema==3.0.2
Requires-Dist: bagit==1.9.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: summary

# oais-utilities

[![PyPI version](https://badge.fury.io/py/oais-utils.svg)](https://pypi.org/project/oais-utils/)

 Utilities to work with the CERN OAIS artifacts, such as Submission Information Packages.

## Features

### Validate CERN SIP

Validates the folder in the given path according to the [CERN SIP specification](https://gitlab.cern.ch/digitalmemory/sip-spec), following these steps:

1. Verify directory structure
2. Validate the manifest file against the desired sip JSON schema. By default uses [sip-schema-v1.json](https://gitlab.cern.ch/digitalmemory/sip-spec/-/blob/main/versions/sip-schema-v1.json), also shipped in this package
3. Validate the folder as a BagIt package
	- file are allowed to be missing if the manifest specifies it's a "lightweight" SIP.
4. Checks if every content file mentioned in the manifest is actually present in the payload

Usage:

```python
from oais_utils import validate
validate("name_of_the_sip_folder")
```

### sip.json schemas

SIP manifest JSON schemas are also shipped and exposed with this package.

To get a python dictionary with the schema short name as keys and the parsed (as python object) schema as value for the corresponding schema name, run:

```python
import oais_utils
schemas = oais_utils.schemas

schemas.keys()
# ['v1']

schemas['v1']
# [...]
# (Returns the sip JSON schema "v1" as parsed python object)

schemas['v1']['$id']
# https://gitlab.cern.ch/digitalmemory/sip-spec/-/raw/main/versions/sip-schema-v1.json
```

## Install

Install from PyPi

```bash
pip install oais-utils
```

For development, you can clone this repository and then install it with the `-e` flag:

```bash
# Clone the repository
git clone https://gitlab.cern.ch/digitalmemory/oais-utils
cd oais-utils
pip install -e .
```

## Use

```python
from oais_utils import validate
validate("../bagit-create/bagitexport::cds::2751237")
```
