MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / print

Method print

cmd2/rich_utils.py:472–515  ·  view source on GitHub ↗

Override to support ANSI sequences. This method calls [cmd2.rich_utils.prepare_objects_for_rendering][] on the objects being printed. This ensures that strings containing ANSI style sequences are converted to Rich Text objects, so that Rich can correctly calculate th

(
        self,
        *objects: Any,
        sep: str = " ",
        end: str = "\n",
        style: StyleType | None = None,
        justify: JustifyMethod | None = None,
        overflow: OverflowMethod | None = None,
        no_wrap: bool | None = None,
        emoji: bool | None = None,
        markup: bool | None = None,
        highlight: bool | None = None,
        width: int | None = None,
        height: int | None = None,
        crop: bool = True,
        soft_wrap: bool | None = None,
        new_line_start: bool = False,
    )

Source from the content-addressed store, hash-verified

470 raise BrokenPipeError
471
472 def print(
473 self,
474 *objects: Any,
475 sep: str = " ",
476 end: str = "\n",
477 style: StyleType | None = None,
478 justify: JustifyMethod | None = None,
479 overflow: OverflowMethod | None = None,
480 no_wrap: bool | None = None,
481 emoji: bool | None = None,
482 markup: bool | None = None,
483 highlight: bool | None = None,
484 width: int | None = None,
485 height: int | None = None,
486 crop: bool = True,
487 soft_wrap: bool | None = None,
488 new_line_start: bool = False,
489 ) -> None:
490 """Override to support ANSI sequences.
491
492 This method calls [cmd2.rich_utils.prepare_objects_for_rendering][] on the
493 objects being printed. This ensures that strings containing ANSI style
494 sequences are converted to Rich Text objects, so that Rich can correctly
495 calculate their display width.
496 """
497 prepared_objects = prepare_objects_for_rendering(*objects)
498
499 super().print(
500 *prepared_objects,
501 sep=sep,
502 end=end,
503 style=style,
504 justify=justify,
505 overflow=overflow,
506 no_wrap=no_wrap,
507 emoji=emoji,
508 markup=markup,
509 highlight=highlight,
510 width=width,
511 height=height,
512 crop=crop,
513 soft_wrap=soft_wrap,
514 new_line_start=new_line_start,
515 )
516
517 def log(
518 self,

Callers 10

get_completionsMethod · 0.80
errorMethod · 0.80
rich_text_to_stringFunction · 0.80
print_toMethod · 0.80
format_exceptionMethod · 0.80
ppagedMethod · 0.80
completeMethod · 0.80
test_indented_textFunction · 0.80
test_indented_tableFunction · 0.80

Calls 1

Tested by 3

test_indented_textFunction · 0.64
test_indented_tableFunction · 0.64