How to use the tabulate.DataRow function in tabulate

To help you get started, we’ve selected a few tabulate 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 astanin / python-tabulate / test / test_regression.py View on Github external
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)
github astanin / python-tabulate / test / test_regression.py View on Github external
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)
github vacancy / SceneGraphParser / sng_parser / utils.py View on Github external
[
                entities[rel['subject']]['head'].lower(),
                rel['relation'].lower(),
                entities[rel['object']]['head'].lower()
            ]
            for rel in graph['relations']
        ]
        _print(tabulate.tabulate(relations_data, headers=['Subject', 'Relation', 'Object'], tablefmt=_tabulate_format))


_tabulate_format = tabulate.TableFormat(
        lineabove=tabulate.Line("+", "-", "+", "+"),
        linebelowheader=tabulate.Line("|", "-", "+", "|"),
        linebetweenrows=None,
        linebelow=tabulate.Line("+", "-", "+", "+"),
        headerrow=tabulate.DataRow("|", "|", "|"),
        datarow=tabulate.DataRow("|", "|", "|"),
        padding=1, with_header_hide=None
)
github vacancy / SceneGraphParser / sng_parser / utils.py View on Github external
entities[rel['subject']]['head'].lower(),
                rel['relation'].lower(),
                entities[rel['object']]['head'].lower()
            ]
            for rel in graph['relations']
        ]
        _print(tabulate.tabulate(relations_data, headers=['Subject', 'Relation', 'Object'], tablefmt=_tabulate_format))


_tabulate_format = tabulate.TableFormat(
        lineabove=tabulate.Line("+", "-", "+", "+"),
        linebelowheader=tabulate.Line("|", "-", "+", "|"),
        linebetweenrows=None,
        linebelow=tabulate.Line("+", "-", "+", "+"),
        headerrow=tabulate.DataRow("|", "|", "|"),
        datarow=tabulate.DataRow("|", "|", "|"),
        padding=1, with_header_hide=None
)
github dbcli / cli_helpers / cli_helpers / tabular_output / tabulate_adapter.py View on Github external
def addColorInElt(elt):
                if not elt:
                    return elt
                if elt.__class__ == tabulate.Line:
                    return tabulate.Line(*(style_field(table_separator_token, val) for val in elt))
                if elt.__class__ == tabulate.DataRow:
                    return tabulate.DataRow(*(style_field(table_separator_token, val) for val in elt))
                return elt
github criteo / biggraphite / biggraphite / cli / command_stats.py View on Github external
import tabulate
from six.moves.configparser import ConfigParser

from biggraphite.cli import command

# Hack to add some more formats.
# TODO: Add Graphite support.
# TODO: Remove padding.
tabulate._table_formats["csv"] = tabulate.TableFormat(
    lineabove=None,
    linebelowheader=None,
    linebetweenrows=None,
    linebelow=None,
    headerrow=tabulate.DataRow("", ";", ""),
    datarow=tabulate.DataRow("", ";", ""),
    padding=0,
    with_header_hide=None,
)

tabulate.tabulate_formats = list(sorted(tabulate._table_formats.keys()))


class Namespaces(object):
    r"""Helper for namespaces.

    The config file would look like:
    ```
    [carbon-relay]
    pattern = carbon\.relay\.*

    [carbon-cache]
github criteo / biggraphite / biggraphite / cli / command_stats.py View on Github external
import logging

import tabulate
from six.moves.configparser import ConfigParser

from biggraphite.cli import command

# Hack to add some more formats.
# TODO: Add Graphite support.
# TODO: Remove padding.
tabulate._table_formats["csv"] = tabulate.TableFormat(
    lineabove=None,
    linebelowheader=None,
    linebetweenrows=None,
    linebelow=None,
    headerrow=tabulate.DataRow("", ";", ""),
    datarow=tabulate.DataRow("", ";", ""),
    padding=0,
    with_header_hide=None,
)

tabulate.tabulate_formats = list(sorted(tabulate._table_formats.keys()))


class Namespaces(object):
    r"""Helper for namespaces.

    The config file would look like:
    ```
    [carbon-relay]
    pattern = carbon\.relay\.*
github IncOQ / incoq / experiments / view_stats.py View on Github external
def _latex_row(cell_values, colwidths, colaligns):
        """Version of tabulate._latex_row() that dispatches to a local
        hook instead of tabulate()._build_simple_row().
        """
        def escape_char(c):
            return my_escape_rules.get(c, c)
        escaped_values = ["".join(map(escape_char, cell))
                          for cell in cell_values]
        rowfmt = DataRow("", "&", "\\\\")
        return rowfunc(escaped_values, rowfmt)