server/msplanner.py
changeset 8696 0bb18407c053
parent 7886 b1c913a6d9f0
child 9167 c05652b108ce
equal deleted inserted replaced
8695:358d8bed9626 8696:0bb18407c053
  1073 
  1073 
  1074     def _expand_sources(self, selected_source, term, solindices):
  1074     def _expand_sources(self, selected_source, term, solindices):
  1075         """return all sources supporting given term / solindices"""
  1075         """return all sources supporting given term / solindices"""
  1076         sources = [selected_source]
  1076         sources = [selected_source]
  1077         sourcesterms = self._sourcesterms
  1077         sourcesterms = self._sourcesterms
  1078         for source in sourcesterms.keys():
  1078         for source in list(sourcesterms):
  1079             if source is selected_source:
  1079             if source is selected_source:
  1080                 continue
  1080                 continue
  1081             if not (term in sourcesterms[source] and
  1081             if not (term in sourcesterms[source] and
  1082                     solindices.issubset(sourcesterms[source][term])):
  1082                     solindices.issubset(sourcesterms[source][term])):
  1083                 continue
  1083                 continue
  1097         sourcesterms = self._sourcesterms
  1097         sourcesterms = self._sourcesterms
  1098         linkedterms = self._linkedterms
  1098         linkedterms = self._linkedterms
  1099         # term has to belong to the same scope if there is more
  1099         # term has to belong to the same scope if there is more
  1100         # than the system source remaining
  1100         # than the system source remaining
  1101         if len(sourcesterms) > 1 and not scope is self.rqlst:
  1101         if len(sourcesterms) > 1 and not scope is self.rqlst:
  1102             candidates = (t for t in sourceterms.keys() if scope is ms_scope(t))
  1102             candidates = (t for t in sourceterms if scope is ms_scope(t))
  1103         else:
  1103         else:
  1104             candidates = sourceterms #.iterkeys()
  1104             candidates = sourceterms
  1105         # we only want one unlinked term in each generated query
  1105         # we only want one unlinked term in each generated query
  1106         candidates = [t for t in candidates
  1106         candidates = [t for t in candidates
  1107                       if isinstance(t, (Constant, Relation)) or
  1107                       if isinstance(t, (Constant, Relation)) or
  1108                       (solindices.issubset(sourceterms[t]) and t in linkedterms)]
  1108                       (solindices.issubset(sourceterms[t]) and t in linkedterms)]
  1109         cross_rels = {}
  1109         cross_rels = {}