Server IP : 51.89.169.208 / Your IP : 18.216.45.231 Web Server : Apache System : Linux ns3209505.ip-198-244-202.eu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Tue Nov 5 04:50:16 EST 2024 x86_64 User : yellowleaf ( 1019) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /opt/imunify360/venv/lib64/python3.11/site-packages/pip/_vendor/rich/ |
Upload File : |
from typing import Optional, TYPE_CHECKING from .jupyter import JupyterMixin from .measure import Measurement if TYPE_CHECKING: from .console import Console, ConsoleOptions, RenderableType, RenderResult class Constrain(JupyterMixin): """Constrain the width of a renderable to a given number of characters. Args: renderable (RenderableType): A renderable object. width (int, optional): The maximum width (in characters) to render. Defaults to 80. """ def __init__(self, renderable: "RenderableType", width: Optional[int] = 80) -> None: self.renderable = renderable self.width = width def __rich_console__( self, console: "Console", options: "ConsoleOptions" ) -> "RenderResult": if self.width is None: yield self.renderable else: child_options = options.update_width(min(self.width, options.max_width)) yield from console.render(self.renderable, child_options) def __rich_measure__( self, console: "Console", options: "ConsoleOptions" ) -> "Measurement": if self.width is not None: options = options.update_width(self.width) measurement = Measurement.get(console, options, self.renderable) return measurement