/usr/lib/python2.7/dist-packages/rdflib/interfaces.py is in python-rdflib 2.4.2-3build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | try:
from zope.interface import Interface, classImplements, implements
except ImportError:
class Interface(object): pass
def classImplements(c, i): pass
def implements(*args): pass
from rdflib import RDF
class IGraph(Interface):
"""\
An rdflib.Graph indexes data expressed in the Resource Description
Framework (RDF). Any kind of content, whether inside Zope or from
some outside source, can be cataloged if it can describe itself
using the RDF standard. Any kind of RDF vocabulary like RSS, OWL,
DAML+OIL, Dublin Core, or any kind of XML schema or data can be
expressed into the graph.
Once data is graphed it can be queried using either the Python
query interface, a TALES-based RDF query expression language, or
the sparql rdf query language. Results of a query can be either a
generator of result records or RDF in xml or NT format.
In Semantic Web terms, a graph is a persistent triple store. RDF
is broken down into subject, predicate, and object relations
(called triples) and each relation is indexed. The triple store
can then be queried for triples that match patterns.
"""
def parse(rdf, format="xml"):
""" Parse RDF-XML into the catalog. """
def add((subject, predicate, object)):
""" Add one triple to the catalog. """
def remove((subject, predicate, object)):
""" Remove one triple from the catalog. """
def triples((subject, predicate, object), *args):
""" Query the triple store. """
def contexts(triple=None):
""" Generator over all contexts in the graph. If triple is
specified, a generator over all contexts the triple is in."""
def value(subject, predicate=RDF.value, 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
"""
def label(subject, default=''):
""" Queries for the RDFS.label of the subject, returns default
if no label exists."""
def comment(subject, default=''):
""" Queries for the RDFS.comment of the subject, returns
default if no comment exists."""
def items(list):
"""Generator over all items in the resource specified by list
(an RDF collection)"""
def __iter__():
""" Iterates over all triples in the store."""
def __contains__(triple):
""" Support for 'triple in graph' syntax."""
def __len__(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."""
def __eq__(other):
""" Test if Graph is exactly equal to Graph other."""
def __iadd__(other):
""" Add all triples in Graph other to Graph."""
def __isub__(other):
""" Subtract all triples in Graph other from Graph."""
def subjects(predicate=None, object=None):
""" A generator of subjects with the given predicate and
object."""
def predicates(subject=None, object=None):
""" A generator of predicates with the given subject and
object."""
def objects(subject=None, predicate=None):
""" A generator of objects with the given subject and
predicate."""
def subject_predicates(object=None):
""" A generator of (subject, predicate) tuples for the given
object"""
def subject_objects(predicate=None):
""" A generator of (subject, object) tuples for the given
predicate"""
def predicate_objects(subject=None):
""" A generator of (predicate, object) tuples for the given
subject"""
def get_context(identifier):
""" Returns a Context graph for the given identifier, which
must be a URIRef or BNode."""
def remove_context(identifier):
""" Removes the given context from the graph. """
def transitive_objects(subject, property, remember=None):
""" """
def transitive_subjects(predicate, object, remember=None):
""" """
def load(location, publicID=None, format="xml"):
""" for b/w compat. See parse."""
def save(location, format="xml", base=None, encoding=None):
""" for b/x compat. See serialize."""
def context_id(uri):
pass
def parse(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. Returns the context into which the source
was parsed."""
def serialize(destination=None, format="xml", base=None, encoding=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)."""
def seq(subject):
"""
Check if subject is an rdf:Seq. If yes, it returns a Seq
class instance, None otherwise.
"""
def absolutize(uri, defrag=1):
""" Will turn uri into an absolute URI if it's not one already. """
def bind(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."""
def namespaces():
"""Generator over all the prefix, namespace tuples.
"""
class IIdentifier(Interface):
def n3():
""" Return N3 representation of identifier. """
def startswith(string):
""" dummy. """
def __cmp__(other):
""" dummy. """
|