Skip to content

Commit

Permalink
Fix conan graph info --format=text being printed to stderr (conan-i…
Browse files Browse the repository at this point in the history
…o#15170)

Fix graph info --format=text being printed to stderr
  • Loading branch information
AbrilRBS authored Nov 24, 2023
1 parent 0d9f52f commit dde76f6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
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}")

0 comments on commit dde76f6

Please sign in to comment.