Exemplo n.º 1
0
def test_render_tree_exclude_reverse():
    rtree = reverse_tree(tree)
    tree_str = render_tree(
        rtree,
        list_all=True,
        exclude={'itsdangerous', 'SQLAlchemy', 'Flask', 'markupsafe', 'wheel'})
    expected = """alembic==0.9.10
click==6.7
Flask-Script==2.0.6
gnureadline==6.3.8
Jinja2==2.10
Lookupy==0.1
Mako==1.0.7
  - alembic==0.9.10 [requires: Mako]
psycopg2==2.7.5
python-dateutil==2.7.3
  - alembic==0.9.10 [requires: python-dateutil]
python-editor==1.0.3
  - alembic==0.9.10 [requires: python-editor>=0.3]
redis==2.10.6
six==1.11.0
  - python-dateutil==2.7.3 [requires: six>=1.5]
    - alembic==0.9.10 [requires: python-dateutil]
slugify==0.0.1
Werkzeug==0.14.1"""
    assert expected == tree_str
Exemplo n.º 2
0
def test_reverse_tree():
    rtree = reverse_tree(tree)
    assert all(isinstance(k, ReqPackage) for k, vs in rtree.items())
    assert all(all(isinstance(v, DistPackage) for v in vs)
               for k, vs in rtree.items())
    assert all(all(v.req is not None for v in vs)
               for k, vs in rtree.items())
Exemplo n.º 3
0
def test_reverse_tree():
    rtree = reverse_tree(tree)
    assert all(isinstance(k, ReqPackage) for k, vs in rtree.items())
    assert all(all(isinstance(v, DistPackage) for v in vs)
               for k, vs in rtree.items())
    assert all(all(v.req is not None for v in vs)
               for k, vs in rtree.items())
Exemplo n.º 4
0
def test_render_tree_exclude_reverse():
    rtree = reverse_tree(tree)

    tree_str = render_tree(
        rtree,
        list_all=True,
        exclude={'itsdangerous', 'SQLAlchemy', 'Flask', 'markupsafe', 'wheel'})
    assert tree_str == """\
Exemplo n.º 5
0
def find_requirements_unique_to_projects(tree, requirements,
                                         root_package_names_to_uninstall,
                                         exclude_packages):
    name_tree = package_tree_to_name_tree(tree)
    name_rtree = package_tree_to_name_tree(reverse_tree(tree))
    packages_to_uninstall = set(name
                                for name in root_package_names_to_uninstall)

    def add_to_uninstall(packages):
        for package in packages:
            if package in requirements or package in exclude_packages:
                continue
            required_by = name_rtree.get(package, set())
            other_required_by = required_by - packages_to_uninstall
            if not other_required_by:
                packages_to_uninstall.add(package)
                p_requirements = name_tree.get(package, None)
                if p_requirements:
                    add_to_uninstall(p_requirements)

    add_to_uninstall(root_package_names_to_uninstall)
    return packages_to_uninstall
Exemplo n.º 6
0
def test_render_tree_exclude_reverse():
    rtree = reverse_tree(tree)
    tree_str = render_tree(rtree, list_all=True, exclude={'itsdangerous', 'SQLAlchemy', 'Flask', 'markupsafe', 'wheel'})
    expected = """alembic==0.9.10
click==6.7
Flask-Script==2.0.6
gnureadline==6.3.8
Jinja2==2.10
Lookupy==0.1
Mako==1.0.7
  - alembic==0.9.10 [requires: Mako]
psycopg2==2.7.5
python-dateutil==2.7.3
  - alembic==0.9.10 [requires: python-dateutil]
python-editor==1.0.3
  - alembic==0.9.10 [requires: python-editor>=0.3]
redis==2.10.6
six==1.11.0
  - python-dateutil==2.7.3 [requires: six>=1.5]
    - alembic==0.9.10 [requires: python-dateutil]
slugify==0.0.1
Werkzeug==0.14.1"""
    assert expected == tree_str
Exemplo n.º 7
0
from __future__ import print_function
import pip
import pipdeptree
import subprocess

pkgs = pkgs = pip.get_installed_distributions()

dist_index = pipdeptree.build_dist_index(pkgs)
tree = pipdeptree.construct_tree(dist_index)

reversed_tree = pipdeptree.reverse_tree(tree)
names = [t.project_name for t, d in reversed_tree.items() if not d]

for name in names:
    try:
        result = subprocess.check_output(
            ["rg", "-i", "-t", "py",
             name.replace('-', '_')])
    except subprocess.CalledProcessError as e:
        if not e.output:
            print(name)
Exemplo n.º 8
0
def test_reverse_tree():
    rtree = reverse_tree(tree)
    assert all((isinstance(k, ReqPackage) and
                all(isinstance(v, DistPackage) for v in vs))
               for k, vs in rtree.items())