turn make_relations_query into a true generator (this allows interleaving of actual entities linking and query generation) stable
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Tue, 20 Oct 2009 14:34:42 +0200
branchstable
changeset 3749 a84e798b99f6
parent 3748 7143198dd8a4
child 3753 310621cfed9b
turn make_relations_query into a true generator (this allows interleaving of actual entities linking and query generation) restore check botched in previous inadvertent commit
devtools/fill.py
--- a/devtools/fill.py	Tue Oct 20 14:24:19 2009 +0200
+++ b/devtools/fill.py	Tue Oct 20 14:34:42 2009 +0200
@@ -379,14 +379,15 @@
                 subjcard, objcard = rschema.rproperty(subj, obj, 'cardinality')
                 # process mandatory relations first
                 if subjcard in '1+' or objcard in '1+' or composite_relation(rschema):
-                    queries += self.make_relation_queries(sedict, oedict,
-                                                          rschema, subj, obj)
+                    for query, args in self.make_relation_queries(sedict, oedict,
+                                                          rschema, subj, obj):
+                        yield query, args
                 else:
                     delayed.append( (subj, obj) )
             for subj, obj in delayed:
-                queries += self.make_relation_queries(sedict, oedict, rschema,
-                                                      subj, obj)
-        return queries
+                for query, args in self.make_relation_queries(sedict, oedict, rschema,
+                                                              subj, obj):
+                    yield query, args
 
     def qargs(self, subjeids, objeids, subjcard, objcard, subjeid, objeid):
         if subjcard in '?1':
@@ -472,8 +473,9 @@
 
 def check_card_satisfied(card, remaining, subj, rschema, obj):
     if card in '1+' and remaining:
-        print "can't satisfy cardinality %s for relation %s %s %s" % (card, subj, rschema, obj)
-        
+        raise Exception("can't satisfy cardinality %s for relation %s %s %s" %
+                        (card, subj, rschema, obj))
+
 
 def choose_eid(values, avoid):
     values = tuple(values)