+
    i/'                     J   R t ^ RIt^ RIHt ]P                  ! R4      t]P                  ! R]P                  ]P                  ,          ]P                  ,          4      t	]P                  ! R]P                  ]P                  ,          ]P                  ,          4      t]P                  ! R]P                  4      t ! R R]4      t ! R	 R
]4      tRR ltR R ltR R ltR R ltR tR tR tR tR t/ tR tR tR!R ltR"R lt ! R R4      t R t!R t"R t# ! R R]4      t$R# )#z
pygments.util
~~~~~~~~~~~~~

Utility functions.

:copyright: Copyright 2006-2025 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
N)TextIOWrapperz[/\\ ]z
    <!DOCTYPE\s+(
     [a-zA-Z_][a-zA-Z0-9]*
     (?: \s+      # optional in HTML5
     [a-zA-Z_][a-zA-Z0-9]*\s+
     "[^"]*")?
     )
     [^>]*>
z<(.+?)(\s.*?)?>.*?</.+?>z\s*<\?xml[^>]*\?>c                       ] tR t^tRtRtR# )ClassNotFoundzCRaised if one of the lookup functions didn't find a matching class. N__name__
__module____qualname____firstlineno____doc____static_attributes__r       `/home/wkmabra/.openclaw/workspace/venv/lib/python3.14/site-packages/pip/_vendor/pygments/util.pyr   r      s    Mr   r   c                       ] tR t^"tRtRtR# )OptionErrorzw
This exception will be raised by all option processing functions if
the type or value of the argument is not correct.
r   Nr   r   r   r   r   r   "   s    r   r   c                    V P                  W4      pV'       d   VP                  4       pWR9  d9   \        RP                  VRP	                  \        \        V4      4      4      4      hV# )zq
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, )getlowerr   formatjoinmapstr)optionsoptnamealloweddefaultnormcasestrings   &&&&& r   get_choice_optr   (   sZ    
 [[*FAHHRVR[R[\_`cel\mRnoppMr   c                j   V P                  W4      p\        V\        4      '       d   V# \        V\        4      '       d   \        V4      # \        V\        4      '       g   \        RV: RV R24      hVP                  4       R9   d   R# VP                  4       R9   d   R# \        RV: RV R24      h)	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/offTFInvalid value )1yestrueon)0nofalseoff)r   
isinstanceboolintr   r   r   r   r   r   r   s   &&& r   get_bool_optr/   5   s     [[*F&$	FC	 	 F|$$M&<y I< < = 	=	5	5	6	6N6*L	 J< < = 	=r   c                    V P                  W4      p \        V4      #   \         d    \        RT: RT R24      h\         d    \        RT: RT R24      hi ; i)z?As :func:`get_bool_opt`, but interpret the value as an integer.r    r!   z ; you must give an integer valuer"   )r   r-   	TypeErrorr   
ValueErrorr.   s   &&& r   get_int_optr3   R   s~    [[*F86{ 8M&<y I7 7 8 	8 8N6*L	 J7 7 8 	88s   
 &AAc                    V P                  W4      p\        V\        4      '       d   VP                  4       # \        V\        \
        34      '       d   \	        V4      # \        RV: RV R24      h)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.
r    r!   z; you must give a list value)r   r+   r   splitlisttupler   )r   r   r   vals   &&& r   get_list_optr9   ^   sj     ++g
'C#syy{	C$	'	'CyM#WI F3 3 4 	4r   c                 F   V P                   '       g   R # . pV P                   P                  4       P                  4        FA  pVP                  4       '       d)   VP                  RVP                  4       ,           4       KA   M	  R P	                  V4      P                  4       # )  )r   strip
splitlinesappendr   lstrip)objreslines   &  r   docstring_headlinerD   n   sq    ;;;
C!!#..0::<<JJsTZZ\)*	 1
 773<  r   c                H   a  V 3R lpS P                   Vn         \        V4      # )zAReturn a static text analyser function that returns float values.c           	         <  S! V 4      pT'       g   R #  \        R\        R \        T4      4      4      #   \          d     R # i ; i  \        \
        3 d     R # i ; i)g        g      ?)	Exceptionminmaxfloatr2   r1   )textrvfs   & r   text_analyse%make_analysator.<locals>.text_analyse|   sb    	4B 	sCU2Y/00  		 I& 		s    5 A AAAA)r   staticmethod)rM   rN   s   f r   make_analysatorrQ   z   s!    
 99L%%r   c                    V P                  R4      pV^ 8  d   V RV P                  4       pMV P                  4       pVP                  R4      '       d    \        P	                  VR,          P                  4       4       Uu. uF(  pV'       g   K  VP                  R4      '       d   K&  VNK*  	  upR
,          p\        P                  ! RT R2\        P                  4      pTP                  T4      e   R	# R# u upi   \         d     R# i ; i)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 ``'^$'``)

Nz#!:   NN-F^z(\.(exe|cmd|bat|bin))?$T)findr   
startswithsplit_path_rer5   r=   
IndexErrorrecompile
IGNORECASEsearch)rK   regexindex
first_linexfounds   &&    r   shebang_matchesre      s    8 IIdOEz&5\'')
ZZ\
T""	 - 3 3JrN4H4H4J K 5 K1 "#,,s"3 Q K 5579E 

aw&=>N<<*5 		s0   ,C> 
C9C9)C9/
C> 9C> >DDc                    \         P                  V 4      pVf   R# VP                  ^4      p\        P                  ! V\        P
                  4      P                  VP                  4       4      RJ# )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_rer_   groupr\   r]   Imatchr=   )rK   r`   mdoctypes   &&  r   doctype_matchesrm      sT     	  &AyggajG::eRTT"((9EEr   c                    \        V R4      # )z3Check if the file looks like it has a html doctype.html)rm   )rK   s   &r   html_doctype_matchesrp      s    4))r   c                   \         P                  V 4      '       d   R# \        V 4      p \        V,          #   \         dI    \
        P                  T 4      pTe    R# \        P                  T R,          4      RJpT\        T&   Tu # i ; i)z2Check if a doctype exists or if we have some tags.TN:Ni  N)xml_decl_rerj   hash_looks_like_xml_cacheKeyErrorrg   r_   tag_re)rK   keyrk   rL   s   &   r   looks_like_xmlrx      s}    
t*C$S)) $$T*=]]4;'t3%'c"	s   7 $B
)B
	B
c                B    RV ^
,	          ,           RV R,          ,           3# )zgGiven a unicode character code with length greater than 16 bits,
return the two 16 bit surrogate pair.
i  i   i  r   )cs   &r   surrogatepairr{      s!     a2g1u9!577r   c                   . pRV,          ^,          pRV^,           ,          ^,          pVP                  WP,           R,           4       V'       d)   V F!  pVP                  Wg,           R,           4       K#  	  MJV FD  p\        VR,           4      pVP                  WhRR ,           VR	,          ,           R,           4       KF  	  VP                  VR,           4       RP                  V4      # )
z)Formats a sequence of strings for output.r<   z = (,"N)rS   rW   )r?   reprr   )	var_nameseqrawindent_levellinesbase_indentinner_indentirs	   &&&&     r   format_linesr      s    E$q(K,*+a/L	LL'&01
ALL)C/0  AQWALL#2.26<=  
LLs"#99Ur   c                    . p\        4       pV  F3  pWC9   g   WA9   d   K  VP                  V4       VP                  V4       K5  	  V# )zU
Returns a list with duplicates removed from the iterable `it`.

Order is preserved.
)setr?   add)italready_seenlstseenr   s   &&   r   duplicates_removedr      sD     C5D9)

1	 
 Jr   c                   *   a  ] tR tRt o RtR tRtV tR# )Futurei	  z{Generic class to defer some work.

Handled specially in RegexLexerMeta, to support regex string construction at
first use.
c                    \         hN)NotImplementedErrorselfs   &r   r   
Future.get  s    !!r   r   N)r   r   r	   r
   r   r   r   __classdictcell____classdict__s   @r   r   r   	  s     
" "r   r   c                     V P                  R4      p V R3#   \         dZ     ^ RIpTP                  4       pT P                  4       p Y3u #   \        \        3 d    T P                  R4      p T R3u u # i ; ii ; i)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.
zutf-8Nlatin1)decodeUnicodeDecodeErrorlocalegetpreferredencodingLookupError)rK   r   prefencodings   &  r   guess_decoder     s    "{{7#W} "	"!668L;;=D%%"K0 	";;x(D>!	""s,    A;&A	A;&A72A;6A77A;c                    \        VRR4      '       d*    V P                  VP                  4      p WP                  3# \	        V 4      #   \         d     Li ; i)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)getattrr   r   r   r   )rK   terms   &&r   guess_decode_from_terminalr   (  sX     tZ&&	';;t}}-D &&	 " 		s   A AAc                h    \        V RR4      '       d   V P                  # ^ RIpVP                  4       # )z7Return our best guess of encoding for the given *term*.r   N)r   r   r   r   )r   r   s   & r   terminal_encodingr   9  s-    tZ&&}}&&((r   c                   &   a  ] tR tRt o R tRtV tR# )UnclosingTextIOWrapperiA  c                &    V P                  4        R # r   )flushr   s   &r   closeUnclosingTextIOWrapper.closeC  s    

r   r   N)r   r   r	   r
   r   r   r   r   s   @r   r   r   A  s      r   r   )NFr   )F    )r   )%r   r\   ior   r]   rZ   DOTALL	MULTILINEVERBOSErg   r^   rv   ri   rr   r2   r   rG   r   r   r/   r3   r9   rD   rQ   re   rm   rp   rt   rx   r{   r   r   r   r   r   r   r   r   r   r   <module>r      s   
  

9%JJ   YY

*,  
/MMBII-<
>jj-rtt4NJ N) 
=:
84 	!&"*Z
F*
   8& " ""*")] r   