Example #1
0
 def getDataByType(self, thetype, context=None):
     thedict = {'p': 'rdf:type', 'o': thetype}
     data = self.getDataByDict(thedict, context)
     bg = ConjunctiveGraph()
     namespaces.bindgraph(bg)
     res = bg.parse(StringIO.StringIO(data))
     listofo = []
     for trip in res:
         listofo.append(str(trip[0].encode('utf-8')))
     return listofo
Example #2
0
 def getDataByType(self, thetype, context=None):
     thedict={'p':'rdf:type', 'o':thetype}
     data=self.getDataByDict(thedict, context)
     bg=ConjunctiveGraph()
     namespaces.bindgraph(bg)
     res=bg.parse(StringIO.StringIO(data))
     listofo=[]
     for trip in res:
         listofo.append(str(trip[0].encode('utf-8')))
     return listofo
Example #3
0
 def getDataBySP(self, thingy, propthingy, context=None):
     qdict = {}
     if context:
         qdict['c'] = namespaces.n3encode(context)
     #print "THINGY", thingy
     if len(thingy.split(':')) > 1:
         qdict['s'] = namespaces.n3encode(thingy)
     else:
         qdict['s'] = thingy
     qdict['p'] = namespaces.n3encode(propthingy)
     #print "qdict", qdict
     data = self.tsc.query_statements(qdict)
     #print data
     bg = ConjunctiveGraph()
     namespaces.bindgraph(bg)
     #abnode=BNode()
     res = bg.parse(StringIO.StringIO(data))
     listofo = []
     #this bnode crap is very fragile TODO:replace
     for trip in res:
         listofo.append(str(trip[2].encode('utf-8')))
     return listofo
Example #4
0
 def getDataBySP(self, thingy, propthingy, context=None):
     qdict={}
     if context:
         qdict['c']=namespaces.n3encode(context)
     #print "THINGY", thingy
     if len(thingy.split(':'))>1:
         qdict['s']=namespaces.n3encode(thingy)
     else:
         qdict['s']=thingy
     qdict['p']=namespaces.n3encode(propthingy)
     #print "qdict", qdict
     data=self.tsc.query_statements(qdict)
     #print data
     bg=ConjunctiveGraph()
     namespaces.bindgraph(bg)
     #abnode=BNode()
     res=bg.parse(StringIO.StringIO(data))
     listofo=[]
     #this bnode crap is very fragile TODO:replace
     for trip in res:
         listofo.append(str(trip[2].encode('utf-8')))
     return listofo
Example #5
0
def makeGraph():
    "Returns a new graph."

    graph = ConjunctiveGraph(identifier=URIRef(ads_baseurl))
    bindgraph(graph)
    return graph
Example #6
0
def makeGraph():
    "Returns a new graph."

    graph = ConjunctiveGraph(identifier=URIRef(ads_baseurl))
    bindgraph(graph)
    return graph