A Python SHACL Compact Syntax parser and serializer.
Project description
Python SHACL Compact Syntax Parser
A Python SHACL Compact Syntax parser and serializer based on the specification at https://w3c.github.io/shacl/shacl-compact-syntax/.
All tests defined in github.com/w3c/data-shapes/shacl-compact-syntax/tests are passing.
Quickstart
Installation.
pip install shaclc
Usage.
from shaclc import shaclc_to_graph
shaclc_str = """
BASE <http://example.com/ns>
IMPORTS <http://example.com/person-ontology>
PREFIX ex: <http://example.com/ns#>
shape ex:PersonShape -> ex:Person {
ex:ssn xsd:string [0..1] pattern="^\\d{3}-\\d{2}-\\d{4}$" .
}
"""
graph = shaclc_to_graph(shaclc_str)
graph.print(format="longturtle")
Output.
BASE <http://example.com/ns>
PREFIX ex: <http://example.com/ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
<>
a owl:Ontology ;
owl:imports <http://example.com/person-ontology> ;
.
<#PersonShape>
a sh:NodeShape ;
sh:property
[
sh:datatype xsd:string ;
sh:maxCount 1 ;
sh:path <#ssn> ;
sh:pattern "^\\d{3}-\\d{2}-\\d{4}$" ;
] ;
sh:targetClass <#Person> ;
.
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
shaclc-0.1.0.tar.gz
(8.3 kB
view details)
Built Distribution
File details
Details for the file shaclc-0.1.0.tar.gz
.
File metadata
- Download URL: shaclc-0.1.0.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.13 Linux/6.2.0-1018-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88c4475684c8855d65e3a792e42ed86d50d7fc25a3c69f970a4e8493549ee145 |
|
MD5 | 7e232ca7d9f487007c4abfd39953eb13 |
|
BLAKE2b-256 | 12d124cd02a2b952586f1e12837cf8f6c47ea92d61ec4011f7cc8963842d1ba7 |
Provenance
File details
Details for the file shaclc-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: shaclc-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.13 Linux/6.2.0-1018-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06b38fdd848c01102b316cfda717350824e40a65ee30f75735d82bf6f495d5e1 |
|
MD5 | 7620da50e84469d3eadeed02cfa81938 |
|
BLAKE2b-256 | 89489c372754124e3d5f0ecb8c54cad2c309515e088c466cd97fd8d5afb93ca8 |