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

Method rstrip_end

rich/text.py:666–678  ·  view source on GitHub ↗

Remove whitespace beyond a certain width at the end of the text. Args: size (int): The desired size of the text.

(self, size: int)

Source from the content-addressed store, hash-verified

664 self.plain = self.plain.rstrip()
665
666 def rstrip_end(self, size: int) -> None:
667 """Remove whitespace beyond a certain width at the end of the text.
668
669 Args:
670 size (int): The desired size of the text.
671 """
672 text_length = len(self)
673 if text_length > size:
674 excess = text_length - size
675 whitespace_match = _re_whitespace.search(self.plain)
676 if whitespace_match is not None:
677 whitespace_count = len(whitespace_match.group(0))
678 self.right_crop(min(whitespace_count, excess))
679
680 def set_length(self, new_length: int) -> None:
681 """Set new length of the text, clipping or padding is required."""

Callers 2

test_rstrip_endFunction · 0.95
wrapMethod · 0.80

Calls 1

right_cropMethod · 0.95

Tested by 1

test_rstrip_endFunction · 0.76