Redland

Dave Beckett

 
 
Hosted by
Dreamhost

since 2005.

Data

DOAP
(See DOAP Project)

Redland librdf Language Bindings - Python API Reference

 
 
RDF (version 1.1, $Date$)
index
 
Modules
        
Redland
string
sys
 
Classes
        
__builtin__.object
Iterator
Model
NS
Node
Parser
NTriplesParser
TurtleParser
Query
RDQLQuery
SPARQLQuery
Serializer
NTriplesSerializer
RDFXMLSerializer
Statement
Storage
HashStorage
MemoryStorage
Stream
Uri
 
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 descriptors inherited from Storage:
__dict__
dictionary for instance variables (if defined)
__weakref__
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)
__next__(self)
Move to the next object on the Iterator
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 = __next__(self)
Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
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 descriptors inherited from Storage:
__dict__
dictionary for instance variables (if defined)
__weakref__
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.
Returns a boolean success or failure.
 
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 descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
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)
Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
 
class NTriplesParser(Parser)
    Redland N-Triples Parser class
 
import RDF
parser=RDF.NTriplesParser()
 
 
Method resolution order:
NTriplesParser
Parser
__builtin__.object
Methods defined here:
__init__(self)
Methods inherited from Parser:
__del__(self)
get_feature(self, uri)
Return the Node value of Parser feature URI uri
namespaces_seen(self)
Get a dictionary of prefix/URI pairs for namespaces seen during parsing.
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.  Returns a boolean success or failure.
 
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.  Returns a boolean success or failure.
 
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.
set_uri_filter(self, filter)
Set a function for rejecting retrieval of URIs seen during parsing.
 
Return False or 0 to not reject the URI
 
def reject(uri):
  if "bad" == uri:
    return True
  return False
 
parser.set_uri_filter(reject)
Data descriptors inherited from Parser:
__dict__
dictionary for instance variables (if defined)
__weakref__
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.
serialize_stream_to_string(self, stream, base_uri=None)
Serialize a stream 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 descriptors inherited from Serializer:
__dict__
dictionary for instance variables (if defined)
__weakref__
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
Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
blank
The blank node identifier
blank_identifier
The node identifier of a blank node
literal
A tuple of the string, language and datatype values of the node
literal_value
A dictionary containing the value of the node literal with keys string, language and datatype
type
The node type, an integer
uri
The URI of a resource node
 
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=None, mime_type=None, 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.  The default
parser is chosen if none are given, which is RDF/XML in the
standard configuration of Raptor.
 
  name      - parser syntax name
  mime_type - syntax mime type
  uri       - URI identifying the syntax
get_feature(self, uri)
Return the Node value of Parser feature URI uri
namespaces_seen(self)
Get a dictionary of prefix/URI pairs for namespaces seen during parsing.
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.  Returns a boolean success or failure.
 
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.  Returns a boolean success or failure.
 
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.
set_uri_filter(self, filter)
Set a function for rejecting retrieval of URIs seen during parsing.
 
Return False or 0 to not reject the URI
 
def reject(uri):
  if "bad" == uri:
    return True
  return False
 
parser.set_uri_filter(reject)
Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
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='sparql', query_uri=None)
execute(self, model)
get_limit(self)
get_offset(self)
set_limit(self, limit)
set_offset(self, offset)
Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
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.
serialize_stream_to_string(self, stream, base_uri=None)
Serialize a stream 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 descriptors inherited from Serializer:
__dict__
dictionary for instance variables (if defined)
__weakref__
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)
get_limit(self)
get_offset(self)
set_limit(self, limit)
set_offset(self, offset)
Data descriptors inherited from Query:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
 
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)
get_limit(self)
get_offset(self)
set_limit(self, limit)
set_offset(self, offset)
Data descriptors inherited from Query:
__dict__
dictionary for instance variables (if defined)
__weakref__
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=None, mime_type=None, 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.
serialize_stream_to_string(self, stream, base_uri=None)
Serialize a stream 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 descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
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.
Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
object
The object node of the statement.
predicate
The predicate node of the statement.
subject
The subject node of the statement.
 
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",options_string="")
 
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',options_string="")
 
  s2=RDF.Storage(storage_name="uri", name='http://rdf.example.org/',options_string="")
 
 
The required 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
 
stoage name 'sqlite' has options:
  synchronous - optional value off, normal or full
      
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 descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
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)
__next__(self)
Move to the next Statement on the Stream
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 = __next__(self)
Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
 
class TurtleParser(Parser)
    Redland Turtle Parser class
 
import RDF
parser=RDF.TurtleParser()
 
 
Method resolution order:
TurtleParser
Parser
__builtin__.object
Methods defined here:
__init__(self)
Methods inherited from Parser:
__del__(self)
get_feature(self, uri)
Return the Node value of Parser feature URI uri
namespaces_seen(self)
Get a dictionary of prefix/URI pairs for namespaces seen during parsing.
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.  Returns a boolean success or failure.
 
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.  Returns a boolean success or failure.
 
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.
set_uri_filter(self, filter)
Set a function for rejecting retrieval of URIs seen during parsing.
 
Return False or 0 to not reject the URI
 
def reject(uri):
  if "bad" == uri:
    return True
  return False
 
parser.set_uri_filter(reject)
Data descriptors inherited from Parser:
__dict__
dictionary for instance variables (if defined)
__weakref__
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 descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
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
 
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://www.dajobe.org/, Edd Dumbi...sefulinc.com> and Matt Biddulph <mb@picdiary.com>'
__date__ = '$Date$'
__version__ = '1.1'
 
Author
         Dave Beckett - http://www.dajobe.org/, Edd Dumbill <edd@usefulinc.com> and Matt Biddulph <mb@picdiary.com>

(C) Copyright (C) 2000-2014 Dave Beckett, Copyright (C) 2000-2005 University of Bristol