KDE 4.5 PyKDE API Reference

- KDE's Python API

# Soprano Namespace Reference

`from PyKDE4.soprano.Soprano import *`

## Detailed Description

## Class Index

A | G | Q
AsyncModel (Soprano.Util) | Graph (Soprano) | QueryResultIterator (Soprano)
AsyncQuery (Soprano.Util) | I | QueryResultIteratorBackend (Soprano)
AsyncResult (Soprano.Util) | InferenceModel (Soprano.Inference) | R
B | L | Rule (Soprano.Inference)
Backend (Soprano) | LanguageTag (Soprano) | RuleParser (Soprano.Inference)
BackendSetting (Soprano) | LiteralValue (Soprano) | RuleSet (Soprano.Inference)
BindingSet (Soprano) | LocalSocketClient (Soprano.Client) | S
D | Locator (Soprano.Error) | Serializer (Soprano)
DBusClient (Soprano.Client) | M | ServerCore (Soprano.Server)
DBusExportIterator (Soprano.Server) | Model (Soprano) | SignalCacheModel (Soprano.Util)
DBusExportModel (Soprano.Server) | MutexModel (Soprano.Util) | SimpleNodeIterator (Soprano.Util)
DBusModel (Soprano.Client) | N | SimpleStatementIterator (Soprano.Util)
DBusNodeIterator (Soprano.Client) | Node (Soprano) | SparqlModel (Soprano.Client)
DBusQueryResultIterator (Soprano.Client) | NodeIterator (Soprano) | Statement (Soprano)
DBusStatementIterator (Soprano.Client) | NodePattern (Soprano.Inference) | StatementIterator (Soprano)
DummyModel (Soprano.Util) | NRLModel (Soprano) | StatementPattern (Soprano.Inference)
E | P | StorageModel (Soprano)
Error (Soprano.Error) | Parser (Soprano) | T
ErrorCache (Soprano.Error) | ParserError (Soprano.Error) | TcpClient (Soprano.Client)
F | Plugin (Soprano) |
FilterModel (Soprano) | PluginManager (Soprano) |

## Enumerations
BackendFeature | { BackendFeatureNone, BackendFeatureAddStatement, BackendFeatureRemoveStatements, BackendFeatureListStatements, BackendFeatureQuery, BackendFeatureInference, BackendFeatureInferenceOptional, BackendFeatureContext, BackendFeatureStorageMemory, BackendFeatureAll, BackendFeatureUser }
BackendOption | { BackendOptionNone, BackendOptionStorageMemory, BackendOptionEnableInference, BackendOptionStorageDir, BackendOptionHost, BackendOptionPort, BackendOptionUsername, BackendOptionPassword, BackendOptionUser }
RdfSerialization | { SerializationUnknown, SerializationRdfXml, SerializationN3, SerializationNTriples, SerializationTurtle, SerializationTrig, SerializationNQuads, SerializationUser }
## Functions
Soprano.Model | createModel ([Soprano.BackendSetting] settings=Soprano.BackendSettings())
Soprano.Backend | discoverBackendByFeatures (Soprano.BackendFeatures features, QStringList userFeatures=QStringList())
Soprano.Backend | discoverBackendByName (QString name)
bool | isOptionInSettings ([Soprano.BackendSetting] settings, Soprano.BackendOption option, QString userOptionName=QString())
Soprano.RdfSerialization | mimeTypeToSerialization (QString mimetype)
long | qHash (Soprano.LanguageTag node)
long | qHash (Soprano.LiteralValue lit)
long | qHash (Soprano.Node node)
QString | serializationMimeType (Soprano.RdfSerialization serialization, QString userSerialization=QString())
| setUsedBackend (Soprano.Backend a0)
Soprano.BackendSetting | settingInSettings ([Soprano.BackendSetting] settings, Soprano.BackendOption option, QString userOptionName=QString())
Soprano.BackendSetting | settingInSettings ([Soprano.BackendSetting] settings, Soprano.BackendOption option, QString userOptionName=QString())
Soprano.BackendSetting | settingInSettings ([Soprano.BackendSetting] settings, QString userOptionName=QString())
Soprano.BackendSetting | settingInSettings ([Soprano.BackendSetting] settings, QString userOptionName)
Soprano.Backend | usedBackend ()
QVariant | valueInSettings ([Soprano.BackendSetting] settings, Soprano.BackendOption option, QString userOptionName=QString())
QVariant | valueInSettings ([Soprano.BackendSetting] settings, QString userOptionName, QVariant defaultValue=QVariant())
QVariant | valueInSettingsWithDefault ([Soprano.BackendSetting] settings, Soprano.BackendOption option, QVariant defaultValue)

## 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 |
  BackendFeatureAll = BackendFeatureAddStatement|BackendFeatureRemoveStatements|BackendFeatureListStatements|BackendFeatureQuery|BackendFeatureInference|BackendFeatureInferenceOptional|BackendFeatureContext|BackendFeatureStorageMemory |
  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 |
  BackendOptionHost = 0x8 |
  BackendOptionPort = 0x10 |
  BackendOptionUsername = 0x20 |
  BackendOptionPassword = 0x40 |
  BackendOptionUser = 0x1000 |

RdfSerialization

Different types of RDF serialization.

\sa serializationMimeType, mimeTypeToSerialization

Enumerator:

  SerializationUnknown = 0x0 |
  SerializationRdfXml = 0x1 |
  SerializationN3 = 0x2 |
  SerializationNTriples = 0x4 |
  SerializationTurtle = 0x8 |
  SerializationTrig = 0x10 |
  SerializationNQuads = 0x20 |
  SerializationUser = 0x0 |

## Function Documentation

Soprano.Model createModel | ( | [Soprano.BackendSetting] | 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.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.

\sa PluginManager.discoverBackendByName()

bool isOptionInSettings | ( | [Soprano.BackendSetting] | 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.

long qHash | ( | Soprano.LanguageTag | node
| ) |  |  |

long qHash | ( | Soprano.LiteralValue | lit
| ) |  |  |

long qHash | ( | Soprano.Node | node
| ) |  |  |

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
| ) |  |  |

Set the Backend to globally use in createModel.

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

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

Parameters:

  | settings | The list to check.

Parameters:

  | userOptionName | The user option to be extracted.

Returns:
  The extracted setting. If the setting is not found an empty BackendSetting is returned.

Since:
  2.4

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

Parameters:

  | settings | The list to check.

Parameters:

  | userOptionName | The user option to be extracted.

Returns:
  The extracted setting. If the setting is not found an empty BackendSetting is returned.

Since:
  2.4

Soprano.BackendSetting settingInSettings | ( | [Soprano.BackendSetting] | settings,
|  | QString | userOptionName=QString()
| ) |  |  |

Parameters:

  | settings | The list to check.

Parameters:

  | userOptionName | The user option to be extracted.

Returns:
  The extracted setting. If the setting is not found an empty BackendSetting is returned.

Since:
  2.4

Soprano.BackendSetting settingInSettings | ( | [Soprano.BackendSetting] | settings,
|  | QString | userOptionName
| ) |  |  |

Parameters:

  | settings | The list to check.

Parameters:

  | userOptionName | The user option to be extracted.

Returns:
  The extracted setting. If the setting is not found an empty BackendSetting is returned.

Since:
  2.4

Soprano.Backend usedBackend | ( |  | ) |

Retrieve the Backend to globally use in createModel.

Can be set via setUsedBackend.

QVariant valueInSettings | ( | [Soprano.BackendSetting] | settings,
|  | Soprano.BackendOption | option,
|  | QString | userOptionName=QString()
| ) |  |  |

Parameters:

  | settings | The list to check.

Parameters:

  | userOptionName | The user option to retrieve.

Parameters:

  | defaultValue | The default to use if option is not part of settings

Returns:
  The value of the specified option or default if settings does not contain the option.

Since:
  2.4

QVariant valueInSettings | ( | [Soprano.BackendSetting] | settings,
|  | QString | userOptionName,
|  | QVariant | defaultValue=QVariant()
| ) |  |  |

Parameters:

  | settings | The list to check.

Parameters:

  | userOptionName | The user option to retrieve.

Parameters:

  | defaultValue | The default to use if option is not part of settings

Returns:
  The value of the specified option or default if settings does not contain the option.

Since:
  2.4

QVariant valueInSettingsWithDefault | ( | [Soprano.BackendSetting] | settings,
|  | Soprano.BackendOption | option,
|  | QVariant | defaultValue
| ) |  |  |

Retrieve the value of an option with a fallback default.

Parameters:

  | settings | The list to check.

Parameters:

  | option | The option to retrieve.

Parameters:

  | defaultValue | The default to use if option is not part of settings

Returns:
  The value of the specified option or default if settings does not contain the option.

Since:
  2.4