src/lsi/utils/table.py
def render_row(num, columns, widths, column_colors=None):
    """
    Render the `num`th row of each column in `columns`.

    :param num: Which row to render.
    :type num: ``int``
    :param columns: The list of columns.
    :type columns: [[``str``]]
    :param widths: The widths of each column.
    :type widths: [``int``]
    :param column_colors: An optional list of coloring functions.
    :type column_colors: [``str`` -> ``str``] or ``NoneType``

    :return: The rendered row.
    :rtype: ``str``
    """
    row_str = '|'
    cell_strs = []
    for i, column in enumerate(columns):
        try:
            cell = column[num]
            # We choose the number of spaces before we color the string, so
            # that the coloring codes don't affect the length.
            spaces = ' ' * (widths[i] - len(cell))
            if column_colors is not None and column_colors[i] is not None:
                cell = column_colors[i](cell)
            cell_strs.append(' %s%s ' % (cell, spaces))
        except IndexError:
            # If the index is out of range, just print an empty cell.
            cell_strs.append(' ' * (widths[i] + 2))
    return '|%s|' % '|'.join(cell_strs)
def render_row(num, columns, widths, column_colors=None):
    row_str = '|'
    cell_strs = []
    for i, column in enumerate(columns):
        try:
            cell = column[num]
            # We choose the number of spaces before we color the string, so
            # that the coloring codes don't affect the length.
            spaces = ' ' * (widths[i] - len(cell))
            if column_colors is not None and column_colors[i] is not None:
                cell = column_colors[i](cell)
            cell_strs.append(' %s%s ' % (cell, spaces))
        except IndexError:
            # If the index is out of range, just print an empty cell.
            cell_strs.append(' ' * (widths[i] + 2))
    return '|%s|' % '|'.join(cell_strs)
def render_row ( num , columns , widths , column_colors = None ) : row_str = '|' cell_strs = [ ] for i , column in enumerate ( columns ) : try : cell = column [ num ] # We choose the number of spaces before we color the string, so # that the coloring codes don't affect the length. spaces = ' ' * ( widths [ i ] - len ( cell ) ) if column_colors is not None and column_colors [ i ] is not None : cell = column_colors [ i ] ( cell ) cell_strs . append ( ' %s%s ' % ( cell , spaces ) ) except IndexError : # If the index is out of range, just print an empty cell. cell_strs . append ( ' ' * ( widths [ i ] + 2 ) ) return '|%s|' % '|' . join ( cell_strs )
Render the `num`th row of each column in `columns`.

    :param num: Which row to render.
    :type num: ``int``
    :param columns: The list of columns.
    :type columns: [[``str``]]
    :param widths: The widths of each column.
    :type widths: [``int``]
    :param column_colors: An optional list of coloring functions.
    :type column_colors: [``str`` -> ``str``] or ``NoneType``

    :return: The rendered row.
    :rtype: ``str``
Render the num th row of each column in columns .