Source code for buildtest.utils.table

from rich.table import Table

from buildtest.defaults import console


[docs] def create_table( columns, data, title=None, header_style="blue", column_style=None, show_lines=False ): """Create a table object with the given columns and data. This function is a wrapper around rich.Table and it can be used to alter table settings. The return value is a rich.Table object. Args: columns (list): List of column names data (list): List of rows, where each row is a list of values title (str): Title of the table header_style (str): Style of the header column_style (str): Style of the columns show_lines (bool): Whether to show lines in the table """ table = Table(title=title, header_style=header_style, show_lines=show_lines) for column in columns: table.add_column(column, style=column_style, overflow="fold") for row in data: table.add_row(*row) return table