entity.py
changeset 10662 10942ed172de
parent 10613 8d9fe02387e3
child 10669 155c29e0ed1c
equal deleted inserted replaced
10661:e6eb0c7c2e98 10662:10942ed172de
   106     You get following restriction : 'O welcomes G, G eid 321'
   106     You get following restriction : 'O welcomes G, G eid 321'
   107 
   107 
   108     """
   108     """
   109     st = cstr.snippet_rqlst.copy()
   109     st = cstr.snippet_rqlst.copy()
   110     # replace relations in ST by eid infos from linkto where possible
   110     # replace relations in ST by eid infos from linkto where possible
   111     for (info_rtype, info_role), eids in lt_infos.iteritems():
   111     for (info_rtype, info_role), eids in lt_infos.items():
   112         eid = eids[0] # NOTE: we currently assume a pruned lt_info with only 1 eid
   112         eid = eids[0] # NOTE: we currently assume a pruned lt_info with only 1 eid
   113         for rel in st.iget_nodes(RqlRelation):
   113         for rel in st.iget_nodes(RqlRelation):
   114             targetvar = rel_matches(rel, info_rtype, info_role, evar.name)
   114             targetvar = rel_matches(rel, info_rtype, info_role, evar.name)
   115             if targetvar is not None:
   115             if targetvar is not None:
   116                 if targetvar.name in eidvars:
   116                 if targetvar.name in eidvars:
   133     # else insert snippets into the global tree
   133     # else insert snippets into the global tree
   134     return GeneratedConstraint(st, cstr.mainvars - set(evarname))
   134     return GeneratedConstraint(st, cstr.mainvars - set(evarname))
   135 
   135 
   136 def pruned_lt_info(eschema, lt_infos):
   136 def pruned_lt_info(eschema, lt_infos):
   137     pruned = {}
   137     pruned = {}
   138     for (lt_rtype, lt_role), eids in lt_infos.iteritems():
   138     for (lt_rtype, lt_role), eids in lt_infos.items():
   139         # we can only use lt_infos describing relation with a cardinality
   139         # we can only use lt_infos describing relation with a cardinality
   140         # of value 1 towards the linked entity
   140         # of value 1 towards the linked entity
   141         if not len(eids) == 1:
   141         if not len(eids) == 1:
   142             continue
   142             continue
   143         lt_card = eschema.rdef(lt_rtype, lt_role).cardinality[
   143         lt_card = eschema.rdef(lt_rtype, lt_role).cardinality[