Исправлена вывод таблицы для консоли

master-3.5
Mike Hiretsky 8 years ago
parent eb9ef3be04
commit 83b7bdfc05

@ -192,17 +192,17 @@ class tableReport(object):
columnsWidth.append(0) columnsWidth.append(0)
# Вычисляем ширину столбцов # Вычисляем ширину столбцов
for e in self.dataList: for e in self.dataList:
i = 0 for i, s in enumerate(e):
for s in e:
lenS = len(_u(s))+1 lenS = len(_u(s))+1
if columnsWidth[i] < lenS: if columnsWidth[i] < lenS:
columnsWidth[i] = lenS columnsWidth[i] = lenS
i += 1
return columnsWidth return columnsWidth
def createFormatStr(self, listStr): def createFormatStr(self, listStr, offset=0):
"""Создает список (текст, ширина ...)""" """Создает список (текст, ширина ...)"""
return chain(*izip_longest(listStr, self.columnsWidth, fillvalue="")) return chain(*izip_longest(listStr,
map(lambda x:x-offset, self.columnsWidth),
fillvalue=""))
def printFunc(self, s): def printFunc(self, s):
""" """
@ -246,7 +246,7 @@ class tableReport(object):
columnMatrix(*self.createFormatStr(listStrSep))]] columnMatrix(*self.createFormatStr(listStrSep))]]
for s in self.dataList: for s in self.dataList:
printData.append([self.vertChar, self.body_printer, printData.append([self.vertChar, self.body_printer,
columnMatrix(*self.createFormatStr(s))]) columnMatrix(*self.createFormatStr(s, 1))])
printData.append([self.crossChar, self.line_printer, printData.append([self.crossChar, self.line_printer,
columnMatrix(*self.createFormatStr(listStrSep))]) columnMatrix(*self.createFormatStr(listStrSep))])
last_col = len(self.headerList) - 1 last_col = len(self.headerList) - 1

Loading…
Cancel
Save