KDE 4.6 PyKDE API Reference

- KDE's Python API

# RuleParser Class Reference

`from PyKDE4.soprano import *`

Namespace: Soprano.Inference

## Detailed Description

\class RuleParser inferenceruleparser.h Soprano/Inference/RuleParser

The RuleParser can be used to parse %Soprano rule files.

\sa RuleSet.standardRuleSet()

Author:
  Sebastian Trueg <trueg@kde.org>

## Methods

| __init__ (self)
| __init__ (self, Soprano.Inference.RuleParser other)
| addPrefix (self, QString qname, QUrl uri)
| clear (self)
bool | parseFile (self, QString path)
Soprano.Inference.Rule | parseRule (self, QString line)
{QString:QUrl} | prefixes (self)
Soprano.Inference.RuleSet | rules (self)

## Method Documentation

__init__ | ( |  | self ) |

__init__ | ( | self, |
|  | Soprano.Inference.RuleParser | other
| ) |  |  |

addPrefix | ( | self, |
|  | QString | qname,
|  | QUrl | uri
| ) |  |  |

Add a prefix to use during rule parsing.

Parameters:

  | qname | The abbreviated name of the prefix

Parameters:

  | uri | The namespace to use for the prefix

Since:
  2.3

clear | ( |  | self ) |

Clear all parsed rules and prefixes.

Since:
  2.3

bool parseFile | ( | self, |
|  | QString | path
| ) |  |  |

Parse rules from a file. The parsed rules can be accessed via rules().

Returns:
  true on success, false otherwise.

Soprano.Inference.Rule parseRule | ( | self, |
|  | QString | line
| ) |  |  |

Parse a single rule from a string.

Parameters:

  | line | A single line defining the rule

Returns:
  The parsed rule in case line is a valid rule line, an invalid rule otherwise. The parsed rule can also be accessed via rules().

Since:
  2.3

{QString:QUrl} prefixes | ( |  | self ) |

Retrieve all prefixes set via addPrefix.

Returns:
  a QHash containing of the prefixe qnames and their URIs.

Since:
  2.3

Soprano.Inference.RuleSet rules | ( |  | self ) |

Retrieve the rules parsed in parseFile and parseRule