MCPcopy Create free account
hub / github.com/dabeaz-course/python-mastery / create_formatter

Function create_formatter

Solutions/3_8/tableformat.py:61–79  ·  view source on GitHub ↗
(name, column_formats=None, upper_headers=False)

Source from the content-addressed store, hash-verified

59 super().headings([h.upper() for h in headers])
60
61def create_formatter(name, column_formats=None, upper_headers=False):
62 if name == 'text':
63 formatter_cls = TextTableFormatter
64 elif name == 'csv':
65 formatter_cls = CSVTableFormatter
66 elif name == 'html':
67 formatter_cls = HTMLTableFormatter
68 else:
69 raise RuntimeError('Unknown format %s' % name)
70
71 if column_formats:
72 class formatter_cls(ColumnFormatMixin, formatter_cls):
73 formats = column_formats
74
75 if upper_headers:
76 class formatter_cls(UpperHeadersMixin, formatter_cls):
77 pass
78
79 return formatter_cls()
80
81
82

Callers 1

stock.pyFile · 0.90

Calls 1

formatter_clsClass · 0.70

Tested by

no test coverage detected