Пример #1
0
	def __init__(self,baseURI,defaultGraph=None) :
		"""
		Class encapsulating a full SPARQL call. In contrast to the L{SPARQLWrapper<SPARQL.SPARQLWrapper>} superclass, the return format
		cannot be set (it is defaulted to L{JSON<Wrapper.JSON>}).
		@param baseURI: string of the SPARQL endpoint's URI
		@type baseURI: string
		@keyword defaultGraph: URI for the default graph. Default is None, can be set via an explicit call, too
		@type defaultGraph: string
		"""
		SPARQLWrapper.__init__(self,baseURI,returnFormat=JSON,defaultGraph=defaultGraph)
Пример #2
0
	def queryAndConvert(self) :
		"""This is here to override the inherited method; it is equivalent to L{query}.

		If the query type is I{not} SELECT, the method falls back to the
		L{corresponding method in the superclass<SPARQLWrapper.queryAndConvert>}.

		@return: the converted query result.
		"""
		if self.queryType == SELECT :
			return self.query()
		else :
			return SPARQLWrapper.queryAndConvert(self)
Пример #3
0
 def queryAndConvert(self) :
     """This is here to override the inherited method; it is equivalent to
     ``query``.
     
     If the query type is *not* SELECT, the method falls back to the
     corresponding method in the superclass 
         :class:`SPARQLWrapper.queryAndConvert`.
     
     :return: the converted query result.
     """
     if self.queryType == SELECT :
         return self.query()
     else :
         return SPARQLWrapper.queryAndConvert(self)
Пример #4
0
 def query(self) :
     """Execute the query and do an automatic conversion.
         
     Exceptions can be raised if either the URI is wrong or the HTTP sends
     back an error. The usual urllib2 exceptions are raised, which cover
     possible SPARQL errors, too.
     
     If the query type is *not* SELECT, the method falls back to the
     ``corresponding method in the superclass<SPARQLWrapper.query>``.
     
     :return: query result
     :rtype: ``Bindings`` instance
     """
     res = SPARQLWrapper.query(self)
     if self.queryType == SELECT :
         return Bindings(res)
     else :
         return res