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

Method remove_color

rich/segment.py:608–627  ·  view source on GitHub ↗

Remove all color from an iterable of segments. Args: segments (Iterable[Segment]): An iterable segments. Yields: Segment: Segments with colorless style.

(cls, segments: Iterable["Segment"])

Source from the content-addressed store, hash-verified

606
607 @classmethod
608 def remove_color(cls, segments: Iterable["Segment"]) -> Iterable["Segment"]:
609 """Remove all color from an iterable of segments.
610
611 Args:
612 segments (Iterable[Segment]): An iterable segments.
613
614 Yields:
615 Segment: Segments with colorless style.
616 """
617
618 cache: Dict[Style, Style] = {}
619 for text, style, control in segments:
620 if style:
621 colorless_style = cache.get(style)
622 if colorless_style is None:
623 colorless_style = style.without_color
624 cache[style] = colorless_style
625 yield cls(text, colorless_style, control)
626 else:
627 yield cls(text, None, control)
628
629 @classmethod
630 def divide(

Callers 3

test_remove_colorFunction · 0.80
_write_bufferMethod · 0.80
_render_bufferMethod · 0.80

Calls 1

getMethod · 0.45

Tested by 1

test_remove_colorFunction · 0.64