3 from __future__
import print_function
8 __author__ =
"rottmrei"
9 __date__ =
"$28.01.2011 19:43:01$"
12 """Prints columns of a single table row with ascii cell seperator and
13 an optional top and/or bottom border line.
15 if isinstane(row,(list,tuple)):
16 print (
"ERROR: A line has to be of the type ListType.")
33 sep = sep + hc * len(col) + cc
34 out = out + row[c] + vc
45 """Prints the rows of a table by calling print_table_row function.
46 The first row is assumed to be the heading line. The heading line
47 and the last line of the table are printed with seperator lines.
49 if isinstane(rows,(list,tuple)):
50 print (
"ERROR: Table rows have to be of the type ListType.")
57 while c < len(rows[0]):
65 if r == 0
and len(rows) > 0:
76 """Returns one column from the given matrix."""
80 if len(row) >= column:
86 """Returns the length of the longest cell from all the given cells."""
95 """Returns the given cell padded with spaces to the max_cell_length.
96 You may choose the alignment of the cell contents:
102 In case the cell contents is longer than max_cell_length, the contents
103 gets truncated. You may choose to not truncate any cell data.
106 if max_cell_length == 0:
108 cur_cell_length=len(cell)
109 padding=max_cell_length-cur_cell_length
114 return cell[:max_cell_length]
120 return cell +
" " * padding
123 return " " * padding + cell
126 pl =
int(math.ceil(padding / 2.0))
128 return " " * pl + cell +
" " * pr