Exemple #1
0
 def test18_get_names(self):
     self.assertEqual('hello.txt.old' in vfs.get_names('tests'), True)
     # Remove temporary file
     vfs.remove('tests/hello.txt.old')
Exemple #2
0
def packages_infos(module_name=None):
    # find the site-packages absolute path
    sites = set([])
    for dir in python_path:
        if 'site-packages' in dir:
            dir = dir.split(sep)
            sites.add(sep.join(dir[:dir.index('site-packages') + 1]))

    packages = {}
    recorded_packages = []
    name_mask = set()
    version_mask = set()
    module_mask = set()

    def add_package(site, package):
        if site in packages:
            packages[site].append(package)
        else:
            packages[site] = [package]

    for site in sites:
        for db_name, db_version, db_module in PACKAGES_DB:
            db_version = db_version.replace('*', '')
            for egg_info in vfs.get_names(site):
                egg_split = egg_info[:-len('.egg-info')].split('-')
                egg_name = egg_split[0]
                if egg_name != db_name:
                    continue
                egg_version = egg_split[1]
                if not egg_version.startswith(db_version):
                    continue
                data = get_egginfo(join(site, egg_info))
                if module_name and module_name != data['name']:
                    continue
                data['module'] = db_module
                add_package(site, (data['name'], data, 'E'))
                recorded_packages.append(data['name'])
                name_mask.add(db_name)
                version_mask.add(egg_version)
                module_mask.add(db_module)
                break

    setupconf_packages = []
    egginfo_packages = []
    default_package = []
    # XXX todo: understand .egg -maybe by using setuptools-
    #egg_packages = []

    for site in sites:
        for package in vfs.get_names(site):
            if package in module_mask:
                continue

            if (package.endswith('.egg-info')):
                pkg_split = package.split('-')
                if pkg_split[0] in name_mask:
                    continue
                if pkg_split[1] in version_mask:
                    continue
                # Why the first?
                data = get_egginfo(join(site, package))
                if (data['name'] in recorded_packages
                        or (module_name and data['name'] != module_name)):
                    continue
                add_package(site, (data['name'], data, 'E'))
                recorded_packages.append(data['name'])
                continue
            elif module_name and module_name != package:
                continue

            data = get_setupconf(join(site, package))
            if data and data['name'] not in recorded_packages:
                add_package(site, (data['name'], data, 'S'))
                recorded_packages.append(data['name'])
                continue

            data = get_minpackage(join(site, package))
            if data and data['name'] not in recorded_packages:
                add_package(site, (data['name'], data, 'M'))
                recorded_packages.append(data['name'])
                continue

    for site in packages:
        packages[site].sort(cmp=lambda a, b: cmp(a.upper(), b.upper()),
                            key=itemgetter(0))
        yield (site, packages[site])
Exemple #3
0
def packages_infos(module_name=None):
    # find the site-packages absolute path
    sites = set([])
    for dir in python_path:
        if 'site-packages' in dir:
            dir = dir.split(sep)
            sites.add(sep.join(dir[:dir.index('site-packages')+1]))

    packages = {}
    recorded_packages = []
    name_mask = set()
    version_mask = set()
    module_mask = set()

    def add_package(site, package):
        if site in packages:
            packages[site].append(package)
        else:
            packages[site] = [package]

    for site in sites:
        for db_name, db_version, db_module in PACKAGES_DB:
            db_version = db_version.replace('*', '')
            for egg_info in vfs.get_names(site):
                egg_split = egg_info[:-len('.egg-info')].split('-')
                egg_name = egg_split[0]
                if egg_name != db_name:
                    continue
                egg_version = egg_split[1]
                if not egg_version.startswith(db_version):
                    continue
                data = get_egginfo(join(site, egg_info))
                if module_name and module_name != data['name']:
                    continue
                data['module'] = db_module
                add_package(site, (data['name'], data, 'E'))
                recorded_packages.append(data['name'])
                name_mask.add(db_name)
                version_mask.add(egg_version)
                module_mask.add(db_module)
                break

    setupconf_packages = []
    egginfo_packages = []
    default_package = []
    # XXX todo: understand .egg -maybe by using setuptools-
    #egg_packages = []

    for site in sites:
        for package in vfs.get_names(site):
            if package in module_mask:
                continue

            if (package.endswith('.egg-info')):
                pkg_split = package.split('-')
                if pkg_split[0] in name_mask:
                    continue
                if pkg_split[1] in version_mask:
                    continue
                # Why the first?
                data = get_egginfo(join(site, package))
                if (data['name'] in recorded_packages or
                   (module_name and data['name'] != module_name)):
                    continue
                add_package(site, (data['name'], data, 'E'))
                recorded_packages.append(data['name'])
                continue
            elif module_name and module_name != package:
                continue

            data = get_setupconf(join(site, package))
            if data and data['name'] not in recorded_packages:
                add_package(site, (data['name'], data, 'S'))
                recorded_packages.append(data['name'])
                continue

            data = get_minpackage(join(site, package))
            if data and data['name'] not in recorded_packages:
                add_package(site, (data['name'], data, 'M'))
                recorded_packages.append(data['name'])
                continue


    for site in packages:
        packages[site].sort(cmp=lambda a, b: cmp(a.upper(),b.upper()),
                      key=itemgetter(0))
        yield (site, packages[site])
Exemple #4
0
 def test18_get_names(self):
     self.assertEqual('hello.txt.old' in vfs.get_names('tests'), True)
     # Remove temporary file
     vfs.remove('tests/hello.txt.old')
Exemple #5
0
def packages_infos(module_name=None):
    # find the site-packages absolute path
    sites = set([])
    for dir in python_path:
        if "site-packages" in dir:
            dir = dir.split(sep)
            sites.add(sep.join(dir[: dir.index("site-packages") + 1]))

    packages = {}
    recorded_packages = []
    name_mask = set()
    version_mask = set()
    module_mask = set()

    def add_package(site, package):
        if site in packages:
            packages[site].append(package)
        else:
            packages[site] = [package]

    for site in sites:
        for db_name, db_version, db_module in PACKAGES_DB:
            db_version = db_version.replace("*", "")
            for egg_info in vfs.get_names(site):
                egg_split = egg_info[: -len(".egg-info")].split("-")
                egg_name = egg_split[0]
                if egg_name != db_name:
                    continue
                egg_version = egg_split[1]
                if not egg_version.startswith(db_version):
                    continue
                data = get_egginfo(join(site, egg_info))
                if module_name and module_name != data["name"]:
                    continue
                data["module"] = db_module
                add_package(site, (data["name"], data, "E"))
                recorded_packages.append(data["name"])
                name_mask.add(db_name)
                version_mask.add(egg_version)
                module_mask.add(db_module)
                break

    # TODO understand .egg -maybe by using setuptools-
    for site in sites:
        for package in vfs.get_names(site):
            if package in module_mask:
                continue

            if package.endswith(".egg-info"):
                pkg_split = package.split("-")
                if pkg_split[0] in name_mask:
                    continue
                if pkg_split[1] in version_mask:
                    continue
                # Why the first?
                data = get_egginfo(join(site, package))
                if data["name"] in recorded_packages or (module_name and data["name"] != module_name):
                    continue
                add_package(site, (data["name"], data, "E"))
                recorded_packages.append(data["name"])
                continue
            elif module_name and module_name != package:
                continue

            data = get_setupconf(join(site, package))
            if data and data["name"] not in recorded_packages:
                add_package(site, (data["name"], data, "S"))
                recorded_packages.append(data["name"])
                continue

            data = get_minpackage(join(site, package))
            if data and data["name"] not in recorded_packages:
                add_package(site, (data["name"], data, "M"))
                recorded_packages.append(data["name"])
                continue

    for site in packages:
        packages[site].sort(cmp=lambda a, b: cmp(a.upper(), b.upper()), key=itemgetter(0))
        yield (site, packages[site])