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