Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
markup.cpython-313.pyc95 linesDownload Raw Back to __pycache__
1�

2�j� ��t�SSKrSSKJr SSKJr SSKJrJrJrJ	r	J3r4JrJrJ
r
 SSKJr SSKJr SSKJr SS	KJr SS5KJrJr \R0"S\R25r\R0"S5r"S
S\65r\	\r\\/\4r\\\/\4r \R0"S5RB4S\S\ S\4Sjjr"S\S\\\#\\\\44Sjr$S!S\S\
\\4S\%S\\S\47Sjjr&\'S:XaB/SQr(SSK)J*r* SSK+J,r, \,"SSSS 9r-\(Hr.\-R_\"\.5\.5 M \*"\-5 gg)"�N)�literal_eval)�8attrgetter)�Callable�Iterable�List�Match�9NamedTuple�Optional�Tuple�Union�)�_emoji_replace)�EmojiVariant)�MarkupError)�Style)�Span�Textz((\\*)\[([a-z#/@][^[]*?)])z^([\w.]*?)(\(.*?\))?$c�^�\rSrSr%Sr\\S'\\\S'S\4Sjr\	S\4Sj5r10Srg	)11�Tag�zA tag in console markup.�name�12parameters�returnc�j�URcUR$URSUR3$)N� �rr��selfs �QD:\code\apps\devtools\python\user_packages\Python313\site-packages\rich/markup.py�__str__�Tag.__str__s3�����0�D�I�I�	13�9=����1�T�_�_�DU�6V�	14�c�v�URcSURS3$SURSURS3$)z*Get the string representation of this tag.�[�]�=rrs r�markup�15Tag.markup!sG��16���&���	�	�{�!��	17��T�Y�Y�K�q���� 1��3�	18r"�N)�__name__�19__module__�__qualname__�__firstlineno__�__doc__�str�__annotations__r20r �propertyr'�__static_attributes__r)r"rrrsA��"�21
�I�$���
��3�22��23�24�25��26��27r"rz(\\*)(\[[a-z#/@][^[]*?])r'�_escaperc��S[[S[4SjnU"X 5nURS5(aURS5(dUS-$U$)z�Escapes text so that it won't be interpreted as markup.28 29Args:30    markup (str): Content to be inserted in to markup.31 32Returns:33    str: Markup with square brackets escaped.34�matchrc�8�UR5upUUSU3$)z!Called by re.sub replace matches.�\)�groups)r5�backslashes�texts   r�escape_backslashes�"escape.<locals>.escape_backslashes=s%��!�L�L�N�����{�m�2�d�V�4�4r"r7z\\)rr/�endswith)r'r3r;s   r�escaper>0sR��5�%��*�5��5�35�'�
0�F�
���t���V�_�_�V�%<�%<���}���Mr"c#��# �Sn[n[n[RU5H�nUR	5upVnUR5up�X�:�aX�XS4v� U(aIU"[
U5S5up�U36(aUSU37-S4v� X�S--
nU(aX�[
U5SS4v� U	nM�URS5up�nUSU"X�(aUOS54v� U	nM� U[
U5:a38XUSS4v� gg7f)z�Parse markup in to an iterable of tuples of (position, text, tag).39 40Args:41    markup (str): A string containing console markup42 43rN�r7r&)�divmodr�RE_TAGS�finditerr8�span�len�	partition)r'�position�_divmod�_Tagr5�	full_text�escapes�tag_text�start�endr9�escapedr:�equalsrs               r�_parserQIs
����H��G��D��!�!�&�)��',�|�|�~�$�	�H��Z�Z�\�44������/��5�5��#*�3�w�<��#;� �K���T�K�/��5�5��q��(����s�7�|�~�6��<�<����#+�#5�#5�c�#:� ��j��T�4��F�j��E�E�E���%*�&�#�f�+���x�y�)�4�/�/��s�C3C5�style�emoji�
emoji_variantc�T^^�[nSU;a[U(a	U"XS9US9$UUS9$[US9nURn[Rn/mTR45m/nURn	[n46[nS[S[[[44UU4Sjjn[U5GH�up�nUb+URSS5nU"U(aU"U5OU5 M5UcM:URRS	5(GaIURS47SR5nU(aU"U5nU"U5unnOT"5unnURRS5(a�UR((a~SnUR(R5n[*R-U5nUbUR/5unnUcSOUn[1U5nU(aU[9U[:5(aUOU44nOSnU	"U48"U[=U5[URU0S955 GMU	"U49"U[=U5[U555 GM�U"U"UR5UR(5nTR[=U5U45 GM� [=U5nT(a>TR5unn[U5nU(aU	"U50"UUU55 T(aM>[?USSS2[AS5S9Ul!U$![ a [#SUR$SU
S
35Sef=f![&a [#SU
S35Sef=f![2a/n[#SU<SUR(<SUR435eSnAf[6a"n[#SUR(<SU35SeSnAff=f)a�Render console markup in to a Text instance.51 52Args:53    markup (str): A string containing console markup.54    style: (Union[str, Style]): The style to use.55    emoji (bool, optional): Also render emoji code. Defaults to True.56    emoji_variant (str, optional): Optional emoji variant, either "text" or "emoji". Defaults to None.57 58 59Raises:60    MarkupError: If there is a syntax error in the markup.61 62Returns:63    Text: A test instance.64r$)�default_variant)rR�65style_namerc�>�[[T5S5H#unup#URU:XdMT"U*5s $ [U5e)z"Pop tag matching given style name.r
)�	enumerate�reversedr�KeyError)rW�index�_�tag�pop�style_stacks    ��r�	pop_style�render.<locals>.pop_style�sE���(��+�)>��B�O�E�8�A��x�x�:�%��E�6�{�"� C��z�"�"r"Nz\[�/r
z
closing tag 'z' at position z doesn't match any open tagzclosing tag '[/]' at position z has nothing to close�@�z()zerror parsing z in z; r))�meta�����rM)�key)"rr�appendr�	normalizer_rrr/r�intrQ�replacer�66startswith�stripr[rr'�67IndexErrorr�68RE_HANDLERr5r8r�SyntaxError�msg�	Exception�69isinstance�tuplerE�sortedr�spans)r'rRrSrT�
emoji_replacer:rirjrw�append_span�_SpanrIrarG�70plain_textr^rWrM�open_tag�handler_namer�
handler_match�match_parameters�meta_params�error�normalized_tag�text_lengthr_r`s                           @@r�renderr�js����*#�M�71�&���DI�M�&�@��72�	73�OU��74�	75��e��D�
�[�[�F����I�)+�K�76�/�/�C��E��,�,�K��E��D�#�c�#�e�C��H�o�#�#�&,�F�^�!��c��!�#�+�+�E�3�7�J���=��,�:�F�
�_��x�x�"�"�3�'�'� �X�X�a�b�\�/�/�1�77��!*�:�!6�J�$�*3�J�*?���x�$�*-�%���x��=�=�+�+�C�0�0��*�*�')��%-�%8�%8�%>�%>�%@�78�(2�(8�(8��(D�
�(�4�=J�=Q�=Q�=S�:�L�*:�(8�(@��FV�'�	(�*6�z�*B�K�(� ,�#-�k�5�#A�#A�!,�&1�^�	+�K��')����!�3�t�9�e�(�-�-��9U�.V��� ��e�S��Y��H�
� F�G�"&�i����&9�3�>�>�!J���"�"�C��I�~�#>�?�I&4�L�d�)�K�79� �_�_�&�80��s��C������e�[�%�8�9�	�+���d��d���G�)<�=�D�J��K��C$�$�)�+�C�J�J�<�~�h�Z�Oj�k��#�$�$��&�$�)�<�X�J�F[�\��#�$�$��$ +��"-�"0���d�8�CV�CV�BY�Y[�\a�\e�\e�[f� g�#��� )�(�"-�"0��1D�1D�0G�r�%�� Q�#�#'�(��(�s<�+K;�881L&�M�;(L#�&M�82N'�*M8�8
N'�N"�"N'�__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)�Table�Markup�Result)rr
)�padding)reTN)0�re�astr�operatorr�typingrrrrr	r83rrrrSr�errorsrrRrr:rr�compile�VERBOSErBrprr/�_ReStringMatch�_ReSubCallable�_EscapeSubMethod�subr>rkrQ�boolr�r*�MARKUP�richr��84rich.tabler��gridr'�add_rowr)r"r�<module>r�s���	���V�V�V�*�����85�*�*�%��J�J���86�Z�Z�0�
1�87�88�*�89�.�s����>�*�C�/�0���^�S�1�3�6�7��90!#�91�92�+F� G� K� K����
��	��20�3�0�8�E�#�x��}�h�s�m�*K�$L�M�0�F "��,0�	}��}���e���}��}��L�)�	}�9394�}�@�z���F�� ���8�V�4�D������T�&�\�6�*��95�$�K�#r"
codekingpro/portable-devtools · Team Ai