A library for mapping a data catalog to rdf
Project description
datacatalogtordf
A small Python library for mapping a data catalog to rdf
The library contains helper classes for the following dcat classes:
Other relevant classes are also supported, such as:
- Contact vcard:Kind
The library will map to the Norwegian Application Profile of the DCAT standard.
Usage
Install
% pip install datacatalogtordf
Getting started
from datacatalogtordf import Catalog, Dataset
# Create catalog object
catalog = Catalog()
catalog.identifier = "http://example.com/catalogs/1"
catalog.title = {"en": "A dataset catalog"}
catalog.publisher = "https://example.com/publishers/1"
# Create a dataset:
dataset = Dataset()
dataset.identifier = "http://example.com/datasets/1"
dataset.title = {"nb": "inntektsAPI", "en": "incomeAPI"}
#
# Add dataset to catalog:
catalog.datasets.append(dataset)
# get rdf representation in turtle (default)
rdf = catalog.to_rdf(format="turtle")
print(rdf.decode())
Will produce the following output:
@prefix dcat: <http://www.w3.org/ns/dcat#> .
@prefix dct: <http://purl.org/dc/terms/> .
<http://example.com/catalogs/1> a dcat:Catalog ;
dct:publisher <https://example.com/publishers/1> ;
dct:title "A dataset catalog"@en ;
dcat:dataset <http://example.com/datasets/1> .
<http://example.com/datasets/1> a dcat:Dataset ;
dct:title "incomeAPI"@en,
"inntekstAPI"@nb .
Development
Requirements
% pipx install poetry==1.1.13
% pipx install nox==2022.1.7
% pipx inject nox nox-poetry==0.9.0
Install developer tools
% git clone https://github.com/Informasjonsforvaltning/datacatalogtordf.git
% cd datacatalogtordf
% pyenv install 3.8.12
% pyenv install 3.9.10
% pyenv local 3.8.12 3.9.10
% poetry install
Run all sessions
% nox
Run all tests with coverage reporting
% nox -rs tests
Debugging
You can enter into Pdb by passing --pdb to pytest:
nox -rs tests -- --pdb
You can set breakpoints directly in code by using the function breakpoint().
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file datacatalogtordf-4.0.1.tar.gz.
File metadata
- Download URL: datacatalogtordf-4.0.1.tar.gz
- Upload date:
- Size: 26.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.19 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f6eb865931f34f45b72c97f91f1b798d65109089dd118f50c9671c3872611e1
|
|
| MD5 |
c5bd287bf2c6e6d1c488a504715ac208
|
|
| BLAKE2b-256 |
0d48f4db883505f099beaadb8fb87ad31579b8a349ce1daaf7927159aec7c567
|
File details
Details for the file datacatalogtordf-4.0.1-py3-none-any.whl.
File metadata
- Download URL: datacatalogtordf-4.0.1-py3-none-any.whl
- Upload date:
- Size: 41.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.19 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d4dfa9b915afcf5d1ad95a38791655fee3a269e2490d6ff95886b641213c49b
|
|
| MD5 |
dc2edbbb390af0e1a31d63821701a2d8
|
|
| BLAKE2b-256 |
2c502d31c54839a9d9bf4d94b8a7cf867f3ea31a5871c39efdac6d99c0adcd34
|