HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/rich/__pycache__/measure.cpython-310.pyc
o

;j��@s�ddlmZddlmZmZmZmZmZddlm	Z	ddl
mZmZer.ddl
mZmZmZGdd�de�Zd	d
ddd
edddfdd�ZdS)�)�
itemgetter)�
TYPE_CHECKING�Callable�
NamedTuple�Optional�Sequence�)�errors)�
is_renderable�	rich_cast)�Console�ConsoleOptions�RenderableTypec@s�eZdZUdZeed<	eed<	edefdd��Zddd�Zd	eddfd
d�Z	d	eddfdd
�Z
	ddeedeeddfdd�Ze
								ddd��ZdS)�MeasurementzSStores the minimum and maximum widths (in characters) required to render an object.�minimum�maximum�returncCs|j|jS)z+Get difference between maximum and minimum.)rr)�self�r�@/opt/saltstack/salt/lib/python3.10/site-packages/rich/measure.py�spanszMeasurement.spancCs4|\}}ttd|�|�}ttd|�tdt||���S)z�Get measurement that ensures that minimum <= maximum and minimum >= 0

        Returns:
            Measurement: A normalized measurement.
        r)�min�maxr)rrrrrr�	normalizeszMeasurement.normalize�widthcCs|\}}tt||�t||��S)z�Get a RenderableWith where the widths are <= width.

        Args:
            width (int): Maximum desired width.

        Returns:
            Measurement: New Measurement object.
        )rr�rrrrrrr�with_maximum"s	zMeasurement.with_maximumcCs(|\}}td|�}tt||�t||��S)z�Get a RenderableWith where the widths are >= width.

        Args:
            width (int): Minimum desired width.

        Returns:
            Measurement: New Measurement object.
        r)rrrrrr�with_minimum.s	
zMeasurement.with_minimumN�	min_width�	max_widthcCs,|}|dur|�|�}|dur|�|�}|S)aNClamp a measurement within the specified range.

        Args:
            min_width (int): Minimum desired width, or ``None`` for no minimum. Defaults to None.
            max_width (int): Maximum desired width, or ``None`` for no maximum. Defaults to None.

        Returns:
            Measurement: New Measurement object.
        N)rr)rrrZmeasurementrrr�clamp;s

zMeasurement.clamp�consoler�optionsr
�
renderablercCs�|j}|dkrtdd�St|t�r|j||jdd�}t|�}t|�rIt|dd�}|durD|||��	��
|�}|jdkr@tdd�S|�	�Std|�St�
d|�d���)	a�Get a measurement for a renderable.

        Args:
            console (~rich.console.Console): Console instance.
            options (~rich.console.ConsoleOptions): Console options.
            renderable (RenderableType): An object that may be rendered with Rich.

        Raises:
            errors.NotRenderableError: If the object is not renderable.

        Returns:
            Measurement: Measurement object containing range of character widths required to render the object.
        rrF)�markupZ	highlightZ__rich_measure__NzUnable to get render width for zD; a str, Segment, or object with __rich_console__ method is required)rr�
isinstance�strZ
render_strr$rr
�getattrrrrr	ZNotRenderableError)�clsr!r"r#Z
_max_widthZget_console_widthZrender_widthrrr�getNs.

�
��



�zMeasurement.get)rr)NN)r!rr"r
r#rrr)�__name__�
__module__�__qualname__�__doc__�int�__annotations__�propertyrrrrrr �classmethodr)rrrrrs:


���
�����rr!rr"r
�renderablesrrcsT|stdd�Stj����fdd�|D�}tt|td�d�jt|td�d�j�}|S)a�Get a measurement that would fit a number of renderables.

    Args:
        console (~rich.console.Console): Console instance.
        options (~rich.console.ConsoleOptions): Console options.
        renderables (Iterable[RenderableType]): One or more renderable objects.

    Returns:
        Measurement: Measurement object containing range of character widths required to
            contain all given renderables.
    rcsg|]}���|��qSrr)�.0r#�r!Zget_measurementr"rr�
<listcomp>�s�z'measure_renderables.<locals>.<listcomp>)�keyr)rr)rrrr)r!r"r2ZmeasurementsZmeasured_widthrr4r�measure_renderables}s
��r7N)�operatorr�typingrrrrr�r	�protocolr
rr!rr
rrr7rrrr�<module>s r����