Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def venv_fixture(pickle_file):
"""Loads required virtualenv pkg data from a pickle file
:param pickle_file: path to a .pickle file
:returns: a tuple of pkgs, pkg_index, req_map
:rtype: tuple
"""
with open(pickle_file, 'rb') as f:
pkgs = pickle.load(f)
dist_index = build_dist_index(pkgs)
tree = construct_tree(dist_index)
return pkgs, dist_index, tree
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