prov.identifier¶
prov.identifier implements PROV’s namespaced identifiers. A
Namespace groups identifiers under a URI and an optional
prefix. A QualifiedName combines a namespace with a local
part to name entities, activities, agents and attributes.
Identifier is the common base class; an Identifier given as
an attribute value is stored as an xsd:anyURI Literal.
prov.model.NamespaceManager (see prov.model) tracks the namespaces registered on a
bundle and resolves prefixes during parsing and serialization.
- class prov.identifier.Identifier(uri: str)[source]¶
Bases:
objectBase class for all identifiers.
Its fields are read-only after construction. Assigning or deleting one raises
AttributeError, while a subclass may still set attributes of its own.
- class prov.identifier.QualifiedName(namespace: Namespace, localpart: str)[source]¶
Bases:
IdentifierRepresents a qualified name, which combines a namespace and a local part for use in identifying entities in a namespace-aware context.
Its fields are read-only after construction. Assigning or deleting one raises
AttributeError, while a subclass may still set attributes of its own.- provn_bare_representation() str[source]¶
Return the
prefix:localPROV-N form used at IDENTIFIER positions.The local part’s PROV-N metacharacters (
= ' ( ) , : ; [ ]) are backslash-escaped, as are a leading-or.and a trailing., which PROV-N does not allow bare. The prefix is never escaped, as it cannot contain these characters.- Raises:
ProvException – If the local part is empty and the namespace has no prefix, which has no PROV-N spelling.
- class prov.identifier.Namespace(prefix: str, uri: str)[source]¶
Bases:
objectPROV Namespace.
A prefix is a SPARQL
PN_PREFIX: it starts with a letter, and holds letters, digits,-,_,., U+00B7 and the combining marks, but does not end with..Its fields are read-only after construction. Assigning or deleting one raises
AttributeError, while a subclass may still set attributes of its own.- contains(identifier: str | Identifier) bool[source]¶
Check whether the given identifier’s URI is contained in this namespace.
- Parameters:
identifier – Identifier (or URI string) to check.
- Returns:
Trueif the identifier’s URI starts with this namespace’s URI,Falseotherwise (including when the URI cannot be determined).
- qname(identifier: str | Identifier) QualifiedName | None[source]¶
Resolve an identifier to a
QualifiedNamein this namespace.- Parameters:
identifier – Identifier (or URI string) to resolve.
- Returns:
A new
QualifiedNamein this namespace ifidentifier’s URI starts with this namespace’s URI, otherwiseNone.