HEX
Server: LiteSpeed
System: Linux srv146.niagahoster.com 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
User: kodi1989 (1633)
PHP: 8.1.34
Disabled: symlink,shell_exec,exec,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,show_source,pcntl_exec
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/rich/__pycache__/markup.cpython-37.pyc
B

��f� �@s�ddlZddlmZddlmZddlmZmZmZm	Z	m
Z
mZmZm
Z
ddlmZddlmZddlmZdd	lmZdd
lmZmZe�dej�Ze�d�ZGd
d�de
�Ze	eZeegefZeeegefZ e�d�j!fee ed�dd�Z"eeee#eeeefd�dd�Z$d'ee
eefe%eeed�dd�Z&e'dk�r�ddddd gZ(dd!l)m*Z*dd"l+m,Z,e,d#d$d%d&�Z-xe(D]Z.e-�/ee.�e.��q�We*e-�dS)(�N)�literal_eval)�
attrgetter)�Callable�Iterable�List�Match�
NamedTuple�Optional�Tuple�Union�)�_emoji_replace)�EmojiVariant)�MarkupError)�Style)�Span�Textz((\\*)\[([a-z#/@][^[]*?)])z^([\w.]*?)(\(.*?\))?$c@sFeZdZUdZeed<eeed<ed�dd�Zeed�dd��Z	d	S)
�TagzA tag in console markup.�name�
parameters)�returncCs"|jdkr|jS|j�d|j��S)N� )rr)�self�r�</opt/alt/python37/lib/python3.7/site-packages/rich/markup.py�__str__szTag.__str__cCs.|jdkrd|j�d�Sd|j�d|j�d�S)z*Get the string representation of this tag.N�[�]�=)rr)rrrr�markup!sz
Tag.markupN)
�__name__�
__module__�__qualname__�__doc__�str�__annotations__r	r�propertyrrrrrrs
rz(\\*)(\[[a-z#/@][^[]*?]))r�_escapercCs>tttd�dd�}|||�}|�d�r:|�d�s:|dS|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_backslashesr)z\\)rr$�endswith)rr'r-rrr�escape0s


r/)rrccsd}t}t}x�t�|�D]�}|��\}}}|��\}}	||krR||||�dfV|r�|t|�d�\}
}|
r�|d|
dfV||
d7}|r�||t|�d�dfV|	}q|�d�\}}
}|d|||
r�|nd�fV|	}qW|t|�kr�|||d�dfVdS)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�positionZ_divmod�_Tagr(Z	full_textZescapesZtag_text�start�endr+�escapedr,�equalsrrrr�_parseIs,r=�T)r�style�emoji�
emoji_variantrcs6t}d|kr(t|r|||d�n||d�St|d�}|j}tj}g��j�g}|j}	t}
t}tt	t
tfd���fdd�}�xZt|�D�]L\}
}}|dk	r�|�dd�}||r�||�n|�q�|dk	r�|j
�d	��r�|j
d
d���}|�r4||�}y||�\}}Wn0tk
�r0td|j�d|
�d
��d�YnXn8y��\}}Wn(tk
�rjtd|
�d��d�YnX|j
�d��r�|j�rnd}|j��}t�|�}|dk	�r�|��\}}|dk�r�dn|}yt|�}Wn|tk
�r}z"td|�d|j�d|j����Wdd}~XYn<tk
�rJ}ztd|j�d|���d�Wdd}~XYnX|�rr|t|t��rd|n|ff}nd}|	|
|t|�t|j
|id���n|	|
|t|�t|���q�|||j
�|j�}��t|�|f�q�Wt|�}x6��r���\}}t|�}|�r�|	|
|||���q�Wt|ddd�t d�d�|_!|S)a�Render console markup in to a Text instance.

    Args:
        markup (str): A string containing console markup.
        style: (Union[str, Style]): The style to use.
        emoji (bool, optional): Also render emoji code. Defaults to True.
        emoji_variant (str, optional): Optional emoji variant, either "text" or "emoji". Defaults to None.


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

    Returns:
        Text: A test instance.
    r)Zdefault_variant)r?)�
style_namercs@x2tt��d�D] \}\}}|j|kr�|�SqWt|��dS)z"Pop tag matching given style name.rN)�	enumerate�reversedr�KeyError)rB�index�_�tag)�pop�style_stackrr�	pop_style�s
zrender.<locals>.pop_styleNz\[�/rz
closing tag 'z' at position z doesn't match any open tagzclosing tag '[/]' at position z has nothing to close�@r>z()zerror parsing z in z; r)�meta���r9)�key)"r
r�appendr�	normalizerIrrr$r
�intr=�replacer�
startswith�striprErr�
IndexErrorr�
RE_HANDLERr(r*r�SyntaxError�msg�	Exception�
isinstance�tupler5�sortedr�spans)rr?r@rAZ
emoji_replacer,rQrRr_Zappend_spanZ_Spanr8rKr7Z
plain_textrHrBr9Zopen_tagZhandler_namerZ
handler_matchZmatch_parametersZmeta_params�errorZnormalized_tagZtext_lengthr)rIrJr�renderjs�




,
ra�__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![/])�print)�TableZMarkupZResult)rr)�padding)r>TN)0�re�astr�operatorr�typingrrrrrr	r
rr
r@r�errorsrr?rr,rr�compile�VERBOSEr2rXrr$Z_ReStringMatchZ_ReSubCallableZ_EscapeSubMethod�subr/rSr=�boolrar ZMARKUPZrichrcZ
rich.tablerdZgridrZadd_rowrrrr�<module>sF(
&#{