def make_underline(col_widths, use_ansi=True, separator="|"):
        underline = [separator]
        for width in col_widths:
            underline.append("{}{}".format("-" * (width + 4), separator))

        return Colour.light_grey(
            "".join(underline)) if use_ansi else "".join(underline)
    def make_row(wrapped_row,
                 col_widths,
                 use_ansi=True,
                 separator='|',
                 column_colours=None,
                 row_colour=None):
        if column_colours is None:
            column_colours = []
        if row_colour is None:
            row_colour = []

        separator = Colour.light_grey(separator) if use_ansi else separator
        string = []

        for h in range(Table.get_row_height(wrapped_row)):
            if h > 0:
                string.append('\n')
            string.append(separator)
            for i, column in enumerate(wrapped_row):
                if h < len(column):
                    data = str(column[h])
                    if use_ansi:
                        colour = column_colours[i] if i < len(
                            column_colours) else row_colour
                        if callable(colour):
                            data = colour(data)

                    padding = ' ' * (col_widths[i] - len(column[h]))
                    string.append('  {}{}  {}'.format(data, padding,
                                                      separator))
                else:
                    padding = ' ' * col_widths[i]
                    string.append('  {}  {}'.format(padding, separator))

        return ''.join(string)
Beispiel #3
0
 def make_row(row, col_widths, separator="|", has_key=False):
     string = ""
     for i, column in enumerate(row):
         data = str(column)
         if i is 0 and has_key:
             data = Colour.green(data)
         padding = "".join(
             [" " for _ in range(col_widths[i] - len(str(column)) + 2)])
         string += "  " + data + padding + Colour.light_grey(separator)
     return string
Beispiel #4
0
    def make_row(row, col_widths, use_ansi=True, separator="|", column_colours=None, row_colour=None):
        if column_colours is None:
            column_colours = []
        if row_colour is None:
            row_colour = []
        separator = Colour.light_grey(separator) if use_ansi else separator
        string = separator
        for i, column in enumerate(row):
            data = str(column)
            if use_ansi:
                colour = column_colours[i] if i < len(column_colours) else row_colour
                if callable(colour):
                    data = colour(data)
            padding = "".join([" " for _ in range(col_widths[i] - len(str(column)) + 2)])
            string += "  " + data + padding + separator

        return string
Beispiel #5
0
 def create(length):
     return Colour.light_grey("".join(['-' for _ in range(length)]))
Beispiel #6
0
    def make_underline(col_widths, use_ansi=True, separator="|"):
        underline = separator
        for width in col_widths:
            underline += "".join(["-" for _ in range(width + 4)]) + "|"

        return Colour.light_grey(underline) if use_ansi else underline
Beispiel #7
0
 def make_underline(col_widths):
     underline = ""
     for width in col_widths:
         underline += "".join(["-" for _ in range(width + 5)])
     return Colour.light_grey(underline)