Redland RDF Application Framework - Python API Reference

 
 
RDF (version 1.1, $Date: 2005/05/04 10:16:37 $)
index
 
Modules
        
Redland
string
sys
 
Classes
        
exceptions.Exception
RedlandError
NodeTypeError
RedlandWarning
StreamIter
__builtin__.object
Iterator
IteratorIter
IteratorWithContextIter
Model
NS
Node
Parser
NTriplesParser
RDFXMLParser
RSSTagSoupParser
TurtleParser
Query
RDQLQuery
SPARQLQuery
QueryResults
Serializer
NTriplesSerializer
RDFXMLAbbrevSerializer
RDFXMLSerializer
RSS10Serializer
Statement
Storage
FileStorage
HashStorage
MemoryStorage
Stream
StreamWithContextIter
Uri
World
 
class FileStorage(Storage)
    Redland file Storage class
 
   import RDF
   s=RDF.FileStorage("abc")
 
Class of file Storage with required name, additional options.
 
 
Method resolution order:
FileStorage
Storage
__builtin__.object

Methods defined here:
__init__(self, mem_name, options_string='')

Methods inherited from Storage:
__del__(self)

Data and other attributes inherited from Storage:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Storage' objects>
list of weak references to the object (if defined)
 
class HashStorage(Storage)
    Redland Hashed Storage class
 
   import RDF
   h1=RDF.HashStorage("abc", options="hash-type='memory'")
 
   # Creating a storage with contexts enabled
   s=RDF.HashStorage("def", options="contexts='yes'")
 
Class of hashed Storage for a particular type of hash (typically
hash-type is "memory" or "bdb") and any other options.
 
 
Method resolution order:
HashStorage
Storage
__builtin__.object

Methods defined here:
__init__(self, hash_name, options='')

Methods inherited from Storage:
__del__(self)

Data and other attributes inherited from Storage:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Storage' objects>
list of weak references to the object (if defined)
 
class Iterator(__builtin__.object)
    Redland Node Iterator class
 
A class for iterating over a sequence of Node s such as
those returned from a Model query.  Some methods return
Iterator s or Python sequences.  If this is used, it works
as follows:
 
  iterator=model.get_targets_iterator(source, arc)
  while not iterator.end():
    # get the current Node
    node=iterator.current()
    # do something with it
    # (it is shared; you must copy it you want to keep it)
    ...
    iterator.next()
  iterator=None
 
  Methods defined here:
__del__(self)
__init__(self, object, creator1=None, creator2=None, creator3=None)
Create an RDF Iterator (constructor).
__iter__(self)
context(self)
Return the context Node of the current object on the Iterator
current(self)
Return the current object on the Iterator
end(self)
Return true if the iterator is exhausted
have_elements(self)
next(self)
Move to the next object on the Iterator

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Iterator' objects>
list of weak references to the object (if defined)
 
class IteratorIter(__builtin__.object)
      Methods defined here:
__init__(self, iterator)
__iter__(self)
next(self)

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'IteratorIter' objects>
list of weak references to the object (if defined)
 
class IteratorWithContextIter(__builtin__.object)
      Methods defined here:
__init__(self, iterator)
__iter__(self)
next(self)

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'IteratorWithContextIter' objects>
list of weak references to the object (if defined)
 
class MemoryStorage(Storage)
    Redland memory Storage class
 
   import RDF
   h1=RDF.MemoryStorage()
   h1=RDF.MemoryStorage("abc")
   h2=RDF.MemoryStorage("abc", "write='no'")
 
   # Creating a storage with contexts enabled
   s = RDF.MemoryStorage(options_string="contexts='yes'")
 
Class of memory Storage with optional name, additional options.
 
 
Method resolution order:
MemoryStorage
Storage
__builtin__.object

Methods defined here:
__init__(self, mem_name='', options_string='')

Methods inherited from Storage:
__del__(self)

Data and other attributes inherited from Storage:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Storage' objects>
list of weak references to the object (if defined)
 
class Model(__builtin__.object)
    Redland Graph class
 
  import RDF
  model = RDF.Model(storage)
 
The main interface to the Redland RDF graph (formed from triples, or
RDF statements).  There are many methods for adding, removing, querying
statements and serializing them to/from syntaxes using the Serializer
or Parser classes.
 
Models can also be used as Python sequences to give every triple in the
model:
 
  for statement in model:
    print statement
 
Models have other aspects of sequence types.  The following also works:
 
  if statement in model:            # do whatever
  if (statement, context) in model: # do whatever
 
  del model[statement]              # remove statement from model
  del model[statement, context]     # ditto for context-aware model
 
  model.append(statement)           # append a statement
  model.append(statement, context)  # append statement with context
 
  num_items = len(model) # get number of statements in the model
                         # works only with countable storages
 
  Methods defined here:
__contains__(self, arg)
__del__(self)
__delitem__(self, arg)
__init__(self, storage=None, **args)
Create an RDF Model (constructor).
 
Create a Model from an existing Storage (most common use).  
 
Optional parameters:
 
  options_string - A string of options for the Model
  options_hash   - A Hash of options for the Model
 
  m1 = RDF.Model(s1)
  m1 = RDF.Model(storage = s1)
 
Copy an existing model m1, copying the underlying Storage of m1
 
  m2 = RDF.Model(model = m1)
 
Create a model using an in-memory storage.
 
  m3 = RDF.Model()
__iter__(self)
__len__(self)
__str__(self)
__unicode__(self)
add(self, subject, predicate, object)
Add the statement (subject,predicate,object) to the model.
DEPRECATED. Use Model.append(Statement(s,p,o)) instead.
add_statement(self, statement, context=None)
Add the Statement to the Model with optional context Node.
For Python idiom you should use Model.append() instead, which does
the same thing.
add_statements(self, statement_stream, context=None)
Add the Stream of Statements to the Model with the optional
context Node
add_typed_literal_statement(self, subject, predicate, string, xml_language=None, datatype=None)
Add the Statement (subject,predicate, typed literal) to the Model
where the typed literal is constructed from the
literal string, optional XML language and optional datatype URI.
DEPRECATED. Use Model.append(Statement(s,p,o)) instead.
append(self, statement, context=None)
Append a Statement to the Model, with optional context Node.
 
model.append(Statement(s, p, o)
arcs = get_predicates(self, source, target)
as_stream(self, context=None)
Return the Model as a Stream of Statements.  No need to use
this explicitly, instead do:
    
    for statement in model:
        # process statement
as_stream_context(self, context=None)
Return the Model as a Stream of (statement, context) tuples.
 
 for (s, c) in model.as_stream_context():
     # do whatever
 
Specify the optional argument context if you want to hardwire
the stream's context.
contains_statement(self, statement)
Return true if the Statement is in the Model
contains_statement_context(self, statement, context)
Return true if the Statement is in the Model with the specified
context.  Note that the implementation is pretty inefficient.
context_remove_statements = remove_statements_with_context(self, context)
execute(self, query)
find_statements(self, statement, context=None)
Return a Stream of Statements matching the given Statement --
any nodes with value None of the statement match any Node in
the Model.
 
Specify the optional argument context if you want to search
only in one context.
 
qs = RDF.Statement(subject = None,
    predicate = RDF.Node(uri_string = "http://example.com/pred"),
    object = None)
for statement in model.find_statements(qs):
    # do whatever
find_statements_context(self, statement)
Return a Stream of Statements with context, matching the given
Statement -- any nodes with value None of the statement match
any Node in the Model.
 
qs = RDF.Statement(subject = None,
    predicate = RDF.Node(uri_string = "http://example.com/pred"),
    object = None)
for (statement, context) in model.find_statements_context(qs):
    # do whatever
get_arc = get_predicate(self, source, target)
get_arcs = get_predicates(self, source, target)
get_contexts(self)
Return a sequence of context Nodes in the Model.
get_feature(self, uri)
Return the Node value of Model feature URI uri
get_predicate(self, source, target)
Return one Node in the Model matching (source, ?, target).
The source can be a Node or Uri, the target a NodeUri or string.
get_predicates(self, source, target)
Return a sequence of Nodes that are the predicates
of Statements in the Model matching (source, ?, target).
 
Instead of specifying a Node for source, you can shortcut with
Uri, and with a Uri or string for target.
 
e.g.
  model.get_predicates(Uri("http://example.com/me"), "Fred")
get_predicates_context(self, source, target)
As for Model.get_predicates but returns a list of 
(statement, context) tuples.
get_source(self, predicate, target)
Return one Node in the Model matching (?, predicate, target).
The predicate can be a Node or Uri, the target a NodeUri or string.
get_sources(self, predicate, target)
Return a sequence of Node s that are the source
of Statements in the Model matching (?, predicate, target).
 
Instead of specifying a Node for predicate, you can shortcut with
Uri, and with a Uri or string for target.
 
e.g.
  model.get_sources(Uri("http://example.com/name"), "Fred")
get_sources_context(self, predicate, target)
As for Model.get_sources but returns a list of 
(statement, context) tuples.
get_target(self, source, predicate)
Return one Node in the Model matching (source, predicate, ?).
The source and predicate can be a Node or Uri.
get_targets(self, source, predicate)
Return a sequence of Nodes that are the targets
of Statements in the Model matching (source, predicate, ?).
 
Instead of specifying a Node for source or predicate, you
can shortcut with a Uri.
 
e.g.
 
  model.get_targets(Uri("http://example.com/me"), prednode)
get_targets_context(self, source, predicate)
As for Model.get_targets but returns a list of 
(statement, context) tuples.
load(self, uri, name='', mime_type='', type_uri=None, handler=None)
Load triples into the Model from a URI in a syntax.
 
If no parser name is given, the parser to use is guessed.
 
If handler is given, an error handler with the signature
  def handler(code, level, facility, message, line, column, byte, file, uri)
is called.
predicates = get_predicates(self, source, target)
remove_statement(self, statement, context=None)
Remove the Statement from the Model with the optional context Node.
This is used by the __delitem__ method.  Preferred way of removing a
Statement is:
    
    del model[statement]
    del model[statement, context]
remove_statements_with_context(self, context)
Remove all Statements from the Model with the given context Node
run_as_statements(self, query)
serialise = as_stream(self, context=None)
set_feature(self, uri, value)
Set the Node value of Model feature URI uri.
size(self)
Return the size of the Model in number of statements.
Returns a value < 0 if number of statements not countable.
sources = get_sources(self, predicate, target)
sync(self)
Synchronise the Model with the underlying Storage.
targets = get_targets(self, source, predicate)
to_string(self, base_uri=None, name='', mime_type='', type_uri=None)
Serialize the Model to a syntax.
 
print model.to_string(base_uri="http://example.org/base")
 
If no serializer name is given, the default serializer RDF/XML is used.

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Model' objects>
list of weak references to the object (if defined)
 
class NS(__builtin__.object)
    Redland Namespace Utility Class
 
import RDF
nspace = RDF.NS("http://example.com/foo")
 
# creates an RDF Node for http://example.com/foo#blah   
node1 = nspace.blah
 
# creates an RDF Node for http://example.com/foo#blah   
node2 = nspace['blah']
 
A class for generating RDF Nodes with URIs from the same vocabulary
(such as XML Namespace) varying only in the appended name in
the vocabulary.  Each node returned is a pointer to a shared copy.
 
  Methods defined here:
__getattr__(self, localName)
__getitem__(self, localName)
__init__(self, prefix)
node(self, localName)

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'NS' objects>
list of weak references to the object (if defined)
 
class NTriplesParser(Parser)
     
Method resolution order:
NTriplesParser
Parser
__builtin__.object

Methods defined here:
__init__(self, uri=None)

Methods inherited from Parser:
__del__(self)
get_feature(self, uri)
Return the Node value of Parser feature URI uri
parse_as_stream(self, uri, base_uri=None)
Return a Stream of Statements from parsing the content at
a URI for the optional base URI or None if the parsing fails.
 
(This depends on what URI support raptor provides to redland)
 
  for statement in parser.parse_as_stream(""):
      print statement
parse_into_model(self, model, uri, base_uri=None, handler=None)
Parse into the Model model from the content at the URI, for
the optional base URI.
 
If handler is given, an error handler with the signature
  def handler(code, level, facility, message, line, column, byte, file, uri)
is called.
 
parser.parse_into_model(model, "file:./foo.rdf",
                        "http://example.com/foo.rdf")
parse_string_as_stream(self, string, base_uri)
Return a Stream of Statements from parsing the content in
string with the required base URI or None if the parsing fails.
 
  for statement in parser.parse_string_as_stream(rdfstring, base_uri):
      print statement
parse_string_into_model(self, model, string, base_uri, handler=None)
Parse into the Model model from the content string
 with the required base URI
 
If handler is given, an error handler with the signature
  def handler(code, level, facility, message, line, column, byte, file, uri)
is called.
set_feature(self, uri, value)
Set the Node value of Parser feature URI uri.

Data and other attributes inherited from Parser:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Parser' objects>
list of weak references to the object (if defined)
 
class NTriplesSerializer(Serializer)
    Redland N-Triples Serializer class
 
import RDF
ser=RDF.NTriplesSerializer()
 
 
Method resolution order:
NTriplesSerializer
Serializer
__builtin__.object

Methods defined here:
__init__(self)

Methods inherited from Serializer:
__del__(self)
get_feature(self, uri)
Return the value of Serializer feature URI uri
serialize_model_to_file(self, name, model, base_uri=None)
Serialize to filename name the Model model using the
optional base URI.
serialize_model_to_string(self, model, base_uri=None)
Serialize to a string using the optional base URI.
set_feature(self, uri, value)
Set the value of Serializer feature URI uri.
set_namespace(self, prefix, uri)
Set a namespace prefix and URI for the Serializer to use.

Data and other attributes inherited from Serializer:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Serializer' objects>
list of weak references to the object (if defined)
 
class Node(__builtin__.object)
    Redland Node (RDF Resource, Property, Literal) Class
 
  import RDF
 
  node1=RDF.Node()
 
  node2=RDF.Node(RDF.Uri("http://example.com/"))
  node3=RDF.Node("Hello, World!")
 
  node4=RDF.Node(uri_string="http://example.com/")
  node5=RDF.Node(literal="<tag>content</tag>", is_wf_xml=1)
  node6=RDF.Node(blank="abc")
  node7=RDF.Node(node5)
...
 
  print node2
  if node7.is_resource():
    print "Resource with URI", node7.uri
 
  if node5.is_blank():
    print "Resource with blank node name ", node5.blank_identifier
 
  Methods defined here:
__del__(self)
Free an RDF Node (destructor).
__eq__(self, other)
Equality of an RDF Node compared to another RDF Node.
__hash__(self)
__init__(self, arg=None, **args)
Create an RDF Node (constructor).
 
Resource or Property node creation:
 
  n1 = Node(Uri("http://example.com/foo"))
 
String literal node creation (see below for more complex
ways of building literals.)
 
  n2 = Node("foo")
 
Node copying:
 
  n3 = Node(n1)
 
Or create a new RDF Node using the following named parameters:
 
  uri_string  - create a resource node from a string URI
  uri         - create a resource node from a URI object
  literal     - create a literal node from a literal string   
    datatype     - the datatype URI
    is_wf_xml    - the literal is XML (alternative to datatype)
    language     - the literal XML language
  blank       - create a resource node from with a blank node identiifer
  node        - copy a node
__ne__(self, other)
Inequality of an RDF Node compared to another RDF Node.
__str__(self)
Get a string representation of an RDF Node.
__unicode__(self)
Get a Unicode string representation of an RDF Node.
is_blank(self)
Return true if node is a blank node
is_literal(self)
Return true if node is a literal
is_resource(self)
Return true if node is a resource  with a URI

Properties defined here:
blank_identifier
The node identifier of a blank node
get = _get_blank_identifier(self)
literal_value
A dictionary containing the value of the node literal with keys string, language and datatype
get = _get_literal_value(self)
type
The node type, an integer
get = _get_type(self)
uri
The URI of a resource node
get = _get_uri(self)

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Node' objects>
list of weak references to the object (if defined)
 
class NodeTypeError(RedlandError)
     
Method resolution order:
NodeTypeError
RedlandError
exceptions.Exception

Methods inherited from RedlandError:
__init__(self, value)
__str__(self)

Methods inherited from exceptions.Exception:
__getitem__(...)
 
class Parser(__builtin__.object)
    Redland Syntax Parser Class
 
import RDF
parser1=RDF.Parser()
parser2=RDF.Parser(name="rdfxml")
parser3=RDF.Parser(mime_type="application/rdf+xml")
 
stream=parser2.parse_as_stream("file://dir/file.rdf")
parser3.parse_into_model(model, "file://dir/file.rdf", "http://example.org/")
 
The default parser type if not given explicitly is raptor,
for the RDF/XML syntax.
 
  Methods defined here:
__del__(self)
__init__(self, name='rdfxml', mime_type='', uri=None)
Create an RDF Parser (constructor).
 
Create a new RDF Parser for a particular syntax.  The parser is
chosen by the fields given to the constructor, all of which are
optional.  When any are given, they must all match.
 
  name      - parser name (currently "rdfxml", "ntriples", "turtle" and "rss-tag-soup")
  mime_type - currently "application/rdf+xml" (default) or "text/plain" (ntriples)
  uri       - URI identifying the syntax
              currently only "http://www.w3.org/TR/rdf-testcases/#ntriples"
get_feature(self, uri)
Return the Node value of Parser feature URI uri
parse_as_stream(self, uri, base_uri=None)
Return a Stream of Statements from parsing the content at
a URI for the optional base URI or None if the parsing fails.
 
(This depends on what URI support raptor provides to redland)
 
  for statement in parser.parse_as_stream(""):
      print statement
parse_into_model(self, model, uri, base_uri=None, handler=None)
Parse into the Model model from the content at the URI, for
the optional base URI.
 
If handler is given, an error handler with the signature
  def handler(code, level, facility, message, line, column, byte, file, uri)
is called.
 
parser.parse_into_model(model, "file:./foo.rdf",
                        "http://example.com/foo.rdf")
parse_string_as_stream(self, string, base_uri)
Return a Stream of Statements from parsing the content in
string with the required base URI or None if the parsing fails.
 
  for statement in parser.parse_string_as_stream(rdfstring, base_uri):
      print statement
parse_string_into_model(self, model, string, base_uri, handler=None)
Parse into the Model model from the content string
 with the required base URI
 
If handler is given, an error handler with the signature
  def handler(code, level, facility, message, line, column, byte, file, uri)
is called.
set_feature(self, uri, value)
Set the Node value of Parser feature URI uri.

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Parser' objects>
list of weak references to the object (if defined)
 
class Query(__builtin__.object)
    Redland Query interface class
 
import RDF
 
q1 = RDF.Query("SELECT ?a ?c WHERE (?a dc:title ?c) USING dc FOR <http://purl.org/dc/elements/1.1/>")
q2 = RDF.Query("- - -", query_language="triples")
q3 = RDF.Query("select $a where ...", query_language="sparql")
 
results=q1.execute(model)
for result in results:
  print result['a']
  print result['c']
 
for statement in q2.execute().as_stream(model):
  print statement
 
  Methods defined here:
__del__(self)
__init__(self, querystring, base_uri=None, query_language='rdql', query_uri=None)
execute(self, model)

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Query' objects>
list of weak references to the object (if defined)
 
class QueryResults(__builtin__.object)
    Redland Query results class
 
  Methods defined here:
__del__(self)
__init__(self, query, results)
__iter__(self)
__len__(self)
Get the number of query results returned so far
__str__(self)
Serialize to string syntax format.
as_stream(self)
Return the query results as a stream of triples (RDF.Statement)
finished(self)
Test if reached the last variable binding result
get_binding_name(self, offset)
Get the name of a variable binding by offset
get_binding_value(self, offset)
Get the value of a variable binding by offset
get_binding_value_by_name(self, name)
Get the value of a variable binding by variable name
get_bindings_count(self)
Get the number of variable bindings in the query result
get_boolean(self)
Get the boolean query result
is_bindings(self)
Test if the query results format is variable bindings
is_boolean(self)
Test if the query results format is a boolean
is_graph(self)
Test if the query results format is an RDF graph
make_results_hash(self)
next(self)
Get the next variable binding result
to_file(self, name, base_uri=None)
Serialize to filename name using the optional base URI.
to_string(self, format_uri=None, base_uri=None)
Serialize to a string syntax format_uri using the optional base URI.

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'QueryResults' objects>
list of weak references to the object (if defined)
 
class RDFXMLAbbrevSerializer(Serializer)
    Redland RDF/XML with abbreviations Serializer class
 
import RDF
ser=RDF.RDFXMLAbbrevSerializer()
 
 
Method resolution order:
RDFXMLAbbrevSerializer
Serializer
__builtin__.object

Methods defined here:
__init__(self)

Methods inherited from Serializer:
__del__(self)
get_feature(self, uri)
Return the value of Serializer feature URI uri
serialize_model_to_file(self, name, model, base_uri=None)
Serialize to filename name the Model model using the
optional base URI.
serialize_model_to_string(self, model, base_uri=None)
Serialize to a string using the optional base URI.
set_feature(self, uri, value)
Set the value of Serializer feature URI uri.
set_namespace(self, prefix, uri)
Set a namespace prefix and URI for the Serializer to use.

Data and other attributes inherited from Serializer:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Serializer' objects>
list of weak references to the object (if defined)
 
class RDFXMLParser(Parser)
     
Method resolution order:
RDFXMLParser
Parser
__builtin__.object

Methods defined here:
__init__(self, uri=None)

Methods inherited from Parser:
__del__(self)
get_feature(self, uri)
Return the Node value of Parser feature URI uri
parse_as_stream(self, uri, base_uri=None)
Return a Stream of Statements from parsing the content at
a URI for the optional base URI or None if the parsing fails.
 
(This depends on what URI support raptor provides to redland)
 
  for statement in parser.parse_as_stream(""):
      print statement
parse_into_model(self, model, uri, base_uri=None, handler=None)
Parse into the Model model from the content at the URI, for
the optional base URI.
 
If handler is given, an error handler with the signature
  def handler(code, level, facility, message, line, column, byte, file, uri)
is called.
 
parser.parse_into_model(model, "file:./foo.rdf",
                        "http://example.com/foo.rdf")
parse_string_as_stream(self, string, base_uri)
Return a Stream of Statements from parsing the content in
string with the required base URI or None if the parsing fails.
 
  for statement in parser.parse_string_as_stream(rdfstring, base_uri):
      print statement
parse_string_into_model(self, model, string, base_uri, handler=None)
Parse into the Model model from the content string
 with the required base URI
 
If handler is given, an error handler with the signature
  def handler(code, level, facility, message, line, column, byte, file, uri)
is called.
set_feature(self, uri, value)
Set the Node value of Parser feature URI uri.

Data and other attributes inherited from Parser:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Parser' objects>
list of weak references to the object (if defined)
 
class RDFXMLSerializer(Serializer)
    Redland RDF/XML Serializer class
 
import RDF
ser=RDF.RDFXMLSerializer()
 
 
Method resolution order:
RDFXMLSerializer
Serializer
__builtin__.object

Methods defined here:
__init__(self)

Methods inherited from Serializer:
__del__(self)
get_feature(self, uri)
Return the value of Serializer feature URI uri
serialize_model_to_file(self, name, model, base_uri=None)
Serialize to filename name the Model model using the
optional base URI.
serialize_model_to_string(self, model, base_uri=None)
Serialize to a string using the optional base URI.
set_feature(self, uri, value)
Set the value of Serializer feature URI uri.
set_namespace(self, prefix, uri)
Set a namespace prefix and URI for the Serializer to use.

Data and other attributes inherited from Serializer:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Serializer' objects>
list of weak references to the object (if defined)
 
class RDQLQuery(Query)
    Redland RDQL Query class
 
 
Method resolution order:
RDQLQuery
Query
__builtin__.object

Methods defined here:
__init__(self, querystring, base_uri=None)

Methods inherited from Query:
__del__(self)
execute(self, model)

Data and other attributes inherited from Query:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Query' objects>
list of weak references to the object (if defined)
 
class RSS10Serializer(Serializer)
    Redland RSS 1.0 Serializer class
 
import RDF
ser=RDF.RSS10Serializer()
 
 
Method resolution order:
RSS10Serializer
Serializer
__builtin__.object

Methods defined here:
__init__(self)

Methods inherited from Serializer:
__del__(self)
get_feature(self, uri)
Return the value of Serializer feature URI uri
serialize_model_to_file(self, name, model, base_uri=None)
Serialize to filename name the Model model using the
optional base URI.
serialize_model_to_string(self, model, base_uri=None)
Serialize to a string using the optional base URI.
set_feature(self, uri, value)
Set the value of Serializer feature URI uri.
set_namespace(self, prefix, uri)
Set a namespace prefix and URI for the Serializer to use.

Data and other attributes inherited from Serializer:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Serializer' objects>
list of weak references to the object (if defined)
 
class RSSTagSoupParser(Parser)
     
Method resolution order:
RSSTagSoupParser
Parser
__builtin__.object

Methods defined here:
__init__(self, uri=None)

Methods inherited from Parser:
__del__(self)
get_feature(self, uri)
Return the Node value of Parser feature URI uri
parse_as_stream(self, uri, base_uri=None)
Return a Stream of Statements from parsing the content at
a URI for the optional base URI or None if the parsing fails.
 
(This depends on what URI support raptor provides to redland)
 
  for statement in parser.parse_as_stream(""):
      print statement
parse_into_model(self, model, uri, base_uri=None, handler=None)
Parse into the Model model from the content at the URI, for
the optional base URI.
 
If handler is given, an error handler with the signature
  def handler(code, level, facility, message, line, column, byte, file, uri)
is called.
 
parser.parse_into_model(model, "file:./foo.rdf",
                        "http://example.com/foo.rdf")
parse_string_as_stream(self, string, base_uri)
Return a Stream of Statements from parsing the content in
string with the required base URI or None if the parsing fails.
 
  for statement in parser.parse_string_as_stream(rdfstring, base_uri):
      print statement
parse_string_into_model(self, model, string, base_uri, handler=None)
Parse into the Model model from the content string
 with the required base URI
 
If handler is given, an error handler with the signature
  def handler(code, level, facility, message, line, column, byte, file, uri)
is called.
set_feature(self, uri, value)
Set the Node value of Parser feature URI uri.

Data and other attributes inherited from Parser:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Parser' objects>
list of weak references to the object (if defined)
 
class RedlandError(exceptions.Exception)
    Redland Runtime errors
 
  Methods defined here:
__init__(self, value)
__str__(self)

Methods inherited from exceptions.Exception:
__getitem__(...)
 
class RedlandWarning(RedlandError)
     
Method resolution order:
RedlandWarning
RedlandError
exceptions.Exception

Methods inherited from RedlandError:
__init__(self, value)
__str__(self)

Methods inherited from exceptions.Exception:
__getitem__(...)
 
class SPARQLQuery(Query)
    Redland SPARQL Query class
 
 
Method resolution order:
SPARQLQuery
Query
__builtin__.object

Methods defined here:
__init__(self, querystring, base_uri=None)

Methods inherited from Query:
__del__(self)
execute(self, model)

Data and other attributes inherited from Query:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Query' objects>
list of weak references to the object (if defined)
 
class Serializer(__builtin__.object)
    Redland Syntax Serializer Class
 
import RDF
ser1=RDF.Serializer()
 
ser2=RDF.Serializer(mime_type="application/rdf+xml")
 
ser3=RDF.Serializer(name="ntriples")
 
A class for turning a Model into a syntax serialization (at present
only to local files).
 
  Methods defined here:
__del__(self)
__init__(self, name='', mime_type='', uri=None)
Create an RDF Serializer (constructor).
 
The arguments name, mime_type and uri are all optional and
when omitted the default serialization syntax is used.  If
any arguments are given, they must all match for an appropriate
syntax to be chosen.  For example, RDF/XML has a MIME type of
'application/rdf+xml' so this can be given with the mime_type
argument, however the N-Triples has none, so the 'ntriples' name
must be used.  Most syntaxes have URIs.
get_feature(self, uri)
Return the value of Serializer feature URI uri
serialize_model_to_file(self, name, model, base_uri=None)
Serialize to filename name the Model model using the
optional base URI.
serialize_model_to_string(self, model, base_uri=None)
Serialize to a string using the optional base URI.
set_feature(self, uri, value)
Set the value of Serializer feature URI uri.
set_namespace(self, prefix, uri)
Set a namespace prefix and URI for the Serializer to use.

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Serializer' objects>
list of weak references to the object (if defined)
 
class Statement(__builtin__.object)
    Redland Statement (triple) class.  The main means of manipulating
statements is by the subject, predicate and object properties.
 
  import RDF
  statement1 = RDF.Statement(node1, node2, node3)
  statement2 = RDF.Statement(statement = statement1)
 
  if statement2.subject.is_resource():
    print "statement2 subject is URI ",statement2.subject.uri
 
  statement.object = Node("hello, world")
 
  Methods defined here:
__del__(self)
__eq__(self, other)
Equality of an RDF Statement compared to another RDF Statement.
__init__(self, subject=None, predicate=None, object=None, **args)
Constructor for Statement.
 
Create a Statement from three Node objects.
 
    s1 = RDF.Statement(subjnode, prednode, objnode)
 
Node argument can be replaced with Uri or string to
shortcut Node creation.
 
    s2 = RDF.Statement(Uri(""), Uri(""), "baz")
 
Copy an existing Statement s1.
 
    s3 = RDF.Statement(statement=s1)
__ne__(self, other)
Inequality of an RDF Statement compared to another RDF Statement.
__str__(self)
__unicode__(self)
matches(self, other)
Comparison of this potentially incomplete RDF Statement compared to another RDF Statement.

Properties defined here:
object
The object node of the statement.
get = _get_object(self)
set = _set_object(self, value)
predicate
The predicate node of the statement.
get = _get_predicate(self)
set = _set_predicate(self, value)
subject
The subject node of the statement.
get = _get_subject(self)
set = _set_subject(self, value)

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Statement' objects>
list of weak references to the object (if defined)
 
class Storage(__builtin__.object)
    Redland Statement Storage class
 
   import RDF
   storage=RDF.Storage(storage_name="memory")
 
The Redland abstraction for storing RDF graphs as Statements.
 
There are no user methods (can only be constructed).
 
You should normally use a specialized class such as MemoryStorage or
HashStorage in preference to this class.
 
  Methods defined here:
__del__(self)
__init__(self, **args)
Create an RDF Storage (constructor).
 
    Create a new RDF Storage using any of these forms
 
  s1=RDF.Storage(storage_name="name")
 
Create a Storage of the given type.  Currently the built in storage
names that are always present are 'memory', 'hashes', 'file' and
'uri'.  'bdb' is available when Sleepycat / BerkeleyDB is compiled
in, 'mysql' when MySQL is compiled in, and 'sqlite' when SQLite is
compiled in.  If storage_name is omitted, it defaults to 'memory'.
 
The argument 'name' can be used when the storage needs a name
to operate, such as used for a filename or URI:
 
  s1=RDF.Storage(storage_name="file", name='/filename')
 
  s2=RDF.Storage(storage_name="uri", name='http://rdf.example.org/')
 
 
The argument options_string allows additional store-specific options
to be given, some of which are required by certain stores.  This uses
the following form:
 
  s3=RDF.Storage(storage_name="name", name='abc',
                 options_string="key1='value1', key2='value2', ...")
 
for multiple key/value option pairs, option values are always
surrounded by single quotes.
 
The common options are:
  new - optional and takes a boolean value (default false)
    If true, it deletes any existing store and creates a new one
    otherwise if false (default) open an existing store.
 
  write - optional and takes a boolean value (default true)
    If true (default) the Storage is opened read-write otherwise
    if false the storage is opened read-only and for file-based
    Storages or those with locks, may be opened with shared-readers.
 
Some storage types have additional options:
 
storage_name 'hashes' has options:
  hash-type -  the name of any hash type supported.
    'memory' (default), 'file' hash types are always present. 'bdb' is
    available when BerkeleyDB is compiled in,
  dir - the directory name to create the files in (default '.')
  mode - the file creation mode (default 0644 octal)
 
storage_name 'mysql' has options:
  host - required MySQL database hostname
  port - optional MySQL database port (defaults to 3306)
  database - required MySQL database name
  user - required MySQL database user
  password - required MySQL database password
      
The other form is:
  s4=RDF.Storage(storage=s1)
Copy an existing Storage s1.
 
 
Note: there are convience classes to create a memory storage
  s5=RDF.MemoryStorage()
 
and Hash storage:
  # memory hash
  s6=RDF.HashStorage('abc')
 
  # specified bdb hash stored in files named 'def'*
  s7=RDF.HashStorage('def', options="hash-type='bdb'")

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Storage' objects>
list of weak references to the object (if defined)
 
class Stream(__builtin__.object)
    Redland Statement Stream class
 
A class encapsulating a sequence of Statements, such as
those returned from a Model query.  Can be used as a Python
sequence.
 
stream = model.find_statements(query_statement)
for statement in stream:
   # do whatever with 'statement'
   # note it is shared and will go out of scope, so you must
   # copy it if you want it to stay around
 
You should not normally find yourself needing to use this
class explicitly.
 
  Methods defined here:
__del__(self)
__init__(self, object, creator)
Create an RDF Stream (constructor).
__iter__(self)
context(self)
Return the context Node of the current object on the Stream
context_iter(self)
Return an iterator over this stream that
returns (stream, context) tuples each time it is iterated.
DEPRECATED.  Instead use the context-aware method appropriate,
e.g.  Model.find_statements_context() or Model.as_stream_context()
current(self)
Return the current Statement on the Stream
end(self)
Return true if the stream is exhausted
next(self)
Move to the next Statement on the Stream

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Stream' objects>
list of weak references to the object (if defined)
 
class StreamIter
      Methods defined here:
__init__(self, stream)
__iter__(self)
next(self)
 
class StreamWithContextIter(__builtin__.object)
      Methods defined here:
__init__(self, stream)
__iter__(self)
next(self)

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'StreamWithContextIter' objects>
list of weak references to the object (if defined)
 
class TurtleParser(Parser)
     
Method resolution order:
TurtleParser
Parser
__builtin__.object

Methods defined here:
__init__(self, uri=None)

Methods inherited from Parser:
__del__(self)
get_feature(self, uri)
Return the Node value of Parser feature URI uri
parse_as_stream(self, uri, base_uri=None)
Return a Stream of Statements from parsing the content at
a URI for the optional base URI or None if the parsing fails.
 
(This depends on what URI support raptor provides to redland)
 
  for statement in parser.parse_as_stream(""):
      print statement
parse_into_model(self, model, uri, base_uri=None, handler=None)
Parse into the Model model from the content at the URI, for
the optional base URI.
 
If handler is given, an error handler with the signature
  def handler(code, level, facility, message, line, column, byte, file, uri)
is called.
 
parser.parse_into_model(model, "file:./foo.rdf",
                        "http://example.com/foo.rdf")
parse_string_as_stream(self, string, base_uri)
Return a Stream of Statements from parsing the content in
string with the required base URI or None if the parsing fails.
 
  for statement in parser.parse_string_as_stream(rdfstring, base_uri):
      print statement
parse_string_into_model(self, model, string, base_uri, handler=None)
Parse into the Model model from the content string
 with the required base URI
 
If handler is given, an error handler with the signature
  def handler(code, level, facility, message, line, column, byte, file, uri)
is called.
set_feature(self, uri, value)
Set the Node value of Parser feature URI uri.

Data and other attributes inherited from Parser:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Parser' objects>
list of weak references to the object (if defined)
 
class Uri(__builtin__.object)
    Redland URI Class
 
import RDF
uri1 = RDF.Uri("http://example.com/")
uri2 = RDF.Uri(uri1)
 
  Methods defined here:
__del__(self)
__eq__(self, other)
Equality of RDF URI to another RDF URI.
__hash__(self)
__init__(self, arg=None, **args)
Create an RDF URI (constructor).
 
Creates a new RDF URI from either of the following forms:
 
  uri1 = RDF.Uri("http://example.com/")
  
Create a URI from the given string.
 
  uri2 = RDF.Uri(uri1)
 
Copy an existing URI uri1.
__ne__(self, other)
Inequality of RDF URI to another RDF URI.
__str__(self)
Get a string representation of an RDF URI.
__unicode__(self)
Get a Unicode string representation of an RDF URI.

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Uri' objects>
list of weak references to the object (if defined)
 
class World(__builtin__.object)
    Redland Initialisation class.
 
There are no user methods (can only be constructed).
 
  Methods defined here:
__del__(self)
Destroy RDF World object (destructor).
__init__(self, digest_name='', uri_hash=None)
Create new RDF World object (constructor)

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'World' objects>
list of weak references to the object (if defined)
 
Functions
        
debug(value=None)
Get/set Redland debugging output status.
 
RDF.debug (1)   # enable debugging
if RDF.debug(): # test for debug mode
message_handler(type, message)
node_type(name)
Return the Redland node type of a node name
node_type_name(num)
Return the name of a Redland node type
set_message_handler(handler)
 
Data
         __all__ = ['Node', 'Statement', 'Model', 'Iterator', 'Serializer', 'NTriplesSerializer', 'RDFXMLSerializer', 'Stream', 'Storage', 'MemoryStorage', 'HashStorage', 'Uri', 'Parser', 'TurtleParser', 'NTriplesParser', 'NS', 'Query', 'RDQLQuery', 'SPARQLQuery', 'debug']
__author__ = 'Dave Beckett - http://purl.org/net/dajobe, Edd D...sefulinc.com> and Matt Biddulph <mb@picdiary.com>'
__date__ = '$Date: 2005/05/04 10:16:37 $'
__version__ = '1.1'
generators = _Feature((2, 2, 0, 'alpha', 1), (2, 3, 0, 'final', 0), 4096)
 
Author
         Dave Beckett - http://purl.org/net/dajobe, Edd Dumbill <edd@usefulinc.com> and Matt Biddulph <mb@picdiary.com>

Copyright 2000-2005 Dave Beckett, Institute for Learning and Research Technology, University of Bristol