Example #1
0
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)
Example #2
0
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!).'
Example #3
0
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!).'
Example #4
0
 def test_manual_overrides(self):
     self.assertTrue(ciu.check(projects=["unittest2"]))
Example #5
0
 def test_ignore_missing_projects(self):
     self.assertTrue(ciu.check(projects=['sdfsjdfsdlfk;jasdflkjasdfdfsdf']))
Example #6
0
 def test_success(self):
     projects = [{'name': 'scipy'}, {'name': 'numpy'}, {'name': 'ipython'}]
     self.assertTrue(ciu.check(projects=projects))
Example #7
0
 def test_ignore_missing_projects(self):
     self.assertTrue(ciu.check(projects=['sdfsjdfsdlfk;jasdflkjasdfdfsdf']))
Example #8
0
 def test_metadata(self):
     self.assertFalse(ciu.check(metadata=[EXAMPLE_METADATA]))
Example #9
0
 def test_failure(self):
     self.assertFalse(ciu.check(projects=[py2_project]))
Example #10
0
 def test_case_insensitivity(self):
     self.assertFalse(ciu.check(projects=['PaStE']))
Example #11
0
 def test_failure(self):
     self.assertFalse(ciu.check(projects=['paste']))
Example #12
0
 def is_py3k_compatible(self):
     """Return whether the package is py3k compatible."""
     return caniusepython3.check(projects=[self.name])
Example #13
0
 def test_success(self):
     self.assertTrue(ciu.check(projects=["scipy", "numpy", "ipython"]))
Example #14
0
 def is_py3k_compatible(self):
     """Return whether the package is py3k compatible."""
     return caniusepython3.check(projects=[self.name])
Example #15
0
 def test_failure(self):
     self.assertFalse(ciu.check(projects=[{'name': py2_project}]))
Example #16
0
 def test_failure(self):
     self.assertFalse(ciu.check(projects=['paste']))
Example #17
0
 def test_case_insensitivity(self):
     self.assertFalse(ciu.check(projects=['PaStE']))
Example #18
0
 def test_success(self):
     self.assertTrue(ciu.check(projects=['scipy', 'numpy', 'ipython']))
Example #19
0
 def test_success(self):
     self.assertTrue(ciu.check(projects=['scipy', 'numpy', 'ipython']))
Example #20
0
 def test_failure(self):
     self.assertFalse(ciu.check(projects=[py2_project]))
Example #21
0
 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]))
Example #22
0
 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]))
Example #23
0
 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]))
Example #24
0
 def test_metadata(self):
     self.assertFalse(ciu.check(metadata=[EXAMPLE_METADATA]))
Example #25
0
 def test_manual_overrides(self):
     self.assertTrue(ciu.check(projects=["unittest2"]))
Example #26
0
 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]))