U ʗRep[@sHdZddlZddlZddlZddlZddlmZddlmZm Z ddl m Z m Z m Z mZmZmZmZddlmZmZmZmZmZmZddlmZddlmZmZdd lmZm Z m!Z!m"Z"m#Z#dd l$m%Z%dd l&m'Z'dd l(m)Z)m*Z*dd l+m,Z,m-Z-ddZ.ddZ/ddZ0ddZ1ddZ2ddZ3Gdddej4Z4ej5fddZ6dS)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 OptionErrordocstring_headline guess_decodeguess_decode_from_terminalterminal_encodingUnclosingTextIOWrapper)get_all_lexersget_lexer_by_name guess_lexerload_lexer_from_fileget_lexer_for_filenamefind_lexer_class_for_filename) TextLexer)LatexEmbeddedLexerLatexFormatter)get_all_formattersget_formatter_by_nameload_formatter_from_fileget_formatter_for_filenamefind_formatter_class)TerminalFormatter)Terminal256Formatter)get_all_filtersfind_filter_class)get_all_stylesget_style_by_namec Csi}|s |S|D]t}|sq|d}|D]V}|}z$|dd\}}|}|}Wntk rxd||<Yq,X|||<q,q|S)N,=T)stripsplit ValueError)Zo_strsoptsZo_strZo_argsZo_argZo_keyZo_valr'/builddir/build/BUILDROOT/alt-python38-pip-22.2.1-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_vendor/pygments/cmdline.py_parse_options!s"   r)cCsVg}|s |S|D]@}d|krB|dd\}}||t|gfq||ifq|S)N:r")r$appendr))Zf_strsfiltersZf_strfnamefoptsr'r'r(_parse_filters6sr/c Csz|dkr0t|}td|jtt|jnX|dkr^t|}td|jtt|jn*|dkrt|}td|tt|jWdSttfk rtd|t j d Yd SXdS) NlexerzHelp on the %s lexer: formatterzHelp on the %s formatter:filterzHelp on the %s filter:rz %s not found!filer") r printnamer__doc__rrAttributeErrorr%sysstderr)whatr6clsr'r'r( _print_helpCs" r=c Cs|dkrttdtdg}tD]@\}}}}d|d||rXdd|dpZdf}||q(||D]}td |qvnB|d kr ttd td g}tD]F}t|} d|jd| |jrdd|jdpdf}||q||D]}td |q n|d krxttdtdt D].} t | }td| dtdt|qFnV|dkrttdtdt D].} t | }td| dtdt|qdS)Nr0zLexers:z~~~~~~~z, r*z (filenames )z* %s %s %sr1z Formatters:z ~~~~~~~~~~~r2zFilters:z~~~~~~~~z* z %sstylezStyles:) r5r joinr+sortrraliases filenamesrrrr) r;infofullnamenamesexts_tupir<docr6r'r'r( _print_listWsZ        rMc Csddl}i}d|krDi}tD]\}}}}|||d||<q||d<d|kri}tD]"}t|} |j|j| d||j<qV||d<d|kri}tD]} t| }d t|i|| <q||d <d |kri}t D]} t | }d t|i|| <q||d <| |t j dS) Nrr0)rCrD mimetypeslexersr1)rCrDrL formattersr2rLr,r@styles)jsonr rrrCrDr6rrrrdumpr9stdout) Zrequested_itemsrRresultrErFrGrDrNr<rLr6r'r'r(_print_list_as_jsonsH      rVc& s< jr|dSjr(tdtdSfdd}jdk rt}tD]\}}|rR| |qR| d| d|r|t j dSj stdd gd d d d hddjD}tfdd|Dr|t j dS|s}j s |D] }t|qnt|dSjrf|ds8|t j dSj\}} |dkr\|t j dSt|| Stjprg} jpgD]B} z| dd\} } Wntk rd| | <Yn X| | | <q| d| d} | d| d}jrtj}|dkr t}t|jddSjrnt jj !}zt"|| d}Wnt#k rZt}YnXt|jddSj$}j%}|dk r*j&}|s|t j dSj'sj(r|t j dSz|| d <t)|f| }Wn8t#k r}zt|t j dWYdSd}~XYnXt|*|p ddSj%dk rF|t j dSt+j,pRg}t-j.}d}j'}|rj|rd|krz\d}d} d|kr|/dd\}} d| krd} |r| rt0|| f| }n t0|f| }Wn:t#k r}ztd|t j dWYdSd}~XYnXnPzt1|f| }Wn>t2t#fk rh}ztd|t j dWYdSd}~XYnXd}j(rԈj3rtdt j ddSj(}z"t4|d }|!}W5QRXWn:t5k r}ztd!|t j dWYdSd}~XYnX| st6|\}} |sPzt7||f| }Wnt#k r}zZj8rnzt"|f| }Wn t#k rjtf| }YnXntd|t j dWYdSW5d}~XYn:t2k r}ztd|t j dWYdSd}~XYnXn|j3s8t jj !}| st9|t j\}} |sPzt"|f| }Wn t#k r4tf| }YnXn|sPtd"t j ddS|D]Z\}}z|j:|f|Wn<t#k r}ztd|t j dWYdSd}~XYnXqTj;}j&}|r|rld|krlz\d}d} d|kr|/dd\}} d| krd} |r | r t<|| f| }n t<|f| }Wn:t#k rh}ztd|t j dWYdSd}~XYnXnPzt)|f| }Wn>t2t#fk r}ztd|t j dWYdSd}~XYnX|rd|szt=|f| }Wn>t2t#fk r}ztd|t j dWYdSd}~XYnXzt4|d#} Wn:t5k r`}ztd$|t j dWYdSd}~XYnXn8|sd%t>j?d&dkrt@f| }n tAf| }t jBj } |s|r| |_Cn tDt jB|_C| s6t jEd'k r6|jFd(k r6tG| |jCd)} d|_CzddlHmImJmK}!WntLk r YnX|!jM| ddd*dd+} | d,d}"tN|"dk rxtO|tP rx|"d}#|"d}$tQ|#|$|}j3 sztS|||| W5| r| RXdSz~z\t jj T}%|% s q| st9|%t jd}%tS|%||| tU| d- r| V qWW$dStWk r"YW dSXW5| r6| RXdS).NruWPygments version %s, (c) 2006-2022 by Georg Brandl, Matthäus Chajdas and contributors.cs tfddtD S)Nc3s|]\}}|kr|VqdSNr').0kvoptr'r( sz5main_inner..is_only_option..)anyvarsitemsr[)argnsr[r(is_only_optionsz"main_inner..is_only_optionLrRr?-Vr0r1r2r@cSsg|]}|dqS)s)rstriprXargr'r'r( szmain_inner..c3s|]}|kVqdSrWr'rh) allowed_typesr'r(r]szmain_inner..H)r0r1r2r!r"T inencodingencoding outencoding)rmr3z.pyr*zError:z5Error: -s option not usable when input file specifiedrbzError: cannot read infile:z7Error: when using -s a lexer has to be selected with -lwbzError: cannot open outfile:256TERM)win32cygwin)ZTerminalZ Terminal256)rnF)convertr# autoresetwrap escapeinsideflush)Xhelp print_helpVr5rrcsetr_r`adddiscardr9r:rRmainr^rMrVrlr=r)OPr$r%getNrrrCCstdinbufferreadrrSafl INPUTFILErZget_style_defsr/Fboolxrsplitrr rrfopen Exceptionrrgr add_filterorrosenvironrrrTrnr platformr6r Zpip._vendor.colorama.initialise_vendorZcoloramaZ initialise ImportErrorZ wrap_streamlen isinstancerrcloserreadlinehasattrrzKeyboardInterrupt)&parserrarbZarg_setrYrZlargsrir;r6Z parsed_optsZp_optvaluermror0ZinpZS_optZa_optZf_optZfmtererrZF_optsZallow_custom_lexer_formatter lexernamefilenamecodeZinfninfpr-r.ZoutfnoutfileZcolorama_initialiseryleftrightliner')rkrar( main_inners                                               rc@seZdZdddZdS) HelpFormatterrdNcCsH|dkr0ztjd}Wntk r.YnXtj|||||dS)Nrd)shutilget_terminal_sizecolumnsrargparser__init__)selfprogindent_incrementmax_help_positionwidthr'r'r(rs zHelpFormatter.__init__)rdrN)__name__ __module__ __qualname__rr'r'r'r(rsrc Csd}tj|dtd}|d}|}|jdddd|jd d d d |jd dddd|jdddd|jddddd|jddddd|jdddd|jddd d!|d"}|jd#d d$d |jd%d d&d |jd'd d(d |jd)d*dd d+|d,}|}|jd-d.d/d|jd0d1d2d3d4|jd5d6d7d|jd8d d9d |jd:d;dd?|jd@d dAd |jdBdCd dDd |jdEdFdGd||dHdI}z t||WStk r|j r*t t j dJt dKt j dJt dLt j dJt dMt j dJt dNt j dJt dKt j dJt t j dJdOdIl } | jt } | dP} t| dQkr| dR| dSdTdOdHdI7} t t j dJt dUt j dJt | t j dJt dVt j dJYdHSXdIS)Wz( Main command line entry point. z?Highlight an input file and write the result to an output file.F) descriptionadd_helpformatter_classzMain operationz-lZLEXERz~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-FzFILTER[:options]r+znAdd a filter to the token stream. (Query names with -L.) Filter options are given after a colon if necessary.)rrr{z-fZ 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-OzOPTION=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-oZ OUTPUTFILEz8Where to write the output. Defaults to standard output.r?z5Where to read the input. Defaults to standard input.)nargsr{zOperation 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-xaAllow 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{defaultrz*Special modes - do not do any highlightingz-SzSTYLE -f formatterzqPrint style definitions for STYLE for a formatter given with -f. The argument given by -a is formatter dependent.z-L*ZWHATzList 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.)rrr{z-NZFILENAMEzGuess 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-Hstorerd)NAMEZTYPEzrPrint detailed help for the object of type , where is one of "lexer", "formatter" or "filter".)rrrr{rezPrint the package version.z-hz--helpzPrint this help.z-aZARGzKFormatter-specific additional argument for the -S (print style sheet) mode.r"Nr3zA*****************************************************************z3An unhandled exception occurred while highlighting.z9Please report the whole traceback to the issue tracker atz..rz (f%s) z*** Error while highlighting:z>*** If this is a bug you want to report, please rerun with -v.)rArgumentParserradd_argument_groupadd_mutually_exclusive_group add_argument parse_argsrrrZr5r9r: tracebackformat_exceptionexc_infor#rr$) argsdescrZ operationZlexerselflagsZspecial_modes_groupZ special_modesrarrEmsgr'r'r(rs(       & r)7r7rr9rrtextwraprZpip._vendor.pygmentsrrpip._vendor.pygments.utilrrrrr r r pip._vendor.pygments.lexersr r rrrrZ#pip._vendor.pygments.lexers.specialrZ%pip._vendor.pygments.formatters.latexrrZpip._vendor.pygments.formattersrrrrrZ(pip._vendor.pygments.formatters.terminalrZ+pip._vendor.pygments.formatters.terminal256rpip._vendor.pygments.filtersrrpip._vendor.pygments.stylesrrr)r/r=rMrVrrargvrr'r'r'r(s2  $     3,O