Python tabulate.TableFormat() Examples

The following are 2 code examples of tabulate.TableFormat(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tabulate , or try the search function .
Example #1
Source File: test_regression.py    From python-tabulate with MIT License 5 votes vote down vote up
def test_custom_tablefmt():
    "Regression: allow custom TableFormat that specifies with_header_hide (github issue #20)"
    tablefmt = TableFormat(
        lineabove=Line("", "-", "  ", ""),
        linebelowheader=Line("", "-", "  ", ""),
        linebetweenrows=None,
        linebelow=Line("", "-", "  ", ""),
        headerrow=DataRow("", "  ", ""),
        datarow=DataRow("", "  ", ""),
        padding=0,
        with_header_hide=["lineabove", "linebelow"],
    )
    rows = [["foo", "bar"], ["baz", "qux"]]
    expected = "\n".join(["A    B", "---  ---", "foo  bar", "baz  qux"])
    result = tabulate(rows, headers=["A", "B"], tablefmt=tablefmt)
    assert_equal(result, expected) 
Example #2
Source File: _bootstrap.py    From armi with Apache License 2.0 5 votes vote down vote up
def _addCustomTabulateTables():
    """Create a custom ARMI tables within tabulate."""
    tabulate._table_formats["armi"] = tabulate.TableFormat(
        lineabove=tabulate.Line("", "-", "  ", ""),
        linebelowheader=tabulate.Line("", "-", "  ", ""),
        linebetweenrows=None,
        linebelow=tabulate.Line("", "-", "  ", ""),
        headerrow=tabulate.DataRow("", "  ", ""),
        datarow=tabulate.DataRow("", "  ", ""),
        padding=0,
        with_header_hide=None,
    )
    tabulate.tabulate_formats = list(sorted(tabulate._table_formats.keys()))
    tabulate.multiline_formats["armi"] = "armi"


# runLog makes tables, so make sure this is setup before we initialize the runLog