8f/'dZddlZddlmZejdZejdejejzejzZ ejdej ejzejzZ ejdej Z Gdd eZGd d eZd"d Zd#dZd#dZd#dZdZdZdZdZdZiZdZdZd$dZd%dZGddZ dZ!dZ"dZ#Gd d!eZ$dS)&z pygments.util ~~~~~~~~~~~~~ Utility functions. :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. N) TextIOWrapperz[/\\ ]z ]*> z<(.+?)(\s.*?)?>.*?z\s*<\?xml[^>]*\?>ceZdZdZdS) ClassNotFoundzCRaised if one of the lookup functions didn't find a matching class.N__name__ __module__ __qualname____doc__y/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pip/_vendor/pygments/util.pyrrsMMMMr rceZdZdZdS) OptionErrorz This exception will be raised by all option processing functions if the type or value of the argument is not correct. Nrr r r rr"sr rFc |||}|r|}||vrItd|dt t ||S)z} If the key `optname` from the dictionary is not in the sequence `allowed`, raise an error, otherwise return it. z%Value for option {} must be one of {}z, )getlowerrformatjoinmapstr)optionsoptnamealloweddefaultnormcasestrings r get_choice_optr(sw [[' * *F  WAHHRVR[R[\_`cel\m\mRnRnooppp Mr c|||}t|tr|St|trt|St|tst d|d|d|dvrdS|dvrdSt d|d|d) a@ Intuitively, this is `options.get(optname, default)`, but restricted to Boolean value. The Booleans can be represented as string, in order to accept Boolean value from the command line arguments. If the key `optname` is present in the dictionary `options` and is not associated with a Boolean, raise an `OptionError`. If it is absent, `default` is returned instead. The valid string values for ``True`` are ``1``, ``yes``, ``true`` and ``on``, the ones for ``False`` are ``0``, ``no``, ``false`` and ``off`` (matched case-insensitively). Invalid type for option z%; use 1/0, yes/no, true/false, on/off)1yestrueonT)0nofalseoffFInvalid value )r isinstanceboolintrrrrrrrs r get_bool_optr.5s[[' * *F&$ = FC =F||  $ $ =<&<<<<<== = 5 5 5t 6 6 6u<6<<<<<== =r c|||} t|S#t$rtd|d|dt$rtd|d|dwxYw)z?As :func:`get_bool_opt`, but interpret the value as an integer.rr z ; you must give an integer valuer))rr, TypeErrorr ValueErrorr-s r get_int_optr2Rs [[' * *F86{{ 8887&7777788 8 888767777788 88s 'AA'c|||}t|tr|St|tt frt |St d|d|d)z If the key `optname` from the dictionary `options` is a string, split it at whitespace and return it. If it is already a list or a tuple, it is returned as a list. rr z; you must give a list value)rr*rsplitlisttupler)rrrvals r get_list_optr8^s ++gw ' 'C#s4yy{{ C$ ' '4Cyy3#33W33344 4r c@|jsdSg}|jD]A}|r+|d|zAd|S)N )r strip splitlinesappendrlstrip)objreslines r docstring_headlinerCns ;r C !!##..00 ::<<  JJsTZZ\\) * * * *  773<<    r cDfd}j|_t|S)zAReturn a static text analyser function that returns float values.c  |}n#t$rYdSwxYw|sdS tdtdt|S#tt f$rYdSwxYw)Ngg?) Exceptionminmaxfloatr1r0)textrvfs r text_analysez%make_analysator..text_analyse|s 4BB   33  3 sCU2YY//00 0I&   33 s  *AA%$A%)r staticmethod)rLrMs` r make_analysatorrOzs6     9L  % %%r c|d}|dkr|d|}n|}|dr dt|ddDd}n#t $rYdSwxYwtjd |d tj }| |d SdS) aCheck if the given regular expression matches the last part of the shebang if one exists. >>> from pygments.util import shebang_matches >>> shebang_matches('#!/usr/bin/env python', r'python(2\.\d)?') True >>> shebang_matches('#!/usr/bin/python2.4', r'python(2\.\d)?') True >>> shebang_matches('#!/usr/bin/python-ruby', r'python(2\.\d)?') False >>> shebang_matches('#!/usr/bin/python/ruby', r'python(2\.\d)?') False >>> shebang_matches('#!/usr/bin/startsomethingwith python', ... r'python(2\.\d)?') True It also checks for common windows executable file extensions:: >>> shebang_matches('#!C:\\Python2.4\\Python.exe', r'python(2\.\d)?') True Parameters (``'-f'`` or ``'--foo'`` are ignored so ``'perl'`` does the same as ``'perl -e'``) Note that this method automatically searches the whole string (eg: the regular expression is wrapped in ``'^$'``)  rNz#!c@g|]}||d|S)-) startswith).0xs r z#shebang_matches..s@55515"#,,s"3"35Q555r F^z(\.(exe|cmd|bat|bin))?$T) findrrT split_path_rer4r< IndexErrorrecompile IGNORECASEsearch)rJregexindex first_linefounds r shebang_matchesrfs8 IIdOOE zz&5&\'')) ZZ\\ T"" 55 3 3JqrrN4H4H4J4J K K555579EE   55  >>>> NN <<   *4 5s#AB(( B65B6ct|}|dS|d}tj|tj|duS)zCheck if the doctype matches a regular expression (if present). Note that this method only checks the first part of a DOCTYPE. eg: 'html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"' NF)doctype_lookup_reragroupr^r_Imatchr<)rJrbmdoctypes r doctype_matchesros_   &&AyuggajjG :eRT " " ( ( 9 9 EEr c"t|dS)z3Check if the file looks like it has a html doctype.html)ro)rJs r html_doctype_matchesrrs 4 ) ))r c2t|rdSt|} t|S#t$rRt |}|YdSt|dddu}|t|<|cYSwxYw)z2Check if a doctype exists or if we have some tags.TNi) xml_decl_rerlhash_looks_like_xml_cacheKeyErrorriratag_re)rJkeyrmrKs r looks_like_xmlrzst t**C$S))   $ $T * * =44 ]]4; ' 't 3%'c" s :&B#0BBc"d|dz zd|dzzfS)zoGiven a unicode character code with length greater than 16 bits, return the two 16 bit surrogate pair. i iir )cs r surrogatepairr~s! a2g 1u9!5 77r cg}d|zdz}d|dzzdz}|||zdz|r!|D]}|||zdznC|D]@}t|dz}|||ddz|d zdzA||d zd |S) z)Formats a sequence of strings for output.r;rhz = (,"NrY)rQ)r>reprr) var_nameseqraw indent_levellines base_indent inner_indentirs r format_linesrs E $q(K,*+a/L LLx'&0111 > 1 1A LL)C/ 0 0 0 0 1 > >AQW A LL#2#.26< = = = = LLs"### 99U  r r cg}t}|D]5}||vs||vr ||||6|S)za Returns a list with duplicates removed from the iterable `it`. Order is preserved. )setr>add)it already_seenlstseenrs r duplicates_removedrs\ C 55D  99\))  1   Jr ceZdZdZdZdS)FuturezGeneric class to defer some work. Handled specially in RegexLexerMeta, to support regex string construction at first use. ctN)NotImplementedErrorselfs r rz Future.gets!!r N)rrr r rr r r rr s- """""r rc |d}|dfS#t$rf ddl}|}|}||fcYS#ttf$r|d}|dfcYcYSwxYwwxYw)zDecode *text* with guessed encoding. First try UTF-8; this should fail for non-UTF-8 encodings. Then try the preferred locale encoding. Fall back to latin-1, which always works. zutf-8rNlatin1)decodeUnicodeDecodeErrorlocalegetpreferredencoding LookupError)rJr prefencodings r guess_decoders "{{7##W} """ " MMM!6688L;;==D% % % %"K0 " " ";;x((D> ! ! ! ! ! " "s, B /AB *BB BB ct|ddr4 ||j}||jfS#t$rYnwxYwt |S)zDecode *text* coming from terminal *term*. First try the terminal encoding, if given. Then try UTF-8. Then try the preferred locale encoding. Fall back to latin-1, which always works. encodingN)getattrrrrr)rJterms r guess_decode_from_terminalr(sqtZ&&' ';;t}--D& &"    D    s6 AAcbt|ddr|jSddl}|S)z7Return our best guess of encoding for the given *term*.rNr)rrrr)rrs r terminal_encodingr9s9tZ&&}MMM  & & ( ((r ceZdZdZdS)UnclosingTextIOWrapperc.|dSr)flushrs r closezUnclosingTextIOWrapper.closeCs r N)rrr rr r r rrAs#r r)NFr)Fr)r )%r r^iorr_r\DOTALL MULTILINEVERBOSErir`rxrkrtr1rrFrrr.r2r8rCrOrfrorrrvrzr~rrrrrrrr r r rs  9%% BJ Y *,, /MBI- < > >bj-rt44 NNNNNJNNN)    ====: 8 8 8 8 4 4 4 4 ! ! !&&&"***Z F F F***     888&     """""""""""*")))]r