|
|
- exceptions.Exception
-
- RedlandError
-
- NodeTypeError
- Iterator
- IteratorIter
- IteratorWithContextIter
- Model
- Node
- Parser
- Serializer
- Statement
- Storage
-
- HashStorage
- MemoryStorage
- Stream
- StreamIter
- StreamWithContextIter
- Uri
- World
class HashStorage(Storage) |
|
Redland Hashed Storage class
import RDF
h1=RDF.HashStorage("abc", options="hash-type='memory'")
Class of hashed Storage for a particular type of hash (typically
hash-type is "memory" or "bdb") and any other options.
|
|
Methods defined here:
- __init__(self, hash_name, options)
Data and non-method functions defined here:
- __doc__ = 'Redland Hashed Storage class\n\n import RDF\n ...e is "memory" or "bdb") and any other options.\n '
- __module__ = 'RDF'
Methods inherited from Storage:
- __del__(self)
|
class Iterator |
|
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).
- context(self)
- Return a SHARED copy of the context Node of the current object on the Iterator
- current(self)
- Return a SHARED copy of 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 non-method functions defined here:
- __doc__ = 'Redland Node Iterator class\n\n A class for it... iterator.next()\n iterator=None\n\n '
- __module__ = 'RDF'
|
class MemoryStorage(Storage) |
|
Redland memory Storage class
import RDF
h1=RDF.MemoryStorage()
h1=RDF.MemoryStorage("abc")
h2=RDF.MemoryStorage("abc", "write='no'")
Class of memory Storage with optional name, additional options.
|
|
Methods defined here:
- __init__(self, mem_name='', options_string='')
Data and non-method functions defined here:
- __doc__ = 'Redland memory Storage class\n\n import RDF\n ...torage with optional name, additional options.\n '
- __module__ = 'RDF'
Methods inherited from Storage:
- __del__(self)
|
class Model |
|
Redland Graph class
import RDF
m1=RDF.Model(storage=s)
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 lists to give every triple in the
model (via the serialise() method):
for statement in model:
print statement
|
|
Methods defined here:
- __del__(self)
- __init__(self, storage=None, **args)
- Create an RDF Model (constructor).
Create a new RDF Model using any of these forms
m1=RDF.Model(storage=s1)
Create a Model from an existing Storage (most common use).
Optional fields:
options_string - A string of options for the Model
options_hash - A Hash of options for the Model
m2=RDF.Model(model=m1)
Copy an existing model m1, copying the underlying Storage of m1
m3=RDF.Model()
Create a model using an in memory storage.
- __iter__(self)
- __len__(self)
- add(self, subject, predicate, object)
- Add the statement (subject,predicate,object) to the model
- add_statement(self, statement, context=None)
- Add the Statement to the Model with optional context Node
- 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.
- arcs(self, source, target)
- Return a sequence of Node s that are the arcs
of Statements in the Model matching (source, ?, target).
- contains_statement(self, statement)
- Return true if the Statement is in the Model
- context_remove_statements(self, context)
- Remove all Statement s from the Model with the given context Node
- find_statements(self, statement)
- Return a Stream of Statements matching the given
partial Statement - the missing nodes of the
partial statement match any node in the Model.
- get_arc(self, source, target)
- Return one Node in the Model matching (source, ?, target).
- get_arcs_iterator(self, source, target)
- Return an Iterator of Node s that are the arcs
of Statements in the Model matching (source, ?, target).
The arcs method is recommended in preference to this.
- get_source(self, arc, target)
- Return one Node in the Model matching (?, arc, target).
- get_sources_iterator(self, arc, target)
- Return an Iterator of Node s that are the sources
of Statements in the Model matching (?, arc, target).
The sources method is recommended in preference to this.
- get_target(self, source, arc)
- Return one Node in the Model matching (source, arc, ?).
- get_targets_iterator(self, source, arc)
- Return an Iterator of Node s that are the targets
of Statements in the Model matching (source, arc, ?).
The targets method is recommended in preference to this.
- remove_statement(self, statement, context=None)
- Remove the Statement from the Model with the optional context Node
- serialise(self)
- Return the Model as a Stream of Statements
- size(self)
- Return the size of the Model in number of statements (<0 if not countabl)
- sources(self, arc, target)
- Return a sequence of Node s that are the source
of Statements in the Model matching (?, arc, target).
- targets(self, source, arc)
- Return a sequence of Node s that are the targets
of Statements in the Model matching (source, arc, ?).
Data and non-method functions defined here:
- __doc__ = 'Redland Graph class\n\n import RDF\n m1=RDF.M... for statement in model:\n print statement\n\n '
- __module__ = 'RDF'
|
class Node |
|
Redland Node (RDF Resource, Property, Literal) Class
import RDF
node1=RDF.Node()
node2=RDF.Node(uri_string="http://example.com/")
node3=RDF.Node(uri=RDF.Uri("http://example.com/"))
node4=RDF.Node(literal="Hello, World!")
node5=RDF.Node(literal="<tag>content</tag>", is_wf_xml=1)
node5=RDF.Node(blank="abc")
node7=RDF.Node(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.get_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.
- __getattr__(self, name)
- __hash__(self)
- __init__(self, **args)
- Create an RDF Node (constructor).
Creates a new RDF Node using the following fields:
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)
xml_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.
- __setattr__(self, name, value)
- __str__(self)
- Get a string representation of an RDF Node.
- _get_type(self)
- _get_uri(self)
- _set_type(self, type)
- _set_uri(self, uri)
- get_blank_identifier(self)
- Get the blank node identifier of the Node
- get_literal_value(self)
- Get a dictionary containing the value of the Node literal
- 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
- set_blank_identifier(self, identifier)
- Get the blank node identifier of the Node
- set_literal_value(self, string, xml_language=None, datatype=None)
- Set a literal Node string value, with optional XML language or datatype URI.
Data and non-method functions defined here:
- __doc__ = 'Redland Node (RDF Resource, Property, Literal) C...ank node name ", node5.get_blank_identifier()\n\n '
- __module__ = 'RDF'
|
class Parser |
|
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='raptor', mime_type='application/rdf+xml', 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 "raptor" and "ntriples")
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 value of Parser feature URI uri
- parse_as_stream(self, uri, base_uri=None)
- "Return a Stream of Statements from parsing the content at
(file: only at present) URI, for the optional base URI
or None if the parsing fails.
- parse_into_model(self, model, uri, base_uri=None)
- "Parse into the Model model from the content at
(file: only at present) URI, for the optional base URI
- set_feature(self, uri, value)
- Set the value of Parser feature URI uri.
Data and non-method functions defined here:
- __doc__ = 'Redland Syntax Parser Class\n\n import RDF\n pars...xplicitly is raptor,\n for the RDF/XML syntax.\n '
- __module__ = 'RDF'
|
class RedlandError(exceptions.Exception) |
|
Redland Runtime errors
|
|
Methods defined here:
- __init__(self, value)
- __str__(self)
Data and non-method functions defined here:
- __doc__ = 'Redland Runtime errors'
- __module__ = 'RDF'
Methods inherited from exceptions.Exception:
- __getitem__(...)
|
class Serializer |
|
Redland Syntax Serializer Class
import RDF
ser1=RDF.Serializer(mime_type="application/rdf+xml")
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='application/rdf+xml', uri=None)
- Create an RDF Serializer (constructor).
- 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.
- set_feature(self, uri, value)
- Set the value of Serializer feature URI uri.
Data and non-method functions defined here:
- __doc__ = ' Redland Syntax Serializer Class\n\n import RDF\n ...ialization (at present\n only to local files).\n '
- __module__ = 'RDF'
|
class Statement |
|
Redland Statement (triple) class
import RDF
statement1=RDF.Statement(subject=node1, predicate=node2, object=node3)
statement2=RDF.Statement(statement=statement1)
if statement2.subject.is_resource:
print "statement2 subject is URI ",statement2.subject.uri
Statements can also be used as if they are Python lists:
for statement in parser.parse_as_stream(source):
model.add_statement(statement)
for statement in model.find_statements(s):
print statement
If you need the context, use the context_iter() method which
returns a 2-tuple of (statement, context node):
for s,c in m.find_statements(s):
print c
|
|
Methods defined here:
- __del__(self)
- __getattr__(self, name)
- __init__(self, **args)
- Create an RDF Statement (constructor).
Creates a new RDF Statement from either of the two forms:
s1=RDF.Statement(subject=node1, predicate=node2, object=node3)
Create a Statement from three Node objects.
s2=RDF.Statement(statement=s1)
Copy an existing Statement s1.
- __setattr__(self, name, value)
- __str__(self)
- _get_object(self)
- _get_predicate(self)
- _get_subject(self)
- _set_object(self, value)
- _set_predicate(self, value)
- _set_subject(self, value)
- _wrap_node(self, rednode)
Data and non-method functions defined here:
- __doc__ = 'Redland Statement (triple) class\n\n import RDF...c in m.find_statements(s):\n print c\n\n \n '
- __module__ = 'RDF'
|
class Storage |
|
Redland Statement Storage class
import RDF
storage=RDF.Storage(storage_name="memory")
The Redland abstraction for storing RDF graphs as Statement s.
There are no user methods (can only be constructed).
|
|
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 with the given name. Currently the built in
storages are "memory" and "hashes". "hashes" takes extra
arguments passed in the field options_string, some of which are
required:
options_string="hash-type='memory',new='yes',write='yes'"
hash-type - required and can be the name of any Hash type supported.
'memory' is always present, and 'bdb' is available
when BerkeleyDB is compiled in.
new - optional and takes a boolean value (default false)
If true, it allows updating of an existing Storage
write - optional and takes a boolean value (default true)
If false, the Storage is opened read-only and for file-based
Storages or those with locks, may be shared-read.
The other form is:
s2=RDF.Storage(storage=s1)
Copy an existing Storage s1.
Data and non-method functions defined here:
- __doc__ = 'Redland Statement Storage class\n\n import RDF...re no user methods (can only be constructed).\n\n '
- __module__ = 'RDF'
|
class Stream |
|
Redland Statement Stream class
A class for iterating over a sequence of Statement s such as
those returned from a Model query. Some methods return
Statement s or Python sequences. If this is used, it works
as follows:
stream=model.serialise()
while not stream.end():
# get the current Statement
statement=stream.current()
# do something with it
# (it is shared; you must copy it you want to keep it)
...
stream.next()
stream=None
|
|
Methods defined here:
- __del__(self)
- __init__(self, object, creator, free_statements)
- Create an RDF Stream (constructor).
- __iter__(self)
- context(self)
- Return a SHARED copy of the context Node of the current object on the Stream
- context_iter(self)
- Return an iterator over this tstream that
returns (stream, context) tuples each time it is iterated.
- current(self)
- Return a SHARED copy of 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 non-method functions defined here:
- __doc__ = 'Redland Statement Stream class\n\n A class for...\n stream.next()\n stream=None\n\n '
- __module__ = 'RDF'
|
class Uri |
|
Redland URI Class
import RDF
uri1=RDF.Uri(string="http://example.com/")
uri2=RDF.Uri(uri=uri1)
|
|
Methods defined here:
- __del__(self)
- __eq__(self, other)
- Equality of RDF URI to another RDF URI.
- __hash__(self)
- __init__(self, **args)
- Create an RDF URI (constructor).
Creates a new RDF URI from either of the following forms:
uri1=RDF.Uri(string="http://example.com/")
Create a URI from the given string.
uri2=RDF.Uri(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.
Data and non-method functions defined here:
- __doc__ = 'Redland URI Class\n\n import RDF\n uri1=RDF.Uri(s...ttp://example.com/")\n uri2=RDF.Uri(uri=uri1)\n\n '
- __module__ = 'RDF'
|
class World |
|
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 non-method functions defined here:
- __doc__ = 'Redland Initialisation class.\n\n There are no user methods (can only be constructed).\n\n '
- __module__ = 'RDF'
|
|