[pypy-svn] r32819 - in pypy/dist/pypy/lib/pyontology: . test

ale at codespeak.net ale at codespeak.net
Mon Oct 2 14:55:23 CEST 2006


Author: ale
Date: Mon Oct  2 14:55:21 2006
New Revision: 32819

Modified:
   pypy/dist/pypy/lib/pyontology/pyontology.py
   pypy/dist/pypy/lib/pyontology/test/test_sparql.py
Log:
Added another case of sparql query, removed prints ..


Modified: pypy/dist/pypy/lib/pyontology/pyontology.py
==============================================================================
--- pypy/dist/pypy/lib/pyontology/pyontology.py	(original)
+++ pypy/dist/pypy/lib/pyontology/pyontology.py	Mon Oct  2 14:55:21 2006
@@ -470,8 +470,6 @@
         where = qe.SelectQuery[0].WhereClause[0]
 
         triples = where.GroupGraphPattern[0].Triples
-#        import pdb
-#        pdb.set_trace()
         new = []
         for trip in triples:
             case = 1
@@ -480,7 +478,6 @@
             trip = list(trip)
             for item in trip:
                 if isinstance(item, Literal):
-                    print "!!!!!!!",item
                     newtrip.append(item)
                 elif item.NCNAME_PREFIX:
                     uri = prefixes[item.NCNAME_PREFIX[0]] + item.NCNAME[0]
@@ -488,7 +485,6 @@
                 elif item.getName() == 'VAR1':
                     newtrip.append(URIRef('query_'+item[0]))
                     case += trip.index(item) + inc
-                    print "Case calc", case, inc, list(trip).index(item),item
                     if inc:
                         inc = 1
                     else:
@@ -534,7 +530,6 @@
                 #  search for s in p
                 prop = self.make_var(None, trip[1])
                 p_vals = self.variables[prop].getValuesPrKey(self.make_var(trip[0]))
-                print "========",p_vals
                 p_vals = p_vals[0][1]
                 var = self.make_var(Thing, trip[2])
                 self.variables[var].setValues((p_vals))
@@ -543,7 +538,13 @@
                 pass
             elif case == 5:
                 #  return the values of p
-                pass
+                prop = self.make_var(Property, URIRef(trip[1]))
+                p_vals = self.variables[prop].getValues()
+                var = self.make_var(Thing, trip[0])
+                self.variables[var].setValues([v[0] for v in p_vals])
+                p_vals = self.variables[prop].getValues()
+                var = self.make_var(Thing, trip[2])
+                self.variables[var].setValues([v[1] for v in p_vals])
             elif case == 6:
                 #  for all p's return p[1] if p[0]==s  
                 pass

Modified: pypy/dist/pypy/lib/pyontology/test/test_sparql.py
==============================================================================
--- pypy/dist/pypy/lib/pyontology/test/test_sparql.py	(original)
+++ pypy/dist/pypy/lib/pyontology/test/test_sparql.py	Mon Oct  2 14:55:21 2006
@@ -108,7 +108,6 @@
     O = Ontology()
     O.add_file(StringIO(Onto))
     O.attach_fd()
-    print "Attached"
     O.sparql(query)
     assert list(O.variables['query_x_'].getValues())[0].uri == u'#sub' 
 
@@ -151,7 +150,7 @@
 
 def test_case_5():
     """ for all p's return p[0] if p[1]==o """
-    py.test.skip("Doesn't work yet")
+    #py.test.skip("Doesn't work yet")
 
     query = qt_proto % ('?x ?y', '?x ns:p ?y .')
     O = Ontology()
@@ -160,6 +159,7 @@
 
     O.sparql(query)
     assert list(O.variables['query_x_'].getValues())[0].uri == u'#sub' 
+    assert list(O.variables['query_y_'].getValues())[0] == u'123' 
 
 def test_case_6():
     """ return the values of p """



More information about the Pypy-commit mailing list