def test_monkeypatch_data_io(): """DataIoInterface only added to registry while context is entered.""" with monkeypatch_plugin_registry_data_io( test_data_io={"test_dio": DummyDataIo(format_name="test")}): assert "test_dio" in known_data_formats() assert "test_mc" not in known_data_formats() with monkeypatch_plugin_registry( test_data_io={"test_full": DummyDataIo(format_name="test")}): assert "test_full" in known_data_formats() assert "test_full" not in known_data_formats()
def test_monkeypatch_plugin_registry_full(create_new_registry: bool): """Create a completely new registry.""" assert "decay" in known_megacomplex_names() assert "yml" in known_project_formats() assert "sdt" in known_data_formats() with monkeypatch_plugin_registry( test_megacomplex={"test_mc": DummyMegacomplex}, test_project_io={"test_pio": DummyProjectIo(format_name="test")}, test_data_io={"test_dio": DummyDataIo(format_name="test")}, create_new_registry=create_new_registry, ): assert "test_mc" in known_megacomplex_names() assert "test_pio" in known_project_formats() assert "test_dio" in known_data_formats() assert ("decay" not in known_megacomplex_names()) is create_new_registry assert ("yml" not in known_project_formats()) is create_new_registry assert ("sdt" not in known_data_formats()) is create_new_registry
def plugin_list_cmd(): """Prints a list of installed plugins.""" output = """ Installed Glotaran Plugins: Models: """ output += "\n" for name in known_model_names(): output += f" * {name}\n" output += "\nData file Formats\n\n" for reader_fmt in known_data_formats(): output += f" * .{reader_fmt}\n" output += "\nProject file Formats\n\n" for reader_fmt in known_project_formats(): output += f" * .{reader_fmt}\n" click.echo(output)
def test_known_data_formats(): """Known formats are the same as mocked register keys""" assert sorted(known_data_formats()) == sorted(["foo", "mock"])
import typing import click from glotaran.analysis.optimize import optimize from glotaran.cli.commands import util from glotaran.io import save_result from glotaran.plugin_system.data_io_registration import known_data_formats from glotaran.project.scheme import Scheme @click.option( "--dataformat", "-dfmt", default=None, type=click.Choice(known_data_formats()), help= "The input format of the data. Will be inferred from extension if not set.", ) @click.option( "--data", "-d", multiple=True, type=(str, click.Path(exists=True, dir_okay=False)), help="Path to a dataset in the form '--data DATASET_LABEL PATH_TO_DATA'", ) @click.option( "--out", "-o", default=None, type=click.Path(file_okay=False),