MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _display_output

Method _display_output

tensorflow/python/debug/cli/curses_ui.py:1060–1128  ·  view source on GitHub ↗

Display text output in a scrollable text pad. This method does some preprocessing on the text lines, render them on the screen and scroll to the appropriate line. These are done according to regex highlighting requests (if any), scroll-to-next-match requests (if any), and screen ref

(self, output, is_refresh=False, highlight_regex=None)

Source from the content-addressed store, hash-verified

1058 ]
1059
1060 def _display_output(self, output, is_refresh=False, highlight_regex=None):
1061 """Display text output in a scrollable text pad.
1062
1063 This method does some preprocessing on the text lines, render them on the
1064 screen and scroll to the appropriate line. These are done according to regex
1065 highlighting requests (if any), scroll-to-next-match requests (if any),
1066 and screen refresh requests (if any).
1067
1068 TODO(cais): Separate these unrelated request to increase clarity and
1069 maintainability.
1070
1071 Args:
1072 output: A RichTextLines object that is the screen output text.
1073 is_refresh: (bool) Is this a refreshing display with existing output.
1074 highlight_regex: (str) Optional string representing the regex used to
1075 search and highlight in the current screen output.
1076 """
1077
1078 if not output:
1079 return
1080
1081 if highlight_regex:
1082 try:
1083 output = debugger_cli_common.regex_find(
1084 output, highlight_regex, font_attr=self._SEARCH_HIGHLIGHT_FONT_ATTR)
1085 except ValueError as e:
1086 self._error_toast(str(e))
1087 return
1088
1089 if not is_refresh:
1090 # Perform new regex search on the current output.
1091 self._unwrapped_regex_match_lines = output.annotations[
1092 debugger_cli_common.REGEX_MATCH_LINES_KEY]
1093 else:
1094 # Continue scrolling down.
1095 self._output_pad_row += 1
1096 else:
1097 self._curr_unwrapped_output = output
1098 self._unwrapped_regex_match_lines = []
1099
1100 # Display output on the screen.
1101 wrapped_regex_match_lines = self._screen_display_output(output)
1102
1103 # Now that the text lines are displayed on the screen scroll to the
1104 # appropriate line according to previous scrolling state and regex search
1105 # and highlighting state.
1106
1107 if highlight_regex:
1108 next_match_line = -1
1109 for match_line in wrapped_regex_match_lines:
1110 if match_line >= self._output_pad_row:
1111 next_match_line = match_line
1112 break
1113
1114 if next_match_line >= 0:
1115 self._scroll_output(
1116 _SCROLL_TO_LINE_INDEX, line_index=next_match_line)
1117 else:

Callers 3

_dispatch_commandMethod · 0.95
_redraw_outputMethod · 0.95

Calls 4

_error_toastMethod · 0.95
_scroll_outputMethod · 0.95
_toastMethod · 0.95

Tested by

no test coverage detected