in qpid/disp.py [0:0]
def table(self, title, heads, rows):
""" Print a table with autosized columns """
# Pad the rows to the number of heads
for row in rows:
diff = len(heads) - len(row)
for idx in range(diff):
row.append("")
print(title)
if len (rows) == 0:
return
colWidth = []
col = 0
line = self.tablePrefix
for head in heads:
width = len (head)
for row in rows:
cellWidth = len (unicode (row[col]))
if cellWidth > width:
width = cellWidth
colWidth.append (width + self.tableSpacing)
line = line + head
if col < len (heads) - 1:
for i in range (colWidth[col] - len (head)):
line = line + " "
col = col + 1
print(line)
line = self.tablePrefix
for width in colWidth:
line = line + "=" * width
line = line[:255]
print(line)
for row in rows:
line = self.tablePrefix
col = 0
for width in colWidth:
line = line + unicode (row[col])
if col < len (heads) - 1:
for i in range (width - len (unicode (row[col]))):
line = line + " "
col = col + 1
print(line)