Format table

    :param sep: separator between columns
    :type sep: unicode on python2 | str on python3

    Given the table::

        table = [
            ['foo', 'bar', 'foo'],
            [1, 2, 3],
            ['54a5a05d-c83b-4bb5-bd95-d90d6ea4a878'],
            ['foo', 45, 'bar', 2345]
        ]

    `format_table` will return::

        foo                                   bar  foo
        1                                     2    3
        54a5a05d-c83b-4bb5-bd95-d90d6ea4a878
        foo                                   45   bar  2345

def format_table(rows, sep='  '):
    """Format table

    :param sep: separator between columns
    :type sep: unicode on python2 | str on python3

    Given the table::

        table = [
            ['foo', 'bar', 'foo'],
            [1, 2, 3],
            ['54a5a05d-c83b-4bb5-bd95-d90d6ea4a878'],
            ['foo', 45, 'bar', 2345]
        ]

    `format_table` will return::

        foo                                   bar  foo
        1                                     2    3
        54a5a05d-c83b-4bb5-bd95-d90d6ea4a878
        foo                                   45   bar  2345
    """
    max_col_length = [0] * 100
    # calculate max length for each col
    for row in rows:
        for index, (col, length) in enumerate(zip(row, max_col_length)):
            if len(text_type(col)) > length:
                max_col_length[index] = len(text_type(col))
    formated_rows = []
    for row in rows:
        format_str = sep.join([
            '{:<%s}' % l if i < (len(row) - 1) else '{}'
            for i, (c, l) in enumerate(zip(row, max_col_length))
        ])
        formated_rows.append(format_str.format(*row))
    return '\n'.join(formated_rows)