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
rdflibDatasetobjects - 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
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 rdfcanon-1.0.0.tar.gz.
File metadata
- Download URL: rdfcanon-1.0.0.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
adc75fa9bd936761d2a5de4a0299ab658446454437ecfb4886c6bf55ee9ddaa1
|
|
| MD5 |
57da0061ceb99e4ea0113685945cfe2a
|
|
| BLAKE2b-256 |
8968b3036862e7292684607c9ff5e8d11c09d4a34a7b792870d19ed4035bc7ab
|
File details
Details for the file rdfcanon-1.0.0-py3-none-any.whl.
File metadata
- Download URL: rdfcanon-1.0.0-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
100a48239044f9cc5342e1d16ccfb806d47bb1bb5cc577ebefd20a81117bf14c
|
|
| MD5 |
7dbd81aaede290b6ece8a06d123a7113
|
|
| BLAKE2b-256 |
df9b31d254f4ebaf166d055deb921211f9a2c5b9a5d63085f7c03f1501c64acd
|