commands.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:dante 作者: sbg 项目源码 文件源码
def get_package_tree(ignore_list=None, include_only=None):
    """Returns dependency package tree
    :param ignore_list: list of dependencies to exclude from tree
    :param include_only: list of dependencies to include if
    :return: dictionary of top level packages with their dependencies
    """
    ignore_list = [i.lower() for i in ignore_list] if ignore_list else []
    include_only = [i.lower() for i in include_only] if include_only else []
    packages = [
        package for package in
        pip.get_installed_distributions()
        if package.key not in ignore_list
    ]

    # if include_only is set, remove other packages
    if include_only:
        packages = [
            package for package in packages
            if package.key in include_only
        ]

    dist_index = pipdeptree.build_dist_index(pkgs=packages)
    tree = pipdeptree.construct_tree(index=dist_index)
    return tree
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号