def pe3(db): #{{{ """ Создание таблицы для перечня элементов. """ # create brand new table for pe3 pe3tab = __newpe3tab() db = __mergecolumns(db) i = 0 while (i < len(db)): partslice = __getslice(db, i, 'Part') i += len(partslice) p = __compact_partslice(partslice) pe3piece = p[0] if p[1] is True: blockname = component_des[p[2]][0] n = pe3piece['Quantity'][0] parts = pe3piece['Part'][0] item = pe3piece['Item'][0] pe3tab = pe3tab.addrecords((str(parts), blockname + ' ' + item, str(n), pe3piece['Note'][0] + '*')) pe3tab = pe3tab.addrecords(('','','','\\tabularnewline*')) pe3tab = pe3tab.addrecords(('','','','\\tabularnewline')) else: blockname = component_des[p[2]][1] pe3tab = pe3tab.addrecords(('','\\centering{' + blockname + '}','','\\tabularnewline*')) pe3tab = pe3tab.addrecords(('','','','\\tabularnewline*')) pe3piece['Note'][0] += '*' if len(pe3piece) == 2: pe3piece['Note'][-1] += '*' elif len(pe3piece) > 2: pe3piece['Note'][-1] += '*' pe3piece['Note'][-2] += '*' pe3tab = pe3tab.rowstack(pe3piece) pe3tab = pe3tab.addrecords(('','','','\\tabularnewline*')) pe3tab = pe3tab.addrecords(('','','','\\tabularnewline')) i = 0 while i < len(pe3tab): # заключим Part в хитрый бокс pe3tab['Part'][i] = '\ESKDsmartScaleBox{\\argi -2\\tabcolsep}{' + pe3tab['Part'][i] + '}' i += 1 # удалим ряд-распорку pe3tab = utils.deleterow(pe3tab, 0) return pe3tab
def __compact_partslice(partslice):#{{{ """ Сжимает срез с одинаковыми элементами в одну строку """ pe3tab = __newpe3tab() i = 0 single = False part = partslice[0]['Part'] while (i < len(partslice)): itemslice = __getslice(partslice, i, 'Part Num') parts = __aggregate_items(itemslice, 0, len(itemslice)) i += len(itemslice) if len(itemslice) == len(partslice): single = True else: single = False item = itemslice[0]['Part Num'] quantity = len(itemslice) package = itemslice[0]['Package'] pe3tab = pe3tab.addrecords((parts, item, str(quantity), package + '\\tabularnewline')) # удалим ряд-распорку pe3tab = utils.deleterow(pe3tab, 0) return (pe3tab, single, part)