Ë „ÿr8ª¨Ðíãó—dZddlZddlmZejd«Zejdej ejzejz«Z ejdejej zejz«Z ejdej«Z Gd„d e«ZGd „d e«Zd d „Zd!d „Zd!d„Zd!d„Zd„Zd„Zd„Zd„Zd„ZiZd„Zd„Zd"d„Zd#d„ZGd„d«Z d„Z!d„Z"d„Z#Gd„de«Z$y)$z± pygments.util ~~~~~~~~~~~~~ Utility functions. :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. éN)Ú TextIOWrapperz[/\\ ]z” ]*> z<(.+?)(\s.*?)?>.*?z\s*<\?xml[^>]*\?>có—eZdZdZy)Ú ClassNotFoundzCRaised if one of the lookup functions didn't find a matching class.N©Ú__name__Ú __module__Ú __qualname__Ú__doc__©óú2/usr/lib/python3.12/site-packages/pygments/util.pyrrs„ÚMr rcó—eZdZdZy)Ú 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"s„òr rc ó²—|j||«}|r|j«}||vr.td|›ddjt t |««›�«‚|S)z} If the key `optname` from the dictionary is not in the sequence `allowed`, raise an error, otherwise return it. zValue for option z must be one of z, )ÚgetÚlowerrÚjoinÚmapÚstr)ÚoptionsÚoptnameÚallowedÚdefaultÚnormcaseÚstrings r Úget_choice_optr(sY€ð �[‰[˜ 'Ó *€FÙØ—‘“ˆØ �WÑÝÚ" D§I¡I¬c´#°wÓ.?Ô$@ðBóCð Cà €Mr có4—|j||«}t|t«r|St|t«r t|«St|t«st d|›d|›d�«‚|j «dvry|j «dvryt 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)Ú1ÚyesÚtrueÚonT)Ú0ÚnoÚfalseÚoffFúInvalid value )rÚ isinstanceÚboolÚintrrr©rrrrs r Ú get_bool_optr-6s•€ð�[‰[˜ 'Ó *€FÜ�&œ$ÔØˆ Ü �FœCÔ Ü�F‹|ÐÜ ˜¤Ô $Ýâ$¢gð/ó0ð 0ð �‰‹Ð5Ñ 5ØØ �‰‹Ð6Ñ 6Øåâ$¢gð/ó0ð 0r có°—|j||«} t|«S#t$rtd|›d|›d�«‚t$rtd|›d|›d�«‚wxYw)z?As :func:`get_bool_opt`, but interpret the value as an integer.rrz ; you must give an integer valuer()rr+Ú TypeErrorrÚ ValueErrorr,s r Ú get_int_optr1Ush€à �[‰[˜ 'Ó *€Fð 0Ü�6‹{ÐøÜ ò0Ýâ$¢gð/ó0ð 0ô ò0Ýâ$¢gð/ó0ð 0ð0ús ” Ÿ6AcóÌ—|j||«}t|t«r|j«St|tt f«r t |«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. rrz; you must give a list value)rr)rÚsplitÚlistÚtupler)rrrÚvals r Ú get_list_optr7csY€ð �+‰+�g˜wÓ '€CÜ�#”sÔØ�y‰y‹{ÐÜ �Cœ$¤˜Ô 'Ü�C‹yÐåâ!¢7ð,ó-ð -r có —|jsyg}|jj«j«D]6}|j«r#|jd|j«z«Œ6ndj |«j «S)NÚÚ )r ÚstripÚ splitlinesÚappendrÚlstrip)ÚobjÚresÚlines r Údocstring_headlinerBtsm€Ø �;Š;ØØ €CØ— ‘ ×!Ñ!Ó#×.Ñ.Ö0ˆØ �:‰:Œ<Ø �J‰J�s˜TŸZ™Z›\Ñ)Õ *á ð 1ð �7‰7�3‹<× Ñ Ó Ð r cóF‡—ˆfd„}‰j|_t|«S)zAReturn a static text analyser function that returns float values.c 󤕗 ‰|«}|sy tdtdt|«««S#t$rYywxYw#tt f$rYywxYw)Nggð?)Ú ExceptionÚminÚmaxÚfloatr0r/)ÚtextÚrvÚfs €r Ú text_analysez%make_analysator..text_analyse‚sbø€ð Ù�4“ˆBñØð Ü�sœC ¤U¨2£YÓ/Ó0Ð 0øô ò Ùð ûô œIÐ&ò Ùð úsƒ.�=® :¹:½AÁA)r Ú staticmethod)rKrLs` r Úmake_analysatorrN€s!ø€ô ðŸ9™9€LÔÜ ˜ Ó %Ð%r cóÊ—|jd«}|dk\r|d|j«}n|j«}|jd«r„ tj |ddj ««D�cgc]}|r|jd«s|‘Œc}d}tjd |ztj«}|j|«�y ycc}w#t $rYywxYw) aòCheck 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#!éÚ-éÿÿÿÿFz^%s(\.(exe|cmd|bat|bin))?$T) ÚfindrÚ startswithÚ split_path_rer3r;Ú IndexErrorÚreÚcompileÚ IGNORECASEÚsearch)rIÚregexÚindexÚ first_lineÚxÚfounds r Úshebang_matchesra‘s߀ð8 �I‰I�d‹O€EØ �‚zؘ&˜5�\×'Ñ'Ó)‰ à—Z‘Z“\ˆ Ø×јTÔ"ð Ü -× 3Ñ 3°J¸q¸r°N×4HÑ4HÓ4JÔ Kó5Ñ K˜1Ù !§,¡,¨sÔ"3òÐ Kñ5Ø57ñ9ˆEô— ‘ Ð8¸5Ñ@Ä"Ç-Á-ÓPˆØ �<‰<˜Ó Ð *ØØ ùò5øäò Ùð ús$Á (CÁ5CÂCÃCà C"Ã!C"cóÚ—tj|«}|€y|jd«}tj|tj «j |j««duS)zÁCheck 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_rer[ÚgrouprXrYÚIÚmatchr;)rIr\ÚmÚdoctypes r Údoctype_matchesrj¾sT€ô × Ñ  Ó&€AØ€yØØ�g‰g�a‹j€GÜ �:‰:�eœRŸT™TÓ "× (Ñ (¨¯©«Ó 9ÀÐ EÐEr có—t|d«S)z3Check if the file looks like it has a html doctype.Úhtml)rj)rIs r Úhtml_doctype_matchesrmËs€ä ˜4 Ó )Ð)r cóò—tj|«ryt|«} t|S#t$rAt j |«}|�Yytj |dd«du}|t|<|cYSwxYw)z2Check if a doctype exists or if we have some tags.TNiè)Ú xml_decl_rergÚhashÚ_looks_like_xml_cacheÚKeyErrorrdr[Útag_re)rIÚkeyrhrJs r Úlooks_like_xmlruÓs|€ä×Ñ˜ÔØÜ ˆt‹*€CðÜ$ SÑ)Ð)øÜ òÜ × $Ñ $ TÓ *ˆØ ˆ=ÙÜ �]‰]˜4  ˜;Ó '¨tÐ 3ˆØ%'Ô˜cÑ"ØŠ ð ús£,¬ A6Á%A6Á5A6có"—d|dz zd|dzzfS)zoGiven a unicode character code with length greater than 16 bits, return the two 16 bit surrogate pair. iÀ×é iÜiÿr )Úcs r Ú surrogatepairryãs!€ð �a˜2‘gÑ  ¨1¨u©9Ñ!5Ð 7Ð7r cóP—g}d|zdz}d|dzzdz}|j||zdz«|r|D]}|j||zdz«Œn5|D]0}t|dz«}|j||ddz|d zdz«Œ2|j|d z«d j|«S) z)Formats a sequence of strings for output.r:ércz = (Ú,Ú"NéþÿÿÿrSÚ)rP)r=Úreprr) Úvar_nameÚseqÚrawÚ indent_levelÚlinesÚ base_indentÚ inner_indentÚiÚrs r Ú format_linesrŠìsÀà €Eؘ Ñ$ qÑ(€Kؘ,¨Ñ*Ñ+¨aÑ/€LØ ‡L�L�˜xÑ'¨&Ñ0Ô1Ù ãˆAØ �L‰L˜¨Ñ)¨CÑ/Õ 0ñóˆAä�Q˜‘W“ ˆAØ �L‰L˜¨¨#¨2¨Ñ.°°2±Ñ6¸Ñ<Õ =ðð ‡L�L�˜sÑ"Ô#Ø �9‰9�UÓ Ðr có‚—g}t«}|D]-}||vs||vrŒ |j|«|j|«Œ/|S)za Returns a list with duplicates removed from the iterable `it`. Order is preserved. )Úsetr=Úadd)ÚitÚ already_seenÚlstÚseenrˆs r Úduplicates_removedr’ÿsH€ð €CÜ ‹5€DÛ ˆØ �‰9˜˜\Ñ)Ø Ø � ‰ �1Œ Ø �‰�� ð ð €Jr có—eZdZdZd„Zy)ÚFuturez‡Generic class to defer some work. Handled specially in RegexLexerMeta, to support regex string construction at first use. có—t‚©N)ÚNotImplementedError©Úselfs r rz Future.gets€Ü!Ð!r N)rrr r rr r r r”r”s „ñó "r r”cóö— |jd«}|dfS#t$rX ddl}|j«}|j«}||fcYS#ttf$r|jd«}|dfcYcYSwxYwwxYw)zÃDecode *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-8rNÚlatin1)ÚdecodeÚUnicodeDecodeErrorÚlocaleÚgetpreferredencodingÚ LookupError)rIržÚ prefencodings r Ú guess_decoder¢s†€ð "Ø�{‰{˜7Ó#ˆØ�Wˆ}ÐøÜ ò"ð "Û Ø!×6Ñ6Ó8ˆLØ—;‘;“=ˆDؘÐ%Ò %øÜ"¤KÐ0ò "Ø—;‘;˜xÓ(ˆDؘ�>Ô !ð "úð "ús,‚— A8¡'A ÁA8Á $A4Á/A8Á3A4Á4A8có¸—t|dd«r* |j|j«}||jfSt |«S#t$r Yt |«SwxYw)zÊDecode *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)Úgetattrrœr¤r�r¢)rIÚterms r Úguess_decode_from_terminalr§.sd€ôˆt�Z Ô&ð 'Ø—;‘;˜tŸ}™}Ó-ˆD𘟙Ð&Ð &Ü ˜Ó Ðøô "ò Ø ô ˜Ó Ðð  ús�AÁ AÁAcó\—t|dd«r |jSddl}|j«S)z7Return our best guess of encoding for the given *term*.r¤Nr)r¥r¤ržrŸ)r¦ržs r Úterminal_encodingr©?s*€äˆt�Z Ô&Ø�}‰}ÐÛØ × &Ñ &Ó (Ð(r có—eZdZd„Zy)ÚUnclosingTextIOWrappercó$—|j«yr–)Úflushr˜s r ÚclosezUnclosingTextIOWrapper.closeIs €Ø � ‰ � r N)rrr r®r r r r«r«Gs„ór r«)NFr–)Fr)r )%r rXÚiorrYrVÚDOTALLÚ MULTILINEÚVERBOSErdrZrsrfror0rrErrr-r1r7rBrNrarjrmrqruryrŠr’r”r¢r§r©r«r r r Úr³s$ðñó Ýð�— ‘ ˜9Ó%€ Ø�B—J‘Jð ð‡Y�Y�—‘Ñ § ¡ Ñ*ó,Ðð ˆ�‰Ð/Ø—M‘M B§I¡IÑ-°· ± Ñ<ó >€àˆb�j‰jÐ-¨r¯t©tÓ4€ ôN�JôNô�)ôó ó0ó> 0ó-ò" !ò&ò"*òZ Fò*ð Ðò ò 8óó& ÷ "ñ"ò"ò*ò")ô˜]õr