How to use the pytablewriter.style.Style function in pytablewriter

To help you get started, we’ve selected a few pytablewriter 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 thombashi / pytablewriter / test / test_style.py View on Github external
            [Style(align=Align.RIGHT), Style(align=Align.RIGHT, font_size=FontSize.TINY), False],
            [Style(font_size=FontSize.TINY), Style(font_size=FontSize.TINY), True],
            [Style(font_size=FontSize.TINY), Style(font_size="tiny"), True],
            [Style(font_size=FontSize.TINY), Style(font_size=FontSize.LARGE), False],
            [Style(font_weight="bold"), Style(font_weight=FontWeight.BOLD), True],
            [Style(font_weight="bold"), Style(font_weight="normal"), False],
            [Style(font_style="italic"), Style(font_style=FontStyle.ITALIC), True],
            [Style(font_style="italic"), Style(font_style="normal"), False],
            [Style(thousand_separator=","), Style(thousand_separator=","), True],
            [Style(thousand_separator=","), Style(thousand_separator="comma"), True],
            [Style(thousand_separator=""), Style(thousand_separator=","), False],
            [
                Style(thousand_separator=ThousandSeparator.COMMA),
                Style(thousand_separator=ThousandSeparator.COMMA),
                True,
            ],
            [
github thombashi / pytablewriter / test / writer / text / test_markdown_writer.py View on Github external
)
        expected = dedent(
            """\
            # set style method
            |normal|style by idx|style by header|
            |-----:|-----------:|:-------------:|
            |    11|      **11**|    **11**     |
            |123456| **123,456**|  **123 456**  |
            """
        )
        output = writer.dumps()
        print_test_result(expected=expected, actual=output)
        assert output == expected

        writer.table_name = "change style"
        writer.set_style(1, Style(align="right", font_style="italic"))
        writer.set_style("style by header", Style())
        expected = dedent(
            """\
            # change style
            |normal|style by idx|style by header|
            |-----:|-----------:|--------------:|
            |    11|        _11_|             11|
            |123456|    _123456_|         123456|
            """
        )
        output = writer.dumps()
        print_test_result(expected=expected, actual=output)
        assert output == expected
github thombashi / pytablewriter / test / writer / text / test_markdown_writer.py View on Github external
expected = dedent(
            """\
            # auto align
            |left|   right   |   center   |auto|auto|   None    |
            |---:|-----------|------------|---:|----|-----------|
            |   0|r          |center align|   0|a   |n          |
            |  11|right align|bb          |  11|auto|none (auto)|
            """
        )
        out = writer.dumps()
        print_test_result(expected=expected, actual=out)
        assert out == expected

        writer.table_name = "specify alignment for each column manually"
        writer.styles = [
            Style(align=Align.LEFT),
            Style(align=Align.RIGHT),
            Style(align=Align.CENTER),
            Style(align=Align.AUTO),
            Style(align=Align.AUTO),
            None,
        ]
        expected = dedent(
            """\
            # specify alignment for each column manually
            |left|   right   |   center   |auto|auto|   None    |
            |----|----------:|:----------:|---:|----|-----------|
            |0   |          r|center align|   0|a   |n          |
            |11  |right align|     bb     |  11|auto|none (auto)|
            """
        )
        out = writer.dumps()
github thombashi / pytablewriter / test / writer / text / test_latex_matrix_writer.py View on Github external
writer.styles = styles

        expected = r"""\begin{equation}
    style test = \left( \begin{array}{rrrrrrlrrr}
         111 &   111 & \tiny 111 & \small 111 &  \normalsize 111 &  \large 111 &              & \large \bf 111 & \small \it 111 & \large \bf \it 111 \\
        1234 &  1234 & \tiny 1234 & \small 1234 & \normalsize 1,234 & \large 1 234 &              & \large \bf 1234 & \small \it 1234 & \large \bf \it 1234 \\
    \end{array} \right)
\end{equation}
"""
        out = writer.dumps()
        print_test_result(expected=expected, actual=out)
        assert out == expected

        writer.styles = [
            None,
            Style(align="auto"),
            Style(align="auto", font_size="tiny", thousand_separator=","),
            Style(align="left", font_size="small", thousand_separator=" "),
            Style(align="right", font_size="medium"),
            Style(align="center", font_size="large"),
            Style(font_size="large", font_weight="bold"),
        ]
        out = writer.dumps()
        expected = r"""\begin{equation}
    style test = \left( \begin{array}{rrrlrclrrr}
         111 &   111 &  \tiny 111 & \small 111  & \normalsize 111 & \large 111 &              &    111 &      111 &           111 \\
        1234 &  1234 & \tiny 1,234 & \small 1 234 & \normalsize 1234 & \large 1234 &              &   1234 &     1234 &          1234 \\
    \end{array} \right)
\end{equation}
"""
        print_test_result(expected=expected, actual=out)
        assert out == expected
github thombashi / pytablewriter / test / data.py View on Github external
"medium",
        "large",
        "null w/ bold",
        "L bold",
        "S italic",
        "L bold italic",
    ],
    [
        [111, 111, 111, 111, 111, 111, "", 111, 111, 111],
        [1234, 1234, 1234, 1234, 1234, 1234, "", 1234, 1234, 1234],
    ])
styles = [
    None,
    Style(),
    Style(font_size="TINY"),
    Style(font_size="SMALL"),
    Style(font_size="MEDIUM", thousand_separator=","),
    Style(font_size="LARGE", thousand_separator=" "),
    Style(font_weight="bold", thousand_separator=","),
    Style(font_size="LARGE", font_weight="bold"),
    Style(font_size="SMALL", font_style="italic"),
    Style(font_size="LARGE", font_weight="bold", font_style="italic"),
]
github thombashi / pytablewriter / test / test_style.py View on Github external
            [Style(font_weight="bold"), Style(font_weight="normal"), False],
            [Style(font_style="italic"), Style(font_style=FontStyle.ITALIC), True],
            [Style(font_style="italic"), Style(font_style="normal"), False],
            [Style(thousand_separator=","), Style(thousand_separator=","), True],
            [Style(thousand_separator=","), Style(thousand_separator="comma"), True],
            [Style(thousand_separator=""), Style(thousand_separator=","), False],
            [
                Style(thousand_separator=ThousandSeparator.COMMA),
                Style(thousand_separator=ThousandSeparator.COMMA),
                True,
            ],
            [
                Style(thousand_separator="space"),
                Style(thousand_separator=ThousandSeparator.SPACE),
                True,
            ],
            [
github thombashi / pytablewriter / test / test_style.py View on Github external
            [Style(font_style="italic"), Style(font_style="normal"), False],
            [Style(thousand_separator=","), Style(thousand_separator=","), True],
            [Style(thousand_separator=","), Style(thousand_separator="comma"), True],
            [Style(thousand_separator=""), Style(thousand_separator=","), False],
            [
                Style(thousand_separator=ThousandSeparator.COMMA),
                Style(thousand_separator=ThousandSeparator.COMMA),
                True,
            ],
            [
                Style(thousand_separator="space"),
                Style(thousand_separator=ThousandSeparator.SPACE),
                True,
            ],
            [
                Style(thousand_separator=ThousandSeparator.COMMA),
                Style(thousand_separator=ThousandSeparator.COMMA, font_size=FontSize.TINY),
github thombashi / pytablewriter / pytablewriter / writer / _table_writer.py View on Github external
def _preprocess_styler(self):
        if self._is_complete_styler_proprocess:
            return

        self._styler_list = []

        for col_dp in self._column_dp_list:
            style = self.__get_style(col_dp.column_index)

            if style is None:
                style = Style()

            self._styler_list.append(self._create_styler(style, self))

        self._is_complete_styler_proprocess = True
github albumentations-team / albumentations / benchmark / benchmark.py View on Github external
def print(self):
        writer = MarkdownTableWriter()
        writer.headers = self._make_headers()
        writer.value_matrix = self._make_value_matrix()
        writer.styles = [Style(align="left")] + [Style(align="center") for _ in range(len(writer.headers) - 1)]
        writer.write_table()
        print("\n" + self._make_versions_text())