Exemplo n.º 1
0
def names() -> List[str]:
    """List the names of the available parsers

    Returns:
        Names of the available parsers
    """
    return plugins.names(package_name=__name__)
Exemplo n.º 2
0
def names() -> List[str]:
    """List the names of the available writers

    Returns:
        List of strings with the names of the available writers.
    """
    return plugins.names(package_name=__name__)
Exemplo n.º 3
0
def names():
    """List the names of the available parsers

    Returns:
        List: List of strings with the names of the available parsers
    """
    return plugins.names(package_name=__name__)
Exemplo n.º 4
0
def satellites():
    """Available satellites and where they are defined

    Returns:
        Dict: For each satellite, a tuple describing which satellite plug-in defines the satellite.
    """
    return {p.lower(): (s, p) for s in plugins.names(__name__) for p in plugins.parts(__name__, s)}
Exemplo n.º 5
0
def test_load_plugin_with_prefix():
    """Test that a plugin can be called using a prefix"""
    package_name = "midgard.parsers"
    plugin_name = [p for p in plugins.names(package_name) if "_" in p][0]
    prefix, _, plugin = plugin_name.partition("_")

    expected_name = plugin_name
    assert plugins.load(package_name, plugin, prefix=prefix) == expected_name
Exemplo n.º 6
0
def names():
    """List names of integrators for a given session

    The list of names will be sorted according to the sort_value of the integrator plugins (use `register_ordered` to
    define a sort value for an integrator).

    Returns:
        List:   Sorted list of names of integrators.
    """
    return plugins.names(package_name=__name__)
Exemplo n.º 7
0
def options():
    """List the command line options for starting the different pipelines

    Returns:
        Dict:  Command line options pointing to pipelines
    """
    options = dict()
    plugin_files = plugins.names(package_name=__name__)

    for pipeline in plugin_files:
        try:
            pipeline_options = plugins.call(package_name=__name__,
                                            plugin_name=pipeline,
                                            part="options")
        except mg_exceptions.UnknownPluginError:
            continue
        options.update({opt: pipeline for opt in pipeline_options})

    return options
Exemplo n.º 8
0
def test_call_existing_plugin(tmpfile):
    """Test that calling a parser-plugin works, and returns a Parser instance"""
    package_name = "midgard.parsers"
    plugin_name = plugins.names(package_name)[0]
    parser = plugins.call(package_name, plugin_name, file_path=tmpfile)
    assert isinstance(parser, Parser)
Exemplo n.º 9
0
def test_plugin_exists():
    """Test that an existing plugin returns True for exists()"""
    package_name = "midgard.parsers"
    plugin_name = plugins.names(package_name)[0]
    assert plugins.exists(package_name, plugin_name)
Exemplo n.º 10
0
def test_package_non_existing():
    """Test that a non-existent package raises an appropriate error"""
    with pytest.raises(exceptions.UnknownPackageError):
        plugins.names("midgard.non_existent")
Exemplo n.º 11
0
def test_package_empty():
    """Test that names() does not find any plugins in midgard.dev-package"""
    lib_plugins = plugins.names("midgard.dev")
    assert len(lib_plugins) == 0
Exemplo n.º 12
0
def test_package_not_empty(plugin_package):
    """Test that names() finds some plugins in package"""
    parsers = plugins.names(plugin_package)
    assert len(parsers) > 0
Exemplo n.º 13
0
def test_ordered_plugin(plugin_package):
    """Test that order of plugins can be customized"""
    plugin_names = plugins.names(plugin_package)
    assert plugin_names[0] == "plugin_first"
    assert plugin_names[-1] == "plugin_last"
Exemplo n.º 14
0
def names() -> List[str]:
    """Names of fieldtype plugins"""
    return plugins.names(__name__)