def get_py2_packages(packages, cache=None, overrides=None): """Get Python 2 only packages from package list :param packages: an iterable of packages :param cache: the cache dictionary to store package info """ # create a temporary cache that discards all info if cache is None: cache = {} session = requests.Session() for package in packages: name = package['name'] # check if overridden as Python 3 override_status = check_overrides(name, overrides=overrides) if override_status is None: # check if cached as Python 3 override_status = cache.get(name) if override_status is not None: # only yield Python 2 packages if len(override_status) == 3: github_user, github_name, url = override_status downloads = package['downloads'] package_with_github = { 'name': name, 'downloads': downloads, 'github_user': github_user, 'github_name': github_name, 'url': url, } yield (package_with_github, None) else: if caniusepython3.check(projects=[name]): cache[name] = () continue package_info = get_package_info(name, session) if is_python3_enabled(package_info): cache[name] = () continue logging.debug('%s is not Python 3 enabled.', name) yield (package, package_info)
def annotate_wheels(packages): print('Getting package data...') num_packages = len(packages) for index, package in enumerate(packages): print(index + 1, num_packages, package['name']) package['value'] = 1 if caniusepython3.check(projects=[package['name']]): package['py3support'] = True package['css_class'] = 'success' package['icon'] = u'\u2713' # Check mark package['title'] = 'This package supports Python 3 :)' else: package['py3support'] = False package['css_class'] = 'default' package['icon'] = u'\u2717' # Ballot X package['title'] = 'This package does not support Python 3 (yet!).'
def test_manual_overrides(self): self.assertTrue(ciu.check(projects=["unittest2"]))
def test_ignore_missing_projects(self): self.assertTrue(ciu.check(projects=['sdfsjdfsdlfk;jasdflkjasdfdfsdf']))
def test_success(self): projects = [{'name': 'scipy'}, {'name': 'numpy'}, {'name': 'ipython'}] self.assertTrue(ciu.check(projects=projects))
def test_metadata(self): self.assertFalse(ciu.check(metadata=[EXAMPLE_METADATA]))
def test_failure(self): self.assertFalse(ciu.check(projects=[py2_project]))
def test_case_insensitivity(self): self.assertFalse(ciu.check(projects=['PaStE']))
def test_failure(self): self.assertFalse(ciu.check(projects=['paste']))
def is_py3k_compatible(self): """Return whether the package is py3k compatible.""" return caniusepython3.check(projects=[self.name])
def test_success(self): self.assertTrue(ciu.check(projects=["scipy", "numpy", "ipython"]))
def test_failure(self): self.assertFalse(ciu.check(projects=[{'name': py2_project}]))
def test_success(self): self.assertTrue(ciu.check(projects=['scipy', 'numpy', 'ipython']))
def test_requirements(self): with tempfile.NamedTemporaryFile('w') as file: file.write(py2_project + '\n') file.flush() self.assertFalse(ciu.check(requirements_paths=[file.name]))
def test_requirements(self): with tempfile.NamedTemporaryFile('w') as file: file.write(py2_project+'\n') file.flush() self.assertFalse(ciu.check(requirements_paths=[file.name]))
def test_case_insensitivity(self): funky_name = (py2_project[:len(py2_project)].lower() + py2_project[len(py2_project):].upper()) self.assertFalse(ciu.check(projects=[funky_name]))