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__/syntax.cpython-310.pyc
o

@%Neri�@sUddlZddlZddlmZddlZddlmZmZddl	m
Z
mZmZm
Z
mZmZmZmZmZddlmZddlmZmZddlmZddlmZdd	lmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'dd
l(m)Z)ddl*m+Z+dd
l,m-Z-m.Z.ddl/m0Z0m1Z1m2Z2m3Z3ddl4m5Z5ddl6m7Z7ddl8m9Z9ddl:mZddl;m<Z<ee=dfZ>e�?�dkZ@dZAie&e��e'edd��eedd��ejBedd��e!edd��e!jedd��e$jCedd��e"jDedd��e"jEedd��e"jFeddd��e"jGeddd��e"jHedd��e"jIeddd��e"jJed d��e"jKed d��e"jLedd��e"jMed!d��e%ed"d�e#edd�e jNed#d�e jOedd�e jPedd$�e jQeddd�e jRedd$�e jed#d�eed dd�i	�ZSee>efeTd%<ie&e��e'ed&d��eedd��ejBed'd��e!ed!d��e!jed'd��e$jCed(d��e"jDed'd��e"jEed)d��e"jFed'dd��e"jGed)dd��e"jHed'd��e"jIed(dd��e"jJed#d��e"jKed#d��e"jLed'd��e"jMed!d��e%ed"d�e#ed!d�e jNed#d�e jOed)d�e jPedd$�e jQed(dd�e jRedd$�e jed#d�eed dd�i	�ZUee>efeTd*<eSeUd+�ZVGd,d-�d-e�ZWGd.d/�d/eW�ZXGd0d1�d1eW�ZYGd2d3�d3e5�ZZe[d4k�rddl\Z\ddl]Z]e\j^d5d6�Z_e_j`d7d8d9d:�e_j`d;d<d=d>dd?d@�e_j`dAdBdCd>dDdEd@�e_j`dFdGdHd>dIdJ�e_j`dKdLeadMddNdO�e_j`dPdQdRd>dDdSd@�e_j`dTdUd>dVdDdWdX�e_j`dYdZd[dd\d]�e_j`d^d_d`ddad]�e_j`dbdcdddedfdg�e_�b�Zcddhldm0Z0e0ecjeecjfdi�Z/ecjgdjk�r�e]jh�i�ZjeZejecjkecjlecjmecjnecjoecjpdk�ZqneZjrecjgecjlecjmecjnecjoecjpdl�Zqe/jseqecjtdm�dSdS)n�N)�Lines)�ABC�abstractmethod)	�Any�Dict�Iterable�List�Optional�Set�Tuple�Type�Union)�Lexer)�get_lexer_by_name�guess_lexer_for_filename)�Style)�get_style_by_name)
�Comment�Error�Generic�Keyword�Name�Number�Operator�String�Token�
Whitespace)�
ClassNotFound�)�
loop_first)�Color�	blend_rgb)�Console�ConsoleOptions�
JustifyMethod�RenderResult)�JupyterMixin)�Measurement)�Segment)�Text.�Windows�monokai�white��colorT��dim�cyan�blue�magenta�green)r.�	underline)r.�bold�red�bright_blue�yellow�
bright_red)r6�
ANSI_LIGHT�bright_black�bright_cyan�bright_magenta�bright_green�	ANSI_DARK)�
ansi_light�	ansi_darkc@s8eZdZdZededefdd��Zedefdd��ZdS)	�SyntaxThemezBase class for a syntax theme.�
token_type�returncC�t�)z'Get a style for a given Pygments token.��NotImplementedError)�selfrD�rJ�9/usr/lib/python3/dist-packages/pip/_vendor/rich/syntax.py�get_style_for_tokenk�zSyntaxTheme.get_style_for_tokencCrF)zGet the background color.rG�rIrJrJrK�get_background_styleprMz SyntaxTheme.get_background_styleN)	�__name__�
__module__�__qualname__�__doc__r�	TokenTyperrLrOrJrJrJrKrChsrCc@sNeZdZdZdeeeefddfdd�Zde	de
fdd	�Zde
fd
d�ZdS)�PygmentsSyntaxThemez.Syntax theme that delegates to Pygments theme.�themerENcCs^i|_t|t�rzt|�|_Wntytd�|_Ynw||_|jj|_t|jd�|_	dS)N�default��bgcolor)
�_style_cache�
isinstance�strr�_pygments_style_classr�background_color�_background_colorr�_background_style)rIrVrJrJrK�__init__ys
�
zPygmentsSyntaxTheme.__init__rDcCs�z|j|WStyOz|j�|�}Wn
ty"t��}Yn%w|d}|d}t|r2d|nd|r9d|n|j|d|d|dd�}||j|<Y|Sw)	z"Get a style from a Pygments class.r.rY�#z#000000r6�italicr5)r.rYr6rcr5)rZ�KeyErrorr]�style_for_tokenr�nullr_)rIrD�pygments_style�styler.rYrJrJrKrL�s(���z'PygmentsSyntaxTheme.get_style_for_tokencC�|jS�N�r`rNrJrJrKrO��z(PygmentsSyntaxTheme.get_background_style)
rPrQrRrSr
r\r�
PygmentsStylerarTrrLrOrJrJrJrKrUvs

rUc@sJeZdZdZdeeefddfdd�Zdedefdd	�Zdefd
d�Z	dS)�ANSISyntaxThemez$Syntax theme to use standard colors.�	style_maprENcCs$||_t��|_t��|_i|_dSrj)rorrf�_missing_styler`rZ)rIrorJrJrKra�s


zANSISyntaxTheme.__init__rDcCsnz|j|WSty6|jj}t|�}|j}|r-||�}|dur%|}n|dd�}|s||j|<|YSw)zLook up style in the style map.N���)rZrdro�get�tuplerp)rIrD�	get_style�tokenrh�_stylerJrJrKrL�s �
�z#ANSISyntaxTheme.get_style_for_tokencCrirjrkrNrJrJrKrO�rlz$ANSISyntaxTheme.get_background_style)
rPrQrRrSrrTrrarLrOrJrJrJrKrn�s
rnc@seZdZUdZeeed<eed<ede	e
efdefdd��Zeddd	d
d
d
ddd
dd�d
e
de	e
e
fde	e
efdedededeeeefdeeedeedededee
dedd
fdd�Zededdd
d	d
d
ddd
dfde
de
de	e
efdededeeeefdedeeedeedededee
deddfdd ��Zdefd!d"�Zd#edeefd$d%�Zedee
fd&d'��Z	
d;d
e
deeeefdefd(d)�Zd<d+edefd,d-�Zedefd.d/��Z d0e!deeeeffd1d2�Z"	0	3	4	5		6d=d7d8�Z#d0e!d4e$de%fd9d:�Z&d
S)>�Syntaxa�Construct a Syntax object to render syntax highlighted code.

    Args:
        code (str): Code to highlight.
        lexer (Lexer | str): Lexer to use (see https://pygments.org/docs/lexers/)
        theme (str, optional): Color theme, aka Pygments style (see https://pygments.org/docs/styles/#getting-a-list-of-available-styles). Defaults to "monokai".
        dedent (bool, optional): Enable stripping of initial whitespace. Defaults to False.
        line_numbers (bool, optional): Enable rendering of line numbers. Defaults to False.
        start_line (int, optional): Starting number for line numbers. Defaults to 1.
        line_range (Tuple[int, int], optional): If given should be a tuple of the start and end line to render.
        highlight_lines (Set[int]): A set of line numbers to highlight.
        code_width: Width of code to render (not including line numbers), or ``None`` to use all available width.
        tab_size (int, optional): Size of tabs. Defaults to 4.
        word_wrap (bool, optional): Enable word wrapping.
        background_color (str, optional): Optional background color, or None to use theme color. Defaults to None.
        indent_guides (bool, optional): Show indent guides. Defaults to False.
    r]�_theme�namerEcCs2t|t�r|S|tvrtt|�}|St|�}|S)zGet a syntax theme instance.)r[rC�RICH_SYNTAX_THEMESrnrU)�clsryrVrJrJrK�	get_theme�s
�zSyntax.get_themeFrN�)rV�dedent�line_numbers�
start_line�
line_range�highlight_lines�
code_width�tab_size�	word_wrapr^�
indent_guides�code�lexerrVr~rr�r�r�r�r�r�r^r�cCst||_||_||_||_||_||_|pt�|_|	|_|
|_	||_
||_|r+t|d�nt�|_
|
|_|�|�|_dS)NrX)r��_lexerr~rr�r��setr�r�r�r�r^r�background_styler�r|rx)rIr�r�rVr~rr�r�r�r�r�r�r^r�rJrJrKra�s�zSyntax.__init__zutf-8�path�encodingcCs�t|d|d��}|��}Wd�n1swYd}d}ztj�|�\}}|r8|�d���}t|�}|j}Wn	t	yBYnw|durYzt
||�j}Wn	t	yXYnw||||||||||	|
|||
d�
S)a?Construct a Syntax object from a file.

        Args:
            path (str): Path to file to highlight.
            encoding (str): Encoding of file.
            theme (str, optional): Color theme, aka Pygments style (see https://pygments.org/docs/styles/#getting-a-list-of-available-styles). Defaults to "emacs".
            dedent (bool, optional): Enable stripping of initial whitespace. Defaults to True.
            line_numbers (bool, optional): Enable rendering of line numbers. Defaults to False.
            start_line (int, optional): Starting number for line numbers. Defaults to 1.
            line_range (Tuple[int, int], optional): If given should be a tuple of the start and end line to render.
            highlight_lines (Set[int]): A set of line numbers to highlight.
            code_width: Width of code to render (not including line numbers), or ``None`` to use all available width.
            tab_size (int, optional): Size of tabs. Defaults to 4.
            word_wrap (bool, optional): Enable word wrapping of code.
            background_color (str, optional): Optional background color, or None to use theme color. Defaults to None.
            indent_guides (bool, optional): Show indent guides. Defaults to False.

        Returns:
            [Syntax]: A Syntax object that may be printed to the console
        �rt)r�NrW�.)rVr~rr�r�r�r�r�r�r^r�)�open�read�osr��splitext�lstrip�lowerrryrr)r{r�r�rVr~rr�r�r�r�r�r�r^r��	code_filer�r��
lexer_name�_�ext�	extensionrJrJrK�	from_pathsH%
�����zSyntax.from_pathcCs|j��|j}|S)zGet the base style.)rxrOr�)rI�
default_stylerJrJrK�_get_base_styleOszSyntax._get_base_stylerDcCs|j�|�}|jS)z�Get a color (if any) for the given token.

        Args:
            token_type (TokenType): A token type tuple from Pygments.

        Returns:
            Optional[Color]: Color from theme, or None for no color.
        )rxrLr.)rIrDrhrJrJrK�_get_token_colorTs	zSyntax._get_token_colorcCs>t|jt�r	|jSzt|jdd|jd�WStyYdSw)z�The lexer for this syntax, or None if no lexer was found.

        Tries to find the lexer by name if a string was passed to the constructor.
        FT)�stripnl�ensurenl�tabsizeN)r[r�rrr�rrNrJrJrKr�`s��zSyntax.lexercs�|��}|jr	dnd}t|||j|jd�}|jj�|j��dur(|���|S|rY|\��dt	t
ttff��fdd��dt	t
tt
tff����fdd	�}|�|��n|��fd
d�����D��|jdurv|�d|j���|S)
aHighlight code and return a Text instance.

        Args:
            code (str): Code to highlight.
            line_range(Tuple[int, int], optional): Optional line range to highlight.

        Returns:
            Text: A text instance containing highlighted syntax.
        rW�left)�justifyrhr��no_wrapNrEc3sH��sJ�����D]\}}|r!|�d�\}}}|||fV|sq
dS)zSplit tokens to one per line.�
N)�
get_tokens�	partition)rDru�
line_token�new_line)r�r�rJrK�
line_tokenize�s����z'Syntax.highlight.<locals>.line_tokenizec3s��t���}d}�d}||kr(t|�\}}|dfV|�d�r$|d7}||ks|D]\}}|�|�fV|�d�rE|d7}|�krEdSq*dS)zConvert tokens to spans.rrNr�)�iter�next�endswith)�tokens�line_no�_line_start�_token_typerurD)�_get_theme_style�line_end�
line_startr�rJrK�tokens_to_spans�s$�


�
��z)Syntax.highlight.<locals>.tokens_to_spansc3s �|]\}}|�|�fVqdSrjrJ)�.0rDru)r�rJrK�	<genexpr>�s
�
�
�z#Syntax.highlight.<locals>.<genexpr>zon )r��transparent_backgroundr)r�r�rxrLr��appendrrrr\r	r�
append_tokensr�r^�stylize)rIr�r��
base_styler��textr�rJ)r�r�r�r�r�r�rK�	highlightss2
��
-� (	�
zSyntax.highlight�333333�?�blendcCsr|j��|j}|j}|dus|jrt��S|�tj	�}|dus#|jr)|p(t��St
|��|��|d�}t�|�S)N)�
cross_fade)
rxrOr�rY�is_system_definedr rWr�rr)r!�
get_truecolor�from_triplet)rIr�r�r^�foreground_color�	new_colorrJrJrK�_get_line_numbers_color�s�
zSyntax._get_line_numbers_colorcCs,d}|jrtt|j|j�d���d}|S)z?Get the number of characters used to render the numbers column.rr��)r�lenr\r�r��count)rI�column_widthrJrJrK�_numbers_column_width�szSyntax._numbers_column_width�consolec	Cs�|��}|jrt��tdd�t��fS|jdvrAt�||j�tj	�t|�
�d�|j�}t�||j�tj	�td|�
d�d�|j�}n|tdd�}|tdd�}|||fS)z>Get background, number, and highlight styles for line numbers.Tr/)�256�	truecolorr-g�������?)r6r.F)r�r�rrf�color_system�chainrxrLrr)r�r�)rIr�r��number_style�highlight_number_stylerJrJrK�_get_number_styles�s&
��
zSyntax._get_number_stylesr"�optionsr#r'cCs0|jdur|j|j}t|j|�St|j|j�Srj)r�r�r'�	max_width)rIr�r��widthrJrJrK�__rich_measure__�s
zSyntax.__rich_measure__c csj�|��j}|jdur|jr|j|jdn|jn|j}d}|jr-|j\}}td|d�}|j�	d�}|r8|jn|jd}	|j
rEt�
|	�n|	}	|	�|j
�}	|�|	|j�}
|�|�\}}}
|js�|js�|js�|sl|
�d�|��|j�t�tdd�|j}|jr�|js�|
j|j
|d�}
d|
_|jr�|j|
|j|d�d	�EdHdS|j|
|j|dd
�|jddd�}|D]}|EdHq�dS|
jd|d�}|jr�|||�}|jr�|js�|��|j�t�tdd�|j}td�� |�j|j
|d�jddd�}|j}|j|d�}|j!j"}t#}|d
|d
|�}|d�}|j$�rdnd}t%||j&|�D]�\}}|j�r;|j||jdd�||d�}nt'|j|dd��}|j(�rL|g}n|j)||j||d�g}|j�r�t*|�D]@\}}|�r�t+|��,|d�d
}||��r�||tdd��V|||
�Vn|d|
�V|||�Vn|V|EdH|V�q`�q$|D]}|EdH|V�q��q$dS)Nrrr�Tr/)rh�crop)r�)r�)r��height)rh�pad�	new_lines)�allow_blank� z> u❱ )r�)rhr��)�endr�r7r-z  )-r�r�r�rr�r�r��maxr�r�r~�textwrap�
expandtabsr�r�r�r��
remove_suffixrxrLrrr�r��
ascii_only�with_indent_guides�overflow�render�update�render_lines�splitr)�joinr��__contains__r(�legacy_windows�	enumerater��listr��adjust_line_lengthrr\�rjust) rIr�r�r�r��line_offsetr��end_line�
ends_on_nlr�r�r�r�r�rh�syntax_lines�syntax_line�lines�numbers_column_width�render_options�highlight_line�_Segment�paddingr��line_pointerr��line�
wrapped_lines�segments�first�wrapped_line�line_columnrJrJrK�__rich_console__�s��

���

�

�����
��
�������
���


�

��zSyntax.__rich_console__rj)r�)r�r"r�r#rEr')'rPrQrRrSrrm�__annotations__rC�classmethodr
r\r|�
DEFAULT_THEMEr�bool�intr	rr
rar�rr�rTr r��propertyr�r)r��floatr�r�r"r�r�r#r%rrJrJrJrKrw�s�
��
�
����	�

���
���
�#���
�����
	�
���
���H���
�L��
����rw�__main__z&Render syntax to the console with Rich)�descriptionr��PATHzpath to file, or - for stdin)�metavar�helpz-cz
--force-color�force_color�
store_truezforce color for non-terminals)�dest�actionrWrz-iz--indent-guidesr�Fzdisplay indent guidesz-lz--line-numbersrzrender line numbers)rrrz-wz--widthr�z*width of output (default will auto-detect))�typerrWrz-rz--wrapr�zword wrap long linesz-sz--soft-wrap�	soft_wrapzenable soft wrapping mode)rrrWrz-tz--themerVzpygments theme)rrWrz-bz--background-colorr^zOverride background colorz-xz--lexerrWr�z
Lexer name)rWrr)r")�force_terminalr��-)r�r�rr�rVr^r�)rr�rVr^r�)r)u�os.pathr��platform�pip._vendor.rich.containersrr��abcrr�typingrrrrr	r
rrr
�pip._vendor.pygments.lexerr�pip._vendor.pygments.lexersrr�pip._vendor.pygments.stylerrm�pip._vendor.pygments.stylesr�pip._vendor.pygments.tokenrrrrrrrrrr�pip._vendor.pygments.utilr�_looprr.r r!r�r"r#r$r%�jupyterr&�measurer'�segmentr(rhr�r)r\rT�system�WINDOWSr�Preproc�Word�Builtin�Function�	Namespace�Class�	Exception�	Decorator�Variable�Constant�	Attribute�Tag�Deleted�Inserted�Heading�
Subheading�Promptr;rr@rzrCrUrnrwrP�argparse�sys�ArgumentParser�parser�add_argumentr
�
parse_args�args�pip._vendor.rich.consolerr�r��stdinr�r�r�rr�rVr^r��syntaxr��printrrJrJrJrK�<module>s�
,0�
�
��
����	�
���
�����

��
�
��
����	�
���
�����

�
*!
:��������
���
�
��