Adapted from http://code.activestate.com/recipes/267662/


indent(rows, hasHeader=False, headerChar='-', delim=' | ', justify='left', separateRows=False, prefix='', postfix='', wrapfunc=<function <lambda>>)[source]

Indents a table by column. :param rows: A sequence of sequences of items, one sequence per row. :param hasHeader: True if the first row consists of the columns’ names. :param headerChar: Character to be used for the row separator line (if hasHeader==True or separateRows==True). :param delim: The column delimiter. :param justify: Determines how are data justified in their column. Valid values are ‘left’,’right’ and ‘center’. :param separateRows: True if rows are to be separated by a line of ‘headerChar’s. :param prefix: A string prepended to each printed row. :param postfix: A string appended to each printed row. :param wrapfunc: A function f(text) for wrapping text; each element in the table is first wrapped by this function. :return: 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.

wrap_onspace(text, width)[source]

A word-wrap function that preserves existing line breaks and most spaces in the text. Expects that existing line breaks are posix newlines (\n).

wrap_onspace_strict(text, width)[source]

Similar to wrap_onspace, but enforces the width constraint: words longer than width are split.