HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/pip/_vendor/rich/__pycache__/markup.cpython-310.pyc
o

@%Nez�@s�ddlmZddlmZddlZddlmZmZmZm	Z	m
Z
mZmZm
Z
ddlmZddlmZddlmZmZdd	lmZdd
lmZe�dej�Ze�d�ZGd
d�de
�Ze	eZeegefZeeegefZ e�d�j!fdede defdd�Z"dedeee#eeeeffdd�Z$			d&dede
eefde%deedef
dd�Z&e'dkr�gd�Z(dd l)m*Z*dd!l+m,Z,e*d"d#d$d%�Z-e(D]
Z.e-�/ee.�e.�q�e,e-�dSdS)'�)�literal_eval)�
attrgetterN)�Callable�Iterable�List�Match�
NamedTuple�Optional�Tuple�Union�)�MarkupError)�Style)�Span�Text)�EmojiVariant)�_emoji_replacez((\\*)\[([a-z#\/@].*?)\])z^([\w\.]*?)(\(.*?\))?$c@sJeZdZUdZeed<	eeed<	defdd�Zedefdd��Z	d	S)
�TagzA tag in console markup.�name�
parameters�returncCs"|jdur|jS|j�d|j��S)N� �rr��self�r�9/usr/lib/python3/dist-packages/pip/_vendor/rich/markup.py�__str__s��zTag.__str__cCs.|jdurd|j�d�Sd|j�d|j�d�S)z*Get the string representation of this tag.N�[�]�=rrrrr�markup"s

���z
Tag.markupN)
�__name__�
__module__�__qualname__�__doc__�str�__annotations__r	r�propertyr!rrrrrs
rz(\\*)(\[[a-z#\/@].*?\])r!�_escapercCs$dttdtfdd�}|||�}|S)z�Escapes text so that it won't be interpreted as markup.

    Args:
        markup (str): Content to be inserted in to markup.

    Returns:
        str: Markup with square brackets escaped.
    �matchrcSs|��\}}|�|�d|��S)z!Called by re.sub replace matches.�\)�groups)r*�backslashes�textrrr�escape_backslashes=sz"escape.<locals>.escape_backslashes)rr&)r!r)r/rrr�escape1s
r0ccs�d}t}t}t�|�D]`}|��\}}}|��\}}	||kr)||||�dfV|rU|t|�d�\}
}|
rD|d|
dfV||
d7}|rU||t|�d�dfV|	}q|�d�\}}
}|d|||
re|nd�fV|	}q|t|�kr|||d�dfVdSdS)z�Parse markup in to an iterable of tuples of (position, text, tag).

    Args:
        markup (str): A string containing console markup

    rN�r+r )�divmodr�RE_TAGS�finditerr,�span�len�	partition)r!�position�_divmod�_Tagr*�	full_text�escapes�tag_text�start�endr-�escapedr.�equalsrrrr�_parseFs0��rB�T�style�emoji�
emoji_variantcs�t}d|vrt|r|||d�|d�S||d�St|d�}|j}tj}g��j�g}|j}	t}
t}dtdt	t
tff��fdd�}t|�D�]
\}
}}|durY||rU||�n|�qD|du�rO|j�
d	��r=|jd
d���}|r�||�}z||�\}}Wn,ty�td|j�d|
�d
��d�wz��\}}Wnty�td|
�d��d�w|j�
d��r0|j�rd}|j��}t�|�}|dur�|��\}}|dur�dn|}zt|�}Wn3ty�}ztd|�d|j�d|j����d}~wt�y}ztd|j�d|���d�d}~ww|�r|t|t��r|n|ff}nd}|	|
|t|�t|j|id���qD|	|
|t|�t|���qD|||j�|j�}��t|�|f�qDt|�}��ro���\}}t|�}|�rl|	|
|||����sWt|ddd�td�d�|_ |S)a9Render console markup in to a Text instance.

    Args:
        markup (str): A string containing console markup.
        emoji (bool, optional): Also render emoji code. Defaults to True.

    Raises:
        MarkupError: If there is a syntax error in the markup.

    Returns:
        Text: A test instance.
    r)�default_variant)rD�
style_namercs<tt��d�D]\}\}}|j|kr�|�Sqt|��)z"Pop tag matching given style name.r)�	enumerate�reversedr�KeyError)rH�index�_�tag��pop�style_stackrr�	pop_style�s

�zrender.<locals>.pop_styleN�/rz
closing tag 'z' at position z doesn't match any open tagzclosing tag '[/]' at position z has nothing to close�@rCz()zerror parsing z in z; r)�meta���r>)�key)!rr�appendr�	normalizerPrrr&r
�intrBr�
startswith�striprKr
r!�
IndexErrorr�
RE_HANDLERr*r,r�SyntaxError�msg�	Exception�
isinstance�tupler6�sortedr�spans)r!rDrErF�
emoji_replacer.rXrYre�append_span�_Spanr:rRr8�
plain_textrNrHr>�open_tag�handler_namer�
handler_match�match_parameters�meta_params�error�normalized_tag�text_lengthrrOr�rendergs���
 
���
���

��������������rr�__main__)z[red]Hello World[/red]zagenta]Hello [b]World[/b]z9[bold]Bold[italic] bold and italic [/bold]italic[/italic]zDClick [link=https://www.willmcgugan.com]here[/link] to visit my Blogz+:warning-emoji: [bold red blink] DANGER![/])�Table)�print�Markup�Result)rr)�padding)rCTN)0�astr�operatorr�re�typingrrrrrr	r
r�errorsr
rDrr.rrrErr�compile�VERBOSEr3r^rr&�_ReStringMatch�_ReSubCallable�_EscapeSubMethod�subr0rZrB�boolrrr"�MARKUP�pip._vendor.rich.tablert�pip._vendor.richru�gridr!�add_rowrrrr�<module>sd(�

���
�(#��
���
�{�