def to_html_table(rows, caption="", classes=[]): """Convert the given rows into an HTML table. The first entry in `rows` will be used as the table headers. """ headers = rows.pop(0) above = "<table{0}>".format( ' class="{0}"'.format(" ".join(classes) if classes else "")) if caption: above += "\n<caption>{0}</caption>\n".format(caption) return tabulate.tabulate( rows, headers, stralign=None, numalign=None, tablefmt=tabulate.TableFormat( lineabove=tabulate.Line(above, "", "", ""), linebelowheader="", linebetweenrows=None, linebelow=tabulate.Line("</tbody>\n</table>", "", "", ""), headerrow=partial(_html_row_with_attrs, "th"), datarow=partial(_html_row_with_attrs, "td"), padding=0, with_header_hide=None, ), )
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"
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
def _setup_tabulate(): """Customise tabulate.""" tabulate.PRESERVE_WHITESPACE = True tabulate.MIN_PADDING = 0 # Overwrite the 'presto' format to use the block-drawing vertical line. # pytype: disable=module-attr tabulate._table_formats["presto"] = tabulate.TableFormat( # pylint: disable=protected-access lineabove=None, linebelowheader=tabulate.Line("", "-", "+", ""), linebetweenrows=None, linebelow=None, headerrow=tabulate.DataRow("", "│", ""), datarow=tabulate.DataRow("", "│", ""), padding=1, with_header_hide=None)
"""Format adapter for the tabulate module.""" from __future__ import unicode_literals from cli_helpers.utils import filter_dict_by_key from cli_helpers.compat import (Terminal256Formatter, StringIO) from .preprocessors import (convert_to_string, truncate_string, override_missing_value, style_output, HAS_PYGMENTS, escape_newlines) import tabulate tabulate.MIN_PADDING = 0 tabulate._table_formats['psql_unicode'] = 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, ) tabulate._table_formats['double'] = tabulate.TableFormat( lineabove=tabulate.Line("╔", "═", "╦", "╗"), linebelowheader=tabulate.Line("╠", "═", "╬", "╣"), linebetweenrows=None, linebelow=tabulate.Line("╚", "═", "╩", "╝"), headerrow=tabulate.DataRow("║", "║", "║"),
e['head'].lower(), e['span'].lower(), ','.join([x['span'].lower() for x in e['modifiers']]) ] for e in graph['entities']] _print( tabulate.tabulate(entities_data, headers=['Head', 'Span', 'Modifiers'], tablefmt=_tabulate_format)) if show_relations: _print('Relations:') entities = graph['entities'] relations_data = [[ 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)
# Last Change: Thu Jul 29, 2021 at 02:35 AM +0200 import fileinput import tabulate as TAB from argparse import ArgumentParser, Action from functools import partial ######################### # Customize LaTeX table # ######################### # Disable LaTeX character escaping TAB._table_formats["latex_booktabs_raw"] = TAB.TableFormat( lineabove=partial(TAB._latex_line_begin_tabular, booktabs=True), linebelowheader=TAB.Line("\\midrule", "", "", ""), linebetweenrows=None, linebelow=TAB.Line("\\bottomrule\n\\end{tabular}", "", "", ""), headerrow=partial(TAB._latex_row, escrules={}), datarow=partial(TAB._latex_row, escrules={}), padding=1, with_header_hide=None, ) ################################ # Command line argument parser # ################################ class ColAlignmentAct(Action): def __call__(self, parser, namespace, value, option_string=None):
import json import tabulate from dockermake.lint.linter import DockerfileLint from dockermake.lint.rules.general import GeneralRules from dockermake.lint.rules.every_stage import EveryStageRules from dockermake.lint.rules.builder_stages import BuilderStagesRules from dockermake.lint.rules.last_stage import LastStageRules from dockermake.utils import display # Until now, tabulate (0.8.2) did not release github flavored table styles... as long as we are waiting, here is # the workaround # pylint: disable=protected-access tabulate._table_formats.update({ "github": tabulate.TableFormat(lineabove=tabulate.Line("|", "-", "|", "|"), linebelowheader=tabulate.Line("|", "-", "|", "|"), linebetweenrows=None, linebelow=None, headerrow=tabulate.DataRow("|", "|", "|"), datarow=tabulate.DataRow("|", "|", "|"), padding=1, with_header_hide=["lineabove"]), }) class SummaryPrinter: @staticmethod def print_tag_list(build_summary): display.info("") for build in build_summary:
"""Format adapter for the tabulate module.""" from __future__ import unicode_literals from cli_helpers.utils import filter_dict_by_key from cli_helpers.compat import (Terminal256Formatter, StringIO) from .preprocessors import (convert_to_string, truncate_string, override_missing_value, style_output, HAS_PYGMENTS, escape_newlines) import tabulate tabulate.MIN_PADDING = 0 tabulate._table_formats['double'] = 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, ) tabulate._table_formats["ascii"] = tabulate.TableFormat( lineabove=tabulate.Line("+", "-", "+", "+"), linebelowheader=tabulate.Line("+", "-", "+", "+"), linebetweenrows=None, linebelow=tabulate.Line("+", "-", "+", "+"), headerrow=tabulate.DataRow("|", "|", "|"),
with open(os.path.join('outputs', filename), "w") as fh: fh.write(output) if args.reports: network_table = json2html.convert( json=raw_vehicle, table_attributes= "id=\"info-table\" class=\"table table-condensed table-bordered table-hover\"" ) metadata_table = json2html.convert( json=vars(args), table_attributes= "id=\"info-table\" class=\"table table-condensed table-bordered table-hover\"" ) MyHTMLFormat = tabulate.TableFormat(lineabove=tabulate.Line( "<table class=\"table table-condensed table-bordered table-hover\">", "", "", ""), linebelowheader=None, linebetweenrows=None, linebelow=tabulate.Line( "</table>", "", "", ""), headerrow=partial( gophercannon_lib. my_html_row_with_attrs, "th"), datarow=partial( gophercannon_lib. my_html_row_with_attrs, "td"), padding=0, with_header_hide=None) transient_table = tabulate.tabulate(message_table, [ "Parameter", "TX Count", "Min Delay (us)", "Max Delay(us)",