ShExJSG - Astract Syntax Tree Definition for the ShEx 2.0 language
Project description
This repository was originally developed by Harold Solbrig and was kindly contributed to the LinkML organization because of his retirement. All credit for the original development of this repository goes to him.
ShExJSG -
Python representation of the ShEx AST(ish) specification.
Use:
from ShExJSG import Schema, ShExJ
from PyShExC import ShExC
from pyjsg.jsglib.loader import is_valid
schema = Schema()
schema.start = ShExJ.Shape()
print(is_valid(schema))
print(schema._as_json_dumps())
print(str(ShExC(schema)))
True
{
"@context": "http://www.w3.org/ns/shex.jsonld",
"start": {
"type": "Shape"
},
"type": "Schema"
}
start= { }
ShExJ.jsg
This file is derived from the ShEx JSG specification. The differences are as follows:
labeledShapeExpr- The official JSG implemention specifies a strange pattern where the objects with atypeof"ShapeOr","ShapeAnd", ... are recognized as instances ofShapeOr,ShapeAnd, ... if they lack anidelement and aslabeledShapeOr,labeledShapeAnd, ... if theidelement exists. We simplify this construct, leavingidoptional. This potentially allows the parser to accept some highly unlikely invalid constructs, but these can be checked in a post-parse step if you feel deeply about it. (Note also that the ShEx semantics document does not include thelabeledShapeExprbranch)- This uses the revised jsg syntax.
ShExJ.py
Output of the PyJSG generate_parser for ShExJ.jsg. Python 3 representation of the ShEx AST
Installation
This package currently requires python 3.6 or later. It could be updated to support earlier python 3 versions if there is sufficient demand.
pip install ShExJSG
Updating the parser
cd ShExJSG
generate_parser ShExJ.jsg
Then run all tests:
uv run pytest
Note for developers
The original way this library was developed created a circular dependency for the test environment, causing uv to fail
to resolve. The reason is that ShExJSG is a runtime dependency for pyshexc, while pyshexc is a dev dependency for
ShExJSG. The only way around this is to run the development install the following way after cloning:
uv syncuv pip install "pyshexc>=0.10.3"
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 shexjsg-0.9.0.tar.gz.
File metadata
- Download URL: shexjsg-0.9.0.tar.gz
- Upload date:
- Size: 65.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
750016fabdb5487b27e2e714145f3602cd3ac4eb0dd9b7d7751d0cde62c0d1d8
|
|
| MD5 |
36b568b1024a7c5cdf72f4e9c48759bf
|
|
| BLAKE2b-256 |
d4d66e948660a888a37a5100e7bf7109e89b249ed526df430b674da12950de17
|
Provenance
The following attestation bundles were made for shexjsg-0.9.0.tar.gz:
Publisher:
pypi-publish.yaml on linkml/ShExJSG
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shexjsg-0.9.0.tar.gz -
Subject digest:
750016fabdb5487b27e2e714145f3602cd3ac4eb0dd9b7d7751d0cde62c0d1d8 - Sigstore transparency entry: 1437421767
- Sigstore integration time:
-
Permalink:
linkml/ShExJSG@b8600623274e81d6dc6ff0805a9e92883be3238d -
Branch / Tag:
refs/tags/v0.9.1 - Owner: https://github.com/linkml
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yaml@b8600623274e81d6dc6ff0805a9e92883be3238d -
Trigger Event:
release
-
Statement type:
File details
Details for the file shexjsg-0.9.0-py3-none-any.whl.
File metadata
- Download URL: shexjsg-0.9.0-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abf18db2d9895bc46740f68ae699b2ccfe08c783f6e0c038e6077293ad01c0a5
|
|
| MD5 |
8a2322628cb5e22e06a9a13cbafe3319
|
|
| BLAKE2b-256 |
8672b03ca1560615933f079ba7d291d3532ed95c2a3205911fe71d192654acaa
|
Provenance
The following attestation bundles were made for shexjsg-0.9.0-py3-none-any.whl:
Publisher:
pypi-publish.yaml on linkml/ShExJSG
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shexjsg-0.9.0-py3-none-any.whl -
Subject digest:
abf18db2d9895bc46740f68ae699b2ccfe08c783f6e0c038e6077293ad01c0a5 - Sigstore transparency entry: 1437421770
- Sigstore integration time:
-
Permalink:
linkml/ShExJSG@b8600623274e81d6dc6ff0805a9e92883be3238d -
Branch / Tag:
refs/tags/v0.9.1 - Owner: https://github.com/linkml
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yaml@b8600623274e81d6dc6ff0805a9e92883be3238d -
Trigger Event:
release
-
Statement type: