owmeta_core.dataobject_property module¶
- class owmeta_core.dataobject_property.ContextMappedPropertyClass(name, typ, dct)[source]¶
Bases:
MappedClass,ContextualizableClassMeta-class for
Property.A few attributes can be specified in the class body which affect how the created type is set up: these are defined in the “Attributes” section.
One aspect in particular is important: a
Propertyclass can represent a single type of property where all instances have the same URI, or aPropertycan represent an a class of RDF properties where the instances have distinct URIs and correspond to instances of the RDF type. An instance of the latter is demonstrated withContainerMembershipProperty.- Attributes
- rdf_type_class
type A sub-class of
DataObjectto use as the type. If set, this will be used instead of whatinit_rdf_type_objectwould create.- rdf_type
strorURIRef The RDF type for the
Property. Must be defined forinit_rdf_type_objectto actually create the rdf type object- rdf_type_object_deferredbool
If
True, defer callinginit_rdf_type_objectuntil it’s explicitly called rather than during normal class init. Useful for cases whereinit_rdf_type_objectuses types that aren’t defined at the point where thePropertyis defined.- rdf_object
RDFProperty An instance of
RDFPropertycorresponding to this class. If set, this will be used instead of whatinit_rdf_objectwould create.- rdf_object_deferredbool
If
True, defer callinginit_rdf_objectuntil it is explicitly called rather than during normal class init. Useful for cases whereinit_rdf_objectuses types that aren’t defined at the point where thePropertyis defined.
- rdf_type_class
- contextualize_class_augment(context)[source]¶
For MappedClass, rdf_type and rdf_namespace have special behavior where they can be auto-generated based on the class name and base_namespace. We have to pass through these values to our “proxy” to avoid this behavior
- init_rdf_type_object()[source]¶
Initializes
rdf_type_classand thereby initializes therdf_type_objectSometimes, we actually use Property sub-classes as
rdf:Propertyclasses (e.g.,rdfs:ContainerMembershipProperty). Therdf_typeattribute has to be defined on this class if we’re going to use it as anrdf:Propertyclass.
- class owmeta_core.dataobject_property.ExprResultObj(expr, ident)[source]¶
Bases:
objectObject returned by
PropertyExpr.to_objects. Attributes for whichPropertyExpr.to_dicthas been called can be accessed on the object. For example we can print out thebproperties of instances of a classA:class B(DataObject): v = DatatypeProperty() class A(DataObject): b = ObjectProperty(value_type=B) a = A().a.expr a.b.v() for anA in a.to_objects(): print(anA.identifier, anA.b)
anAis anExprResultObjin the example. The- property rdf_type¶
Allias to rdf_type_property
- class owmeta_core.dataobject_property.Property(*args, **kwargs)[source]¶
Bases:
DataUser,ContextualizableA property attached to a
DataObject.- contextualize_augment(context)[source]¶
For MappedClass, rdf_type and rdf_namespace have special behavior where they can be auto-generated based on the class name and base_namespace. We have to pass through these values to our “proxy” to avoid this behavior
- has_defined_value()[source]¶
Returns
Trueif this property has a value in the current context which is either aGraphObjectwithdefinedset toTrueor a literal value
- one()[source]¶
Query for a single value from this property.
For a multi-valued property, the returned value is chosen arbitrarily. If there’s no value returned from the query, then
Noneis returned.
- onedef()[source]¶
Return a single defined value set on this property in the current context
This does not execute a query, but returns a value which was set on this property.
- unset(v)¶
Remove a from this property
- property defined_values¶
The “defined” values set on this property in the current context
- property expr¶
An query expression from this property
- property identifier¶
Alias to
link
- lazy = True¶
If
True, then the property is not attached to an instance until the property is set or queried.
- multiple = False¶
If
True, then the property will only maintain a single staged value at a time. No effort is made to check how many values are stored in the RDF graph.
- property values¶
Return all values set on this property in the current context
- class owmeta_core.dataobject_property.PropertyExpr(props, triples_provider=None, terms_provider=None, origin=None)[source]¶
Bases:
objectA property expression
- property(property_class)[source]¶
Create a sub-expression with the given property.
Allows for creating expressions with properties that are not necessarily declared for the
value_typeof this expression’s property
- to_dict(multiple=False)[source]¶
Return a
dictmapping from identifiers for subjects of this expression’s property to the objects for that property.
- to_objects()[source]¶
Returns a list of
ExprResultObjthat allow for retrieving results in a convenient attribute traversal
- to_terms()[source]¶
Return a list of
rdflib.term.Nodeterms produced by this expression.
- property rdf_type¶
Short-hand for
rdf_type_property