Skip to main content

A library for mapping a data catalog to rdf

Project description

datacatalogtordf

Tests codecov PyPI Read the Docs

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:

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datacatalogtordf-4.1.1.tar.gz (26.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datacatalogtordf-4.1.1-py3-none-any.whl (41.3 kB view details)

Uploaded Python 3

File details

Details for the file datacatalogtordf-4.1.1.tar.gz.

File metadata

  • Download URL: datacatalogtordf-4.1.1.tar.gz
  • Upload date:
  • Size: 26.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.12.13 Linux/6.17.0-1013-azure

File hashes

Hashes for datacatalogtordf-4.1.1.tar.gz
Algorithm Hash digest
SHA256 0c4bb369dbff97313413bc627a05914380ff577f20b8d93b39fc53d9a9eab568
MD5 f2b3dca8f573cd0421a24005907e32ea
BLAKE2b-256 81d77f2de3fb55f1a9b1fad63b5d29c4076e4d05e904245eb5026c0ddb0926e9

See more details on using hashes here.

File details

Details for the file datacatalogtordf-4.1.1-py3-none-any.whl.

File metadata

  • Download URL: datacatalogtordf-4.1.1-py3-none-any.whl
  • Upload date:
  • Size: 41.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.12.13 Linux/6.17.0-1013-azure

File hashes

Hashes for datacatalogtordf-4.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a8a05a0ce0b1e53a631523ad6ddcfe00ed7c53d2084d6c1e75d239190c8c15bb
MD5 46829cefe4a4bd2f2b7733c1cc4a6262
BLAKE2b-256 1b64a10f2356ae9fde058138260db42b59302210e5a87b34bc9930991eb122b9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page