o
    Ëý°jp[  ã                   @   sH  d Z ddlZddlZddlZddlZddlmZ ddlmZm	Z	 ddl
mZmZmZmZmZmZmZ ddlmZmZmZmZmZmZ ddlmZ ddlmZmZ dd	lmZm Z m!Z!m"Z"m#Z# dd
l$m%Z% ddl&m'Z' ddl(m)Z)m*Z* ddl+m,Z,m-Z- dd„ Z.dd„ Z/dd„ Z0dd„ Z1dd„ Z2dd„ Z3G dd„ dej4ƒZ4ej5fdd„Z6dS )z¼
    pygments.cmdline
    ~~~~~~~~~~~~~~~~

    Command line interface.

    :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
é    N)Údedent)Ú__version__Ú	highlight)ÚClassNotFoundÚOptionErrorÚdocstring_headlineÚguess_decodeÚguess_decode_from_terminalÚterminal_encodingÚUnclosingTextIOWrapper)Úget_all_lexersÚget_lexer_by_nameÚguess_lexerÚload_lexer_from_fileÚget_lexer_for_filenameÚfind_lexer_class_for_filename)Ú	TextLexer)ÚLatexEmbeddedLexerÚLatexFormatter)Úget_all_formattersÚget_formatter_by_nameÚload_formatter_from_fileÚget_formatter_for_filenameÚfind_formatter_class)ÚTerminalFormatter)ÚTerminal256Formatter)Úget_all_filtersÚfind_filter_class)Úget_all_stylesÚget_style_by_namec              
   C   sˆ   i }| s|S | D ]9}|  ¡ sq| d¡}|D ]*}|  ¡ }z| dd¡\}}|  ¡ }|  ¡ }W n ty;   d||< Y qw |||< qq|S )Nú,ú=é   T)ÚstripÚsplitÚ
ValueError)Úo_strsÚoptsÚo_strÚo_argsÚo_argÚo_keyÚo_val© r-   ú�/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/pip/_vendor/pygments/cmdline.pyÚ_parse_options!   s&   
ÿ
÷
r/   c                 C   sV   g }| s|S | D ] }d|v r!|  dd¡\}}| |t|gƒf¡ q| |i f¡ q|S )Nú:r"   )r$   Úappendr/   )Úf_strsÚfiltersÚf_strÚfnameÚfoptsr-   r-   r.   Ú_parse_filters6   s   r7   c              	   C   sÀ   zJ| dkrt |ƒ}td|j ƒ tt|jƒƒ W dS | dkr3t|ƒ}td|j ƒ tt|jƒƒ W dS | dkrHt|ƒ}td| ƒ tt|jƒƒ W dS  ttfy_   td|  t	j
d	� Y d
S w )NÚlexerzHelp on the %s lexer:Ú	formatterzHelp on the %s formatter:ÚfilterzHelp on the %s filter:r   z%s not found!©Úfiler"   )r   ÚprintÚnamer   Ú__doc__r   r   ÚAttributeErrorr%   ÚsysÚstderr)Úwhatr>   Úclsr-   r-   r.   Ú_print_helpC   s(   	øüþrE   c                 C   sÎ  | dkrFt ƒ  t dƒ t dƒ g }tƒ D ] \}}}}d |¡d ||r,dd |¡ d p-df}| |¡ q| ¡  |D ]}t d	| ƒ q;d S | d
kr�t ƒ  t dƒ t dƒ g }tƒ D ]#}t|ƒ}	d |j¡d |	|jrudd |j¡ d pvdf}| |¡ qZ| ¡  |D ]}t d	| ƒ q„d S | dkrºt ƒ  t dƒ t dƒ t	ƒ D ]}
t
|
ƒ}t d|
 d ƒ t dt|ƒ ƒ q¡d S | dkrãt ƒ  t dƒ t dƒ tƒ D ]}
t|
ƒ}t d|
 d ƒ t dt|ƒ ƒ qÌd S d S )Nr8   zLexers:z~~~~~~~z, r0   z(filenames ú)Ú z* %s
    %s %sr9   zFormatters:z~~~~~~~~~~~r:   zFilters:z~~~~~~~~z* z    %sÚstylezStyles:)r=   r   Újoinr1   Úsortr   r   ÚaliasesÚ	filenamesr   r   r   r   )rC   ÚinfoÚfullnameÚnamesÚextsÚ_ÚtupÚirD   Údocr>   r-   r-   r.   Ú_print_listW   sd   ÿÿ
ÿÿÿ
ý
ørU   c                 C   s  dd l }i }d| v r"i }tƒ D ]\}}}}|||dœ||< q||d< d| v rAi }tƒ D ]}t|ƒ}	|j|j|	dœ||j< q+||d< d| v r]i }tƒ D ]}
t|
ƒ}d	t|ƒi||
< qJ||d
< d| v ryi }t	ƒ D ]}
t
|
ƒ}d	t|ƒi||
< qf||d< | |tj¡ d S )Nr   r8   )rK   rL   Ú	mimetypesÚlexersr9   )rK   rL   rT   Ú
formattersr:   rT   r3   rH   Ústyles)Újsonr   r   r   rK   rL   r>   r   r   r   r   ÚdumprA   Ústdout)Úrequested_itemsrZ   ÚresultrM   rN   rO   rL   rV   rD   rT   r>   r-   r-   r.   Ú_print_list_as_jsonŠ   sD   ý
ý

ÿ

ÿr_   c           &         s€
  ˆj r	|  ¡  dS ˆjrtdt ƒ dS ‡fdd„}ˆjd urˆtƒ }tˆƒ ¡ D ]\}}|r3| 	|¡ q(| 
d¡ | 
d¡ |rH|  tj¡ dS ˆjsQtdd	gƒ h d
£‰ dd„ ˆjD ƒ}t‡ fdd„|D ƒƒrp|  tj¡ dS |stˆ }ˆjs‚|D ]}t|ƒ qydS t|ƒ dS ˆjr­|dƒs—|  tj¡ dS ˆj\}}	|dvr¨|  tj¡ dS t||	ƒS tˆjp²g ƒ}
ˆjp¸g D ]}z
| dd¡\}	}W n tyÒ   d|
|< Y q¹w ||
|	< q¹|
 d|
 d¡¡}|
 d|
 d¡¡}ˆj�rtˆjƒ}|d u rùt}t|jd ƒ dS ˆj�r*tjj  !¡ }zt"||d�}W n t#�y    t}Y nw t|jd ƒ dS ˆj$}ˆj%}|d u�r‰ˆj&}|�sC|  tj¡ dS ˆj'�sKˆj(�rS|  tj¡ dS z||
d< t)|fi |
¤Ž}W n t#�y| } zt|tjd� W Y d }~dS d }~ww t| *|�p„d¡ƒ dS ˆj%d u�r—|  tj¡ dS t+ˆj,�p�g ƒ}t-ˆj.ƒ}d }ˆj'}|�r,|�rd|v �rz2d }d }	d|v �rÍ| /dd¡\}}	d|	v �rÍd }	|�rÝ|	�rÝt0||	fi |
¤Ž}nt0|fi |
¤Ž}W nE t#�y } ztd|tjd� W Y d }~dS d }~ww z
t1|fi |
¤Ž}W n t2t#f�y+ } ztd|tjd� W Y d }~dS d }~ww d }ˆj(�rñˆj3�r?tdtjd� dS ˆj(}zt4|dƒ�}| !¡ }W d   ƒ n	1 �sXw   Y  W n t5�yz } ztd|tjd� W Y d }~dS d }~ww |�s„t6|ƒ\}}|�sðzt7||fi |
¤Ž}W nŸ t#�yÔ } z5ˆj8�r»z
t"|fi |
¤Ž}W n  t#�yº   td,i |
¤Ž}Y nw td|tjd� W Y d }~dS W Y d }~nbd }~w t2�yï } ztd|tjd� W Y d }~dS d }~ww nAˆj3�s&tjj  !¡ }|�st9|tjƒ\}}|�s%z
t"|fi |
¤Ž}W n t#�y$   td,i |
¤Ž}Y nw n|�s2td tjd� dS |D ]-\}}z|j:|fi |¤Ž W �q4 t#�ya } ztd|tjd� W Y d }~ dS d }~ww ˆj;}ˆj&}|�rë|�rÂd|v �rÂz2d }d }	d|v �rŒ| /dd¡\}}	d|	v �rŒd }	|�rœ|	�rœt<||	fi |
¤Ž}nt<|fi |
¤Ž}W nE t#�yÁ } ztd|tjd� W Y d }~dS d }~ww z
t)|fi |
¤Ž}W n t2t#f�yê } ztd|tjd� W Y d }~dS d }~ww |�r>|�sz
t=|fi |
¤Ž}W n t2t#f�y } ztd|tjd� W Y d }~dS d }~ww zt4|d!ƒ} W n< t5�y= } ztd"|tjd� W Y d }~dS d }~ww |�sZd#t>j? d$d¡v �rSt@d,i |
¤Ž}ntAd,i |
¤Ž}tjBj } |�sn|�rh||_CntDtjBƒ|_C|�sªtjEd%v �rª|jFd&v �rªtG| |jCd'�} d |_Czdd lHmI  mJ  mK}! W n
 tL�yŸ   Y nw |!jM| d d d(dd)�} |
 d*d¡}"tN|"ƒdk�rËtO|tPƒ�rË|"d }#|"d }$tQ|#|$|ƒ}ˆj3�sêztR|||| ƒ W |�rß|  S¡  dS |�ré|  S¡  w w zLz6	 tjj  T¡ }%|%�s÷n|�st9|%tjƒd }%tR|%||| ƒ tU| d+ƒ�r|  V¡  �qíW W |�r |  S¡  dS dS  tW�y6   Y W |�r4|  S¡  dS dS w |�r?|  S¡  w w )-Nr   uW   Pygments version %s, (c) 2006-2021 by Georg Brandl, MatthÃ¤us Chajdas and contributors.c                    s    t ‡ fdd„tˆƒ ¡ D ƒƒ S )Nc                 3   s    � | ]\}}|ˆ kr|V  qd S ©Nr-   )Ú.0ÚkÚv©Úoptr-   r.   Ú	<genexpr>Á   s   € z5main_inner.<locals>.is_only_option.<locals>.<genexpr>)ÚanyÚvarsÚitemsrd   )Úargnsrd   r.   Úis_only_optionÀ   s    z"main_inner.<locals>.is_only_optionÚLrZ   é   rG   ú-V>   r8   rH   r:   r9   c                 S   s   g | ]}|  d ¡‘qS )Ús)Úrstrip©ra   Úargr-   r-   r.   Ú
<listcomp>Õ   s    zmain_inner.<locals>.<listcomp>c                 3   s   � | ]}|ˆ vV  qd S r`   r-   rq   )Úallowed_typesr-   r.   rf   Ö   s   € zmain_inner.<locals>.<genexpr>ÚH)r8   r9   r:   r!   r"   TÚ
inencodingÚencodingÚoutencoding)rv   rH   r;   z.pyr0   zError:z5Error: -s option not usable when input file specifiedÚrbzError: cannot read infile:z7Error: when using -s a lexer has to be selected with -lÚwbzError: cannot open outfile:Ú256ÚTERM)Úwin32Úcygwin)ÚTerminalÚTerminal256)rw   F)Úconvertr#   Ú	autoresetÚwrapÚescapeinsideÚflushr-   )XÚhelpÚ
print_helpÚVr=   r   rl   Úsetrh   ri   ÚaddÚdiscardrA   rB   rZ   Úmainrg   rU   r_   ru   rE   r/   ÚOÚPr$   r%   ÚgetÚNr   r   rK   ÚCÚstdinÚbufferÚreadr   r   ÚSÚaÚfÚlÚ	INPUTFILEr   Úget_style_defsr7   ÚFÚboolÚxÚrsplitr   r   r   ro   ÚopenÚ	Exceptionr   r   Úgr	   Ú
add_filterÚor   r   ÚosÚenvironr   r   r\   rw   r
   Úplatformr>   r   Úpip._vendor.colorama.initialiseÚ_vendorÚcoloramaÚ
initialiseÚImportErrorÚwrap_streamÚlenÚ
isinstancer   r   r   ÚcloseÚreadlineÚhasattrr…   ÚKeyboardInterrupt)&Úparserrj   rk   Úarg_setrb   rc   Úlargsrr   rC   r>   Úparsed_optsÚp_optÚvaluerv   rx   r8   ÚinpÚS_optÚa_optÚf_optÚfmterÚerrÚF_optsÚallow_custom_lexer_formatterÚ	lexernameÚfilenameÚcodeÚinfnÚinfpr5   r6   ÚoutfnÚoutfileÚcolorama_initialiser„   ÚleftÚrightÚliner-   )rt   rj   r.   Ú
main_inner¶   sD  ÿ

€


ÿ

ÿ

ÿ
€þ



ÿ€€þ€þÿ
ÿ€€þÿ€€þôÿýÿ€þ


ÿ€€þ€þ€þ€þÿ
ÿþ
ÿø	ÿýÿý
ÿrÌ   c                   @   s   e Zd Zddd„ZdS )ÚHelpFormatterrm   é   Nc                 C   sF   |d u rz	t  ¡ jd }W n	 ty   Y nw tj | ||||¡ d S )Nrm   )ÚshutilÚget_terminal_sizeÚcolumnsr    ÚargparserÍ   Ú__init__)ÚselfÚprogÚindent_incrementÚmax_help_positionÚwidthr-   r-   r.   rÓ     s   ÿÿzHelpFormatter.__init__)rm   rÎ   N)Ú__name__Ú
__module__Ú__qualname__rÓ   r-   r-   r-   r.   rÍ     s    rÍ   c                 C   s¼  d}t j|dtd�}| d¡}| ¡ }|jdddd� |jd	d
dd� |jddddd� |jdddd� |jddddd� |jddddd� |jdddd� |jddd d!� | d"¡}|jd#d
d$d� |jd%d
d&d� |jd'd
d(d� |jd)d*dd
d+� | d,¡}| ¡ }|jd-d.d/d� |jd0d1d2d3d4� |jd5d6d7d� |jd8d
d9d� |jd:d;d<d=d>d?� |jd@d
dAd� |jdBdCd
dDd� |jdEdFdGd� | | dHdI… ¡}zt||ƒW S  t�y]   |j	�rt
tjdJ� t
dKtjdJ� t
dLtjdJ� t
dMtjdJ� t
dNtjdJ� t
dKtjdJ� t
tjdJ� ‚ dOdIl}	|	jt ¡ Ž }
|
dP  ¡ }t|
ƒdQk�r?|dR|
dS  dT¡dO  ¡ dHdI…  7 }t
tjdJ� t
dUtjdJ� t
|tjdJ� t
dVtjdJ� Y dHS w )Wz(
    Main command line entry point.
    z?Highlight an input file and write the result to an output file.F)ÚdescriptionÚadd_helpÚformatter_classzMain operationz-lÚLEXERz~Specify the lexer to use.  (Query names with -L.)  If not given and -g is not present, the lexer is guessed from the filename.)Úmetavarr†   z-gÚ
store_truez`Guess the lexer from the file contents, or pass through as plain text if nothing can be guessed.)Úactionr†   z-FzFILTER[:options]r1   znAdd a filter to the token stream.  (Query names with -L.) Filter options are given after a colon if necessary.)rà   râ   r†   z-fÚ	FORMATTERzÜSpecify the formatter to use.  (Query names with -L.) If not given, the formatter is guessed from the output filename, and defaults to the terminal formatter if the output is to the terminal or an unknown file extension.z-OzOPTION=value[,OPTION=value,...]zyGive options to the lexer and formatter as a comma-separated list of key-value pairs. Example: `-O bg=light,python=cool`.z-PzOPTION=valuez·Give a single option to the lexer and formatter - with this you can pass options whose value contains commas and equal signs. Example: `-P "heading=Pygments, the Python highlighter"`.z-oÚ
OUTPUTFILEz8Where to write the output.  Defaults to standard output.r™   ú?z5Where to read the input.  Defaults to standard input.)Únargsr†   zOperation flagsz-vzbPrint a detailed traceback on unhandled exceptions, which is useful for debugging and bug reports.z-sa!  Process lines one at a time until EOF, rather than waiting to process the entire file.  This only works for stdin, only for lexers with no line-spanning constructs, and is intended for streaming input such as you get from `tail -f`. Example usage: `tail -f sql.log | pygmentize -s -l sql`.z-xa«  Allow custom lexers and formatters to be loaded from a .py file relative to the current working directory. For example, `-l ./customlexer.py -x`. By default, this option expects a file with a class named CustomLexer or CustomFormatter; you can also specify your own class name with a colon (`-l ./lexer.py:MyLexer`). Users should be very careful not to use this option with untrusted files, because it will import and run them.z--jsonz=Output as JSON. This can be only used in conjunction with -L.)r†   Údefaultrâ   z*Special modes - do not do any highlightingz-SzSTYLE -f formatterzqPrint style definitions for STYLE for a formatter given with -f. The argument given by -a is formatter dependent.z-LÚ*ÚWHATz›List lexers, formatters, styles or filters -- give additional arguments for the thing(s) you want to list (e.g. "styles"), or omit them to list everything.)ræ   rà   r†   z-NÚFILENAMEzªGuess and print out a lexer name based solely on the given filename. Does not take input or highlight anything. If no specific lexer can be determined, "text" is printed.z-CzXLike -N, but print out a lexer name based solely on a given content from standard input.z-HÚstorerm   )ÚNAMEÚTYPEzrPrint detailed help for the object <name> of type <type>, where <type> is one of "lexer", "formatter" or "filter".)râ   ræ   rà   r†   rn   zPrint the package version.z-hz--helpzPrint this help.z-aÚARGzKFormatter-specific additional argument for the -S (print style sheet) mode.r"   Nr;   zA*****************************************************************z3An unhandled exception occurred while highlighting.z9Please report the whole traceback to the issue tracker atz.<https://github.com/pygments/pygments/issues>.r   éÿÿÿÿé   z	
   (f%s)éþÿÿÿÚ
z*** Error while highlighting:z>*** If this is a bug you want to report, please rerun with -v.)rÒ   ÚArgumentParserrÍ   Úadd_argument_groupÚadd_mutually_exclusive_groupÚadd_argumentÚ
parse_argsrÌ   r    rc   r=   rA   rB   Ú	tracebackÚformat_exceptionÚexc_infor#   r­   r$   )ÚargsÚdescr³   Ú	operationÚlexerselÚflagsÚspecial_modes_groupÚspecial_modesrj   rø   rM   Úmsgr-   r-   r.   rŒ     sö   ÿ
þþþþþþþþ
þþþ	ýÿþþþþþþþþÿÿÿ&ÿèrŒ   )7r?   r¤   rA   rÏ   rÒ   Útextwrapr   Úpip._vendor.pygmentsr   r   Úpip._vendor.pygments.utilr   r   r   r   r	   r
   r   Úpip._vendor.pygments.lexersr   r   r   r   r   r   Ú#pip._vendor.pygments.lexers.specialr   Ú%pip._vendor.pygments.formatters.latexr   r   Úpip._vendor.pygments.formattersr   r   r   r   r   Ú(pip._vendor.pygments.formatters.terminalr   Ú+pip._vendor.pygments.formatters.terminal256r   Úpip._vendor.pygments.filtersr   r   Úpip._vendor.pygments.stylesr   r   r/   r7   rE   rU   r_   rÌ   rÍ   ÚargvrŒ   r-   r-   r-   r.   Ú<module>   s4    
$ 3,  O