bsfs.schema package#
- class bsfs.schema.Predicate(uri: URI, parent: Predicate | None, domain: Node, range: Vertex, unique: bool, **kwargs)#
Bases:
_Type
Predicate base type.
- child(uri: URI, domain: Node | None = None, range: Vertex | None = None, unique: bool | None = None, **kwargs)#
Return a child of the current class.
- range: Vertex#
- unique: bool#
- class bsfs.schema.Schema(predicates: Iterable[Predicate] | None = None, nodes: Iterable[Node] | None = None, literals: Iterable[Literal] | None = None)#
Bases:
object
Graph schema.
Use Schema.Empty() to create a new, empty Schema rather than construct it directly.
The schema is defined by three sets: Predicates, Nodes, and Literals.
The Schema class guarantees two properties: completeness and consistency. Completeness means that the schema covers all class that are referred to by any other class in the schema. Consistency means that each class is identified by a unique URI and all classes that use that URI consequently use the same definition.
- class SchemaDiff(nodes, literals, predicates)#
Bases:
tuple
- literals#
Alias for field number 1
- nodes#
Alias for field number 0
- predicates#
Alias for field number 2
- classmethod Union(*args: Schema | Iterable[Schema]) Schema #
Combine multiple Schema instances into a single one. As argument, you can either pass multiple Schema instances, or a single iterable over Schema instances. Any abc.Iterable will be accepted.
Example:
>>> a, b, c = Schema.Empty(), Schema.Empty(), Schema.Empty() >>> # multiple Schema instances >>> Schema.Union(a, b, c) >>> # A single iterable over Schema instances >>> Schema.Union([a, b, c])
- consistent_with(other: Schema) bool #
Checks if two schemas have different predicate, node, or literal definitions for the same uri.
- diff(other: Schema) SchemaDiff #
Return node, literals, and predicates that are in self but not in other.
- bsfs.schema.to_string(schema_inst: Schema, fmt: str = 'turtle') str #
Serialize a bsfs.schema.Schema to a string. See rdflib.Graph.serialize for viable formats (default: turtle).