(no commit message)
[sfa.git] / sfatables / pretty.py
1 #!/usr/bin/python
2
3 class Pretty:
4     rows = []
5     column_width = []
6
7     def __init__(self, header):
8         self.rows.append(header)
9         for c in header:
10             self.column_width.append(len(header))
11
12     def push_row (self, row):
13         self.rows.append(row)
14         num = 0
15         for c in row:
16             if (self.column_width[num] < len(c)):
17                 self.column_width[num] = len(c)
18             num = num + 1
19         return
20
21     def pprint (self):
22         print '\n'
23
24         for rule in self.rows:
25             cur_line = ""
26             num = 0
27
28             import pdb
29             pdb.set_trace()
30             for r in rule:
31                 cur_line = cur_line + "%s "%r
32                 if (self.column_width[num] > len(r)):
33                     padding0 = ''.zfill(self.column_width[num] - len(r))
34                     padding = padding0.replace('0',' ')
35                     cur_line = cur_line + padding
36                 num = num + 1
37
38             print cur_line
39
40