def _getStatementsSparQL(self, subject=None, predicate=None, object=None):
     if not subject is None and not Uri.matchesUriSyntax(subject):
         raise ValueError('subject must be an URI')
     if not predicate is None and not Uri.matchesUriSyntax(predicate):
         raise ValueError('predicate must be an URI')
     yield "SELECT DISTINCT"
     if subject is None:
         yield " ?s"
     if predicate is None:
         yield " ?p"
     if object is None:
         yield " ?o"
     if (subject and predicate and object):
         yield " *"
     yield " WHERE {"
     yield " " + ('<%s>' % subject if subject else "?s")
     yield " " + ('<%s>' % predicate if predicate else "?p")
     yield " " + (['"%s"', '<%s>'][Uri.matchesUriSyntax(object)] % object if object else "?o")
     yield " }"
 def _getStatementsResults(self, jsonString, subject, predicate, object):
     jsonData = loads(jsonString)
     if not subject is None:
         subject = Uri(subject)
     if not predicate is None:
         predicate = Uri(predicate)
     if not object is None:
         object = Uri(object) if Uri.matchesUriSyntax(object) else Literal(object)
     for binding in jsonData['results']['bindings']:
         resultSubject = self._fromBinding(binding, 's', subject)
         resultPredicate = self._fromBinding(binding, 'p', predicate)
         resultObject = self._fromBinding(binding, 'o', object)
         yield resultSubject, resultPredicate, resultObject
Example #3
0
 def testCreate(self):
     u = Uri.fromDict({"type": "uri", "value": "http://www.rnaproject.org/data/rnax/odw/InformationConcept"})
     self.assertNotEquals("http://www.rnaproject.org/data/rnax/odw/InformationConcept", u)
     self.assertEquals("http://www.rnaproject.org/data/rnax/odw/InformationConcept", str(u))
     self.assertEquals(u, Uri('http://www.rnaproject.org/data/rnax/odw/InformationConcept'))