Skip to main content

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.

Browser playground

Play around with the implementation in your browser at https://edmondchuc.github.io/shaclc/.

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


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.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

shaclc-0.1.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file shaclc-0.1.1.tar.gz.

File metadata

  • Download URL: shaclc-0.1.1.tar.gz
  • Upload date:
  • Size: 8.4 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

Hashes for shaclc-0.1.1.tar.gz
Algorithm Hash digest
SHA256 84f0f3813d488dca2c814e3d5748a97653514371d757b251d413635c05e924ae
MD5 5475157b5b907acd86fbf03039a0e408
BLAKE2b-256 f40cb89cfb529076ba9b94f7ba0453358bf9fd03def4c38d79f2d438d4b80c5c

See more details on using hashes here.

Provenance

File details

Details for the file shaclc-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: shaclc-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.6 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

Hashes for shaclc-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 48240b97097214a63ba99408f02f178cd65a52aac6912a49fc9e2cd6f7bf5314
MD5 9626b1dcf3a3830c814bb321a3e9a12e
BLAKE2b-256 2f7738862f0a6ed45727e1eca775ec5a2c232dc0d664fa9d8cee3b7797a95314

See more details on using hashes here.

Provenance

Supported by

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