summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreikeon <devnull@localhost>2010-02-13 01:56:25 +0000
committereikeon <devnull@localhost>2010-02-13 01:56:25 +0000
commit93c5a12c6c57120d273af13568a764c0e86b5779 (patch)
tree1e0cdb60fa375e7c02455925f85f94d78133c2fb
parent91fd12c2b3a51fc471f988fb222f3a99d665ea0a (diff)
downloadrdflib-93c5a12c6c57120d273af13568a764c0e86b5779.tar.gz
Update issue 120
Moving parsers and serializer implementations into rdflib.plugins package
-rw-r--r--rdflib/query.py32
-rw-r--r--rdflib/serializer.py30
2 files changed, 62 insertions, 0 deletions
diff --git a/rdflib/query.py b/rdflib/query.py
new file mode 100644
index 00000000..f4b82002
--- /dev/null
+++ b/rdflib/query.py
@@ -0,0 +1,32 @@
+"""
+Query plugin interface.
+
+This module is useful for those wanting to write a query processor
+that can plugin to rdf. If you are wanting to execute a query you
+likely want to do so through the Graph class query method.
+
+"""
+
+
+class Processor(object):
+
+ def __init__(self, graph):
+ pass
+
+ def query(self, strOrQuery, initBindings={}, initNs={}, DEBUG=False):
+ pass
+
+
+class Result(object):
+ """
+ A common class for representing query result in a variety of formats, namely:
+
+ xml : as an XML string using the XML result format of the query language
+ python: as Python objects
+ json : as JSON
+ """
+ def __init__(self, pythonResult):
+ self.rt = pythonResult
+
+ def serialize(self, format='xml'):
+ pass
diff --git a/rdflib/serializer.py b/rdflib/serializer.py
new file mode 100644
index 00000000..bf1e9c47
--- /dev/null
+++ b/rdflib/serializer.py
@@ -0,0 +1,30 @@
+"""
+Serializer plugin interface.
+
+This module is useful for those wanting to write a serializer that can
+plugin to rdflib. If you are wanting to invoke a serializer you likely
+want to do so through the Graph class serialize method.
+
+TODO: info for how to write a serializer that can plugin to rdflib. See also rdflib.plugin
+
+"""
+
+from rdflib.term import URIRef
+
+
+class Serializer(object):
+
+ def __init__(self, store):
+ self.store = store
+ self.encoding = "UTF-8"
+ self.base = None
+
+ def serialize(self, stream, base=None, encoding=None, **args):
+ """Abstract method"""
+
+ def relativize(self, uri):
+ base = self.base
+ if base is not None and uri.startswith(base):
+ uri = URIRef(uri.replace(base, "", 1))
+ return uri
+