Exemple #1
0
 def expand(r, c, end):
     print('expand(%s,%s,%s)' % (r, c, end))
     i0, t0 = r, table[r][c]
     if not t0:
         return t0
     if c + 1 < ncols and (table[r][c + 1] or not c):
         d = {}
         keys = []
         new_end = r + 1
         for i in range(r + 1, end + 1):
             t = table[i][c] if i < end else None
             if t or i >= end:
                 # start,name,stop for each key
                 keys.append((i0, t0, new_end))
                 t0, i0 = t, i
             new_end = i + 1
         for i, key, new_end in keys:
             nd = expand(i, c + 1, new_end)
             d[key] = nd if key not in d else djoin(d.get(key), nd)
         print('expand(%s to %s,%s): %s' % (r, end, c, d))
         return d
     else:
         d = [table[i][c] for i in range(r, end)]
         print('expand(%s to %s,%s): %s' % (r, end, c, d))
         return d
Exemple #2
0
 def save(self):
     self.getValues()
     self.info('DictionaryEditor.save(%s(%s)): %s' %
               (type(self.data), self.data, self.callback))
     if self.callback:
         self.callback(self.data)
     elif self.dctmodel is None:
         self.dctmodel = self.data
     else:  # Overwriting dctmodel
         if isSequence(self.dctmodel):
             while len(self.dctmodel):
                 self.dctmodel.pop(0)
             self.dctmodel.extend(self.data)
         elif isDictionary(self.dctmodel):
             self.dctmodel.clear()
             self.dctmodel = djoin(self.dctmodel, self.data)
     return self.data