Rename jsonify_tree() to render_json()

This commit is contained in:
Haiko Schol 2018-01-31 16:05:25 +01:00
parent 6f70dd5508
commit 1262d7ce55
2 changed files with 5 additions and 5 deletions

View File

@ -323,8 +323,8 @@ def render_tree(tree, list_all=True, show_only=None, frozen=False):
return '\n'.join(lines) return '\n'.join(lines)
def jsonify_tree(tree, indent): def render_json(tree, indent):
"""Converts the tree into json representation. """Converts the tree into a flat json representation.
The json repr will be a list of hashes, each hash having 2 fields: The json repr will be a list of hashes, each hash having 2 fields:
- package - package
@ -505,7 +505,7 @@ def main():
tree = construct_tree(dist_index) tree = construct_tree(dist_index)
if args.json: if args.json:
print(jsonify_tree(tree, indent=4)) print(render_json(tree, indent=4))
return 0 return 0
elif args.output_format: elif args.output_format:
output = dump_graphviz(tree, output_format=args.output_format) output = dump_graphviz(tree, output_format=args.output_format)

View File

@ -9,7 +9,7 @@ from operator import attrgetter
from pipdeptree import (build_dist_index, construct_tree, from pipdeptree import (build_dist_index, construct_tree,
DistPackage, ReqPackage, render_tree, DistPackage, ReqPackage, render_tree,
reverse_tree, cyclic_deps, conflicting_deps, reverse_tree, cyclic_deps, conflicting_deps,
get_parser, jsonify_tree, dump_graphviz, get_parser, render_json, dump_graphviz,
print_graphviz) print_graphviz)
@ -140,7 +140,7 @@ def test_render_tree_freeze():
def test_render_json(capsys): def test_render_json(capsys):
output = jsonify_tree(tree, indent=4) output = render_json(tree, indent=4)
print_graphviz(output) print_graphviz(output)
out, _ = capsys.readouterr() out, _ = capsys.readouterr()
assert out.startswith('[\n {\n "') assert out.startswith('[\n {\n "')