owmeta_core.identifier_mixin module

class owmeta_core.identifier_mixin.IdMixin(ident=None, key=None, *args, direct_key=None, **kwargs)[source]

Bases: object

Mixin that provides common identifier logic

Attributes
hashfunfunction

Returns a sha224 hash object; optionally initialized with a string

rdf_namespacerdflib.namespace.Namespace

The namespace for identifiers created

direct_keybool

Whether to make a key directly, just adding the string onto the namespace or indirectly by hashing the key before joining with the namespace.

defined_augment()[source]

This fuction must return False if identifier_augment() would raise an IdentifierMissingException. Override it when defining a non-standard identifier for subclasses of DataObjects.

hashfun()

Returns a sha224 hash object; optionally initialized with a string

identifier_augment()[source]

Override this method to define an identifier in lieu of one explicity set.

One must also override defined_augment() to return True whenever this method could return a valid identifier. IdentifierMissingException should be raised if an identifier cannot be generated by this method.

Raises
IdentifierMissingException
classmethod make_identifier(data)[source]

Makes an identifier based on this class’ rdf_namespace by calling __str__ on the data and passing to the class’ hashfun.

If the __str__ for data’s type doesn’t function as an identifier, you should use either make_identifier_direct() or override identifier_augment() and defined_augment()

classmethod make_identifier_direct(string)[source]

Make identifier by using the quote’d value of key appended to the rdf_namespace value

property identifier

The identifier