KDE 4.2 PyKDE API Reference

- KDE's Python API

# Soprano Namespace Reference

`from PyKDE4.soprano.Soprano import *`

## Detailed Description

## Class Index

B | M | QueryResultIterator (Soprano)
Backend (Soprano) | Model (Soprano) | R
BackendSetting (Soprano) | N | RdfSchemaModel (Soprano)
BindingSet (Soprano) | Node (Soprano) | S
F | NodeIterator (Soprano) | Serializer (Soprano)
FilterModel (Soprano) | P | Statement (Soprano)
I | Parser (Soprano) | StatementIterator (Soprano)
IteratorBackend (Soprano) | Plugin (Soprano) | StorageModel (Soprano)
L | PluginManager (Soprano) |
LiteralValue (Soprano) | Q |

## Enumerations

BackendFeature | { BackendFeatureNone, BackendFeatureAddStatement, BackendFeatureRemoveStatements, BackendFeatureListStatements, BackendFeatureQuery, BackendFeatureInference, BackendFeatureInferenceOptional, BackendFeatureContext, BackendFeatureStorageMemory, BackendFeatureUser }
BackendOption | { BackendOptionNone, BackendOptionStorageMemory, BackendOptionEnableInference, BackendOptionStorageDir, BackendOptionUser }
RdfSerialization | { SerializationUnknown, SerializationRdfXml, SerializationN3, SerializationNTriples, SerializationTurtle, SerializationTrig, SerializationNQuads, SerializationUser }

## Functions

Soprano.Model | createModel (Soprano.BackendSettings settings=Soprano.BackendSettings())
Soprano.Model | createModel ([Soprano.BackendSetting] settings)
Soprano.Backend | discoverBackendByFeatures (Soprano.BackendFeatures features, QStringList userFeatures=QStringList())
Soprano.Backend | discoverBackendByName (QString name)
bool | isOptionInSettings (Soprano.BackendSettings settings, Soprano.BackendOption option, QString userOptionName=QString())
Soprano.RdfSerialization | mimeTypeToSerialization (QString mimetype)
QString | serializationMimeType (Soprano.RdfSerialization serialization, QString userSerialization=QString())
| setUsedBackend (Soprano.Backend a0)
Soprano.BackendSetting | settingInSettings (Soprano.BackendSettings settings, Soprano.BackendOption option, QString userOptionName=QString())
Soprano.Backend | usedBackend ()
QVariant | valueInSettings (Soprano.BackendSettings settings, Soprano.BackendOption option, QString userOptionName=QString())

## Enumeration Documentation

BackendFeature

Each Backend plugin can support different features. %Soprano defines a list of well-known features that each backend implementation should try to realize. In addition user features can be defined. For this BackendFeatureUser has to be included in the supported features. Then additional features may be reported through Backend.supportedUserFeatures().

\sa Backend.supportedFeatures(), Backend.supportedUserFeatures()

Enumerator:

  BackendFeatureNone = 0x0 |
  BackendFeatureAddStatement = 0x1 |
  BackendFeatureRemoveStatements = 0x2 |
  BackendFeatureListStatements = 0x4 |
  BackendFeatureQuery = 0x8 |
  BackendFeatureInference = 0x10 |
  BackendFeatureInferenceOptional = 0x20 |
  BackendFeatureContext = 0x40 |
  BackendFeatureStorageMemory = 0x80 |
  BackendFeatureUser = 0x1000 |

BackendOption

There are two types of backend settings: boolean flags and key/value pairs. The boolean flags are identified by BackendFlag.

\sa BackendSetting, Backend.createModel()

Enumerator:

  BackendOptionNone = 0x0 |
  BackendOptionStorageMemory = 0x1 |
  BackendOptionEnableInference = 0x2 |
  BackendOptionStorageDir = 0x4 |
  BackendOptionUser = 0x1000 |

RdfSerialization

Different types of RDF serialization.

\sa serializationMimeType, mimeTypeToSerialization

Enumerator:

  SerializationUnknown = 0x0 The serialization is unknown. < p> |
  SerializationRdfXml = 0x1 Standard RDF XML serialization < p> |
  SerializationN3 = 0x2 Notation 3: http: www.w3.org DesignIssues Notation3 < p> |
  SerializationNTriples = 0x4 N-Triples as defined by W3: http: www.w3.org TR rdf-testcases #ntriples < p> |
  SerializationTurtle = 0x8 Turtle - Terse RDF Triple Language: http: www.dajobe.org 2004 01 turtle < p> |
  SerializationTrig = 0x10 TriG - Turtle + Named Graphs: http: sites.wiwiss.fu-berlin.de suhl bizer TriG < p> |
  SerializationNQuads = 0x20 N-Quads extends over N-Triples in that it adds an optional context node. < p> |
  SerializationUser = 0x0 The user type can be used to introduce unknown RDF serializations by name < p> |

## Function Documentation

Soprano.Model createModel | ( | Soprano.BackendSettings | settings=Soprano.BackendSettings()
| ) |  |  |

Creates a new RDF storage using the backend set via setUsedBackend. The caller takes ownership and has to care about deletion.

Parameters:

  | settings | The settings that should be used to create the Model. Backend implementations should never ignore settings but rather return 0 if an option is not supported. Backends can, however, define their own default settings.

\sa Model, Backend.createModel, BackendSetting

Soprano.Model createModel | ( | [Soprano.BackendSetting] | settings
| ) |  |  |

Soprano.Backend discoverBackendByFeatures | ( | Soprano.BackendFeatures | features,
|  | QStringList | userFeatures=QStringList()
| ) |  |  |

Find a backend plugin by its features.

Parameters:

  | features | The features that are requested.

Parameters:

  | userFeatures | If features contain Soprano.BackendFeatureUser this paramter states the additionally requested user features.

Returns:
  a backend that supports the features defined in features.

\sa PluginManager.discoverBackendByFeatures()

Soprano.Backend discoverBackendByName | ( | QString | name
| ) |  |  |

Find a backend plugin by its name.

Returns:
  the backend specified by name or null if could not be found.

bool isOptionInSettings | ( | Soprano.BackendSettings | settings,
|  | Soprano.BackendOption | option,
|  | QString | userOptionName=QString()
| ) |  |  |

Check if a certain option is defined in a list of BackendSettings.

Parameters:

  | settings | The list to check.

Parameters:

  | option | The option to check.

Parameters:

  | userOptionName | If option is Soprano.BackendOptionUser, this defines the user option to be checked.

Returns:
  true if the option is defined.

Since:
  2.2

Soprano.RdfSerialization mimeTypeToSerialization | ( | QString | mimetype
| ) |  |  |

Parse a mimetype and match it to the Soprano.RdfSerialization enum.

Returns:
  the Soprano.RdfSerialization type that matches mimetype or SerializationUnknown if the mimetype could not be parsed. Be aware that Soprano is very lax in parsing the mimetype, i.e. you can use simple strings like 'trig' or 'n-quads' instead of the proper mimetype for convenience.

QString serializationMimeType | ( | Soprano.RdfSerialization | serialization,
|  | QString | userSerialization=QString()
| ) |  |  |

Get the mimetype string of a serialization.

Parameters:

  | serialization | The serialization the mimetype is wanted for.

Parameters:

  | userSerialization | If serialization is SerializationUser then this is the user defined serialization. (this parameter is added for convinience to avoid having an additional check before using this method.)

Returns:
  The mimetype of serialization, an empty string is serialization is SerializationUnknown, or

userSerialization if serialization is SerializationUser.

setUsedBackend | ( | Soprano.Backend | a0
| ) |  |  |

By default and if available backend "redland" is used.

Soprano.BackendSetting settingInSettings | ( | Soprano.BackendSettings | settings,
|  | Soprano.BackendOption | option,
|  | QString | userOptionName=QString()
| ) |  |  |

Get a setting from the set, allowing to modify it.

Parameters:

  | settings | The list to check.

Parameters:

  | option | The option to extract.

Parameters:

  | userOptionName | If option is Soprano.BackendOptionUser, this defines the user option to be extracted.

Returns:
  The extracted setting.

Since:
  2.2

Soprano.Backend usedBackend | ( |  | self ) |

QVariant valueInSettings | ( | Soprano.BackendSettings | settings,
|  | Soprano.BackendOption | option,
|  | QString | userOptionName=QString()
| ) |  |  |

Retrieve the value of an option.

Parameters:

  | settings | The list to check.

Parameters:

  | option | The option to retrieve.

Parameters:

  | userOptionName | If option is Soprano.BackendOptionUser, this defines the user option to be retrieved.

Returns:
  The value of the specified option or an invalid variant if the set does not contain the option.

Since:
  2.2