diff --git a/pipdeptree.py b/pipdeptree.py index 1317dde..79632d3 100644 --- a/pipdeptree.py +++ b/pipdeptree.py @@ -111,7 +111,7 @@ def confusing_deps(req_map): def render_tree(pkgs, pkg_index, req_map, list_all, - top_pkg_str, non_top_pkg_str): + top_pkg_str, non_top_pkg_str, bullets=True): """Renders a package dependency tree as a string :param list pkgs: pkg_resources.Distribution instances @@ -123,6 +123,8 @@ def render_tree(pkgs, pkg_index, req_map, list_all, package as string :param function non_top_pkg_str: function to render a non-top level package as string + :param bool bullets: whether or not to show bullets for child + dependencies [default: True] :returns: dependency tree encoded as string :rtype: str @@ -144,8 +146,8 @@ def render_tree(pkgs, pkg_index, req_map, list_all, # FixMe! Some dependencies are not present in the result of # `pip.get_installed_distributions` # eg. `testresources`. This is a hack around it. - name = pkg.project_name if dist is None else non_top_pkg_str(pkg, dist) - result = [' '*indent+'- '+name] + name = pkg.project_name if dist is None else non_top_pkg_str(pkg, dist) + result = [' '*indent + ('-' if bullets else ' ') + ' ' + name] else: result = [top_pkg_str(pkg)] @@ -266,7 +268,8 @@ def main(): req_map=req_map, list_all=args.all, top_pkg_str=top_pkg_str, - non_top_pkg_str=non_top_pkg_str) + non_top_pkg_str=non_top_pkg_str, + bullets=not args.freeze) print(tree) return 0 diff --git a/tests/test_pipdeptree.py b/tests/test_pipdeptree.py index f391f7a..4879ece 100644 --- a/tests/test_pipdeptree.py +++ b/tests/test_pipdeptree.py @@ -76,7 +76,7 @@ def test_render_tree_list_all(): def test_render_tree_freeze(): tree_str = render_tree(pkgs, pkg_index, req_map, False, - top_pkg_src, non_top_pkg_src) + top_pkg_src, non_top_pkg_src, bullets=False) lines = set() for line in tree_str.split('\n'): # Workaround for https://github.com/pypa/pip/issues/1867 @@ -86,7 +86,7 @@ def test_render_tree_freeze(): line = line.replace('origin/HEAD', 'master') lines.add(line) assert 'Flask-Script==0.6.6' in lines - assert ' - SQLAlchemy==0.9.1' in lines + assert ' SQLAlchemy==0.9.1' in lines assert '-e git+https://github.com/naiquevin/lookupy.git@cdbe30c160e1c29802df75e145ea4ad903c05386#egg=Lookupy-master' in lines assert 'itsdangerous==0.23' not in lines