results Package¶
csvresults
Module¶
This module implements a parser and serializer for the CSV SPARQL result formats
http://www.w3.org/TR/sparql11-results-csv-tsv/
-
class
rdflib.plugins.sparql.results.csvresults.
CSVResultParser
[source]¶ Bases:
rdflib.query.ResultParser
-
__module__
= 'rdflib.plugins.sparql.results.csvresults'¶
-
jsonlayer
Module¶
Thin abstraction layer over the different available modules for decoding and encoding JSON data.
- This module currently supports the following JSON modules:
simplejson
: http://code.google.com/p/simplejson/cjson
: http://pypi.python.org/pypi/python-cjsonjson
: This is the version ofsimplejson
that is bundled with the Python standard library since version 2.6 (see http://docs.python.org/library/json.html)
The default behavior is to use simplejson
if installed, and otherwise
fallback to the standard library module. To explicitly tell SPARQLWrapper
which module to use, invoke the use() function with the module name:
import jsonlayer
jsonlayer.use('cjson')
In addition to choosing one of the above modules, you can also configure SPARQLWrapper to use custom decoding and encoding functions:
import jsonlayer
jsonlayer.use(decode=my_decode, encode=my_encode)
-
rdflib.plugins.sparql.results.jsonlayer.
decode
(string)[source]¶ Decode the given JSON string.
Parameters: string (basestring) – the JSON string to decode Returns: the corresponding Python data structure Return type: object
-
rdflib.plugins.sparql.results.jsonlayer.
encode
(obj)[source]¶ Encode the given object as a JSON string.
Parameters: obj (object) – the Python data structure to encode Returns: the corresponding JSON string Return type: basestring
-
rdflib.plugins.sparql.results.jsonlayer.
use
(module=None, decode=None, encode=None)[source]¶ Set the JSON library that should be used, either by specifying a known module name, or by providing a decode and encode function.
The modules “simplejson”, “cjson”, and “json” are currently supported for the
module
parameter.If provided, the
decode
parameter must be a callable that accepts a JSON string and returns a corresponding Python data structure. Theencode
callable must accept a Python data structure and return the corresponding JSON string. Exceptions raised by decoding and encoding should be propagated up unaltered.Parameters:
jsonresults
Module¶
-
class
rdflib.plugins.sparql.results.jsonresults.
JSONResult
(json)[source]¶ Bases:
rdflib.query.Result
-
__module__
= 'rdflib.plugins.sparql.results.jsonresults'¶
-
-
class
rdflib.plugins.sparql.results.jsonresults.
JSONResultParser
[source]¶ Bases:
rdflib.query.ResultParser
-
__module__
= 'rdflib.plugins.sparql.results.jsonresults'¶
-
-
class
rdflib.plugins.sparql.results.jsonresults.
JSONResultSerializer
(result)[source]¶ Bases:
rdflib.query.ResultSerializer
-
__module__
= 'rdflib.plugins.sparql.results.jsonresults'¶
-
-
rdflib.plugins.sparql.results.jsonresults.
parseJsonTerm
(d)[source]¶ rdflib object (Literal, URIRef, BNode) for the given json-format dict.
- input is like:
- { ‘type’: ‘uri’, ‘value’: ‘http://famegame.com/2006/01/username‘ } { ‘type’: ‘literal’, ‘value’: ‘drewp’ }
rdfresults
Module¶
-
class
rdflib.plugins.sparql.results.rdfresults.
RDFResult
(source, **kwargs)[source]¶ Bases:
rdflib.query.Result
-
__module__
= 'rdflib.plugins.sparql.results.rdfresults'¶
-
tsvresults
Module¶
This implements the Tab Separated SPARQL Result Format
It is implemented with pyparsing, reusing the elements from the SPARQL Parser
xmlresults
Module¶
-
rdflib.plugins.sparql.results.xmlresults.
RESULTS_NS_ET
= u'{http://www.w3.org/2005/sparql-results#}'¶ A Parser for SPARQL results in XML:
http://www.w3.org/TR/rdf-sparql-XMLres/
Bits and pieces borrowed from: http://projects.bigasterisk.com/sparqlhttp/
Authors: Drew Perttula, Gunnar Aastrand Grimnes
-
class
rdflib.plugins.sparql.results.xmlresults.
SPARQLXMLWriter
(output, encoding='utf-8')[source]¶ Python saxutils-based SPARQL XML Writer
-
__module__
= 'rdflib.plugins.sparql.results.xmlresults'¶
-
-
class
rdflib.plugins.sparql.results.xmlresults.
XMLResult
(source)[source]¶ Bases:
rdflib.query.Result
-
__module__
= 'rdflib.plugins.sparql.results.xmlresults'¶
-
-
class
rdflib.plugins.sparql.results.xmlresults.
XMLResultParser
[source]¶ Bases:
rdflib.query.ResultParser
-
__module__
= 'rdflib.plugins.sparql.results.xmlresults'¶
-
-
class
rdflib.plugins.sparql.results.xmlresults.
XMLResultSerializer
(result)[source]¶ Bases:
rdflib.query.ResultSerializer
-
__module__
= 'rdflib.plugins.sparql.results.xmlresults'¶
-