How to use the tabulate._table_formats 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 EI-CoreBioinformatics / mikado / Mikado / subprograms / util / class_codes.py View on Github external
else:
        codes = [class_codes.codes[_] for _ in class_codes.codes]

    for code in codes:
        definition = textwrap.wrap(code.definition, 30)
        code_rows = zip_longest([code.code],
                                definition,
                                [code.ref_multi],
                                [code.pred_multi],
                                [code.nucl],
                                [code.junc],
                                [code.reverse],
                                code.category.split())
        rows.extend(code_rows)

    __table_format = tabulate._table_formats[args.format]

    if args.format not in ("grid", "fancy_grid"):

        print(tabulate.tabulate(rows,
                                headers=["Class code",
                                         "Definition",
                                         "Reference multiexonic?",
                                         "Prediction multiexonic?",
                                         "Nucleotide: RC, PC, F1",
                                         "Junction: RC, PC, F1",
                                         "Reverse",
                                         "Category"],
                                tablefmt=args.format))

    else:
        out_of_header = False
github criteo / biggraphite / biggraphite / cli / command_stats.py View on Github external
import collections
import re
import time
import socket
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.
github EI-CoreBioinformatics / mikado / Mikado / subprograms / util / metrics.py View on Github external
rtype = getattr(getattr(Transcript, metric), "rtype", "str")

        if metric == "external_scores":
            usable_raw = True
            rtype = "Namespace"
            category = "External"

        if docstring is None:
            docstring = ''
        else:
            docstring = textwrap.wrap(docstring, 57)

        met_rows = zip_longest([metric], docstring, [category], [rtype], [str(usable_raw)])
        rows.extend(met_rows)

    __table_format = tabulate._table_formats[args.format]

    # TableFormat(lineabove=Line("+", "-", "+", "+"),
    #             linebelowheader=Line("+", "=", "+", "+"),
    #             linebetweenrows=Line("+", "-", "+", "+"),
    #             linebelow=Line("+", "-", "+", "+"),
    #             headerrow=DataRow("|", "|", "|"),
    #             datarow=DataRow("|", "|", "|"),
    #             padding=1, with_header_hide=None),
    # Line = namedtuple("Line", ["begin", "hline", "sep", "end"])
    #
    # DataRow = namedtuple("DataRow", ["begin", "sep", "end"])

    if args.format not in ("grid", "fancy_grid"):

        print(tabulate.tabulate(rows,
                                headers=["Metric name", "Description", "Category", "Data type", "Usable raw"],
github dbcli / cli_helpers / cli_helpers / tabular_output / tabulate_adapter.py View on Github external
def style_field(token, field):
                """Get the styled text for a *field* using *token* type."""
                s = StringIO()
                formatter.format(((token, field),), s)
                return s.getvalue()

            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

            srcfmt = tabulate._table_formats[format_name]
            newfmt = tabulate.TableFormat(
                *(addColorInElt(val) for val in srcfmt))
            tabulate._table_formats[format_name] = newfmt

        return iter(data), headers
    return style_output