MCPcopy Index your code
hub / github.com/prompt-toolkit/ptpython / display_result

Method display_result

src/ptpython/printer.py:52–83  ·  view source on GitHub ↗

Show __repr__ (or `__pt_repr__`) for an `eval` result and print to output. :param reformat: Reformat result using 'black' before printing if the result is parsable as Python code. :param highlight: Syntax highlight the result. :param paginate: Show pagin

(
        self,
        result: object,
        *,
        out_prompt: AnyFormattedText,
        reformat: bool,
        highlight: bool,
        paginate: bool,
    )

Source from the content-addressed store, hash-verified

50 style_transformation: StyleTransformation
51
52 def display_result(
53 self,
54 result: object,
55 *,
56 out_prompt: AnyFormattedText,
57 reformat: bool,
58 highlight: bool,
59 paginate: bool,
60 ) -> None:
61 """
62 Show __repr__ (or `__pt_repr__`) for an `eval` result and print to output.
63
64 :param reformat: Reformat result using 'black' before printing if the
65 result is parsable as Python code.
66 :param highlight: Syntax highlight the result.
67 :param paginate: Show paginator when the result does not fit on the
68 screen.
69 """
70 out_prompt = to_formatted_text(out_prompt)
71 out_prompt_width = fragment_list_width(out_prompt)
72
73 result = self._insert_out_prompt_and_split_lines(
74 self._format_result_output(
75 result,
76 reformat=reformat,
77 highlight=highlight,
78 line_length=self.output.get_size().columns - out_prompt_width,
79 paginate=paginate,
80 ),
81 out_prompt=out_prompt,
82 )
83 self._display_result(result, paginate=paginate)
84
85 def display_exception(
86 self, e: BaseException, *, highlight: bool, paginate: bool

Callers 1

_show_resultMethod · 0.80

Calls 3

_format_result_outputMethod · 0.95
_display_resultMethod · 0.95

Tested by

no test coverage detected