|e[hdZddlZddlZddlZddlZddlmZddlmZm 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'm(Z(dd l)m*Z*m+Z+dd l,m-Z-m.Z.dZ/dZ0dZ1dZ2dZ3dZ4GddejjZ5ejlfdZ7y)z pygments.cmdline ~~~~~~~~~~~~~~~~ Command line interface. :copyright: Copyright 2006-2023 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)Terminal256FormatterTerminalTrueColorFormatter)get_all_filtersfind_filter_class)get_all_stylesget_style_by_namec0i}|s|S|D]v}|js|jd}|D]M}|j} |jdd\}}|j}|j}|||<Ox|S#t$rd||<YdwxYw)N,=T)stripsplit ValueError)o_strsoptso_stro_argso_argo_keyo_vals 2/usr/lib/python3/dist-packages/pygments/cmdline.py_parse_optionsr1!s D   ${{} S! $EKKME $${{32 u  $U  $ $ K  #"U  #s5BBBcg}|s|S|D]L}d|vr3|jdd\}}|j|t|gf:|j|ifN|S)N:r%)r'appendr1)f_strsfiltersf_strfnamefoptss r0_parse_filtersr:6shG ( %< ;;sA.LE5 NNE>5'#:; < NNE2; ' ( Nc |dk(rBt|}td|jztt|jy|dk(rBt |}td|jztt|jy|dk(r7t |}td|ztt|jy#ttf$r!td|ztj Yy wxYw) NlexerzHelp on the %s lexer: formatterzHelp on the %s formatter:filterzHelp on the %s filter:rz %s not found!filer%) rprintnamer__doc__rrAttributeErrorr(sysstderr)whatrCclss r0 _print_helprJCs 7?#D)C )CHH4 5 &% &[ &t,C -8 9 &% &  X #D)C *T1 2 &% & J ' o$3::6sAC AC z Formatters:z ~~~~~~~~~~~r?zFilters:z~~~~~~~~z* z %sstylezStyles:) rBr joinr4sortrraliases filenamesrrr r!) rHinfofullnamenamesexts_tupirIdocrCs r0 _print_listr[Ws0 w  i i(6(8  $HeT199U#C'AMDIIdO;cAGRIC KK    +A $) * +    m m%' C$S)C99S[[)C/cmm7B 499S]]#;;cA7HEGIC KK     +A $) * +    j j#% 6D#D)C $+# $ (/44 5 6   i i"$ 6D#D)C $+# $ (/44 5 6 r;c ddl}i}d|vr$i}tD]\}}}}|||d||<||d<d|vrHi}tD]4}t|} |j|j | d||j <6||d<d|vr1i}tD]} t| }d t|i|| <||d <d |vr1i}tD]} t| }d t|i|| <||d <|j|tjy) Nrr=)rQrR mimetypeslexersr>)rQrRrZ formattersr?rZr6rNstyles)jsonr rrrQrRrCrrr r!dumprFstdout) requested_itemsraresultrSrTrUrRr]rIrZrCs r0_print_list_as_jsonrfsO F/!5C5E  1HeY  &&DN   xo%%' C$S)C;; ]]DN  $|?"#% D#D)C)#.DJ  !y/!"$ D#D)C)#.DJ   xIIfcjj!r;c&jr|jyjrtdtzyfd}j +t }tjD]\}}|s |j||jd|jd|r |jtjyjs tddghd &j Dcgc]}|jd }}t!&fd |Dr |jtjy|s&}js|D] }t#|yt%|yj&rg|d s |jtjyj&\}} |d vr |jtjyt)|| St+j,xsg} j.xsgD]} | j1dd\} } | | | <| j5d| j5d} | j5d| j5d}j6r6t9j6}|t:}t|j<dyj>rOtj@jBjE} tG|| }t|j<dyjJ}jL}|jN}|s |jtjyjPs jRr |jtjy || d<tU|fi| }t|jW|xsdyjL |jtjytYjZxsg}t]j^}d}jP}|rV|rGd|vrC d}d} d|vr|jadd\}} d| vrd} |r| rtc|| fi| }n tc|fi| }n te|fi| }d}jRr{jhrtdtjyjR} tk|d5}|jE}ddd| sto|\}} |s tq||fi| }njhsWtj@jBjE}| stu|tj@\}} |s, tG|fi| }n|stdtjy|D]\}} |jv|fi|jx}jN}|rV|rGd|vrC d}d} d|vr|jadd\}} d| vrd} |r| rt{|| fi| }n t{|fi| }n tU|fi| }|r|s t}|fi| } tk|d} n|sgt~jj5d dd!vr td+i| }n9d"t~jj5d#dvr td+i| }n td+i| }tjjB} |s(|r| |_Enttj|_E|sctjd$vrQ|jd%vrCt| |j&} d|_E ddlJ}!|!jj| ddd'd(} | j5d)d}"t|"dk(r't|tr|"d}#|"d}$t|#|$|}jhs" t|||| |r| jy tj@jBj}%|%snJ| stu|%tj@d}%t|%||| t| d*r| ju |r| jyycc}w#t2$r d| | <YPwxYw#tH$r t:}YwxYw#tH$r%}t|tjYd}~yd}~wwxYw#tH$r&}td|tjYd}~yd}~wwxYw#tftHf$r&}td|tjYd}~yd}~wwxYw#1swY7xYw#tl$r&}td|tjYd}~yd}~wwxYw#tH$r`}jrr( tG|fi| }n;#tH$rt;d+i| }Yn%wxYwtd|tjYd}~yYd}~.d}~wtf$r&}td|tjYd}~yd}~wwxYw#tH$rt;d+i| }YzwxYw#tH$r'}td|tjYd}~yd}~wwxYw#tH$r&}td|tjYd}~yd}~wwxYw#tftHf$r&}td|tjYd}~yd}~wwxYw#tftHf$r&}td|tjYd}~yd}~wwxYw#tl$r&}td|tjYd}~yd}~wwxYw#t$rYwxYw#|r| jwwxYw#t$rY|r| jyywxYw#|r| jwwxYw),NruWPygments version %s, (c) 2006-2023 by Georg Brandl, Matthäus Chajdas and contributors.c^tfdtjD S)Nc34K|]\}}|k7s |ywN).0kvopts r0 z5main_inner..is_only_option..sGVaa3hqGs )anyvarsitems)roargnss`r0is_only_optionz"main_inner..is_only_options$GtE{'8'8':GGGGr;LrarM-V>r=rNr?r>sc3&K|]}|v ywrjrk)rlarg allowed_typess r0rpzmain_inner..s9Cs-'9sH)r=r>r?r$r%T inencodingencoding outencoding)r~rNr@z.pyr3zError: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: COLORTERM) truecolor24bit256TERM)win32cygwin)Terminal Terminal256)rF)convertr& autoresetwrap escapeinsideflushrk)Xhelp print_helpVrBrrvsetrrrsadddiscardrFrGramainrstriprqr[rfr}rJr1OPr'r(getNrrrQCstdinbufferreadrrSafl INPUTFILErget_style_defsr:Fboolxrsplitrrrryopen Exceptionr rgr add_filterorrosenvironrrrrcrr platformrCr colorama.initialise initialise wrap_stream ImportErrorlen isinstancerrrclosereadlinehasattrrKeyboardInterrupt)'parserrtruarg_setrmrnr{largsrHrC parsed_optsp_optvaluer~rr=inpS_opta_optf_optfmtererrF_optsallow_custom_lexer_formatter lexernamefilenamecodeinfninfpr8r9outfnoutfilecoloramarleftrightliner|s' ` @r0 main_innerrsr  zz ww *,78 9H ww%K%%' DAq A      cjj )zz "d A ,1GG4SC44 959 9   cjj )!Ezz !C  !  & wwc"   cjj )WW d 7 7   cjj )4&&!B/KB& &++c1-KD%!&K  &{z/JKJ//-1LMK ww-egg6 =E emmA wwii##%  ;E emmA GGE GGE    cjj ) 77eoo   cjj ) #(K )%?;?E e""5;B/0 ww#**%EGGMr *F$(=  EI 'EY,> )#%.%5%5c1%=NHd} $04@3>@E1JkJE  ))C{C D  77 Izz # dD! #Tyy{ # +D1 D* .tTI[IWWyy$$&9$ J D* 1#D8K8  Kzz # u  E  U ,e , GGE GGE 'EUN %<%*\\#q%9NHd}#4XtD7BDE5UJkJE  -eC{C   25HKH 5$'G zz~~k"-1GG2A[A"**..44,;{;)8K8**##  'EN/szz:EN S\\%88 zz00(5>>J O &))55TU6OG ??>26L <A*UN"CAQ"46 77 dE5' 2  yy''002!5dCIIFqID$ug67G,MMO Y 5> &!%K  &. E *  #CJJ ' T! h#**5   / h#**5  # #  .#** E ! 779 +D @K @(9 ) 8K 89(Ccjj9 h#**5 ! 1!0K0 1  (Ccjj 1 2! h#**5   / h#**5  / h#**5    /3:: F <   *  !    s?aa1 a,b9Ab3< c% d*d(d* e' g5hAi i5% j-2 k%-l%l'A6l?a)(a),a?>a? b0 b++b03 c"<cc"%d4ddd'"d** e3ee g2% g2 e?>g?fgfg g2 g--g25h  h  ih;;i i2 i--i25j*j%%j*-k"<kk"% l.ll l$#l$'l<? mm!mm!!m6ceZdZddZy) HelpFormatterNc|" tjjdz }tj j |||||y#t$rY/wxYw)Nrw)shutilget_terminal_sizecolumnsrargparser__init__)selfprogindent_incrementmax_help_positionwidths r0rzHelpFormatter.__init__s\ = 002::Q> ''d4D(95 B  s!A AA)rwN)__name__ __module__ __qualname__rrkr;r0rrsBr;rcd}tj|dt}|jd}|j }|j ddd|j d d d |j d ddd|j ddd|j dddd|j dddd|j ddd|j ddd !|jd"}|j d#d d$ |j d%d d& |j d'd d( |j d)d*dd +|jd,}|j }|j d-d.d/|j d0d1d2d34|j d5d6d7|j d8d d9 |j d:d;d?|j d@d dA |j dBdCd dD |j dEdFdG|j |dHdI} t||S#t$rYyJt$r|jrttjKtdLtjKtdMtjKtdNtjKtdOtjKtdLtjKttjKdJdIl} | jtj } | dPj#} t%| dQk\r.| dR| dSj'dTdJj#dHdIzz } ttjKtdUtjKt| tjKtdVtjKYyHwxYw)Wz( Main command line entry point. z?Highlight an input file and write the result to an output file.F) descriptionadd_helpformatter_classzMain operationz-lLEXERz~Specify the lexer to use. (Query names with -L.) If not given and -g is not present, the lexer is guessed from the filename.)metavarrz-g store_truez`Guess the lexer from the file contents, or pass through as plain text if nothing can be guessed.)actionrz-FzFILTER[:options]r4znAdd a filter to the token stream. (Query names with -L.) Filter options are given after a colon if necessary.)rrrz-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-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-o OUTPUTFILEz8Where to write the output. Defaults to standard output.r?z5Where to read the input. Defaults to standard input.)nargsrzOperation 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.)rdefaultrz*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*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.)rrrz-NFILENAMEzGuess 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-Hstorerw)NAMETYPEzrPrint detailed help for the object of type , where is one of "lexer", "formatter" or "filter".)rrrrrxzPrint the package version.z-hz--helpzPrint this help.z-aARGzKFormatter-specific additional argument for the -S (print style sheet) mode.r%Nrr@zA*****************************************************************z3An unhandled exception occurred while highlighting.z9Please report the whole traceback to the issue tracker atz..z (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_argsrBrokenPipeErrorrrnrBrFrG tracebackformat_exceptionexc_infor&rr') argsdescr operationlexerselflagsspecial_modes_group special_modesrtrrSmsgs r0rrsU MD  $ $5BDF))*:;I557H  gOP  \34 (?@ k12  7./  nXDE  l GI3 DF  % %&7 8E  \34  \CD  \67 x'/ !3346'DDFM *  C<=  j67  \/0 WA/?CD \ )+ h| !$$ e%   d12h 'E&%((   77 szz " ( , Gzz # Mzz # Bzz # ( , szz " )y))3<<>:2hnn t9> <$r(.."6q"9"?"?"A!""EE EC 3:: -CJJ? c # N:: 1s H++ O)6F0O)(O))8rDrrFrrtextwraprpygmentsrr pygments.utilrrrr r r r pygments.lexersr rrrrrpygments.lexers.specialrpygments.formatters.latexrrpygments.formattersrrrrrpygments.formatters.terminalrpygments.formatters.terminal256rrpygments.filtersrrpygments.stylesr r!r1r:rJr[rfrrargvrrkr;r0rs +PP-HOO:\?=* (06f*"XL ^ BH**BhhLr;