Skip to content

Commit

Permalink
Implement Class NodeKind support
Browse files Browse the repository at this point in the history
Add support for Classes to specify what kind of node they must be (e.g.
"IRI", "BlankNode", "BlankNodeOrIRI")
  • Loading branch information
JPEWdev committed Apr 2, 2024
1 parent 4fecbf1 commit 2e58c1f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions spec_parser/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class Class:
"Instantiability",
"name",
"SubclassOf",
"NodeKind",
)
VALID_PROP_METADATA = (
"maxCount",
Expand Down
5 changes: 5 additions & 0 deletions spec_parser/rdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ def gen_rdf_ontology(model):
pns = "" if parent.startswith("/") else f"/{c.ns.name}/"
p = model.classes[pns+parent]
g.add((node, RDFS.subClassOf, URIRef(p.iri)))

node_kind = c.metadata.get("NodeKind")
if node_kind:
g.add((node, SH.nodeKind, getattr(SH, node_kind)))

for p in c.properties:
fqprop = c.properties[p]["fqname"]
if fqprop == "/Core/spdxId":
Expand Down

0 comments on commit 2e58c1f

Please sign in to comment.