]>
jfr.im git - dlqueue.git/blob - venv/lib/python3.11/site-packages/pip/_vendor/rich/styled.py
1 from typing
import TYPE_CHECKING
3 from .measure
import Measurement
4 from .segment
import Segment
5 from .style
import StyleType
8 from .console
import Console
, ConsoleOptions
, RenderResult
, RenderableType
12 """Apply a style to a renderable.
15 renderable (RenderableType): Any renderable.
16 style (StyleType): A style to apply across the entire renderable.
19 def __init__(self
, renderable
: "RenderableType", style
: "StyleType") -> None:
20 self
.renderable
= renderable
24 self
, console
: "Console", options
: "ConsoleOptions"
26 style
= console
.get_style(self
.style
)
27 rendered_segments
= console
.render(self
.renderable
, options
)
28 segments
= Segment
.apply_style(rendered_segments
, style
)
32 self
, console
: "Console", options
: "ConsoleOptions"
34 return Measurement
.get(console
, options
, self
.renderable
)
37 if __name__
== "__main__": # pragma: no cover
38 from pip
._vendor
.rich
import print
39 from pip
._vendor
.rich
.panel
import Panel
41 panel
= Styled(Panel("hello"), "on blue")