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

Method __rich__

rich/palette.py:20–41  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

18 return ColorTriplet(*self._colors[number])
19
20 def __rich__(self) -> "Table":
21 from rich.color import Color
22 from rich.style import Style
23 from rich.text import Text
24 from rich.table import Table
25
26 table = Table(
27 "index",
28 "RGB",
29 "Color",
30 title="Palette",
31 caption=f"{len(self._colors)} colors",
32 highlight=True,
33 caption_justify="right",
34 )
35 for index, color in enumerate(self._colors):
36 table.add_row(
37 str(index),
38 repr(color),
39 Text(" " * 16, style=Style(bgcolor=Color.from_rgb(*color))),
40 )
41 return table
42
43 # This is somewhat inefficient and needs caching
44 @lru_cache(maxsize=1024)

Callers

nothing calls this directly

Calls 5

add_rowMethod · 0.95
TableClass · 0.90
TextClass · 0.90
StyleClass · 0.90
from_rgbMethod · 0.80

Tested by

no test coverage detected