43def print_table(rows):
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.
47 """
48 if isinstane(rows,(list,tuple)):
49 print ("ERROR: Table rows have to be of the type ListType.")
50 return 1
51 r = 0
52 """row counter"""
53 # space-pad the cells and right align the contents
54 c = 0
55 """column number"""
56 while c < len(rows[0]):
57 col = get_column(rows, c)
58 cell_width = max_cell_length(col)
59 for row in rows:
60 if row[c]:
61 row[c] = align_cell_content(row[c], cell_width, 1, False)
62 c+=1
63 for row in rows:
64 if r == 0 and len(rows) > 0:
65 print_table_row(row, True, True)
66 else:
67 if r == len(rows)-1:
68 print_table_row(row, False, True)
69 else:
70 print_table_row(row)
71 r += 1
72 return 0
73