7 __author__ =
"rottmrei"
8 __date__ =
"$28.01.2011 19:43:01$"
11 """Prints columns of a single table row with ascii cell seperator and
12 an optional top and/or bottom border line.
14 if isinstane(row,(list,tuple)):
15 print (
"ERROR: A line has to be of the type ListType.")
32 sep = sep + hc * len(col) + cc
33 out = out + row[c] + vc
44 """Prints the rows of a table by calling print_table_row function.
45 The first row is assumed to be the heading line. The heading line
46 and the last line of the table are printed with seperator lines.
48 if isinstane(rows,(list,tuple)):
49 print (
"ERROR: Table rows have to be of the type ListType.")
56 while c < len(rows[0]):
64 if r == 0
and len(rows) > 0:
75 """Returns one column from the given matrix."""
79 if len(row) >= column:
85 """Returns the length of the longest cell from all the given cells."""
94 """Returns the given cell padded with spaces to the max_cell_length.
95 You may choose the alignment of the cell contents:
101 In case the cell contents is longer than max_cell_length, the contents
102 gets truncated. You may choose to not truncate any cell data.
105 if max_cell_length == 0:
107 cur_cell_length=len(cell)
108 padding=max_cell_length-cur_cell_length
113 return cell[:max_cell_length]
119 return cell +
" " * padding
122 return " " * padding + cell
125 pl =
int(math.ceil(padding / 2.0))
127 return " " * pl + cell +
" " * pr