format_table(headings=None,
contents=None,
max_width=None,
separator=' ' ,
pad_left=' ' ,
pad_right=' ' ,
prefix=' ' ,
postfix=' ' ,
custom_format=None,
spacing=False,
debug=False)
| source code
|
Format and return the table as text.
If the heading or contents contains the value of the MULTI_COL
constant defined in this module, then that cell will be merged with the
previous cell to allow elements to span multiple columns.
- Parameters:
headings (list of lists of str) - The table header.
contents (list of lists of str) - The table contents.
max_width (int) - The maximum width of the table.
separator (str) - The column separation string.
pad_left (str) - The string to pad the left side of the table with.
pad_right (str) - The string to pad the right side of the table with.
prefix (str) - The text to add to the start of the line.
postfix (str) - The text to add to the end of the line.
custom_format (None or list of None and str) - This list allows a custom format to be specified for each column.
The number of elements must match the number of columns. If an
element is None, then the default will be used. Otherwise the
elements must be valid string formatting constructs.
spacing (bool) - A flag which if True will add blank line between each row.
debug (bool) - A flag which if True will activate a number of debugging
printouts.
- Returns: str
- The formatted table.
|