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

Function create_formatter

Solutions/6_7/tableformat.py:60–71  ·  view source on GitHub ↗

Create an appropriate formatter given an output format name

(name)

Source from the content-addressed store, hash-verified

58 pass
59
60def create_formatter(name):
61 '''
62 Create an appropriate formatter given an output format name
63 '''
64 if name == 'txt':
65 return TextTableFormatter()
66 elif name == 'csv':
67 return CSVTableFormatter()
68 elif name == 'html':
69 return HTMLTableFormatter()
70 else:
71 raise FormatError(f'Unknown table format {name}')
72
73def print_table(objects, columns, formatter):
74 '''

Callers

nothing calls this directly

Calls 4

TextTableFormatterClass · 0.70
CSVTableFormatterClass · 0.70
HTMLTableFormatterClass · 0.70
FormatErrorClass · 0.70

Tested by

no test coverage detected