
     f\                     \   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'm(Z( ddl)m*Z*m+Z+ ddl,m-Z-m.Z. d Z/d Z0d Z1d Z2d Z3d Z4 G d dej5                  Z5ej6        fdZ7dS )z
    pygments.cmdline
    ~~~~~~~~~~~~~~~~

    Command line interface.

    :copyright: Copyright 2006-2022 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TerminalTrueColorFormatter)get_all_filtersfind_filter_class)get_all_stylesget_style_by_namec                 Z   i }| s|S | D ]}|                                 s|                    d          }|D ]r}|                                 }	 |                    dd          \  }}|                                 }|                                 }|||<   ^# t          $ r d||<   Y ow xY w|S )N,=   T)stripsplit
ValueError)o_strsoptso_stro_argso_argo_keyo_vals          _/var/www/api.educacionweb.es/myenv/lib/python3.11/site-packages/pip/_vendor/pygments/cmdline.py_parse_optionsr1   !   s    D  $ ${{}} 	S!! 		$ 		$EKKMME$${{322u $U  # # #"U#		$ Ks   ABB'&B'c                     g }| s|S | D ]\}d|v r?|                     dd          \  }}|                    |t          |g          f           E|                    |i f           ]|S )N:r%   )r'   appendr1   )f_strsfiltersf_strfnamefoptss        r0   _parse_filtersr:   6   s    G  ( (%<< ;;sA..LE5NNE>5'#:#:;<<<<NNE2;''''N    c                 <   	 | dk    rHt          |          }t          d|j        z             t          t          |j                             n| dk    rHt          |          }t          d|j        z             t          t          |j                             nH| dk    rBt          |          }t          d|z             t          t          |j                             dS # t          t          f$ r" t          d| z  t          j
        	           Y d
S w xY 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)whatrC   clss      r0   _print_helprJ   C   s!   7??#D))C)CH4555&%%&&&&[  &t,,C-8999&%%&&&&X#D))C*T1222&%%&&&qJ'   o$3:6666qqs   C$C( (/DDc                 h   | dk    rt                       t          d           t          d           g }t                      D ]T\  }}}}d                    |          dz   ||rdd                    |          z   dz   pdf}|                    |           U|                                 |D ]}t          d	|z             d S | d
k    rt                       t          d           t          d           g }t                      D ]m}t          |          }	d                    |j                  dz   |	|j        r dd                    |j                  z   dz   pdf}|                    |           n|                                 |D ]}t          d	|z             d S | dk    rt                       t          d           t          d           t                      D ]E}
t          |
          }t          d|
z   dz              t          dt          |          z             Fd S | dk    rt                       t          d           t          d           t                      D ]G}
t          |
          }t          d|
z   dz              t          dt          |          z             Fd S d S )Nr=   zLexers:z~~~~~~~z, r3   z(filenames ) z* %s
    %s %sr>   zFormatters:z~~~~~~~~~~~r?   zFilters:z~~~~~~~~z* z    %sstylezStyles:)rB   r   joinr4   sortr   r   aliases	filenamesr   r   r    r!   )rH   infofullnamenamesexts_tupirI   docrC   s              r0   _print_listr[   W   s
   wii(6(8(8 	 	$HeT199U##C'AMDIIdOO;cAGRICKK		 	+ 	+A$)****	+ 	+ 
		mm%'' 	 	C$S))C99S[))C/cm 7B 499S]#;#;;cA7HEGICKK		 	+ 	+A$)****	+ 	+ 
		jj#%% 	6 	6D#D))C$+#$$$(/4445555	6 	6
 
ii"$$ 	6 	6D#D))C$+#$$$(/4445555 

	6 	6r;   c                 (   dd l }i }d| v r&i }t                      D ]\  }}}}|||d||<   ||d<   d| v r?i }t                      D ])}t          |          }	|j        |j        |	d||j        <   *||d<   d| v r;i }t                      D ]%}
t          |
          }d	t          |          i||
<   &||d
<   d| v r;i }t                      D ]%}
t          |
          }d	t          |          i||
<   &||d<   |                    |t          j                   d S )Nr   r=   )rQ   rR   	mimetypeslexersr>   )rQ   rR   rZ   
formattersr?   rZ   r6   rN   styles)jsonr   r   r   rQ   rR   rC   r   r   r    r!   dumprF   stdout)requested_itemsra   resultrS   rT   rU   rR   r]   rI   rZ   rC   s              r0   _print_list_as_jsonrf      s   KKKF/!!5C5E5E 	 	1HeY	 && DNN
  xo%%%'' 	 	C$S))C; ] DNN
  $|?""#%% 	 	D#D))C)#..DJJ !y/!!"$$ 	 	D#D))C)#..DJJ  xIIfcj!!!!!r;   c                 T  & j         r|                                  dS j        rt          dt          z             dS fd}j        3t                      }t                                                    D ]\  }}|r|	                    |           |
                    d           |
                    d           |r!|                     t          j                   dS j        st          ddg           h d	&d
 j        D             }t          &fd|D                       r!|                     t          j                   dS |s&}j        s|D ]}t!          |           nt#          |           dS j        rk |d          s!|                     t          j                   dS j        \  }}	|dvr!|                     t          j                   dS t'          ||	          S t)          j        pg           }
j        pg D ]6}	 |                    dd          \  }	}||
|	<   "# t0          $ r d|
|<   Y 3w xY w|
                    d|
                    d                    }|
                    d|
                    d                    }j        r9t7          j                  }|t8          }t          |j        d                    dS j        rit          j        j         !                                }	 tE          ||          }n# tF          $ r
 t8          }Y nw xY wt          |j        d                    dS j$        }j%        }|Ɖj&        }|s!|                     t          j                   dS j'        sj(        r!|                     t          j                   dS 	 ||
d<   tS          |fi |
}n3# tF          $ r&}t          |t          j                   Y d }~dS d }~ww xY wt          |*                    |pd                     dS j%        !|                     t          j                   dS tW          j,        pg           }t[          j.                  }d }j'        }|r|rd|v r}	 d }d }	d|v r|/                    dd          \  }}	d|	v rd }	|r|	rta          ||	fi |
}nta          |fi |
}n~# tF          $ r'}t          d|t          j                   Y d }~dS d }~ww xY w	 tc          |fi |
}n;# td          tF          f$ r'}t          d|t          j                   Y d }~dS d }~ww xY wd }j(        r_j3        rt          dt          j                   dS j(        }	 ti          |d          5 }|!                                }d d d            n# 1 swxY w Y   n4# tj          $ r'}t          d|t          j                   Y d }~dS d }~ww xY w|stm          |          \  }}|s	 to          ||fi |
}n1# tF          $ r^}j8        r+	 tE          |fi |
}n># tF          $ r t9          d+i |
}Y n&w xY wt          d|t          j                   Y d }~dS Y d }~nd }~wtd          $ r'}t          d|t          j                   Y d }~dS d }~ww xY wnj3        spt          j        j         !                                }|sts          |t          j                  \  }}|s+	 tE          |fi |
}n<# tF          $ r t9          d+i |
}Y n$w xY wn|st          dt          j                   dS |D ]I\  }}	  |j:        |fi | # tF          $ r(}t          d|t          j                   Y d }~ dS d }~ww xY wj;        }j&        }|r|rd|v r}	 d }d }	d|v r|/                    dd          \  }}	d|	v rd }	|r|	rty          ||	fi |
}nty          |fi |
}n~# tF          $ r'}t          d|t          j                   Y d }~dS d }~ww xY w	 tS          |fi |
}n;# td          tF          f$ r'}t          d|t          j                   Y d }~dS d }~ww xY w|r|sJ	 t{          |fi |
}n;# td          tF          f$ r'}t          d|t          j                   Y d }~dS d }~ww xY w	 ti          |d          } n# tj          $ r'}t          d|t          j                   Y d }~dS d }~ww xY w|sjt|          j?                            d d          d!v rt          d+i |
}n;d"t|          j?                            d#d          v rt          d+i |
}nt          d+i |
}t          jC        j         } |s(|r||_D        nt          t          jC                  |_D        |slt          jF        d$v r^|jG        d%v rUt          | |jD        &          } d |_D        	 dd lImJc mKc mL}! |!M                    | d d d'd(          } n# t          $ r Y nw xY w|
                    d)d          }"t          |"          dk    r6t          |t                    r!|"d         }#|"d         }$t          |#|$|          }j3        sH	 t          ||||            |r| T                                 n# |r| T                                 w w xY wdS 	 	 t          j        j         U                                }%|%snY|s ts          |%t          j                  d         }%t          |%|||            t          | d*          r| W                                 	 |r| T                                 dS dS # t          $ r Y |r| T                                 dS dS w xY w# |r| T                                 w w xY w),Nr   uW   Pygments version %s, (c) 2006-2022 by Georg Brandl, Matthäus Chajdas and contributors.c                 |     t           fdt                                                    D                        S )Nc              3   .   K   | ]\  }}|k    |V  d S N ).0kvopts      r0   	<genexpr>z5main_inner.<locals>.is_only_option.<locals>.<genexpr>   s+      GGVaa3hhqhhhhGGr;   )anyvarsitems)ro   argnss   `r0   is_only_optionz"main_inner.<locals>.is_only_option   s<    GGGGtE{{'8'8':':GGGGGGGr;   Lra      rM   -V>   r=   rN   r?   r>   c                 8    g | ]}|                     d           S )s)rstrip)rl   args     r0   
<listcomp>zmain_inner.<locals>.<listcomp>   s"    444SC444r;   c              3       K   | ]}|vV  	d S rj   rk   )rl   r|   allowed_typess     r0   rp   zmain_inner.<locals>.<genexpr>   s(      99Cs-'999999r;   H)r=   r>   r?   r$   r%   T
inencodingencodingoutencoding)r   rN   r@   z.pyr3   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:	COLORTERM)	truecolor24bit256TERM)win32cygwin)TerminalTerminal256)r   F)convertr&   	autoresetwrapescapeinsideflushrk   )Yhelp
print_helpVrB   r   rv   setrr   rs   adddiscardrF   rG   ra   mainrq   r[   rf   r   rJ   r1   OPr'   r(   getNr   r   rQ   Cstdinbufferreadr   r   Safl	INPUTFILEr   get_style_defsr:   Fboolxrsplitr   r   r   rz   open	Exceptionr	   r   gr
   
add_filteror   r   osenvironr   r   r   rc   r   r   platformrC   r   pip._vendor.colorama.initialise_vendorcolorama
initialisewrap_streamImportErrorlen
isinstancer   r   r   closereadlinehasattrr   KeyboardInterrupt)'parserrt   ru   arg_setrm   rn   largsr|   rH   rC   parsed_optsp_optvaluer   r   r=   inpS_opta_optf_optfmtererrF_optsallow_custom_lexer_formatter	lexernamefilenamecodeinfninfpr8   r9   outfnoutfilecolorama_initialiser   leftrightliner   s'    `                                    @r0   
main_innerr      sL   z qw  *,78 	9 	9 	9qH H H H H w%%KK%%'' 	 	DAq A 	cj)))1 z 	"dAAA44EG4449999599999 	cj)))1 	"!Ez 	' ! !C    !  &&&q w '~c"" 	cj)))1W
d777cj)))14&&& !B//K B & &	&++c1--KD% !&K  	& 	& 	&!%K	& {z/J/JKKJ//-1L1LMMK w -eg66=EemAq w i##%%	
;;;EE 	 	 	EEE	 	emAq GEGE 	cj)))17 	eo 	cj)))1	#(K )%??;??EE 	 	 	#CJ''''11111	 	e""5;B//000q w#*%%%q EGMr**F $(==  E I ' 	EY,>,>)##%.%5%5c1%=%=NHd}}  $ K K04 @ @3>@ @EE 1JJkJJE    h#*5555qqqqq))CC{CC/   h#*5555qqqqq
 D 27 	Iz# # # #1	dD!! #Tyy{{# # # # # # # # # # # # # # # 	 	 	.#*EEEE11111	  	2+D11D*  	.tTII[II    7 9 +D @ @K @ @( 9 9 9 ) 8 8K 8 89 (Ccj999911111   h#*5555qqqqq	  W  y$$&& 	K9$	JJD* 	11#D88K88  1 1 1!00K001	1  	Kz# # # #1   u	EU,,e,,,, 	 	 	(Ccj1111111111	
 GEGE ' 	EUNN%<<%*\\#q%9%9NHd}}# K K4Xt D D7BD DEE 5UJJkJJE    h#*5555qqqqq-eCC{CC/   h#*5555qqqqq  $ 	25HHKHH/   h#*5555qqqqq	5$''GG 	 	 	/3:FFFF11111	  	9z~~k"--1GGG2AA[AA"*..4444,;;{;;)88K88*#  ; 	;'ENN /sz::EN  OS\%888z000(5>JJJ	OIIIIIIIIIIII *55TU 6 O OGG  	 	 	D	 ??>266L
<A*UN"C"CAQ"466 7  	 dE5'222      q	 $y'0022 ! J5dCIFFqID$ug6667G,, $MMOOO$        ! 	 	 	     	    s  H33IIL L+*L+4O 
O7O22O7AS 
S=S88S=T U UU V= V1%V= 1V55V= 8V59V= =
W.W))W.X 
Z/"Y;*X87Y;8YY;YY;;Z/Z**Z/?\ \&%\&]  
^*^^,A_4 4
`%>`  `%)`7 7a/a**a/7b b=b88b=c 
dc>>d$h 
hhj+ +k
B m% %
n/n 
nn n'c                       e Zd ZddZdS )HelpFormatterrw      Nc                     |-	 t          j                    j        dz
  }n# t          $ r Y nw xY wt          j                            | ||||           d S )Nrw   )shutilget_terminal_sizecolumnsr   argparser   __init__)selfprogindent_incrementmax_help_positionwidths        r0   r   zHelpFormatter.__init__  sz    =022:Q>   ''d4D(95	B 	B 	B 	B 	Bs     
--)rw   r   N)__name__
__module____qualname__r   rk   r;   r0   r   r     s.        B B B B B Br;   r   c                    d}t          j        |dt                    }|                    d          }|                                }|                    ddd           |                    d	d
d           |                    dddd           |                    ddd           |                    dddd           |                    dddd           |                    ddd           |                    ddd !           |                    d"          }|                    d#d
d$           |                    d%d
d&           |                    d'd
d(           |                    d)d*dd
+           |                    d,          }|                                }|                    d-d.d/           |                    d0d1d2d34           |                    d5d6d7           |                    d8d
d9           |                    d:d;d<d=d>?           |                    d@d
dA           |                    dBdCd
dD           |                    dEdFdG           |                    | dHdI                   }	 t          ||          S # t          $ r Y dJS t          $ r |j
        rt          t          j        K           t          dLt          j        K           t          dMt          j        K           t          dNt          j        K           t          dOt          j        K           t          dLt          j        K           t          t          j        K            dJdIl}	 |	j        t          j                     }
|
dP                                         }t%          |
          dQk    rA|dR|
dS                             dT          dJ                                         dHdI         z  z  }t          t          j        K           t          dUt          j        K           t          |t          j        K           t          dVt          j        K           Y dHS w xY 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]r4   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	FORMATTERzSpecify 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=valuezGive 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*WHATzList 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FILENAMEzGuess 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storerw   )NAMETYPEzrPrint detailed help for the object <name> of type <type>, where <type> is one of "lexer", "formatter" or "filter".)r   r   r   r   rx   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   r@   zA*****************************************************************z3An unhandled exception occurred while highlighting.z9Please report the whole traceback to the issue tracker atz.<https://github.com/pygments/pygments/issues>.   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   BrokenPipeErrorr   rn   rB   rF   rG   	tracebackformat_exceptionexc_infor&   r   r'   )argsdescr   	operationlexerselflagsspecial_modes_groupspecial_modesrt   r
  rS   msgs               r0   r   r     s    MD$5BD D DF ))*:;;I5577HgO  P P P \3  4 4 4 (?  @ @ @ k1  2 2 2 7.  / / /
 nXD  E E E
 lG  I I I 3D  F F F %%&788E	\3  4 4 4 
\C  D D D 
\6  7 7 7 
x '/    
 !3346 6'DDFFM*    
 C<  = = =
 j6  7 7 7
 \/  0 0 0 WA/?C  D D D \)  + + + h|  ! ! ! $$e %   
 d122h''E&%(((   qq   7 	sz""""(,,,,Gz# # # #Mz# # # #Bz# # # #(,,,,sz"""")y)3<>>:2hnnt99>><$r(.."6"6q"9"?"?"A"A!"""EEEC3:-CJ????c
####N:	 	 	 	qq1s   J 
Q2)GQ21Q2)8rD   r   rF   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   r   pip._vendor.pygments.filtersr   r   pip._vendor.pygments.stylesr    r!   r1   r:   rJ   r[   rf   r   r   argvr   rk   r;   r0   <module>r!     s    
			 



         7 7 7 7 7 7 7 7                 P P P P P P P P P P P P P P P P 9 9 9 9 9 9 T T T T T T T TO O O O O O O O O O O O O O F F F F F F h h h h h h h h K K K K K K K K I I I I I I I I  *
 
 
  (06 06 06f*" *" *"XL  L  L ^
B B B B BH* B B B h L L L L L Lr;   