How to use the texttable.TextTable function in texttable

To help you get started, we’ve selected a few texttable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DrDomAdmin / security-tools / texttable.py View on Github external
for row in self.__rows:
            rstr = ' ' * self.pad
            
            for i in range(self.__num_cols):
                width = self.__col_widths[i]
                align = self.__col_aligns[i]
                rstr += '{0:{j}{w}} '.format(row[i], j=align, w=width)
                                
            s += rstr + '\n'
        #s += '\n'
        
        return s

if __name__ == '__main__':

    t1 = TextTable()
    t1.header = 'A Table of Numbers'
    t1.add_col_names(['Col1', 'Col2', 'Col3', 'Col4'])
    t1.add_col_align(['<', '<', '^', '>'])
    rows = [[1, 2, 3, 4],
            [5, 6, 7, 8],
            [9, 10, 11, 12],
            [111111, 22222222, 3333333333, 444444444444]]
    t1.add_rows(rows)
    
    print t1
    
    t2 = TextTable()
    t2.header = 'Another Table of Numbers'
    t2.add_col_names(['Col1', 'Col2', 'Col3', 'Col4'])
    t2.add_row([1, 2, 3, 4])
    t2.add_row([5, 6, 7, 8])
github DrDomAdmin / security-tools / texttable.py View on Github external
if __name__ == '__main__':

    t1 = TextTable()
    t1.header = 'A Table of Numbers'
    t1.add_col_names(['Col1', 'Col2', 'Col3', 'Col4'])
    t1.add_col_align(['<', '<', '^', '>'])
    rows = [[1, 2, 3, 4],
            [5, 6, 7, 8],
            [9, 10, 11, 12],
            [111111, 22222222, 3333333333, 444444444444]]
    t1.add_rows(rows)
    
    print t1
    
    t2 = TextTable()
    t2.header = 'Another Table of Numbers'
    t2.add_col_names(['Col1', 'Col2', 'Col3', 'Col4'])
    t2.add_row([1, 2, 3, 4])
    t2.add_row([5, 6, 7, 8])
    t2.add_row([9, 10, 11, 12])
    print t2