How to use the pytablewriter.TableWriterFactory.create_from_format_name 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_writer_factory.py View on Github external
def test_exception(self, format_name, expected):
        with pytest.raises(expected):
            ptw.TableWriterFactory.create_from_format_name(format_name)
github thombashi / pytablewriter / test / writer / text / test_multibyte.py View on Github external
def test_smoke_multi_byte(self, capsys, format_name):
        writer = ptw.TableWriterFactory.create_from_format_name(format_name)
        writer.table_name = "生成に関するパターン"
        writer.headers = ["パターン名", "概要", "GoF", "Code Complete[1]"]
        writer.value_matrix = [
            ["Abstract Factory", "関連する一連のインスタンスを状況に応じて、適切に生成する方法を提供する。", "Yes", "Yes"],
            ["Builder", "複合化されたインスタンスの生成過程を隠蔽する。", "Yes", "No"],
            ["Factory Method", "実際に生成されるインスタンスに依存しない、インスタンスの生成方法を提供する。", "Yes", "Yes"],
            ["Prototype", "同様のインスタンスを生成するために、原型のインスタンスを複製する。", "Yes", "No"],
            ["Singleton", "あるクラスについて、インスタンスが単一であることを保証する。", "Yes", "Yes"],
        ]

        writer.write_table()

        out, _err = capsys.readouterr()

        assert len(out) > 100
github thombashi / pytablewriter / test / test_writer_factory.py View on Github external
def test_normal(self, format_name, expected):
        writer = ptw.TableWriterFactory.create_from_format_name(format_name)

        assert isinstance(writer, expected)
github thombashi / pytablereader / examples / load_table_from_url.py View on Github external
#!/usr/bin/env python3

import pytablewriter as ptw

import pytablereader as ptr


loader = ptr.TableUrlLoader(
    "https://en.wikipedia.org/wiki/List_of_unit_testing_frameworks",
    "html")

writer = ptw.TableWriterFactory.create_from_format_name("rst")
writer.stream = open("load_url_result.rst", "w", encoding=loader.encoding)
for table_data in loader.load():
    writer.from_tabledata(table_data)
    writer.write_table()