How to use the entrypoints.Distribution 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 / entrypoints.py View on Github external
continue
                    distro_names_seen.add(distro.name)

                    cp = CaseSensitiveConfigParser(delimiters=('=',))
                    with zf.open(info) as f:
                        fu = io.TextIOWrapper(f)
                        cp.read_file(fu, source=osp.join(folder, info.filename))
                    yield cp, distro

        # Regular file imports (not egg, not zip file)
        for path in itertools.chain(
            glob.iglob(osp.join(folder, '*.dist-info', 'entry_points.txt')),
            glob.iglob(osp.join(folder, '*.egg-info', 'entry_points.txt'))
        ):
            distro_name_version = osp.splitext(osp.basename(osp.dirname(path)))[0]
            distro = Distribution.from_name_version(distro_name_version)

            if (repeated_distro == 'first') \
                    and (distro.name in distro_names_seen):
                continue
            distro_names_seen.add(distro.name)

            cp = CaseSensitiveConfigParser(delimiters=('=',))
            cp.read([path])
            yield cp, distro
github takluyver / entrypoints / hybrid_cache.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 distro, epinfo in iter_all_epinfo(path=path):
        if epinfo['group'] != group:
            continue
        distro_obj = Distribution(distro['name'], distro['version'])
        result.append(EntryPoint(
            epinfo['name'], epinfo['module_name'], epinfo['object_name'],
            distro=distro_obj
        ))
    return result
github iotile / coretools / iotilecore / iotile / core / dev / registry.py View on Github external
frozen_path = os.path.join(_registry_folder(), 'frozen_extensions.json')
        with open(frozen_path, "r") as infile:
            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)