Beispiel #1
0
def render_tables():
    console = Console(
        width=60,
        force_terminal=True,
        file=io.StringIO(),
        legacy_windows=False,
        color_system=None,
    )

    table = Table(title="test table", caption="table caption", expand=True)
    table.add_column("foo",
                     footer=Text("total"),
                     no_wrap=True,
                     overflow="ellipsis")
    table.add_column("bar", justify="center")
    table.add_column("baz", justify="right")

    table.add_row("Averlongwordgoeshere", "banana pancakes", None)

    assert Measurement.get(console, table, 80) == Measurement(41, 48)

    for width in range(10, 60, 5):
        console.print(table, width=width)

    table.expand = False
    console.print(table, justify="left")
    console.print(table, justify="center")
    console.print(table, justify="right")

    assert table.row_count == 1

    table.row_styles = ["red", "yellow"]
    table.add_row("Coffee")
    table.add_row("Coffee", "Chocolate", None, "cinnamon")

    assert table.row_count == 3

    console.print(table)

    table.show_lines = True
    console.print(table)

    table.show_footer = True
    console.print(table)

    table.show_edge = False

    console.print(table)

    table.padding = 1
    console.print(table)

    table.width = 20
    assert Measurement.get(console, table, 80) == Measurement(20, 20)
    console.print(table)

    return console.file.getvalue()
Beispiel #2
0
 def _setup_table() -> Table:
     table = Table(box=box.MINIMAL_HEAVY_HEAD)
     table.add_column(
         "ID",
         style="bold",
         width=len("bake-f6bd815b-3a3b-4ea1-b5ec-e8ab13678e3e"),
     )
     table.add_column("NAME", min_width=12)
     table.add_column("BATCH", min_width=20)
     table.add_column(
         "EXECUTOR",
         width=len("job-f6bd815b-3a3b-4ea1-b5ec-e8ab13678e3e"))
     table.add_column("STATUS", width=9)
     table.add_column("WHEN", min_width=10)
     table.show_edge = False
     return table