Revision b482fbcc snf-webproject/synnefo/webproject/management/utils.py
b/snf-webproject/synnefo/webproject/management/utils.py | ||
---|---|---|
117 | 117 |
|
118 | 118 |
|
119 | 119 |
def pprint_table(out, table, headers=None, output_format='pretty', |
120 |
separator=None, vertical=False): |
|
120 |
separator=None, vertical=False, title=None):
|
|
121 | 121 |
"""Print a pretty, aligned string representation of table. |
122 | 122 |
|
123 | 123 |
Works by finding out the max width of each column and padding to data |
... | ... | |
167 | 167 |
widths = [max(map(len, col)) for col in zip(*(columns))] |
168 | 168 |
|
169 | 169 |
t_length = sum(widths) + len(sep) * (len(widths) - 1) |
170 |
if title is not None: |
|
171 |
out.write(title.center(t_length) + "\n") |
|
170 | 172 |
if headers: |
171 | 173 |
# pretty print the headers |
172 | 174 |
line = sep.join(uenc(v.rjust(w))\ |
Also available in: Unified diff