shaclc


Nameshaclc JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/edmondchuc/shaclc
SummaryA Python SHACL Compact Syntax parser and serializer.
upload_time2024-01-12 16:27:13
maintainer
docs_urlNone
authorEdmond Chuc
requires_python>=3.10
licenseMIT
keywords rdf shacl python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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](https://github.com/w3c/data-shapes/tree/gh-pages/shacl-compact-syntax/tests) are passing.

## Browser playground

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

## Quickstart

Installation.

```shell
pip install shaclc
```

Usage.

```python
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> ;
.
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/edmondchuc/shaclc",
    "name": "shaclc",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "RDF,SHACL,Python",
    "author": "Edmond Chuc",
    "author_email": "edmond.chuc@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/f4/0c/b89cfb529076ba9b94f7ba0453358bf9fd03def4c38d79f2d438d4b80c5c/shaclc-0.1.1.tar.gz",
    "platform": null,
    "description": "# Python SHACL Compact Syntax Parser\n\nA Python SHACL Compact Syntax parser and serializer based on the specification at https://w3c.github.io/shacl/shacl-compact-syntax/.\n\nAll tests defined in [github.com/w3c/data-shapes/shacl-compact-syntax/tests](https://github.com/w3c/data-shapes/tree/gh-pages/shacl-compact-syntax/tests) are passing.\n\n## Browser playground\n\nPlay around with the implementation in your browser at https://edmondchuc.github.io/shaclc/.\n\n## Quickstart\n\nInstallation.\n\n```shell\npip install shaclc\n```\n\nUsage.\n\n```python\nfrom shaclc import shaclc_to_graph\n\nshaclc_str = \"\"\"\nBASE <http://example.com/ns>\n\nIMPORTS <http://example.com/person-ontology>\n\nPREFIX ex: <http://example.com/ns#>\n\nshape ex:PersonShape -> ex:Person {\n\tex:ssn xsd:string [0..1] pattern=\"^\\\\d{3}-\\\\d{2}-\\\\d{4}$\" .\n}\n\"\"\"\n\ngraph = shaclc_to_graph(shaclc_str)\n\ngraph.print(format=\"longturtle\")\n```\n\nOutput.\n\n```\nBASE <http://example.com/ns>\nPREFIX ex: <http://example.com/ns#>\nPREFIX owl: <http://www.w3.org/2002/07/owl#>\nPREFIX sh: <http://www.w3.org/ns/shacl#>\nPREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n\n<>\n    a owl:Ontology ;\n    owl:imports <http://example.com/person-ontology> ;\n.\n\n<#PersonShape>\n    a sh:NodeShape ;\n    sh:property\n        [\n            sh:datatype xsd:string ;\n            sh:maxCount 1 ;\n            sh:path <#ssn> ;\n            sh:pattern \"^\\\\d{3}-\\\\d{2}-\\\\d{4}$\" ;\n        ] ;\n    sh:targetClass <#Person> ;\n.\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python SHACL Compact Syntax parser and serializer.",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/edmondchuc/shaclc",
        "Repository": "https://github.com/edmondchuc/shaclc"
    },
    "split_keywords": [
        "rdf",
        "shacl",
        "python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2f7738862f0a6ed45727e1eca775ec5a2c232dc0d664fa9d8cee3b7797a95314",
                "md5": "9626b1dcf3a3830c814bb321a3e9a12e",
                "sha256": "48240b97097214a63ba99408f02f178cd65a52aac6912a49fc9e2cd6f7bf5314"
            },
            "downloads": -1,
            "filename": "shaclc-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9626b1dcf3a3830c814bb321a3e9a12e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 8642,
            "upload_time": "2024-01-12T16:27:12",
            "upload_time_iso_8601": "2024-01-12T16:27:12.511470Z",
            "url": "https://files.pythonhosted.org/packages/2f/77/38862f0a6ed45727e1eca775ec5a2c232dc0d664fa9d8cee3b7797a95314/shaclc-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f40cb89cfb529076ba9b94f7ba0453358bf9fd03def4c38d79f2d438d4b80c5c",
                "md5": "5475157b5b907acd86fbf03039a0e408",
                "sha256": "84f0f3813d488dca2c814e3d5748a97653514371d757b251d413635c05e924ae"
            },
            "downloads": -1,
            "filename": "shaclc-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "5475157b5b907acd86fbf03039a0e408",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 8398,
            "upload_time": "2024-01-12T16:27:13",
            "upload_time_iso_8601": "2024-01-12T16:27:13.872544Z",
            "url": "https://files.pythonhosted.org/packages/f4/0c/b89cfb529076ba9b94f7ba0453358bf9fd03def4c38d79f2d438d4b80c5c/shaclc-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-12 16:27:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "edmondchuc",
    "github_project": "shaclc",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "shaclc"
}
        
Elapsed time: 0.44928s