How to use the entrypoints.EntryPoint.from_string 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_parse_bad():
    with pytest.raises(entrypoints.BadEntryPoint):
        entrypoints.EntryPoint.from_string("this won't work", 'foo')
github iotile / coretools / iotilecore / iotile / core / dev / registry.py View on Github external
extensions = json.load(infile)

        ComponentRegistry._frozen_extensions = {}
        for group in extensions:
            ComponentRegistry._frozen_extensions[group] = []

            for ext_info in extensions.get(group, []):
                name = ext_info['name']
                obj_path = ext_info['object']
                distro_info = ext_info['distribution']

                distro = None
                if distro_info is not None:
                    distro = entrypoints.Distribution(*distro_info)

                entry = entrypoints.EntryPoint.from_string(obj_path, name, distro=distro)
                ComponentRegistry._frozen_extensions[group].append(entry)
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)
github takluyver / entrypoints / entrypoints.py View on Github external
def get_group_all(group, path=None):
    """Find all entry points in a group.

    Returns a list of :class:`EntryPoint` objects.
    """
    result = []
    for config, distro in iter_files_distros(path=path):
        if group in config:
            for name, epstr in config[group].items():
                with BadEntryPoint.err_to_warnings():
                    result.append(EntryPoint.from_string(epstr, name, distro))

    return result