How to use the pipdeptree.ReqPackage function in pipdeptree

To help you get started, we’ve selected a few pipdeptree examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github naiquevin / pipdeptree / tests / test_pipdeptree.py View on Github external
def test_tree():
    assert len(tree) == len(pkgs)
    assert all((isinstance(k, DistPackage) and
                all(isinstance(v, ReqPackage) for v in vs))
               for k, vs in tree.items())
github naiquevin / pipdeptree / tests / test_pipdeptree.py View on Github external
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())
github naiquevin / pipdeptree / pipdeptree.py View on Github external
def as_requirement(self):
        """Return a ReqPackage representation of this DistPackage"""
        return ReqPackage(self._obj.as_requirement(), dist=self)
github sbg / dante / dante / core / commands.py View on Github external
def get_required_package_version(package):
    """Returns required version for a package
    :param package: package for which the required version is requested
    :return: version string
    """
    package_version = None
    if isinstance(package, pipdeptree.ReqPackage):
        package_version = package.version_spec
    return package_version or VERSION_ANY
github naiquevin / pipdeptree / pipdeptree.py View on Github external
def construct_tree(index):
    """Construct tree representation of the pkgs from the index.

    The keys of the dict representing the tree will be objects of type
    DistPackage and the values will be list of ReqPackage objects.

    :param dict index: dist index ie. index of pkgs by their keys
    :returns: tree of pkgs and their dependencies
    :rtype: dict

    """
    return dict((p, [ReqPackage(r, index.get(r.key))
                     for r in p.requires()])
                for p in index.values())
github naiquevin / pipdeptree / pipdeptree.py View on Github external
def __init__(self, obj, dist=None):
        super(ReqPackage, self).__init__(obj)
        self.dist = dist