How to use the entrypoints.get_single function in entrypoints

To help you get started, we’ve selected a few entrypoints 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 takluyver / entrypoints / tests / test_entrypoints.py View on Github external
def test_bad(temp_cache_file):
    bad_path = [osp.join(samples_dir, 'packages3')]

    group = entrypoints.get_group_named('entrypoints.test1', bad_path)

    assert 'bad' not in group

    with pytest.raises(entrypoints.NoSuchEntryPoint):
        ep = entrypoints.get_single('entrypoints.test1', 'bad', bad_path)
github takluyver / entrypoints / tests / test_entrypoints.py View on Github external
def test_missing(temp_cache_file):
    with pytest.raises(entrypoints.NoSuchEntryPoint) as ec:
        entrypoints.get_single('no.such.group', 'no_such_name', sample_path)

    assert ec.value.group == 'no.such.group'
    assert ec.value.name == 'no_such_name'
github takluyver / entrypoints / tests / test_entrypoints.py View on Github external
def test_dot_prefix(temp_cache_file):
    ep = entrypoints.get_single('blogtool.parsers', '.rst', sample_path)
    assert ep.object_name == 'SomeClass.some_classmethod'
    assert ep.extras == ['reST']

    group = entrypoints.get_group_named('blogtool.parsers', sample_path)
    assert set(group.keys()) == {'.rst'}
github takluyver / entrypoints / tests / test_entrypoints.py View on Github external
def test_get_single(temp_cache_file):
    ep = entrypoints.get_single('entrypoints.test1', 'abc', sample_path)
    assert ep.module_name == 'foo'
    assert ep.object_name == 'abc'

    ep2 = entrypoints.get_single('entrypoints.test1', 'njn', sample_path)
    assert ep2.module_name == 'qux.extn'
    assert ep2.object_name == 'Njn.load'
github cuthbertLab / music21 / music21 / ext / nbconvert / exporters / script.py View on Github external
def _get_language_exporter(self, lang_name):
        """Find an exporter for the language name from notebook metadata.

        Uses the nbconvert.exporters.script group of entry points.
        Returns None if no exporter is found.
        """
        if lang_name not in self._lang_exporters:
            try:
                Exporter = entrypoints.get_single(
                    'nbconvert.exporters.script', lang_name).load()
            except entrypoints.NoSuchEntryPoint:
                self._lang_exporters[lang_name] = None
            else:
                self._lang_exporters[lang_name] = Exporter(parent=self)
        return self._lang_exporters[lang_name]
github altair-viz / altair / altair / utils / plugin_registry.py View on Github external
def _enable(self, name: str, **options) -> None:
        if name not in self._plugins:
            try:
                ep = entrypoints.get_single(self.entry_point_group, name)
            except entrypoints.NoSuchEntryPoint:
                if name in self.entrypoint_err_messages:
                    raise ValueError(self.entrypoint_err_messages[name])
                else:
                    raise
            value = cast(PluginType, ep.load())
            self.register(name, value)
        self._active_name = name
        self._active = self._plugins[name]
        for key in set(options.keys()) & set(self._global_settings.keys()):
            self._global_settings[key] = options.pop(key)
        self._options = options
github Kintyre / ksconf / ksconf / commands / __init__.py View on Github external
def _get_entrypoints_lib(group, name=None):
    import entrypoints

    # Monkey patch some attributes for better API compatibility
    entrypoints.EntryPoint.dist = property(lambda self: self.distro)

    if name:
        return entrypoints.get_single(group, name)
    else:
        from collections import OrderedDict
        # Copied from 'get_group_named()' except that it preserves order
        result = OrderedDict()
        for ep in entrypoints.get_group_all(group):
            if ep.name not in result:
                result[ep.name] = ep
        return result