Skip to main content

No project description provided

Project description

RDF Canonicalisation

A Python library for RDF canonicalisation based on the W3C RDF Canonicalisation specification. This library allows you to deterministically canonicalise RDF datasets, making it easier to compare, sign, or hash RDF graphs.

Features

  • Deterministic RDF blank node canonicalisation
  • Support for multiple hash algorithms (e.g., sha256)
  • Integration with rdflib Dataset objects
  • Time-based ticker for controlling the maximum duration of the canonicalisation task.

Installation

pip install rdfcanon

Usage

from rdfcanon import RDFCanon, RDFCanonTimeTicker
from rdflib import BNode, Dataset, URIRef

# Create a sample RDF dataset
dataset = Dataset()
dataset.add(
    (
        BNode("e0"),
        URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
        URIRef("http://example.org/vocab#Foo"),
        BNode("g0")
    )
)

# Initialise RDF canonicalisation
rdf_canon = RDFCanon(
    hash_algorithm="sha256",
    dataset=dataset,
    ticker=RDFCanonTimeTicker(3000)  # Optional time ticker
)

# Canonicalise the RDF dataset
print(rdf_canon.canonize())

This will output:

_:c14n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/vocab#Foo> _:c14n0 .

Development

Build the library

python setup.py sdist bdist_wheel

Run tests

pytest

Contributing

Contributions are welcome! Please submit issues or pull requests via GitHub.

License

MIT License © 2025 YoucTagh

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

rdfcanon-0.1.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

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

rdfcanon-0.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file rdfcanon-0.1.0.tar.gz.

File metadata

  • Download URL: rdfcanon-0.1.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for rdfcanon-0.1.0.tar.gz
Algorithm Hash digest
SHA256 22c9c8cc17b713e1583d9dc6ee06bfe1974011cb85329217fbf4477ca8ea4604
MD5 0341591186cf61fa92db591f8c5fc135
BLAKE2b-256 07395c9420ebd94cd16057d90b1249b5c7bd5417405207eb443381871e5c4b6a

See more details on using hashes here.

File details

Details for the file rdfcanon-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rdfcanon-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for rdfcanon-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 39748129dc317b8ec24d0371e1be00624da68195246d0efab889bdded21755b0
MD5 749a1c4f06d6aa2a23e98164bbe4f749
BLAKE2b-256 a7d39f09e9fdbe6c836f24f4e08eba159cd3a77c2557d487c8c432ea00c489fa

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