HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/site-packages/pip/_vendor/rich/__pycache__/measure.cpython-37.pyc
B

L��g��@s�ddlmZddlmZmZmZmZmZddlm	Z	ddl
mZmZer\ddl
mZmZmZGdd�de�Zd	d
eddd�d
d�ZdS)�)�
itemgetter)�
TYPE_CHECKING�Callable�
NamedTuple�Optional�Sequence�)�errors)�
is_renderable�	rich_cast)�Console�ConsoleOptions�RenderableTypec@s�eZdZUdZeed<eed<eed�dd��Zdd�dd�Zedd	�d
d�Z	edd	�dd
�Z
deeeedd�dd�Ze
ddddd�dd��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�</tmp/pip-unpacked-wheel-hv55ucu3/pip/_vendor/rich/measure.py�spanszMeasurement.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)�widthrcCs|\}}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)rr)rrrrrrr�with_minimum.s	
zMeasurement.with_minimumN)�	min_width�	max_widthrcCs,|}|dk	r|�|�}|dk	r(|�|�}|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.clamprr
r)�console�options�
renderablercCs�|j}|dkrtdd�St|t�r4|j||jdd�}t|�}t|�r�t|dd�}|dk	r�|||��	��
|�}|jdkr�tdd�S|�	�Std|�Snt�
d|�d���dS)	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)NN)�__name__�
__module__�__qualname__�__doc__�int�__annotations__�propertyrrrrrr�classmethodr(rrrrrs

rrr
r)r r!�renderablesrcsT|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 �get_measurementr!rr�
<listcomp>�sz'measure_renderables.<locals>.<listcomp>)�keyr)rr(rrrr)r r!r1ZmeasurementsZmeasured_widthr)r r3r!r�measure_renderables}s
r6N)�operatorr�typingrrrrr�r	�protocolr
rr rr
rrr6rrrr�<module>ss