MCPcopy
hub / github.com/Textualize/rich / decode

Method decode

rich/ansi.py:126–136  ·  view source on GitHub ↗

Decode ANSI codes in an iterable of lines. Args: terminal_text: Output potentially containing ANSI escape sequences. Yields: Text: Marked up Text.

(self, terminal_text: str)

Source from the content-addressed store, hash-verified

124 self.style = Style.null()
125
126 def decode(self, terminal_text: str) -> Iterable[Text]:
127 """Decode ANSI codes in an iterable of lines.
128
129 Args:
130 terminal_text: Output potentially containing ANSI escape sequences.
131
132 Yields:
133 Text: Marked up Text.
134 """
135 for line in re.split(r"(?<=\n)", terminal_text):
136 yield self.decode_line(line.rstrip("\n"))
137
138 def decode_line(self, line: str) -> Text:
139 """Decode a line containing ansi codes.

Callers 6

test_decodeFunction · 0.95
from_ansiMethod · 0.95
test_decode_exampleFunction · 0.80
test_decode_issue_2688Function · 0.80
file_progress.pyFile · 0.80
ansi.pyFile · 0.80

Calls 3

decode_lineMethod · 0.95
rstripMethod · 0.80
splitMethod · 0.45

Tested by 3

test_decodeFunction · 0.76
test_decode_exampleFunction · 0.64
test_decode_issue_2688Function · 0.64