hydra.shacl.model module

A SHACL syntax model. See https://www.w3.org/TR/shacl.

class hydra.shacl.model.Closed(is_closed: bool, ignored_properties: object)

Bases: object

A SHACL closed-shape constraint, restricting a node’s properties to those explicitly listed or ignored.

class Builder(_is_closed: 'bool' = None, _ignored_properties: 'Optional[Set[hydra.rdf.syntax.Property]]' = None)

Bases: object

build()
ignored_properties(ignored_properties)
is_closed(is_closed)
IGNORED_PROPERTIES = Name(value='ignoredProperties')
IS_CLOSED = Name(value='isClosed')
TYPE_ = Name(value='hydra.shacl.model.Closed')
static builder()
ignored_properties: object
is_closed: bool
with_ignored_properties(ignored_properties)
with_is_closed(is_closed)
class hydra.shacl.model.CommonConstraint

Bases: object

CommonConstraintAnd | CommonConstraintClosed | CommonConstraintClass | CommonConstraintDatatype | CommonConstraintDisjoint | CommonConstraintEquals | CommonConstraintHasValue | CommonConstraintIn | CommonConstraintLanguageIn | CommonConstraintNodeKind | CommonConstraintNode | CommonConstraintNot | CommonConstraintMaxExclusive | CommonConstraintMaxInclusive | CommonConstraintMaxLength | CommonConstraintMinExclusive | CommonConstraintMinInclusive | CommonConstraintMinLength | CommonConstraintPattern | CommonConstraintProperty | CommonConstraintOr | CommonConstraintXone

AND = Name(value='and')
CLASS = Name(value='class')
CLOSED = Name(value='closed')
DATATYPE = Name(value='datatype')
DISJOINT = Name(value='disjoint')
EQUALS = Name(value='equals')
HAS_VALUE = Name(value='hasValue')
IN = Name(value='in')
LANGUAGE_IN = Name(value='languageIn')
MAX_EXCLUSIVE = Name(value='maxExclusive')
MAX_INCLUSIVE = Name(value='maxInclusive')
MAX_LENGTH = Name(value='maxLength')
MIN_EXCLUSIVE = Name(value='minExclusive')
MIN_INCLUSIVE = Name(value='minInclusive')
MIN_LENGTH = Name(value='minLength')
NODE = Name(value='node')
NODE_KIND = Name(value='nodeKind')
NOT = Name(value='not')
OR = Name(value='or')
PATTERN = Name(value='pattern')
PROPERTY = Name(value='property')
TYPE_ = Name(value='hydra.shacl.model.CommonConstraint')
XONE = Name(value='xone')
class hydra.shacl.model.CommonConstraintAnd(value: T)

Bases: Node[Set[Reference[Shape]]]

See https://www.w3.org/TR/shacl/#AndConstraintComponent

class hydra.shacl.model.CommonConstraintClass(value: T)

Bases: Node[Set[hydra.rdf.syntax.RdfsClass]]

See https://www.w3.org/TR/shacl/#ClassConstraintComponent

class hydra.shacl.model.CommonConstraintClosed(value: T)

Bases: Node[Closed]

See https://www.w3.org/TR/shacl/#ClosedConstraintComponent

class hydra.shacl.model.CommonConstraintDatatype(value: T)

Bases: Node[hydra.rdf.syntax.Iri]

See https://www.w3.org/TR/shacl/#DatatypeConstraintComponent

class hydra.shacl.model.CommonConstraintDisjoint(value: T)

Bases: Node[Set[hydra.rdf.syntax.Property]]

See https://www.w3.org/TR/shacl/#DisjointConstraintComponent

class hydra.shacl.model.CommonConstraintEquals(value: T)

Bases: Node[Set[hydra.rdf.syntax.Property]]

See https://www.w3.org/TR/shacl/#EqualsConstraintComponent

class hydra.shacl.model.CommonConstraintHasValue(value: T)

Bases: Node[Set[hydra.rdf.syntax.Node_]]

Specifies the condition that at least one value node is equal to the given RDF term. See https://www.w3.org/TR/shacl/#HasValueConstraintComponent

class hydra.shacl.model.CommonConstraintIn(value: T)

Bases: Node[Sequence[hydra.rdf.syntax.Node_]]

Specifies the condition that each value node is a member of a provided SHACL list. See https://www.w3.org/TR/shacl/#InConstraintComponent

class hydra.shacl.model.CommonConstraintLanguageIn(value: T)

Bases: Node[Set[hydra.rdf.syntax.LanguageTag]]

See https://www.w3.org/TR/shacl/#LanguageInConstraintComponent

class hydra.shacl.model.CommonConstraintMaxExclusive(value: T)

Bases: Node[hydra.rdf.syntax.Literal]

See https://www.w3.org/TR/shacl/#MaxExclusiveConstraintComponent

class hydra.shacl.model.CommonConstraintMaxInclusive(value: T)

Bases: Node[hydra.rdf.syntax.Literal]

See https://www.w3.org/TR/shacl/#MaxInclusiveConstraintComponent

class hydra.shacl.model.CommonConstraintMaxLength(value: T)

Bases: Node[int]

See https://www.w3.org/TR/shacl/#MaxLengthConstraintComponent

class hydra.shacl.model.CommonConstraintMinExclusive(value: T)

Bases: Node[hydra.rdf.syntax.Literal]

See https://www.w3.org/TR/shacl/#MinExclusiveConstraintComponent

class hydra.shacl.model.CommonConstraintMinInclusive(value: T)

Bases: Node[hydra.rdf.syntax.Literal]

See https://www.w3.org/TR/shacl/#MinInclusiveConstraintComponent

class hydra.shacl.model.CommonConstraintMinLength(value: T)

Bases: Node[int]

See https://www.w3.org/TR/shacl/#MinLengthConstraintComponent

class hydra.shacl.model.CommonConstraintNode(value: T)

Bases: Node[Set[Reference[NodeShape]]]

See https://www.w3.org/TR/shacl/#NodeConstraintComponent

class hydra.shacl.model.CommonConstraintNodeKind(value: T)

Bases: Node[NodeKind]

See https://www.w3.org/TR/shacl/#NodeKindConstraintComponent

class hydra.shacl.model.CommonConstraintNot(value: T)

Bases: Node[Set[Reference[Shape]]]

See https://www.w3.org/TR/shacl/#NotConstraintComponent

class hydra.shacl.model.CommonConstraintOr(value: T)

Bases: Node[Set[Reference[Shape]]]

See https://www.w3.org/TR/shacl/#OrConstraintComponent

class hydra.shacl.model.CommonConstraintPattern(value: T)

Bases: Node[Pattern]

See https://www.w3.org/TR/shacl/#PatternConstraintComponent

class hydra.shacl.model.CommonConstraintProperty(value: T)

Bases: Node[Set[Reference[PropertyShape]]]

See https://www.w3.org/TR/shacl/#PropertyConstraintComponent

class hydra.shacl.model.CommonConstraintXone(value: T)

Bases: Node[Set[Reference[Shape]]]

See https://www.w3.org/TR/shacl/#XoneConstraintComponent

class hydra.shacl.model.CommonProperties(constraints: Annotated[Set[CommonConstraint], 'Common constraint parameters attached to this shape'], deactivated: Annotated[object, 'See https://www.w3.org/TR/shacl/#deactivated'], message: Annotated[LangStrings, 'See https://www.w3.org/TR/shacl/#message'], severity: Annotated[Severity, 'See https://www.w3.org/TR/shacl/#severity'], target_class: Annotated[Set[RdfsClass], 'See https://www.w3.org/TR/shacl/#targetClass'], target_node: Annotated[Set[IriOrLiteral], 'See https://www.w3.org/TR/shacl/#targetNode'], target_objects_of: Annotated[Set[Property], 'See https://www.w3.org/TR/shacl/#targetObjectsOf'], target_subjects_of: Annotated[Set[Property], 'See https://www.w3.org/TR/shacl/#targetSubjectsOf'])

Bases: object

Common constraint parameters and other properties for SHACL shapes.

class Builder(_constraints: 'Set[CommonConstraint]' = None, _deactivated: 'Optional[bool]' = None, _message: 'hydra.rdf.syntax.LangStrings' = None, _severity: 'Severity' = None, _target_class: 'Set[hydra.rdf.syntax.RdfsClass]' = None, _target_node: 'Set[hydra.rdf.syntax.IriOrLiteral]' = None, _target_objects_of: 'Set[hydra.rdf.syntax.Property]' = None, _target_subjects_of: 'Set[hydra.rdf.syntax.Property]' = None)

Bases: object

build()
constraints(constraints)
deactivated(deactivated)
message(message)
severity(severity)
target_class(target_class)
target_node(target_node)
target_objects_of(target_objects_of)
target_subjects_of(target_subjects_of)
CONSTRAINTS = Name(value='constraints')
DEACTIVATED = Name(value='deactivated')
MESSAGE = Name(value='message')
SEVERITY = Name(value='severity')
TARGET_CLASS = Name(value='targetClass')
TARGET_NODE = Name(value='targetNode')
TARGET_OBJECTS_OF = Name(value='targetObjectsOf')
TARGET_SUBJECTS_OF = Name(value='targetSubjectsOf')
TYPE_ = Name(value='hydra.shacl.model.CommonProperties')
static builder()
constraints: Annotated[Set[CommonConstraint], 'Common constraint parameters attached to this shape']
deactivated: Annotated[object, 'See https://www.w3.org/TR/shacl/#deactivated']
message: Annotated[LangStrings, 'See https://www.w3.org/TR/shacl/#message']
severity: Annotated[Severity, 'See https://www.w3.org/TR/shacl/#severity']
target_class: Annotated[Set[RdfsClass], 'See https://www.w3.org/TR/shacl/#targetClass']
target_node: Annotated[Set[IriOrLiteral], 'See https://www.w3.org/TR/shacl/#targetNode']
target_objects_of: Annotated[Set[Property], 'See https://www.w3.org/TR/shacl/#targetObjectsOf']
target_subjects_of: Annotated[Set[Property], 'See https://www.w3.org/TR/shacl/#targetSubjectsOf']
with_constraints(constraints)
with_deactivated(deactivated)
with_message(message)
with_severity(severity)
with_target_class(target_class)
with_target_node(target_node)
with_target_objects_of(target_objects_of)
with_target_subjects_of(target_subjects_of)
class hydra.shacl.model.Definition(iri: Iri, target: A)

Bases: Generic[A]

An instance of a type like sh:Shape or sh:NodeShape, together with a unique IRI for that instance.

class Builder(_iri: 'hydra.rdf.syntax.Iri' = None, _target: 'A' = None)

Bases: Generic[A]

build()
iri(iri)
target(target)
IRI = Name(value='iri')
TARGET = Name(value='target')
TYPE_ = Name(value='hydra.shacl.model.Definition')
static builder()
iri: Iri
target: A
with_iri(iri)
with_target(target)
class hydra.shacl.model.NodeKind(*values)

Bases: Enum

The SHACL node kind of an RDF term.

BLANK_NODE = Name(value='blankNode')

A blank node

BLANK_NODE_OR_IRI = Name(value='blankNodeOrIri')

A blank node or an IRI

BLANK_NODE_OR_LITERAL = Name(value='blankNodeOrLiteral')

A blank node or a literal

IRI = Name(value='iri')

An IRI

IRI_OR_LITERAL = Name(value='iriOrLiteral')

An IRI or a literal

LITERAL = Name(value='literal')

A literal

TYPE_ = Name(value='hydra.shacl.model.NodeKind')
class hydra.shacl.model.NodeShape(common: CommonProperties)

Bases: object

A SHACL node shape. See https://www.w3.org/TR/shacl/#node-shapes.

class Builder(_common: 'CommonProperties' = None)

Bases: object

build()
common(common)
COMMON = Name(value='common')
TYPE_ = Name(value='hydra.shacl.model.NodeShape')
static builder()
common: CommonProperties
with_common(common)
class hydra.shacl.model.Pattern(regex: str, flags: object)

Bases: object

A SHACL pattern. See https://www.w3.org/TR/shacl/#PatternConstraintComponent.

class Builder(_regex: 'str' = None, _flags: 'Optional[str]' = None)

Bases: object

build()
flags(flags)
regex(regex)
FLAGS = Name(value='flags')
REGEX = Name(value='regex')
TYPE_ = Name(value='hydra.shacl.model.Pattern')
static builder()
flags: object
regex: str
with_flags(flags)
with_regex(regex)
class hydra.shacl.model.PropertyShape(common: CommonProperties, constraints: Annotated[Set[PropertyShapeConstraint], 'Any property shape -specific constraint parameters'], default_value: Annotated[object, 'See https://www.w3.org/TR/shacl/#defaultValue'], description: Annotated[LangStrings, 'See https://www.w3.org/TR/shacl/#name'], name: Annotated[LangStrings, 'See https://www.w3.org/TR/shacl/#name'], order: Annotated[object, 'See https://www.w3.org/TR/shacl/#order'], path: Iri)

Bases: object

A SHACL property shape. See https://www.w3.org/TR/shacl/#property-shapes.

class Builder(_common: 'CommonProperties' = None, _constraints: 'Set[PropertyShapeConstraint]' = None, _default_value: 'Optional[hydra.rdf.syntax.Node_]' = None, _description: 'hydra.rdf.syntax.LangStrings' = None, _name: 'hydra.rdf.syntax.LangStrings' = None, _order: 'Optional[int]' = None, _path: 'hydra.rdf.syntax.Iri' = None)

Bases: object

build()
common(common)
constraints(constraints)
default_value(default_value)
description(description)
name(name)
order(order)
path(path)
COMMON = Name(value='common')
CONSTRAINTS = Name(value='constraints')
DEFAULT_VALUE = Name(value='defaultValue')
DESCRIPTION = Name(value='description')
NAME = Name(value='name')
ORDER = Name(value='order')
PATH = Name(value='path')
TYPE_ = Name(value='hydra.shacl.model.PropertyShape')
static builder()
common: CommonProperties
constraints: Annotated[Set[PropertyShapeConstraint], 'Any property shape -specific constraint parameters']
default_value: Annotated[object, 'See https://www.w3.org/TR/shacl/#defaultValue']
description: Annotated[LangStrings, 'See https://www.w3.org/TR/shacl/#name']
name: Annotated[LangStrings, 'See https://www.w3.org/TR/shacl/#name']
order: Annotated[object, 'See https://www.w3.org/TR/shacl/#order']
path: Iri
with_common(common)
with_constraints(constraints)
with_default_value(default_value)
with_description(description)
with_name(name)
with_order(order)
with_path(path)
class hydra.shacl.model.PropertyShapeConstraint

Bases: object

PropertyShapeConstraintLessThan | PropertyShapeConstraintLessThanOrEquals | PropertyShapeConstraintMaxCount | PropertyShapeConstraintMinCount | PropertyShapeConstraintUniqueLang | PropertyShapeConstraintQualifiedValueShape

LESS_THAN = Name(value='lessThan')
LESS_THAN_OR_EQUALS = Name(value='lessThanOrEquals')
MAX_COUNT = Name(value='maxCount')
MIN_COUNT = Name(value='minCount')
QUALIFIED_VALUE_SHAPE = Name(value='qualifiedValueShape')
TYPE_ = Name(value='hydra.shacl.model.PropertyShapeConstraint')
UNIQUE_LANG = Name(value='uniqueLang')
class hydra.shacl.model.PropertyShapeConstraintLessThan(value: T)

Bases: Node[Set[hydra.rdf.syntax.Property]]

See https://www.w3.org/TR/shacl/#LessThanConstraintComponent

class hydra.shacl.model.PropertyShapeConstraintLessThanOrEquals(value: T)

Bases: Node[Set[hydra.rdf.syntax.Property]]

See https://www.w3.org/TR/shacl/#LessThanOrEqualsConstraintComponent

class hydra.shacl.model.PropertyShapeConstraintMaxCount(value: T)

Bases: Node[int]

The maximum cardinality. Node shapes cannot have any value for sh:maxCount. See https://www.w3.org/TR/shacl/#MaxCountConstraintComponent

class hydra.shacl.model.PropertyShapeConstraintMinCount(value: T)

Bases: Node[int]

The minimum cardinality. Node shapes cannot have any value for sh:minCount. See https://www.w3.org/TR/shacl/#MinCountConstraintComponent

class hydra.shacl.model.PropertyShapeConstraintQualifiedValueShape(value: T)

Bases: Node[QualifiedValueShape]

See https://www.w3.org/TR/shacl/#QualifiedValueShapeConstraintComponent

class hydra.shacl.model.PropertyShapeConstraintUniqueLang(value: T)

Bases: Node[bool]

See https://www.w3.org/TR/shacl/#UniqueLangConstraintComponent

class hydra.shacl.model.QualifiedValueShape(qualified_value_shape: object, qualified_max_count: int, qualified_min_count: int, qualified_value_shapes_disjoint: object)

Bases: object

A SHACL qualified value shape constraint, requiring a count of values conforming to a given shape.

class Builder(_qualified_value_shape: 'Reference[Shape]' = None, _qualified_max_count: 'int' = None, _qualified_min_count: 'int' = None, _qualified_value_shapes_disjoint: 'Optional[bool]' = None)

Bases: object

build()
qualified_max_count(qualified_max_count)
qualified_min_count(qualified_min_count)
qualified_value_shape(qualified_value_shape)
qualified_value_shapes_disjoint(qualified_value_shapes_disjoint)
QUALIFIED_MAX_COUNT = Name(value='qualifiedMaxCount')
QUALIFIED_MIN_COUNT = Name(value='qualifiedMinCount')
QUALIFIED_VALUE_SHAPE = Name(value='qualifiedValueShape')
QUALIFIED_VALUE_SHAPES_DISJOINT = Name(value='qualifiedValueShapesDisjoint')
TYPE_ = Name(value='hydra.shacl.model.QualifiedValueShape')
static builder()
qualified_max_count: int
qualified_min_count: int
qualified_value_shape: object
qualified_value_shapes_disjoint: object
with_qualified_max_count(qualified_max_count)
with_qualified_min_count(qualified_min_count)
with_qualified_value_shape(qualified_value_shape)
with_qualified_value_shapes_disjoint(qualified_value_shapes_disjoint)
class hydra.shacl.model.Reference

Bases: object

ReferenceNamed | ReferenceAnonymous[A] | ReferenceDefinition[A]

ANONYMOUS = Name(value='anonymous')
DEFINITION = Name(value='definition')
NAMED = Name(value='named')
TYPE_ = Name(value='hydra.shacl.model.Reference')
class hydra.shacl.model.ReferenceAnonymous(value: T)

Bases: Node[A]

An anonymous instance

class hydra.shacl.model.ReferenceDefinition(value: T)

Bases: Node[Definition[A]]

An inline definition

class hydra.shacl.model.ReferenceNamed(value: T)

Bases: Node[hydra.rdf.syntax.Iri]

class hydra.shacl.model.Severity(*values)

Bases: Enum

The severity of a SHACL constraint violation.

INFO = Name(value='info')

A non-critical constraint violation indicating an informative message

TYPE_ = Name(value='hydra.shacl.model.Severity')
VIOLATION = Name(value='violation')

A constraint violation

WARNING = Name(value='warning')

A non-critical constraint violation indicating a warning

class hydra.shacl.model.Shape

Bases: object

ShapeNode | ShapeProperty

NODE = Name(value='node')
PROPERTY = Name(value='property')
TYPE_ = Name(value='hydra.shacl.model.Shape')
class hydra.shacl.model.ShapeNode(value: T)

Bases: Node[NodeShape]

class hydra.shacl.model.ShapeProperty(value: T)

Bases: Node[PropertyShape]

class hydra.shacl.model.ShapesGraph(value: T)

Bases: Node[Set[Definition[Shape]]]

An RDF graph containing zero or more shapes that is passed into a SHACL validation process so that a data graph can be validated against the shapes.

TYPE_ = Name(value='hydra.shacl.model.ShapesGraph')