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
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
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
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
def makeGraph(): "Returns a new graph." graph = ConjunctiveGraph(identifier=URIRef(ads_baseurl)) bindgraph(graph) return graph