How to use the pipdeptree.DistPackage 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_build_dist_index():
    assert len(dist_index) == len(pkgs)
    assert all(isinstance(x, str) for x in dist_index.keys())
    assert all(isinstance(x, DistPackage) for x in dist_index.values())
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 / pipdeptree.py View on Github external
def __init__(self, obj, req=None):
        super(DistPackage, self).__init__(obj)
        self.version_spec = None
        self.req = req
github naiquevin / pipdeptree / pipdeptree.py View on Github external
def build_dist_index(pkgs):
    """Build an index pkgs by their key as a dict.

    :param list pkgs: list of pkg_resources.Distribution instances
    :returns: index of the pkgs by the pkg key
    :rtype: dict

    """
    return dict((p.key, DistPackage(p)) for p in pkgs)
github sbg / dante / dante / core / commands.py View on Github external
def get_installed_package_version(package):
    """Returns installed package version
    :param package: package for which the version is requested
    :return: version string
    """
    package_version = None
    if isinstance(package, pipdeptree.ReqPackage):
        return package.installed_version
    elif isinstance(package, pipdeptree.DistPackage):
        package_version = package.version
    return package_version or VERSION_ANY