cli_helpers/tabular_output/vertical_table_adapter.py
def vertical_table(data, headers, sep_title='{n}. row', sep_character='*',
                   sep_length=27):
    """Format *data* and *headers* as an vertical table.

    The values in *data* and *headers* must be strings.

    :param iterable data: An :term:`iterable` (e.g. list) of rows.
    :param iterable headers: The column headers.
    :param str sep_title: The title given to each row separator. Defaults to
                          ``'{n}. row'``. Any instance of ``'{n}'`` is
                          replaced by the record number.
    :param str sep_character: The character used to separate rows. Defaults to
                              ``'*'``.
    :param int/tuple sep_length: The number of separator characters that should
                                 appear on each side of the *sep_title*. Use
                                 a tuple to specify the left and right values
                                 separately.
    :return: The formatted data.
    :rtype: str

    """
    header_len = max([len(x) for x in headers])
    padded_headers = [x.ljust(header_len) for x in headers]
    formatted_rows = [_format_row(padded_headers, row) for row in data]

    output = []
    for i, result in enumerate(formatted_rows):
        yield _get_separator(i, sep_title, sep_character, sep_length) + result
def vertical_table(data, headers, sep_title='{n}. row', sep_character='*',
                   sep_length=27):
    """Format *data* and *headers* as an vertical table.

    The values in *data* and *headers* must be strings.

    :param iterable data: An :term:`iterable` (e.g. list) of rows.
    :param iterable headers: The column headers.
    :param str sep_title: The title given to each row separator. Defaults to
                          ``'{n}. row'``. Any instance of ``'{n}'`` is
                          replaced by the record number.
    :param str sep_character: The character used to separate rows. Defaults to
                              ``'*'``.
    :param int/tuple sep_length: The number of separator characters that should
                                 appear on each side of the *sep_title*. Use
                                 a tuple to specify the left and right values
                                 separately.
    :return: The formatted data.
    :rtype: str

    """
    header_len = max([len(x) for x in headers])
    padded_headers = [x.ljust(header_len) for x in headers]
    formatted_rows = [_format_row(padded_headers, row) for row in data]

    output = []
    for i, result in enumerate(formatted_rows):
        yield _get_separator(i, sep_title, sep_character, sep_length) + result
Format *data* and *headers* as an vertical table.

    The values in *data* and *headers* must be strings.

    :param iterable data: An :term:`iterable` (e.g. list) of rows.
    :param iterable headers: The column headers.
    :param str sep_title: The title given to each row separator. Defaults to
                          ``'{n}. row'``. Any instance of ``'{n}'`` is
                          replaced by the record number.
    :param str sep_character: The character used to separate rows. Defaults to
                              ``'*'``.
    :param int/tuple sep_length: The number of separator characters that should
                                 appear on each side of the *sep_title*. Use
                                 a tuple to specify the left and right values
                                 separately.
    :return: The formatted data.
    :rtype: str