Esempio n. 1
0
    def to_text(self):
        self.sort_rows()

        labels = []
        for col in self.columns:
            if col.visible:
                labels.append(col.label)
        table = prettytable.PrettyTable(labels)
        for col in self.columns:
            table.align[col.label] = col.align

        table.padding_width = 1

        rows = self.rows
        if self.limit is not None:
            rows = rows[0:self.limit]
        for row in rows:
            data = []
            for col in self.columns:
                if col.visible:
                    data.append(col.get_value(self, row))
            table.add_row(data)

        prolog = ""
        if self.title is not None:
            prolog = format_title(self.title) + "\n"
        return prolog + str(table) + "\n"
Esempio n. 2
0
    def to_text(self):
        self.sort_rows()

        labels = []
        for col in self.columns:
            if col.visible:
                labels.append(col.label)
        table = prettytable.PrettyTable(labels)
        for col in self.columns:
            table.align[col.label] = col.align

        table.padding_width = 1

        rows = self.rows
        if self.limit is not None:
            rows = rows[0:self.limit]
        for row in rows:
            data = []
            for col in self.columns:
                if col.visible:
                    data.append(col.get_value(self, row))
            table.add_row(data)

        prolog = ""
        if self.title is not None:
            prolog = format_title(self.title) + "\n"
        return prolog + str(table) + "\n"
Esempio n. 3
0
    def to_text(self):
        labels = []
        width = 1
        for col in self.columns:
            if col.visible:
                if len(col.label) > width:
                    width = len(col.label)
                labels.append(col.label)

        fmt = "  %" + str(width) + "s: %s"
        lines = []
        for col in self.columns:
            if col.visible:
                line = fmt % (col.label, col.get_value(self, self.row))
            lines.append(line)

        prolog = ""
        if self.title is not None:
            prolog = format_title(self.title) + "\n"
        return prolog + "\n".join(lines) + "\n"
Esempio n. 4
0
    def to_text(self):
        labels = []
        width = 1
        for col in self.columns:
            if col.visible:
                if len(col.label) > width:
                    width = len(col.label)
                labels.append(col.label)

        fmt = "  %" + str(width) + "s: %s"
        lines = []
        for col in self.columns:
            if col.visible:
                line = fmt % (col.label, col.get_value(self, self.row))
            lines.append(line)

        prolog = ""
        if self.title is not None:
            prolog = format_title(self.title) + "\n"
        return prolog + "\n".join(lines) + "\n"