How to use the entrypoints.reader.CaseSensitiveConfigParser 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 / reader.py View on Github external
continue  # In a subdirectory

            distro_name_version = z.filename.split('/')[0].rsplit('.', 1)[0]
            if '-' in distro_name_version:
                name, version = distro_name_version.split('-', 1)
            else:
                log.warning("Can't get name & version from %s %s", path, z.filename)
                name, version = None, None

            distro = {
                'name': name, 'version': version,
                'entrypoints': []
            }
            distributions.append(distro)

            cp = CaseSensitiveConfigParser()
            ep_path = osp.join(path, z.filename)
            with z.open(info) as f:
                fu = io.TextIOWrapper(f)
                cp.read_file(fu, source=osp.join(path, z.filename))
            distro['entrypoints'] = entrypoints_from_configparser(cp, ep_path)

        distributions.sort(key=lambda d: "%s-%s" % (d['name'], d['version']))

        if NO_CACHE_MARKER_FILE in z.namelist():
            self.non_cacheable_paths.add(path)

        return {
            'mtime': path_st.st_mtime,
            'isdir': True,
            'distributions': distributions,
        }
github takluyver / entrypoints / entrypoints / reader.py View on Github external
"""
        path_st = os.stat(path)
        isdir = stat.S_ISDIR(path_st.st_mode)
        egg_name = osp.basename(path)
        if '-' in egg_name:
            name, version = egg_name.split('-')[:2]
        else:
            log.warning("Can't get name & version from %s", path)
            name = version = None

        entrypoints = []

        if isdir:
            ep_path = osp.join(path, 'EGG-INFO', 'entry_points.txt')
            if osp.isfile(ep_path):
                cp = CaseSensitiveConfigParser()
                cp.read(ep_path)
                entrypoints = entrypoints_from_configparser(cp, ep_path)

        elif zipfile.is_zipfile(path):
            z = zipfile.ZipFile(path)
            try:
                info = z.getinfo('EGG-INFO/entry_points.txt')
            except KeyError:
                return None
            cp = CaseSensitiveConfigParser()
            ep_path = osp.join(path, 'EGG-INFO', 'entry_points.txt')
            with z.open(info) as f:
                fu = io.TextIOWrapper(f)
                cp.read_file(fu, source=ep_path)
                entrypoints = entrypoints_from_configparser(cp, ep_path)
github takluyver / entrypoints / entrypoints / reader.py View on Github external
):
            info_dir = osp.dirname(ep_path)
            distro_name_version = osp.splitext(osp.basename(info_dir))[0]
            if '-' in distro_name_version:
                name, version = distro_name_version.split('-', 1)
            else:
                log.warning("Can't get name & version from %s", info_dir)
                name = version = None

            distro = {
                'name': name, 'version': version,
                'entrypoints': []
            }
            distributions.append(distro)

            cp = CaseSensitiveConfigParser()
            cp.read(ep_path)
            distro['entrypoints'] = entrypoints_from_configparser(cp, ep_path)

        distributions.sort(key=lambda d: "%s-%s" % (d['name'], d['version']))

        if os.path.isfile(os.path.join(path, NO_CACHE_MARKER_FILE)):
            self.non_cacheable_paths.add(path)

        return {
            'mtime': path_st.st_mtime,
            'isdir': True,
            'distributions': distributions,
        }
github takluyver / entrypoints / entrypoints / reader.py View on Github external
entrypoints = []

        if isdir:
            ep_path = osp.join(path, 'EGG-INFO', 'entry_points.txt')
            if osp.isfile(ep_path):
                cp = CaseSensitiveConfigParser()
                cp.read(ep_path)
                entrypoints = entrypoints_from_configparser(cp, ep_path)

        elif zipfile.is_zipfile(path):
            z = zipfile.ZipFile(path)
            try:
                info = z.getinfo('EGG-INFO/entry_points.txt')
            except KeyError:
                return None
            cp = CaseSensitiveConfigParser()
            ep_path = osp.join(path, 'EGG-INFO', 'entry_points.txt')
            with z.open(info) as f:
                fu = io.TextIOWrapper(f)
                cp.read_file(fu, source=ep_path)
                entrypoints = entrypoints_from_configparser(cp, ep_path)

        return {
            'mtime': path_st.st_mtime,
            'isdir': isdir,
            'distributions': [{
                'name': name,
                'version': version,
                'entrypoints': entrypoints
            }],