Tracker.NamespaceManager

g GObject.Object GObject.Object Tracker.NamespaceManager Tracker.NamespaceManager GObject.Object->Tracker.NamespaceManager

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

get_default ()

class

new ()

add_prefix (prefix, ns)

compress_uri (uri)

expand_uri (compact_uri)

foreach (func, *user_data)

has_prefix (prefix)

lookup_prefix (prefix)

print_turtle ()

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Tracker.NamespaceManager(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Tracker.NamespaceManagerClass

TrackerNamespaceManager object represents a mapping between namespaces and their shortened prefixes.

This object keeps track of namespaces, and allows you to assign short prefixes for them to avoid frequent use of full namespace IRIs. The syntax used is that of Compact URIs (CURIEs).

Usually you will want to use a namespace manager obtained through [method`Tracker`.SparqlConnection.get_namespace_manager] from the [class`Tracker`.SparqlConnection] that manages the RDF data, as that will contain all prefixes and namespaces that are pre-defined by its ontology.

classmethod get_default()
Returns:

a global, shared TrackerNamespaceManager instance

Return type:

Tracker.NamespaceManager

Returns the global TrackerNamespaceManager that contains a set of well-known namespaces and prefixes, such as rdf:, rdfs:, nie:, tracker:, etc.

Note that the list of prefixes and namespaces is hardcoded in libtracker-sparql. It may not correspond with the installed set of ontologies, if they have been modified since they were installed.

Deprecated since version 3.3: Use [method`Tracker`.SparqlConnection.get_namespace_manager] instead.

classmethod new()
Returns:

a new TrackerNamespaceManager instance

Return type:

Tracker.NamespaceManager

Creates a new, empty TrackerNamespaceManager instance.

add_prefix(prefix, ns)
Parameters:
  • prefix (str) – a short, unique prefix to identify namespace

  • ns (str) – the URL of the given namespace

Adds prefix as the recognised abbreviaton of namespace.

Only one prefix is allowed for a given namespace, and all prefixes must be unique.

Since 3.3, The TrackerNamespaceManager instances obtained through [method`Tracker`.SparqlConnection.get_namespace_manager] are “sealed”, this API call should not performed on those.

compress_uri(uri)
Parameters:

uri (str) – a URI or compact URI

Returns:

(nullable): the compressed URI

Return type:

str

If uri begins with one of the namespaces known to this TrackerNamespaceManager, then the return value will be the compressed URI. Otherwise, None will be returned.

New in version 3.3.

expand_uri(compact_uri)
Parameters:

compact_uri (str) – a URI or compact URI

Returns:

The possibly expanded URI in a newly-allocated string.

Return type:

str

If compact_uri begins with one of the prefixes known to this TrackerNamespaceManager, then the return value will be the expanded URI. Otherwise, a copy of compact_uri will be returned.

foreach(func, *user_data)
Parameters:
  • func (GLib.HFunc) – the function to call for each prefix / URI pair

  • user_data (object or None) – user data to pass to the function

Calls func for each known prefix / URI pair.

has_prefix(prefix)
Parameters:

prefix (str) – a string

Returns:

True if the TrackerNamespaceManager knows about prefix, False otherwise

Return type:

bool

Returns whether prefix is known.

lookup_prefix(prefix)
Parameters:

prefix (str) – a string

Returns:

a string owned by the TrackerNamespaceManager, or None

Return type:

str or None

Looks up the namespace URI corresponding to prefix, or None if the prefix is not known.

print_turtle()
Returns:

a newly-allocated string

Return type:

str

Writes out all namespaces as @prefix statements in the Turtle RDF format.