Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix conan graph info --format=text being printed to stderr #15170

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions conan/cli/commands/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def print_serial(item, indent=None, color_index=None):


def print_list_text(results):
""" Do litte format modification to serialized
list bundle so it looks prettier on text output
""" Do a little format modification to serialized
list bundle, so it looks prettier on text output
"""
info = results["results"]

Expand Down
4 changes: 2 additions & 2 deletions conan/cli/commands/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@


def summary_upload_list(results):
""" Do litte format modification to serialized
list bundle so it looks prettier on text output
""" Do a little format modification to serialized
list bundle, so it looks prettier on text output
"""
ConanOutput().subtitle("Upload summary")
info = results["results"]
Expand Down
12 changes: 5 additions & 7 deletions conan/cli/formatters/graph/graph_info_text.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fnmatch
from collections import OrderedDict

from conan.api.output import ConanOutput
from conan.api.output import ConanOutput, cli_out_write


def filter_graph(graph, package_filter=None, field_filter=None):
Expand All @@ -27,23 +27,21 @@ def format_graph_info(result):
field_filter = result["field_filter"]
package_filter = result["package_filter"]

out = ConanOutput()
out.title("Basic graph information")
ConanOutput().subtitle("Basic graph information")
serial = graph.serialize()
serial = filter_graph(serial, package_filter, field_filter)
for n in serial["nodes"].values():
out.writeln(f"{n['ref']}:") # FIXME: This can be empty for consumers and it is ugly ":"
cli_out_write(f"{n['ref']}:") # FIXME: This can be empty for consumers and it is ugly ":"
_serial_pretty_printer(n, indent=" ")
if graph.error:
raise graph.error


def _serial_pretty_printer(data, indent=""):
out = ConanOutput()
for k, v in data.items():
if isinstance(v, dict):
out.writeln(f"{indent}{k}:")
cli_out_write(f"{indent}{k}:")
# TODO: increment color too
_serial_pretty_printer(v, indent=indent+" ")
else:
out.writeln(f"{indent}{k}: {v}")
cli_out_write(f"{indent}{k}: {v}")