Make a nicely formatted table from a list of objects and attribute names.
(objects, columns, formatter)
| 71 | raise FormatError(f'Unknown table format {name}') |
| 72 | |
| 73 | def print_table(objects, columns, formatter): |
| 74 | ''' |
| 75 | Make a nicely formatted table from a list of objects and attribute names. |
| 76 | ''' |
| 77 | formatter.headings(columns) |
| 78 | for obj in objects: |
| 79 | rowdata = [ str(getattr(obj, name)) for name in columns ] |
| 80 | formatter.row(rowdata) |
| 81 |