Print dict as key-value pairs.
(data: dict[str, Any], title: str | None = None)
| 568 | |
| 569 | |
| 570 | def print_key_value(data: dict[str, Any], title: str | None = None) -> None: |
| 571 | """Print dict as key-value pairs.""" |
| 572 | if console.no_color: |
| 573 | for key, value in data.items(): |
| 574 | print(f"{sanitize_tsv(str(key))}\t{sanitize_tsv(str(value))}") |
| 575 | return |
| 576 | |
| 577 | if title: |
| 578 | console.print(f"[bold]{escape(title)}[/bold]") |
| 579 | |
| 580 | for key, value in data.items(): |
| 581 | console.print(f" [cyan]{escape(str(key))}:[/cyan] {escape(str(value))}") |