diff options
Diffstat (limited to 'src/semanticxo/sparql.py')
-rw-r--r-- | src/semanticxo/sparql.py | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/src/semanticxo/sparql.py b/src/semanticxo/sparql.py deleted file mode 100644 index 968ecef..0000000 --- a/src/semanticxo/sparql.py +++ /dev/null @@ -1,42 +0,0 @@ -''' -Created on 25 Aug 2011 - -@author: cgueret -''' -import httplib -import urllib -import cjson -from rdflib import URIRef, Literal - -class SPARQL(object): - ''' - classdocs - ''' - - - def __init__(self): - ''' - Constructor - ''' - self._url = '127.0.0.1:8080' - - def execute_select(self, query): - params = {'query': query, 'format' : 'json'} - headers = {'Content-Type': 'application/x-www-form-urlencoded'} - conn = httplib.HTTPConnection(self._url) - conn.request("POST", "/sparql", urllib.urlencode(params), headers=headers) - # Get the results - response = conn.getresponse() - r = cjson.decode(response.read(), all_unicode=False) - # Recode them - results = [] - for entry in r['results']['bindings']: - result = {} - for (name,data) in entry.iteritems(): - value = Literal(data['value']) - if data['type']=='uri': - value = URIRef(data['value']) - result[name] = value - results.append(result) - conn.close() - return results |