taurus.core.util.tablepprint
Adapted from http://code.activestate.com/recipes/267662/
Functions
- indent(rows, hasHeader=False, headerChar='-', delim=' | ', justify='left', separateRows=False, prefix='', postfix='', wrapfunc=<function <lambda>>)[source]
Indents a table by column.
- Parameters:
rows – A sequence of sequences of items, one sequence per row.
hasHeader – True if the first row consists of the columns’ names.
headerChar – Character to be used for the row separator line (if hasHeader==True or separateRows==True).
delim – The column delimiter.
justify – Determines how are data justified in their column. Valid values are ‘left’,’right’ and ‘center’.
separateRows – True if rows are to be separated by a line of ‘headerChar’s.
prefix – A string prepended to each printed row.
postfix – A string appended to each printed row.
wrapfunc – A function f(text) for wrapping text; each element in the table is first wrapped by this function.
- Returns:
a list of strings. One for each row of the table
- wrap_always(text, width)[source]
A simple word-wrap function that wraps text on exactly width characters. It doesn’t split the text in words.