Home | Trees | Index | Help |
---|
Package rdflib :: Module Graph :: Class Graph |
|
object
--+
|
Graph
Context
,
InformationStore
,
TripleStore
An RDF Graph. The constructor accepts one argument, the 'backend' that will be used to store the graph data (see the 'backends' package for backends currently shipped with rdflib).
Backends can be context-aware or unaware. Unaware backends take up (some) less space in the backend but cannot support features that require context, such as true merging/demerging of sub-graphs and provenance.Method Summary | |
---|---|
__init__(self,
backend)
| |
Support for 'triple in graph' syntax. | |
Test if Graph is exactly equal to Graph other. | |
Add all triples in Graph other to Graph. | |
Subtract all triples in Graph other from Graph. | |
Iterates over all triples in the store. | |
Returns the number of triples in the graph. | |
Will turn uri into an absolute URI if it's not one already. | |
Add a triple, optionally provide a context. | |
Bind prefix to namespace. | |
Close the graph backend. | |
Queries for the RDFS.comment of the subject, returns default if no comment exists. | |
Generator over all contexts in the graph. | |
Returns a Context graph for the given identifier, which must be a URIRef or BNode. | |
Generator over all items in the resource specified by list (an RDF collection) | |
Queries for the RDFS.label of the subject, returns default if no label exists. | |
for b/w compat. | |
Generator over all the prefix, namespace tuples. | |
A generator of objects with the given subject and predicate. | |
Open the graph backend. | |
Parse source into Graph. | |
A generator of (predicate, object) tuples for the given subject | |
A generator of predicates with the given subject and object. | |
Remove a triple from the graph. | |
Removes the given context from the graph. | |
Save Graph to location using format. | |
Check if subject is an rdf:Seq. | |
Serialize the Graph to destination. | |
A generator of (subject, object) tuples for the given predicate | |
A generator of (subject, predicate) tuples for the given object | |
A generator of subjects with the given predicate and object. | |
transitive_objects(self,
subject,
property,
remember)
| |
transitive_subjects(self,
predicate,
object,
remember)
| |
Generator over the triple store. | |
Get a value for a subject/predicate, predicate/object, or subject/object pair -- exactly one of subject, predicate, object must be None. | |
__get_backend(self)
| |
_get_context_aware(self)
| |
_get_namespace_manager(self)
| |
_set_namespace_manager(self,
nm)
| |
Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
x.__hash__() <==> hash(x) | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
helper for pickle | |
helper for pickle | |
x.__repr__() <==> repr(x) | |
x.__setattr__('name', value) <==> x.name = value | |
x.__str__() <==> str(x) |
Property Summary | |
---|---|
backend | |
context_aware | |
namespace_manager |
Method Details |
---|
__contains__(self,
triple)
Support for 'triple in graph' syntax.
|
__eq__(self,
other)
Test if Graph is exactly equal to Graph other.
|
__iadd__(self, other)Add all triples in Graph other to Graph. |
__isub__(self, other)Subtract all triples in Graph other from Graph. |
__iter__(self)Iterates over all triples in the store. |
__len__(self,
context=None)
Returns the number of triples in the graph. If context is specified
then the number of triples in the context is returned instead.
|
absolutize(self, uri, defrag=1)Will turn uri into an absolute URI if it's not one already. |
add(self, (s, p, o), context=None)Add a triple, optionally provide a context. A 3-tuple or rdflib.Triple can be provided. Context must be a URIRef. If no context is provides, triple is added to the default context. |
bind(self, prefix, namespace, override=True)Bind prefix to namespace. If override is True will bind namespace to given prefix if namespace was already bound to a different prefix. |
close(self)Close the graph backend. Might be necessary for backends that require closing a connection to a database or releasing some resource. |
comment(self, subject, default='')Queries for the RDFS.comment of the subject, returns default if no comment exists. |
contexts(self, triple=None)Generator over all contexts in the graph. If triple is specified, a generator over all contexts the triple is in. |
get_context(self, identifier)Returns a Context graph for the given identifier, which must be a URIRef or BNode. |
items(self, list)Generator over all items in the resource specified by list (an RDF collection) |
label(self, subject, default='')Queries for the RDFS.label of the subject, returns default if no label exists. |
load(self, location, publicID=None, format='xml')for b/w compat. |
namespaces(self)Generator over all the prefix, namespace tuples. |
objects(self, subject=None, predicate=None)A generator of objects with the given subject and predicate. |
open(self, path)Open the graph backend. Might be necessary for backends that require opening a connection to a database or acquiring some resource. |
parse(self, source, publicID=None, format='xml')Parse source into Graph. If Graph is context-aware it'll get loaded into it's own context (sub graph). Format defaults to xml (AKA rdf/xml). The publicID argument is for specifying the logical URI for the case that it's different from the physical source URI. |
predicate_objects(self, subject=None)A generator of (predicate, object) tuples for the given subject |
predicates(self, subject=None, object=None)A generator of predicates with the given subject and object. |
remove(self, (s, p, o), context=None)Remove a triple from the graph. If the triple does not provide a context attribute, removes the triple from all contexts. |
remove_context(self, identifier)Removes the given context from the graph. |
save(self, location, format='xml', base=None)Save Graph to location using format. Format defaults to xml (AKA rdf/xml). |
seq(self, subject)Check if subject is an rdf:Seq. If yes, it returns a Seq class instance, None otherwise. |
serialize(self, destination=None, format='xml', base=None)Serialize the Graph to destination. If destination is None serialize method returns the serialization as a string. Format defaults to xml (AKA rdf/xml). |
subject_objects(self, predicate=None)A generator of (subject, object) tuples for the given predicate |
subject_predicates(self, object=None)A generator of (subject, predicate) tuples for the given object |
subjects(self, predicate=None, object=None)A generator of subjects with the given predicate and object. |
triples(self, (s, p, o), context=None)Generator over the triple store. Returns triples that match the given triple pattern. If triple pattern does not provide a context, all contexts will be searched. |
value(self, subject, predicate, object=None, default=None, any=False)Get a value for a subject/predicate, predicate/object, or subject/object pair -- exactly one of subject, predicate, object must be None. Useful if one knows that there may only be one value. It is one of those situations that occur a lot, hence this 'macro' like utility Parameters: ----------- subject, predicate, object -- exactly one must be None default -- value to be returned if no values found any -- if True: return any value in the case there is more than one else: raise UniquenessError |
Property Details |
---|
backend
|
context_aware
|
namespace_manager
|
Home | Trees | Index | Help |
---|
Generated by Epydoc 2.1 on Wed Jun 29 09:50:16 2005 | http://epydoc.sf.net |