How to use the entrypoints.NoSuchEntryPoint 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_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 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 takluyver / entrypoints / entrypoints.py View on Github external
def get_single(group, name, path=None):
    """Find a single entry point.

    Returns an :class:`EntryPoint` object, or raises :exc:`NoSuchEntryPoint`
    if no match is found.
    """
    for config, distro in iter_files_distros(path=path):
        if (group in config) and (name in config[group]):
            epstr = config[group][name]
            with BadEntryPoint.err_to_warnings():
                return EntryPoint.from_string(epstr, name, distro)

    raise NoSuchEntryPoint(group, name)