owmeta_core.dataobject module¶
- exception owmeta_core.dataobject.ClassResolutionFailed[source]¶
Bases:
ExceptionThrown when a
PythonClassDescriptioncan’t resolve its class
- exception owmeta_core.dataobject.ModuleResolutionFailed[source]¶
Bases:
ExceptionThrown when a
PythonModulecan’t resolve its module
- class owmeta_core.dataobject.Alias(target)[source]¶
Bases:
objectUsed to declare that a descriptor is an alias to some other
PropertyExample usage:
class Person(DataObject): child = DatatypeProperty() offspring = Alias(child)
- Parameters
- target
dataobject_property.Property The property to alias
- target
- class owmeta_core.dataobject.BaseDataObject(*args, no_type_decl=False, **kwargs)[source]¶
Bases:
IdMixin,GraphObject,ContextualizableDataUserMixinAn object which can be mapped to an RDF graph
- Attributes
- rdf_type
rdflib.term.URIRef The RDF type URI for objects of this type
- rdf_namespace
rdflib.namespace.Namespace The rdflib namespace (prefix for URIs) for instances of this class
- schema_namespace
rdflib.namespace.Namespace The rdflib namespace (prefix for URIs) for types that are part of this class’ schema
- properties
listofowmeta_core.dataobject_property.Propertyorowmeta_core.custom_dataobject_property.CustomProperty Properties belonging to this object
- owner_properties
listofowmeta_core.dataobject_property.Propertyorowmeta_core.custom_dataobject_property.CustomProperty Properties belonging to parents of this object
- properties_are_init_argsbool
If true, then properties defined in the class body can be passed as keyword arguments to __init__. For example:
>>> class A(DataObject): ... p = DatatypeProperty() >>> A(p=5)
If the arguments are written explicitly into the __init__ method definition, then no special processing is done.
- rdf_type
- classmethod DatatypeProperty(*args, **kwargs)[source]¶
Attach a, possibly new, property to this class that has a simple type (string, number, etc) for its values
- Parameters
- linkName
str The name of this property.
- owner
owmeta_core.dataobject.BaseDataObject The owner of this property.
- linkName
- classmethod ObjectProperty(*args, **kwargs)[source]¶
Attach a, possibly new, property to this class that has a
BaseDataObjectfor its values- Parameters
- linkName
str The name of this property.
- owner
owmeta_core.dataobject.BaseDataObject The owner of this property.
- value_type
type The type of BaseDataObject for values of this property
- linkName
- classmethod UnionProperty(*args, **kwargs)[source]¶
Attach a, possibly new, property to this class that has a simple type (string,number,etc) or
BaseDataObjectfor its values- Parameters
- linkName
str The name of this property.
- owner
owmeta_core.dataobject.BaseDataObject The owner of this property.
- linkName
- 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
- get_owners(property_class_name)[source]¶
Return a generator of owners along a property pointing to this object
- graph_pattern(shorten=False, show_namespaces=True, **kwargs)[source]¶
Get the graph pattern for this object.
It should be as simple as converting the result of triples() into a BGP
- Parameters
- shortenbool
Indicates whether to shorten the URLs with the namespace manager attached to the
self
- hashfun()¶
Returns a md5 hash object; optionally initialized with a string
- load(graph=None)[source]¶
Loads
DataObjectsby matching between the object graph and the RDF graph- Parameters
- graph
rdflib.graph.ConjunctiveGraph the RDF graph to load from
- graph
- load_one(graph=None)[source]¶
Load a single
DataObject
- load_terms(graph=None)[source]¶
Loads URIs by matching between the object graph and the RDF graph
- Parameters
- graph
rdflib.graph.ConjunctiveGraph the RDF graph to load from
- graph
- save()[source]¶
Write in-memory data to the database. Derived classes should call this to update the store.
- property expr¶
Create a query expression rooted at this object
- property rdf¶
Returns either the configured RDF graph or the
Context.rdf_graphof its context
- property rdfs_comment¶
Corresponds to the rdfs:comment predicate
- property rdfs_label¶
Corresponds to the rdfs:label predicate
- property rdfs_member¶
Corresponds to the rdfs:member predicate
- class owmeta_core.dataobject.ClassDescription(*args, no_type_decl=False, **kwargs)[source]¶
Bases:
DataObjectDescribes a class in the programming language.
Note that, in other languages, there may not actually be classes per se. In such cases, the
ClassDescriptionmay instead indicate a function. The conventions for how that function accepts a URI for the sake of creating an “instance” of is up to the associated software module.- property module¶
The module the class belongs to
- class owmeta_core.dataobject.ContextMappedClass(name, typ, dct)[source]¶
Bases:
MappedClass,ContextualizableClassThe metaclass for a
BaseDataObject.- 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
- property definition_context¶
Unlike self.context, definition_context isn’t meant to be overriden
- property query¶
Creates a proxy that changes how some things behave for purposes of querying
- class owmeta_core.dataobject.ContextualizableList(*args, **kwargs)[source]¶
Bases:
Contextualizable,listA Contextualizable list
- class owmeta_core.dataobject.DataObject(*args, no_type_decl=False, **kwargs)[source]¶
Bases:
BaseDataObjectAn object that can be mapped to an RDF graph
- class owmeta_core.dataobject.Module(*args, no_type_decl=False, **kwargs)[source]¶
Bases:
DataObjectRepresents a module of code
Most modern programming languages organize code into importable modules of one kind or another. This is basically the nearest level above a class in the language.
Modules are accessible by one or more
ModuleAccessor- property accessor¶
Describes a way to get the module
- property package¶
Package that provides the module
- class owmeta_core.dataobject.ModuleAccessor(*args, no_type_decl=False, **kwargs)[source]¶
Bases:
DataObjectDescribes how to access a module.
Module access is how a person or automated system brings the module to where it can be imported/included, possibly in a subsequent
- class owmeta_core.dataobject.OptionalKeyValue(prop)[source]¶
Bases:
objectAn optional key value to use in
key_properties
- class owmeta_core.dataobject.PIPInstall(*args, no_type_decl=False, **kwargs)[source]¶
Bases:
ModuleAccessorDescribes a
pip installcommand line- property index_url¶
URL of the index from which the package should be retrieved
- class owmeta_core.dataobject.Package(*args, no_type_decl=False, **kwargs)[source]¶
Bases:
DataObjectDescribes an idealized software package identifiable by a name and version number
- property name¶
The standard name of the package
- property version¶
The version of the package
- class owmeta_core.dataobject.PythonClassDescription(*args, no_type_decl=False, **kwargs)[source]¶
Bases:
ClassDescriptionDescription for a Python class
- resolve_class()[source]¶
Load the class described by this object
- Returns
typeThe class described by this object
- Raises
ClassResolutionFailedRaised if the class can’t be resolved for whatever reason
- property module¶
The module the class belongs to
- property name¶
Local name of the class (i.e., relative to the module name)
- class owmeta_core.dataobject.PythonModule(*args, no_type_decl=False, **kwargs)[source]¶
Bases:
ModuleA Python module
- resolve_module()[source]¶
Load the module referenced by this object
- Returns
types.ModuleTypeThe module referenced by this object
- Raises
ModuleResolutionFailedRaised if the class can’t be resolved for whatever reason
- property name¶
The full name of the module
- class owmeta_core.dataobject.PythonPackage(*args, no_type_decl=False, **kwargs)[source]¶
Bases:
PackageA Python package
- class owmeta_core.dataobject.RDFProperty(*args, no_type_decl=False, **kwargs)[source]¶
Bases:
BaseDataObjectThe
DataObjectcorresponding to rdf:Property- property rdfs_subpropertyof¶
Corresponds to the rdfs:subPropertyOf predidcate
- class owmeta_core.dataobject.RDFSClass(*args, no_type_decl=False, **kwargs)[source]¶
Bases:
BaseDataObjectThe GraphObject corresponding to rdfs:Class
- property rdfs_subclassof_property¶
Corresponds to the rdfs:subClassOf predidcate
- class owmeta_core.dataobject.RDFSCommentProperty(*args, **kwargs)[source]¶
Bases:
DatatypePropertyCorresponds to the rdfs:comment predicate
- Parameters
- resolver
RDFTypeResolver Resolves RDF identifiers returned from
get()into objects
- resolver
- owner_type¶
alias of
BaseDataObject
- class owmeta_core.dataobject.RDFSLabelProperty(*args, **kwargs)[source]¶
Bases:
DatatypePropertyCorresponds to the rdfs:label predicate
- Parameters
- resolver
RDFTypeResolver Resolves RDF identifiers returned from
get()into objects
- resolver
- owner_type¶
alias of
BaseDataObject
- class owmeta_core.dataobject.RDFSMemberProperty(*args, **kwargs)[source]¶
Bases:
UnionPropertyCorresponds to the rdfs:member predicate
- Parameters
- resolver
RDFTypeResolver Resolves RDF identifiers into objects returned from
get()
- resolver
- owner_type¶
alias of
BaseDataObject
- class owmeta_core.dataobject.RDFSSubClassOfProperty(*args, **kwargs)[source]¶
Bases:
ObjectPropertyCorresponds to the rdfs:subClassOf predidcate
- class owmeta_core.dataobject.RDFSSubPropertyOfProperty(*args, **kwargs)[source]¶
Bases:
ObjectPropertyCorresponds to the rdfs:subPropertyOf predidcate
- owner_type¶
alias of
RDFProperty
- value_type¶
alias of
RDFProperty
- class owmeta_core.dataobject.RDFTypeProperty(*args, **kwargs)[source]¶
Bases:
ObjectPropertyCorresponds to the rdf:type predidcate
- owner_type¶
alias of
BaseDataObject
- class owmeta_core.dataobject.RegistryEntry(*args, no_type_decl=False, **kwargs)[source]¶
Bases:
DataObjectA mapping from a class in the programming language to an RDF class.
Objects of this type are utilized in the resolution of classes from the RDF graph
- property class_description¶
The description of the class
- property rdf_class¶
The RDF type for the class
We use rdf_type for the type of a
DataObject(RegistryEntry.rdf_typein this case), so we call thisrdf_classto avoid the conflict
- owmeta_core.dataobject.DatatypeProperty(*args, **kwargs)[source]¶
Used in a
DataObjectimplementation to designate a property whose values are notDataObjects.An example
DatatypePropertyuse:class Person(DataObject): name = DatatypeProperty() age = DatatypeProperty() Person(name='Abioye', age=34)
- owmeta_core.dataobject.ObjectProperty(*args, **kwargs)[source]¶
Used in a
DataObjectimplementation to designate a property whose values are otherDataObjects.An example
ObjectPropertyuse:class Person(DataObject): name = DatatypeProperty() friend = ObjectProperty() Person(name='Abioye', friend=Person(name='Baako'))
- owmeta_core.dataobject.UnionProperty(*args, **kwargs)[source]¶
Used in a
DataObjectimplementation to designate a property whose values are either otherDataObjectsor literals (e.g., str, int).An example
UnionPropertyuse:class Address(DataObject): street = DatatypeProperty() number = DatatypeProperty() city = DatatypeProperty() state = DatatypeProperty() zip = DatatypeProperty() class Person(DataObject): name = DatatypeProperty() address = UnionProperty() Person(name='Umoja', address='38 West 88th Street, Manhattan NY 10024 , New York, USA') Person(name='Umoja', address=Address(number=38, street='West 88th Street', city='New York', state='NY', zip=10024))
- owmeta_core.dataobject.DATAOBJECT_PROPERTY_NAME_PREFIX = '_owm_'¶
Prefix for property attribute names
- owmeta_core.dataobject.This = <object object>¶
A reference to be used in class-level property declarations to denote the class currently being defined. For example:
>>> class Person(DataObject): ... parent = ObjectProperty(value_type=This, ... inverse_of=(This, 'child')) ... child = ObjectProperty(value_type=This)