server/msplanner.py
changeset 6650 72f2fd93a622
parent 6649 29f8e5c35392
child 6651 4a0283b3ce0c
equal deleted inserted replaced
6649:29f8e5c35392 6650:72f2fd93a622
  1106                            'X': 't2.C0', 'T': 't2.C1'}),
  1106                            'X': 't2.C0', 'T': 't2.C1'}),
  1107                   ([0,2], {'A': 't1.login1', 'U': 't1.C0', 'U.login': 't1.login1'})]
  1107                   ([0,2], {'A': 't1.login1', 'U': 't1.C0', 'U.login': 't1.login1'})]
  1108         """
  1108         """
  1109         if not self._inputmaps:
  1109         if not self._inputmaps:
  1110             return [(allsolindices, None)]
  1110             return [(allsolindices, None)]
       
  1111         _allsolindices = allsolindices.copy()
  1111         mapbysol = {}
  1112         mapbysol = {}
  1112         # compute a single map for each solution
  1113         # compute a single map for each solution
  1113         for solindices, basemap in self._inputmaps.iteritems():
  1114         for solindices, basemap in self._inputmaps.iteritems():
  1114             for solindex in solindices:
  1115             for solindex in solindices:
       
  1116                 if not solindex in allsolindices:
       
  1117                     continue
  1115                 solmap = mapbysol.setdefault(solindex, {})
  1118                 solmap = mapbysol.setdefault(solindex, {})
  1116                 solmap.update(basemap)
  1119                 solmap.update(basemap)
  1117                 try:
  1120                 try:
  1118                     allsolindices.remove(solindex)
  1121                     _allsolindices.remove(solindex)
  1119                 except KeyError:
  1122                 except KeyError:
  1120                     continue # already removed
  1123                     continue # already removed
  1121         # group results by identical input map
  1124         # group results by identical input map
  1122         result = []
  1125         result = []
  1123         for solindex, solmap in mapbysol.iteritems():
  1126         for solindex, solmap in mapbysol.iteritems():
  1125                 if commonmap == solmap:
  1128                 if commonmap == solmap:
  1126                     solindices.append(solindex)
  1129                     solindices.append(solindex)
  1127                     break
  1130                     break
  1128             else:
  1131             else:
  1129                 result.append( ([solindex], solmap) )
  1132                 result.append( ([solindex], solmap) )
  1130         if allsolindices:
  1133         if _allsolindices:
  1131             result.append( (list(allsolindices), None) )
  1134             result.append( (list(_allsolindices), None) )
  1132         return result
  1135         return result
  1133 
  1136 
  1134     def build_final_part(self, select, solindices, inputmap,  sources,
  1137     def build_final_part(self, select, solindices, inputmap,  sources,
  1135                          insertedvars):
  1138                          insertedvars):
  1136         solutions = [self._solutions[i] for i in solindices]
  1139         solutions = [self._solutions[i] for i in solindices]