Skip to main content

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.

Pyversions PyPi Build Publish

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:

  1. labeledShapeExpr - The official JSG implemention specifies a strange pattern where the objects with a type of "ShapeOr", "ShapeAnd", ... are recognized as instances of ShapeOr, ShapeAnd, ... if they lack an id element and as labeledShapeOr, labeledShapeAnd, ... if the id element exists. We simplify this construct, leaving id optional. 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 the labeledShapeExpr branch)
  2. 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:

  1. uv sync
  2. uv pip install "pyshexc>=0.10.3"

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

shexjsg-0.9.0.tar.gz (65.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shexjsg-0.9.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

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

Hashes for shexjsg-0.9.0.tar.gz
Algorithm Hash digest
SHA256 750016fabdb5487b27e2e714145f3602cd3ac4eb0dd9b7d7751d0cde62c0d1d8
MD5 36b568b1024a7c5cdf72f4e9c48759bf
BLAKE2b-256 d4d66e948660a888a37a5100e7bf7109e89b249ed526df430b674da12950de17

See more details on using hashes here.

Provenance

The following attestation bundles were made for shexjsg-0.9.0.tar.gz:

Publisher: pypi-publish.yaml on linkml/ShExJSG

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for shexjsg-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 abf18db2d9895bc46740f68ae699b2ccfe08c783f6e0c038e6077293ad01c0a5
MD5 8a2322628cb5e22e06a9a13cbafe3319
BLAKE2b-256 8672b03ca1560615933f079ba7d291d3532ed95c2a3205911fe71d192654acaa

See more details on using hashes here.

Provenance

The following attestation bundles were made for shexjsg-0.9.0-py3-none-any.whl:

Publisher: pypi-publish.yaml on linkml/ShExJSG

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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