def test_bool_table_repr():
    """All bools get replaced by their repr."""
    table_data = [["foo", True, False], ["bar", False, True]]
    expected = [["foo", "*", "/"], ["bar", "/", "*"]]

    for row, expected_row in zip(bool_table_repr(table_data), expected):
        assert list(row) == expected_row
def data_io_plugin_table() -> str:
    """Return registered data io plugins and which functions they support as markdown table.

    This is especially useful when you work with new plugins.

    Returns
    -------
    str
        Markdown table of data io plugins.
    """
    table_data = methods_differ_from_baseclass_table(
        DATA_IO_METHODS, known_data_formats(), get_data_io, DataIoInterface
    )
    headers = tuple(map(lambda x: f"__{x}__", ["Plugin", *DATA_IO_METHODS]))
    return tabulate(
        bool_table_repr(table_data), tablefmt="github", headers=headers, stralign="center"
    )
Exemple #3
0
def project_io_plugin_table(
    *, plugin_names: bool = False, full_names: bool = False
) -> MarkdownStr:
    """Return registered project io plugins and which functions they support as markdown table.

    This is especially useful when you work with new plugins.

    Parameters
    ----------
    plugin_names : bool
        Whether or not to add the names of the plugins to the table.
    full_names : bool
        Whether to display the full names the plugins are
        registered under as well.

    Returns
    -------
    MarkdownStr
        Markdown table of project io plugins.
    """
    table_data = methods_differ_from_baseclass_table(
        PROJECT_IO_METHODS,
        known_project_formats(full_names=full_names),
        get_project_io,
        ProjectIoInterface,
        plugin_names=plugin_names,
    )
    header_values = ["Format name", *PROJECT_IO_METHODS]
    if plugin_names:
        header_values.append("Plugin name")
    headers = tuple(map(lambda x: f"__{x}__", header_values))
    return MarkdownStr(
        tabulate(
            bool_table_repr(table_data), tablefmt="github", headers=headers, stralign="center"
        )
    )