How to use the entrypoints.get_group_named 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_case_sensitive(tmpdir):
    group = entrypoints.get_group_named('test.case_sensitive', sample_path)
    assert set(group.keys()) == {'Ptangle', 'ptangle'}
github pypa / virtualenv / src / virtualenv / run.py View on Github external
def _collect_seeders():
    seeder_types = {e.name: e.load() for e in get_group_named("virtualenv.seed").values()}
    return seeder_types
github pypa / virtualenv / src / virtualenv / run.py View on Github external
def _collect_creators(interpreter):
    all_creators = {e.name: e.load() for e in get_group_named("virtualenv.create").values()}
    creators = {k: v for k, v in all_creators.items() if v.supports(interpreter)}
    return creators
github bluesky / databroker / databroker / discovery.py View on Github external
def _load(self):
        catalogs = entrypoints.get_group_named(self._entrypoints_group,
                                               path=self._paths)
        self.name = self.name or 'EntrypointsCatalog'
        self.description = (self.description
                            or f'EntrypointsCatalog of {len(catalogs)} catalogs.')
        for name, entrypoint in catalogs.items():
            try:
                self._entries[name] = EntrypointEntry(entrypoint)
            except Exception as e:
                warnings.warn(f"Failed to load {name}, {entrypoint}, {e!r}.")
github pypa / virtualenv / src / virtualenv / run.py View on Github external
def _collect_discovery_types():
    discover_types = {e.name: e.load() for e in get_group_named("virtualenv.discovery").values()}
    return discover_types
github bluesky / databroker / databroker / core.py View on Github external
Parameters
    ----------
    entrypoint_group_name: str
        Default is 'databroker.handlers', the "official" databroker entrypoint
        for handlers.
    skip_failures: boolean
        True by default. Errors loading a handler class are converted to
        warnings if this is True.

    Returns
    -------
    handler_registry: dict
        A suitable default handler registry
    """
    group = entrypoints.get_group_named(entrypoint_group_name)
    group_all = entrypoints.get_group_all(entrypoint_group_name)
    if len(group_all) != len(group):
        # There are some name collisions. Let's go digging for them.
        for name, matches in itertools.groupby(group_all, lambda ep: ep.name):
            matches = list(matches)
            if len(matches) != 1:
                winner = group[name]
                warnings.warn(
                    f"There are {len(matches)} entrypoints for the "
                    f"databroker handler spec {name!r}. "
                    f"They are {matches}. The match {winner} has won the race.")
    handler_registry = {}
    for name, entrypoint in group.items():
        try:
            handler_class = entrypoint.load()
        except Exception as exc: