Team Ai
Datasetpublic

codekingpro/portable-devtools

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

2�jэ��,
�%SSKJr SSKrSSKrSSKrSSKrSSKJrJ	r	 SSK3Jr SSKJ
r
JrJrJrJrJrJrJrJrJrJrJr SSKJr SSKJrJr SSKJr  SS	K!J"r" SS4K#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r- SSK.J/r/ \
(aSS
K0J1r1J2r2J3r3J4r4 SSK5J6r6 SSK7J8r8J9r9 SSK:J;r; SSK<J=r= SSK>J?r?J@r@ SSKAJBrB SSKCJDrD SSKEJFrFJGrG SSKHJrJIrI SSKJJKrK \\LS4rM\R�S:HrOSrP0\,\"5_\-\"SS9_\$\"SS9_\$R�\"SS9_\'\"S S9_\'R.\"SS9_\*R�\"S!S9_\(R�\"SS9_\(R�\"S"S9_\(R�\"SSS#9_\(R�\"S"SS#9_\(R�\"SS9_\(R�\"S!SS$9_\(R�\"S%S9_\(R�\"S%S9_\(R�\"SS9_\(R�\"S&S9_\+\"S'S9\)\"S S9\&R�\"S(S9\&R�\"S"S9\&R�\"SS)9\&R�\"S!SS$9\&R�\"SS)9\&RJ\"S(S9\%\"S%SS#90	ErbS*\cS+'0\,\"5_\-\"S,S9_\$\"SS9_\$R�\"S-S9_\'\"S&S9_\'R.\"S-S9_\*R�\"S.S9_\(R�\"S-S9_\(R�\"S/S9_\(R�\"S-SS#9_\(R�\"S/SS#9_\(R�\"S-S9_\(R�\"S.SS$9_\(R�\"S(S9_\(R�\"S(S9_\(R�\"S-S9_\(R�\"S&S9_\+\"S'S9\)\"S&S9\&R�\"S(S9\&R�\"S/S9\&R�\"SS)9\&R�\"S.SS$9\&R�\"SS)9\&RJ\"S(S9\%\"S%SS#90	ErdS*\cS0'\b\dS1.reS2rf"S3S4\5rg"S5S6\g5rh"S7S8\g5ri\\j\j4rk"S9S:\5rl"S;S<5rm"S=S>\B5rnS�S?jro\pS@:XGaWSSKqrqSSKr\qR�"SASB9rs\sR�SCSDSESF9 \sR�SGSHSISJSSKSL9 \sR�SMSNSOSJSPSQSL9 \sR�SRSSSTSJSUSV9 \sR�SWSX\jSYSSZS[9 \sR�S\S]S^SJSPS_SL9 \sR�S`SaSJSbSPScSd9 \sR�SeSfSgSShSi9 \sR�SjSkSlSSmSi9 \sR�SnSoSSpSqSr9 \sR�SsSt\jSSuSvSw9 \sR�Sx\jSSySzSw9 \sR�5rvSS{KwJ1r1 \1"\vR�\vR�S|9r0\vR�S}:Xa�\R�R�5r}\n"\}\vR�\vR�\vGR\vGR\vGR\vGR\vGR\vGR51S~9	r�Oy\nGR\vR�\vR�\vR�\vGR\vGR\vGR\vGR\vGR\vGR61S9	r�\0GR\�\vGRS�9 gg)��)�annotationsN)�ABC�abstractmethod)�Path)�
TYPE_CHECKING�Any�Dict�Iterable�List�7NamedTuple�Optional�Sequence�Set�Tuple�Type�Union)�Lexer)�get_lexer_by_name�guess_lexer_for_filename)�Style)�get_style_by_name)8�Comment�Error�Generic�Keyword�Name�Number�Operator�String�Token�9Whitespace)�
ClassNotFound�)�Console�ConsoleOptions�
JustifyMethod�RenderResult)�Lines)�Padding�PaddingDimensions)�10loop_first��cell_len)�Color�	blend_rgb)�JupyterMixin)�Measurement)�Segment�Segments)r�	StyleType)�Text.�win32�monokai�white��colorT��dim�cyan�blue�magenta�green)r:�	underline)r:�bold�red�bright_blue�yellow�11bright_red)rB�Dict[TokenType, Style]�12ANSI_LIGHT�bright_black�bright_cyan�bright_magenta�bright_green�	ANSI_DARK)�13ansi_light�	ansi_dark�c�@�\rSrSrSr\SSj5r\SSj5rSrg)	�SyntaxTheme�zBase class for a syntax theme.c��[e)z'Get a style for a given Pygments token.��NotImplementedError)�self�14token_types  �QD:\code\apps\devtools\python\user_packages\Python313\site-packages\rich/syntax.py�get_style_for_token�SyntaxTheme.get_style_for_token��15��"�!�c��[e)zGet the background color.rU�rWs rY�get_background_style� SyntaxTheme.get_background_style�r\r]�N�rX�	TokenType�returnr�rer)	�__name__�16__module__�__qualname__�__firstlineno__�__doc__rrZr`�__static_attributes__rbr]rYrRrRs+��(��"��"��"��"r]rRc�6�\rSrSrSrSSjrS	SjrS17SjrSrg)�PygmentsSyntaxTheme�z.Syntax theme that delegates to Pygments theme.c��0Ul[U[5(a[U5UlOXlURRUl[URS9Ul	g![18a [S5UlNPf=f)N�default��bgcolor)19�_style_cache�20isinstance�strr�_pygments_style_classr"�background_color�_background_colorr�_background_style)rW�themes  rY�__init__�PygmentsSyntaxTheme.__init__�sy��46����e�S�!�!�
J�->�u�-E��*�*/�&�!%�!;�!;�!L�!L���!&�t�/E�/E�!F����
!�
J�->�y�-I��*�
J�s�A)�)B�Bc	�h�URU$![a� URRU5nUSnUSn[	U(aSU-OSU(aSU-OUR21USUSUSS9nO%![a [R"5nOf=fXPRU'U$f=f)	z"Get a style from a Pygments class.r:rs�#z#000000rB�italicrA)r:rsrBr�rA)rt�KeyErrorrw�style_for_tokenrry�null)rWrX�pygments_styler:rs�styles      rYrZ�'PygmentsSyntaxTheme.get_style_for_token�s���	2��$�$�Z�0�0���	2�

�!%�!;�!;�!K�!K�J�!W��'�w�/��(��3���).�#��+�I�-4�C�'�M�$�:P�:P�'��/�)�(�3�,�[�9�����
%��22�23���
%��-2���j�)���!	2�s2��24B1�A:�AB1�:B�B1�B�B1�0B1c��UR$�N�rzr_s rYr`�(PygmentsSyntaxTheme.get_background_style�����%�%�%r])ryrzrwrtN)r{zUnion[str, Type[PygmentsStyle]]re�Nonercrf�	rgrhrirjrkr|rZr`rlrbr]rYrnrn�s��8�G��,&r]rnc�6�\rSrSrSrSSjrS	SjrS25SjrSrg)�ANSISyntaxTheme�z$Syntax theme to use standard colors.c��Xl[R"5Ul[R"5Ul0Ulgr�)�	style_maprr��_missing_stylerzrt)rWr�s  rYr|�ANSISyntaxTheme.__init__�s+��"��#�j�j�l���!&������46��r]c��URU$![ac URRn[	U5nUR26nU(aU"U5nUbUnOUSSnU(aMX@RU'Us$f=f)zLook up style in the style map.N�����)rtr�r��get�tupler�)rWrX�	get_style�tokenr��_styles      rYrZ�#ANSISyntaxTheme.get_style_for_token�s���	��$�$�Z�0�0���	����*�*�I��*�%�E��'�'�E��"�5�)���%�"�E���c�r�27���%�-2���j�)��L�	�s��AA>�+A>�=A>c��UR$r�r�r_s rYr`�$ANSISyntaxTheme.get_background_style�r�r])rzr�rtr�N)r�rGrer�rcrfr�rbr]rYr�r��s��.�7��(&r]r�c�F�\rSrSr%SrS\S'S\S'S\S'SrS	\S28'Srg)
�_SyntaxHighlightRange��z�29A range to highlight in a Syntax object.30`start` and `end` are 2-integers tuples, where the first integer is the line number31(starting from 1) and the second integer is the column index (starting from 0).32r4r��SyntaxPosition�start�endF�bool�style_beforerbN)rgrhrirjrk�__annotations__r�rlrbr]rYr�r��s%�������	���L�$�r]r�c�,�\rSrSrSrSSjrSSjrSrg)	�PaddingProperty��z"Descriptor to get and set padding.c��UR$)zSpace around the Syntax.)�_padding)rW�obj�objtypes   rY�__get__�PaddingProperty.__get__�s���|�|�r]c�:�[R"U5Ulgr�)r)�unpackr�)rWr��paddings   rY�__set__�PaddingProperty.__set__�s���~�~�g�.��r]rbN)r��Syntaxr�zType[Syntax]rezTuple[int, int, int, int])r�r�r�r*rer�)rgrhrirjrkr�r�rlrbr]rYr�r��s��,��/r]r�c�6�\rSrSr%SrS\S'S\S'\S!Sj5r\SSS	S33S34S35SSS36SSS
.S"Sjjr	\37"5r\SS38\SSS39S	S40S41SSS42SS4S#Sjj5r\S$S%Sjj5r
S&SjrS'Sjr\S(Sj5r\S)Sj5rS$S*SjjrS+S,SjjrS-S.Sjjr\S/Sj5rS0SjrS1SjrS2SjrS3SjrS4SjrS5SjrS rg43)6r���a`Construct a Syntax object to render syntax highlighted code.44 45Args:46    code (str): Code to highlight.47    lexer (Lexer | str): Lexer to use (see https://pygments.org/docs/lexers/)48    theme (str, optional): Color theme, aka Pygments style (see https://pygments.org/docs/styles/#getting-a-list-of-available-styles). Defaults to "monokai".49    dedent (bool, optional): Enable stripping of initial whitespace. Defaults to False.50    line_numbers (bool, optional): Enable rendering of line numbers. Defaults to False.51    start_line (int, optional): Starting number for line numbers. Defaults to 1.52    line_range (Tuple[int | None, int | None], optional): If given should be a tuple of the start and end line to render.53        A value of None in the tuple indicates the range is open in that direction.54    highlight_lines (Set[int]): A set of line numbers to highlight.55    code_width: Width of code to render (not including line numbers), or ``None`` to use all available width.56    tab_size (int, optional): Size of tabs. Defaults to 4.57    word_wrap (bool, optional): Enable word wrapping.58    background_color (str, optional): Optional background color, or None to use theme color. Defaults to None.59    indent_guides (bool, optional): Show indent guides. Defaults to False.60    padding (PaddingDimensions): Padding to apply around the syntax. Defaults to 0 (no padding).61zType[PygmentsStyle]rwrR�_themec��[U[5(aU$U[;a[[U5nU$[	U5nU$)zGet a syntax theme instance.)rurR�RICH_SYNTAX_THEMESr�rn)�cls�namer{s   rY�	get_theme�Syntax.get_themesG���d�K�(�(��K��%�%�#�$6�t�$<�=�E���(��-�E��r]Fr#N�r)r{�dedent�line_numbers�62start_line�63line_range�highlight_lines�64code_width�tab_size�	word_wraprx�
indent_guidesr�c�f�XlX lX@lXPlX`lXplU=(d65 [
5UlX�lX�l	X�l66X�lU(a	[US9O	[5Ul
X�l[R "U5UlUR%U5Ul/Ulg)Nrr)�code�_lexerr�r�r�r��setr�r�r�r�rxr�background_styler�r)r�r�r�r��_stylized_ranges)rWr��lexerr{r�r�r�r�r�r�r�r�rxr�r�s               rYr|�Syntax.__init__s���$�	�����(��$��$��.�7�#�%���$�� �
�"�� 0��/?�E�*�+�U�W�	
��+�����w�/��
��n�n�U�+���=?��r]zutf-8c��[U5RUS9nU(dURUUS9nU"UUUUUUUU	U67UUU
UUS9$)a�Construct a Syntax object from a file.68 69Args:70    path (str): Path to file to highlight.71    encoding (str): Encoding of file.72    lexer (str | Lexer, optional): Lexer to use. If None, lexer will be auto-detected from path/file content.73    theme (str, optional): Color theme, aka Pygments style (see https://pygments.org/docs/styles/#getting-a-list-of-available-styles). Defaults to "emacs".74    dedent (bool, optional): Enable stripping of initial whitespace. Defaults to True.75    line_numbers (bool, optional): Enable rendering of line numbers. Defaults to False.76    start_line (int, optional): Starting number for line numbers. Defaults to 1.77    line_range (Tuple[int, int], optional): If given should be a tuple of the start and end line to render.78    highlight_lines (Set[int]): A set of line numbers to highlight.79    code_width: Width of code to render (not including line numbers), or ``None`` to use all available width.80    tab_size (int, optional): Size of tabs. Defaults to 4.81    word_wrap (bool, optional): Enable word wrapping of code.82    background_color (str, optional): Optional background color, or None to use theme color. Defaults to None.83    indent_guides (bool, optional): Show indent guides. Defaults to False.84    padding (PaddingDimensions): Padding to apply around the syntax. Defaults to 0 (no padding).85 86Returns:87    [Syntax]: A Syntax object that may be printed to the console88)�encoding)r�)r{r�r�r�r�r�r�r�r�rxr�r�)r�	read_text�guess_lexer)r��pathr�r�r{r�r�r�r�r�r�r�r�rxr�r�r�s                 rY�	from_path�Syntax.from_path?sh��R�D�z�#�#�X�#�6����O�O�D�t�O�4�E������%�!�!�+�!���-�'��89�	90r]c��SnSnU(a[X5nU(dS[RR	U5upVU(a*URS5R
5n[U5nU(a.UR(aURSnU$URnU$![a N�f=f![a NSf=f)aMGuess the alias of the Pygments lexer to use based on a path and an optional string of code.91If code is supplied, it will use a combination of the code and the filename to determine the92best lexer to use. For example, if the file is ``index.html`` and the file contains Django93templating syntax, then "html+django" will be returned. If the file is ``index.html``, and no94templating language is used, the "html" lexer will be used. If no string of code95is supplied, the lexer will be chosen based on the file extension..96 97Args:98    path (AnyStr): The path to the file containing the code you wish to know the lexer for.99    code (str, optional): Optional string of code that will be used as a fallback if no lexer100        is found for the supplied path.101 102Returns:103    str: The name of the Pygments lexer that best matches the supplied path/code.104Nrq�.r)105rr"�osr��splitext�lstrip�lowerr�aliasesr�)r�r�r�r��106lexer_name�_�ext�	extensions        rYr��Syntax.guess_lexer~s���""&���107��
�0��<���
����)�)�$�/���� #�108�109�3�� 5� 5� 7�I�-�i�8�E���}�}�"�]�]�1�-�110���#�Z�Z�111����%!�
��
��!�
��
�s#�B)�AB9�)112B6�5B6�9113C�Cc�T�URR5UR-nU$)zGet the base style.)r�r`r�)rW�
default_styles  rY�_get_base_style�Syntax._get_base_style�s%�����8�8�:�T�=R�=R�R�
��r]c�P�URRU5nUR$)z�Get a color (if any) for the given token.114 115Args:116    token_type (TokenType): A token type tuple from Pygments.117 118Returns:119    Optional[Color]: Color from theme, or None for no color.120)r�rZr:)rWrXr�s   rY�_get_token_color�Syntax._get_token_color�s"�����/�/�121�;���{�{�r]c��[UR[5(aUR$[URSSURS9$![122a gf=f)z�The lexer for this syntax, or None if no lexer was found.123 124Tries to find the lexer by name if a string was passed to the constructor.125FT��stripnl�ensurenl�tabsizeN)rur�rrr�r"r_s rYr��Syntax.lexer�sY���d�k�k�5�)�)��;�;��	�$�������
�
�	�
���	��	�s�A
�
126A�Ac�.�[SSSURS9$)z;A Pygments Lexer to use if one is not specified or invalid.�textFTr�)rr�r_s rY�
default_lexer�Syntax.default_lexer�s!��!�����M�M�	127�	128r]c�^^^^	^129^�UR5nUR(aSOSn[UUURUR(+S9nUR130RmUR=(d URmTcURT5 O�U(a0Uum131m	SUU4SjjmS	UU	U132U4SjjnURU"55 O*URU4SjTRT555 URbURSUR35 UR(aURU5 U$)133z�Highlight code and return a Text instance.134 135Args:136    code (str): Code to highlight.137    line_range(Tuple[int, int], optional): Optional line range to highlight.138 139Returns:140    Text: A text instance containing highlighted syntax.141rq�left)�justifyr�r��no_wrapc3�># �T(deTRT5H3upU(dMURS5up#nXU-4v� U(aM%M5 g7f)zSplit tokens to one per line.�142N)�143get_tokens�	partition)rXr��144line_token�new_liner�r�s    ��rY�
line_tokenize�'Syntax.highlight.<locals>.line_tokenize�sS���� �L�5�-2�-=�-=�d�-C�)�145�#�e�:?�/�/�$�:O�7�J�%�",�8�.C�"C�C�$�e�.D�s�%A�#A�Ac3�p># �[T	"55nSnT(aTS-146OSnX:a6[U5up4US4v� URS5(aUS-
nX:aM6UH?upTUT"U54v� URS5(dM)US-
nT(dM7UT:�dM? g g![a MSf=f7f)zConvert tokens to spans.rr#Nr�)�iter�next�
StopIteration�endswith)147�tokens�line_no�_line_start�_token_typer�rX�_get_theme_style�line_end�148line_startrs149      ����rY�tokens_to_spans�)Syntax.highlight.<locals>.tokens_to_spanss�����!�-�/�2�F��G�4>�*�q�.�A�K�"�/�"�15�f��.�K� %�d�m�+� �>�>�$�/�/�#�q�L�G�"�/�.4�)�150�$�&6�z�&B�C�C� �>�>�$�/�/�#�q�L�G�'�x�G�x�,?� %�.4��
 -�"�!�"�s?�&B6�
B%�&B6�'B6�151 152B6�B6� B6�%153B3�/B6�2B3�3B6c3�<># �UHupUT"U54v� M g7fr�rb)�.0rXr�rs   �rY�	<genexpr>�#Syntax.highlight.<locals>.<genexpr>s&����#�-C�)�154��,�Z�8�9�-C�s�zon )rezIterable[Tuple[Any, str]])rez%Iterable[Tuple[str, Optional[Style]]])r��transparent_backgroundr5r�r�r�rZr�r��append�
append_tokensr�rx�stylizer��_apply_stylized_ranges)rWr�r��155base_styler�r�rrr�rr
rs `     @@@@@rY�	highlight�Syntax.highlight�s#����)�)�+�156�#�:�:�I��	�����]�]����&�	157�� �;�;�:�:���158�159�0�d�0�0���=��K�K����(2�$�160�H�D�D�&�&�.�"�"�?�#4�5��"�"�#�-2�-=�-=�d�-C�#���$�$�0����s�4�#8�#8�"9�:�;�� � ��'�'��-��r]c�N�URR[XX455 g)a�161Adds a custom style on a part of the code, that will be applied to the syntax display when it's rendered.162Line numbers are 1-based, while column indexes are 0-based.163 164Args:165    style (StyleType): The style to apply.166    start (Tuple[int, int]): The start of the range, in the form `[line number, column index]`.167    end (Tuple[int, int]): The end of the range, in the form `[line number, column index]`.168    style_before (bool): Apply the style before any existing styles.169N)r�rr�)rWr�r�r�r�s     rY�
stylize_range�Syntax.stylize_range+s"��"	
���$�$�!�%��B�	170r]c���URR5UR-nURnUbUR(a[171R"5$UR[R5nUbUR(aU=(d [172R"5$[UR5UR5US9n[173R"U5$)N)�174cross_fade)
r�r`r�rs�is_system_definedr.rqr�r r5r/�
get_truecolor�from_triplet)rW�blendr�rx�foreground_color�	new_colors      rY�_get_line_numbers_color�Syntax._get_line_numbers_color@s����;�;�;�;�=��@U�@U�U��+�3�3���#�'7�'I�'I��=�=�?�"��0�0����<���#�'7�'I�'I�#�6�u�}�}��6���*�*�,��*�*�,��175�	�176�!�!�)�,�,r]c��SnUR(aA[[URURRS5-55[-nU$)z?Get the number of characters used to render the numbers column.rr�)r��lenrvr�r��count�NUMBERS_COLUMN_DEFAULT_PADDING)rW�column_widths  rY�_numbers_column_width�Syntax._numbers_column_widthOsJ��������C����$�)�)�/�/�$�*?�?�@�A�0�1�
��r]c177��UR5nUR(a2[R"5[SS9[R"54$URS;a�[R178"UURR[R5[UR5S9UR5n[R179"UURR[R5[SURS5S9UR5nOU[SS9-nU[SS9-nX#U4$)z>Get background, number, and highlight styles for line numbers.Tr;)�256�	truecolorr9g�������?)rBr:F)r�rrr��color_system�chainr�rZr r5r'r�)rW�consoler��number_style�highlight_number_styles     rY�_get_number_styles�Syntax._get_number_stylesZs����/�/�1���2�2��:�:�<��4��%�*�*�,�>�>����#7�7� �;�;� ����/�/��180�181�;��D�8�8�:�;��%�%�	�L�&+�[�[� ����/�/��182�183�;��4�t�'C�'C�C�'H�I��%�%�	&�"�,�e��o�=�L�%5��%�8H�%H�"��/E�E�Er]c��URup4p5XT-nURb5URUR-U-S-n[URU5$URR5nURU-U(a[
SU55OS-nUR(aUS-
n[URU5$)Nr#c3�8# �UHn[U5v� M g7fr�r,)r�lines  rYr�*Syntax.__rich_measure__.<locals>.<genexpr>}s���4�e�d�8�D�>�>�e�s�r)r�r�r.r1r��184splitlines�maxr�)	rWr5�optionsr��rightr�r��width�liness	         rY�__rich_measure__�Syntax.__rich_measure__qs���!�L�L���!��,���?�?�&��O�O�d�&@�&@�@�7�J�Q�N�E��t�9�9�5�A�A��	�	�$�$�&���&�&��
�8=�s�4�e�4�4�1�
F�	�185����Q�J�E��4�5�5�u�=�=r]c#��# �[URX55n[UR5(a%[	X0R5URS9v� gUv� g7f)N�r��pad)r3�_get_syntax�anyr�r)r�)rWr5r@�segmentss    rY�__rich_console__�Syntax.__rich_console__�sJ����D�,�,�W�>�?���t�|�|����(�*>�*>�*@�d�l�l�S�S��N�s�AA!c	#�8186# �UR5RnURupEpgXu-nURc<UR(aUR187UR-188S-189OUR190U-191OURn	[SU	5n	URUR5up�URX�R5nUR(Gd<UR(Gd*UR(GdU192(dURS5 UR5URR[ 5-[#SS9-UR$-n
UR&(a2UR((d!UR+UR,U
S9nSUlU
R(a%UR1X�R3U	S	9S1939Shv�N gUR5UUR3U	SSS9UR$SSS
9nUH
nUShv�N M gUR=(d SunnSnU(a[SUS-1945nUR7SU195S9nUR(aU[9U5:�agUUUnUR&(a�UR((d�UR5URR[ 5-[#SS9-UR$-n
[;S5R=U5R+UR,U
[#SS9-S9R7SSS9nURnUR3U	S	9nUR>R@n[BnU"S5nURD(aSOSnURGU5unnn[IUURJU-5GHXunnUR(a&UR5UUR3SSS9UU(+S9nOP[MUR1USS95n URN(aU /nO"URQU UR196UU(+S9/nUR(a�U"SU-S-U5n![SU5H�un"n#U"(ab[UU5RWUS-1975S-n$U"U5(aU"U[#SS95v� U"U$U5v� OU"SU5v� U"U$U5v� OU!v� U#Shv�N Uv� M� GMAUHn#U#Shv�N Uv� M GM[ gGN?GNN2N7f)zS198Get the Segments for the Syntax object, excluding any vertical/horizontal padding199Nr#rr�Tr;)r��crop)rB)r@r�)rB�heightr�)r�rH�	new_lines)NN)�allow_blankF)r�z> u❱ )rPr�rG�)r�� rPrCr9z  ),r�rr�r�r��	max_widthr.r?�
_process_coder�rr�r��
remove_suffixr�rZrrr�r��200ascii_only�with_indent_guidesr��overflow�render�update�render_lines�splitr*r5�joinr��__contains__r2�legacy_windowsr8�	enumerater��listr��adjust_line_lengthr+rv�rjust)%rWr5r@r�_pad_top�	pad_right�_pad_bottom�pad_left�horizontal_paddingr��201ends_on_nl�processed_coder�r��syntax_lines�syntax_liner��end_line�line_offsetrC�numbers_column_width�render_options�highlight_line�_Segmentr��line_pointerr�r6r7rr<�
wrapped_linesrK�wrapped_line_left_pad�first�wrapped_line�line_columns%                                     rYrI�Syntax._get_syntax�s����"&�!5�!5�!7�!N�!N��59�\�\�2��[�%�1�����&�	�$�$��"�"�T�%?�%?�?�!�C��&�&� �
!����	���J�'�202�%)�%7�%7��	�	�%B�"�203��~�~�n�o�o�>��� � � �����������"�"�4�(��$�$�&��+�+�1�1�'�:�;��D�/�"��'�'�(�
��!�!�'�*<�*<��.�.�t�}�}�E�.�J�� &��
��+�+�"�>�>��.�.�z�.�"B�*����
� '�3�3���N�N��D�&�N�Q��/�/��"� 4� ��$0�K�*�*�*�$0��#���>�,��204�H�����a��a��0�K�*.�*�*�T�z�*�*R���?�?��S��Z�'���+�h�/�E����g�&8�&8��$�$�&��+�+�1�1�'�:�;��D�/�"��'�'�(�
��T�205���e��#�#�D�M�M���e�AT�9T�#�U���t���.�	
� $�9�9�� ���j��9���-�-�:�:�����D�>��&�5�5�t�6��
�#�#�G�,�		206���"�'�u�d�o�o��.K�L�M�G�T��~�~� '� 4� 4��"�)�)��v�)�F�*�2�2�	!5�!�
� ����G��� <�=���?�?�%-�J�M�!�3�3�$�*�4�4�"2�$:� :�	4��%�M�� � �(0��.�.��4�6F�)�%�,6�m�+D�'�E�<��&)�'�l�&8�&8�9M�PQ�9Q�&R�UX�&X��)�'�2�2�"*�<��U�9K�"L�L�"*�;�8N�"O�O�"*�4�1G�"H�H�"*�;��"E�E�3�3�+�+�+�"�N�,E�%2�L�+�+�+�"�N�%2�QM�m�+�^,�,�sI�GT�T�;T�
T�KT�#T�$T�=T�>T�T�T�Tc���URnS/[R"SU[RS9Vs/sHnUR	5S-PM snQ[U5S-PnURH�n[XER5n[XER5nUcM2UcM7UR(aURURXg5 MfURURXg5 M� gs snf)z�207Apply stylized ranges to a text instance,208using the given code to determine the right portion to apply the style to.209 210Args:211    text (Text): Text instance to apply the style to.212rr�)�flagsr#N)
�plain�re�finditer�	MULTILINEr�r*r��#_get_code_index_for_syntax_positionr�r��stylize_beforer�r)rWr�r��match�newlines_offsets�stylized_ranger�r�s        rYr�Syntax._apply_stylized_rangess����z�z��
�	213� �[�[��t�2�<�<�H��H�E����
��!�H��		214�
��I��M�	215��#�3�3�N�7� �"6�"6��E�6� �"4�"4��C�� �S�_�!�.�.��'�'��(<�(<�e�I��L�L��!5�!5�u�B�4��s�C7c���URS5nU(aUOUS-nUR(a[R"U5OUnURUR5nX#4$)aO216Applies various processing to a raw code string217(normalises it so it always ends with a line return, dedents it if necessary, etc.)218 219Args:220    code (str): The raw code string to process221 222Returns:223    Tuple[bool, str]: the boolean indicates whether the raw code ends with a line return,224        while the string is the processed code.225r�)rr��textwrap�226expandtabsr�)rWr�rkrls    rYrV�Syntax._process_code7sW���]�]�4�(�227�!+������/3�{�{�H�O�O�N�+��	�(�2�2�4�=�=�A���)�)r])r�r�r�r�rxr�r�r�r�r�r�r�r�r�r�r�)r��Union[str, SyntaxTheme]rerR)r�rvr�zUnion[Lexer, str]r{r�r�r�r�r�r��intr��-Optional[Tuple[Optional[int], Optional[int]]]r��Optional[Set[int]]r��
Optional[int]r�r�r�r�rx�
Optional[str]r�r�r�r*rer�) r�rvr�rvr�zOptional[Union[Lexer, str]]r{r�r�r�r�r�r�zOptional[Tuple[int, int]]r�r�r�r�r�r�r�r�r�r�rxr�r�r�r�r*rez'Syntax'r�)r�rvr�r�rervrf)rXrdrezOptional[Color])rezOptional[Lexer])rer)r�rvr�r�rer5)F)228r�r4r�r�r�r�r�r�rer�)g333333�?)r$�floatrer.)rer�)r5r$rezTuple[Style, Style, Style])r5z	'Console'r@z'ConsoleOptions'rez
'Measurement')r5r$r@r%rer')r5r$r@r%rezIterable[Segment])r�r5rer�)r�rvrezTuple[bool, str])rgrhrirjrkr��classmethodr��
DEFAULT_THEMEr|r�r�r�r�r�r��propertyr�r�rrr'r.r8rDrLrIrrVrlrbr]rYr�r��s���(/�.����	��	� *7��"��DH�.2�$(���*.�#�%&�!$@��$@�!�$@�229'�$@��
$@��$@��$@�B�$@�,�$@�"�$@��$@��$@�(�$@��$@� #�!$@�"230�#$@�L��G�� �-1�)6��"�04��.2�$(���*.�#�%&�!<231��<232��<233�+�	<234�235'�<236��
<237��<238�.�<239��<240�,�<241�"�<242��<243��<244�(�<245��<246� #�!<247�"248�#<249��<250�|�'��'�R�251 252�����$�253��254�EI�S��S�B�S�255�	S�t#�256��257��258��	259�260�261�262�
263�*
-�����F�.>� �>�+;�>�	�>�$���)7��	��H#��H#� �H#�264�	H#�TC�B*r]r�c��[U5nUup4X2:�d[U5US-:agUS-265nXS-X-266S-267n[Xd5nXU-$)a�268Returns the index of the code string for the given positions.269 270Args:271    newlines_offsets (Sequence[int]): The offset of each newline character found in the code snippet.272    position (SyntaxPosition): The position to search for.273 274Returns:275    Optional[int]: The index of the code string for this position, or `None`276        if the given position's line number is out of range (if it's the column that is out of range277        we silently clamp its value so that it reaches the end of the line)278r#N)r*�min)r��position�lines_count�line_number�column_index�279line_index�line_lengths       rYr�r�Lsm���&�'�K� (��K�� �C�(8�$9�[�1�_�$M���q��J�"��>�2�5E�5Q�Q�TU�U�K��{�1�L��'�,�6�6r]�__main__z&Render syntax to the console with Rich)�descriptionr��PATHzpath to file, or - for stdin)�metavar�helpz-cz
--force-color�force_color�280store_truezforce color for non-terminals)�dest�actionrqr�z-iz--indent-guidesr�Fzdisplay indent guidesz-lz--line-numbersr�zrender line numbers)r�r�r�z-wz--widthrBz*width of output (default will auto-detect))�typer�rqr�z-rz--wrapr�zword wrap long linesz-sz--soft-wrap�	soft_wrapzenable soft wrapping mode)r�r�rqr�z-tz--themer{zpygments theme)r�rqr�z-bz--background-colorrxzOverride background colorz-xz--lexerr�z281Lexer name)rqr�r�z-pz	--paddingr�r))r�rqr�r�z--highlight-linersz)The line number (not index!) to highlight)r$)�force_terminalrB�-)	r�r�r�r�r{rxr�r�r�)r�r�r�r{rxr�r�r�)r�)r�z
Sequence[int]r�r�rer�)��282__future__r�os.pathr�r�sysr��abcrr�pathlibr�typingrrr	r283rrr
rrrrr�pygments.lexerr�pygments.lexersrr�pygments.styler�
PygmentsStyle�pygments.stylesr�pygments.tokenrrrrrrrrr r!�
pygments.utilr"r5r$r%r&r'�rich.containersr(�rich.paddingr)r*�_loopr+�cellsr-r:r.r/�jupyterr0�measurer1�segmentr2r3r�r4r�r5rvrd�platform�WINDOWSr��Preproc�Word�Builtin�Function�	Namespace�Class�	Exception�	Decorator�Variable�Constant�	Attribute�Tag�Deleted�Inserted�Heading�284Subheading�PromptrHr�rMr�r,rRrnr�r�r�r�r�r�r�rg�argparse�ArgumentParser�parser�add_argument�285parse_args�args�rich.consoler�rBr��stdin�readr�r�r�r�r{rxr�r�rs�syntaxr��printr�rbr]rY�<module>r�s���"��	�286��#��
�
�
�
�!�G�1�-����(��M�M�!�3���#�!� �&�#���#�s�(�O�	�287
�,�,�'�288!���
�289&�	�5�7�&���G�$�&��U�t�_�&��O�O�U��(�	&�290�U��
 �&��L�L�%�f�%�
&�
�M�M�5�y�)�&�	�L�L�%�f�%�&�	�M�M�5�w�'�&�	�N�N�E��$�7�&�	�J�J��G�t�4�&�	�N�N�E��'�&�	�N�N�E�	��5�&�	�M�M�5�u�%�&�	�M�M�5�u�%�&� 	�N�N�E��'�!&�"	�H�H�e�-�(�#&�$�E��!�291�E����O�O�U��.����e�'�*��O�O�U��%�����I�D�9��N�N�E�t�$��M�M�5�|�,�	�5�u��-�5&�292�"��:%�	�5�7�%���N�+�%��U�t�_�%��O�O�U��/�	%�293�U��
'�%��L�L�%�m�,�
%�
�M�M�5�/�0�%�	�L�L�%�m�,�%�	�M�M�5�~�.�%�	�N�N�E�
��>�%�	�J�J��N�d�;�%�	�N�N�E�
�.�%�	�N�N�E� 0�t�<�%�	�M�M�5�|�,�%�	�M�M�5�|�,�%� 	�N�N�E�
�.�!%�"	�H�H�e�-�(�#%�$�E��!�294�E�
�&��O�O�U��.����e�.�1��O�O�U��%�����$4�4�@��N�N�E�t�$��M�M�5�|�,�	�5�u��-�5%�	�!��:%/�Y�G��!"��"�#�"�'&�+�'&�T&�k�&�B�s�C�x���295�J�296�/�/�V	*�\�V	*�r7�#�7�/=�7��7�6�z����
�
$�
$�<��F������
+���297�����
���
,�
�������
���
$�
�������
��
"��������
�
��
9�
�������
���
#�
��������
��
(�
������i�g�y�?O��������
��
(���������
�
�������k��Q�Y�Y�������
��
�
8�������D�$��T�%5�%5�T�Z�Z�H�G��y�y�C���y�y�~�~������/�/��*�*��n�n��*�*�!�2�2��,�,��L�L�!�0�0�1�298299���!�!��I�I��/�/��*�*��n�n��*�*�!�2�2��,�,��L�L�!�0�0�1�"�300301���M�M�&�D�N�N�M�3�kr]
codekingpro/portable-devtools · Team Ai