# 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`

  Bases: `rdflib.query.ResultParser`

  `__init__`()
  `__module__` = 'rdflib.plugins.sparql.results.csvresults'
  `convertTerm`(t)
  `parse`(source)
  `parseRow`(row, v)

class `rdflib.plugins.sparql.results.csvresults.``CSVResultSerializer`(result)

  Bases: `rdflib.query.ResultSerializer`

  `__init__`(result)
  `__module__` = 'rdflib.plugins.sparql.results.csvresults'
  `serialize`(stream, encoding='utf-8')
  `serializeTerm`(term, encoding)

## `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-cjson
  - `json`: This is the version of `simplejson` 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)

  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)

  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)

  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. The `encode` 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:

  - module (str or module) – the name of the JSON library module to use, or the module object itself
  - decode (callable) – a function for decoding JSON strings
  - encode (callable) – a function for encoding objects as JSON strings

## `jsonresults` Module

class `rdflib.plugins.sparql.results.jsonresults.``JSONResult`(json)

  Bases: `rdflib.query.Result`

  `__init__`(json)
  `__module__` = 'rdflib.plugins.sparql.results.jsonresults'

class `rdflib.plugins.sparql.results.jsonresults.``JSONResultParser`

  Bases: `rdflib.query.ResultParser`

  `__module__` = 'rdflib.plugins.sparql.results.jsonresults'
  `parse`(source)

class `rdflib.plugins.sparql.results.jsonresults.``JSONResultSerializer`(result)

  Bases: `rdflib.query.ResultSerializer`

  `__init__`(result)
  `__module__` = 'rdflib.plugins.sparql.results.jsonresults'
  `serialize`(stream, encoding=None)

`rdflib.plugins.sparql.results.jsonresults.``parseJsonTerm`(d)

  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’ }

`rdflib.plugins.sparql.results.jsonresults.``termToJSON`(self, term)

## `rdfresults` Module

class `rdflib.plugins.sparql.results.rdfresults.``RDFResult`(source, **kwargs)

  Bases: `rdflib.query.Result`

  `__init__`(source, **kwargs)
  `__module__` = 'rdflib.plugins.sparql.results.rdfresults'

class `rdflib.plugins.sparql.results.rdfresults.``RDFResultParser`

  Bases: `rdflib.query.ResultParser`

  `__module__` = 'rdflib.plugins.sparql.results.rdfresults'
  `parse`(source, **kwargs)

## `tsvresults` Module

This implements the Tab Separated SPARQL Result Format

It is implemented with pyparsing, reusing the elements from the SPARQL Parser

class `rdflib.plugins.sparql.results.tsvresults.``TSVResultParser`

  Bases: `rdflib.query.ResultParser`

  `__module__` = 'rdflib.plugins.sparql.results.tsvresults'
  `convertTerm`(t)
  `parse`(source)

## `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')

  Python saxutils-based SPARQL XML Writer

  `__init__`(output, encoding='utf-8')
  `__module__` = 'rdflib.plugins.sparql.results.xmlresults'
  `close`()
  `write_ask`(val)
  `write_binding`(name, val)
  `write_end_result`()
  `write_header`(allvarsL)
  `write_results_header`()
  `write_start_result`()

class `rdflib.plugins.sparql.results.xmlresults.``XMLResult`(source)

  Bases: `rdflib.query.Result`

  `__init__`(source)
  `__module__` = 'rdflib.plugins.sparql.results.xmlresults'

class `rdflib.plugins.sparql.results.xmlresults.``XMLResultParser`

  Bases: `rdflib.query.ResultParser`

  `__module__` = 'rdflib.plugins.sparql.results.xmlresults'
  `parse`(source)

class `rdflib.plugins.sparql.results.xmlresults.``XMLResultSerializer`(result)

  Bases: `rdflib.query.ResultSerializer`

  `__init__`(result)
  `__module__` = 'rdflib.plugins.sparql.results.xmlresults'
  `serialize`(stream, encoding='utf-8')

`rdflib.plugins.sparql.results.xmlresults.``parseTerm`(element)

  rdflib object (Literal, URIRef, BNode) for the given elementtree element