示例#1
0
    def __init__(self,
                 title=None,
                 header=None,
                 descr=None,
                 data=None,
                 export='plain',
                 max_width=80):
        Texttable.__init__(self, max_width=max_width)
        if export == 'plain':
            self.set_chars(['-', '|', '+', '-'])
            self.set_deco(Texttable.HEADER | Texttable.VLINES)  # Texttable.BORDER | Texttable.HLINE
        self.set_precision(3)

        self._title = title
        self._descr = descr
        if header is not None:
            self.header(header)
        if data is not None:
            self.add_rows(data, header=False)
示例#2
0
    def draw(self):
        """
        Draw the table and return it in a string.
        """
        self._add_left_space()

        # for Texttable, add a column of whitespace on the left for better visual effect
        if self._title and self._descr:
            pre = self._title + '\n' + self._descr + '\n\n'
        elif self._title:
            pre = self._title + '\n\n'
        elif self._descr:
            pre = 'Empty Title' + '\n' + self._descr + '\n'
        else:
            pre = ''
        return pre + str(Texttable.draw(self)) + '\n\n'
示例#3
0
 def header(self, header_list):
     """Set the header with a list."""
     Texttable.header(self, header_list)