Print ``content`` with optional color, honoring suppression context.
(
content: str | list[ColoredText],
color: PrinterColor | None = None,
sep: str | None = " ",
end: str | None = "\n",
file: SupportsWrite[str] | None = None,
flush: Literal[False] = False,
)
| 76 | |
| 77 | @staticmethod |
| 78 | def print( |
| 79 | content: str | list[ColoredText], |
| 80 | color: PrinterColor | None = None, |
| 81 | sep: str | None = " ", |
| 82 | end: str | None = "\n", |
| 83 | file: SupportsWrite[str] | None = None, |
| 84 | flush: Literal[False] = False, |
| 85 | ) -> None: |
| 86 | """Print ``content`` with optional color, honoring suppression context.""" |
| 87 | if should_suppress_console_output(): |
| 88 | return |
| 89 | if isinstance(content, str): |
| 90 | content = [ColoredText(content, color)] |
| 91 | print( |
| 92 | "".join( |
| 93 | f"{_COLOR_CODES[c.color] if c.color else ''}{c.text}{RESET}" |
| 94 | for c in content |
| 95 | ), |
| 96 | sep=sep, |
| 97 | end=end, |
| 98 | file=file, |
| 99 | flush=flush, |
| 100 | ) |
| 101 | |
| 102 | |
| 103 | PRINTER: Printer = Printer() |