+
     h/'  c                   sJ   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                   s    ] 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       >/usr/lib/python3.14/site-packages/pip/_vendor/pygments/util.pyr   r      s    Mr
   r   c                   s    ] 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                s    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   ZformatjoinZmapstr)optionsoptnameZalloweddefaultZnormcasestrings   &&&&& r   get_choice_optr   (   sZ    
 [[*FAHHRVR[R[\_`cel\mRnoppMr
   c                sj   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 )Z1ZyesZtrueZon)Z0ZnoZfalseZoff)r   
isinstanceZboolintr   r   r   r   r   r   r      &&& r   get_bool_optr   5   s     [[*F&$	FC	 	 F|$$M&<y I< < = 	=	5	5	6	6N6*L	 J< < = 	=r
   c                s    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   r   r   get_int_optr    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                s    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   splitZlistZtupler   )r   r   r   Zvalr   r   get_list_optr"   ^   sj     ++g
'C#syy{	C$	'	'CyM#WI F3 3 4 	4r
   c                 sF   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       # )Z  )r   stripZ
splitlinesappendr   Zlstrip)ZobjZresZline   &  r   docstring_headliner'   n   sq    ;;;
C!!#..0::<<JJsTZZ\)*	 1
 773<  r
   c                sH   a  V 3R lpS P                   Vn         \        V4      # )zAReturn a static text analyser function that returns float values.c           	      s   <  S! V 4      pT'       g   R #  \        R\        R \        T4      4      4      #   \          d     R # i ; i  \        \
        3 d     R # i ; i)g        g      ?)	ExceptionZminZmaxZfloatr   r   )textrvfs   & r   text_analyseZ%make_analysator.<locals>.text_analyse|   sb    	4B 	sCU2Y/00  		 I& 		s    5 A AAAA)r   Zstaticmethod)r+   r,   s   f r   make_analysatorr-   z   s!    
 99L%%r
   c                s    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#!:i   NNZ-FZ^z(\.(exe|cmd|bat|bin))?$T)Zfindr   Z
startswithsplit_path_rer!   r$   Z
IndexErrorrecompile
IGNORECASEsearch)r)   regexZindexZ
first_lineZxZfounds   &&    r   shebang_matchesr6      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                s    \         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_rer4   Zgroupr1   r2   Imatchr$   )r)   r5   mZdoctypes   &&  r   doctype_matchesr;      sT     	  &AyggajG::eRTT"((9EEr
   c                s    \        V R4      # )z3Check if the file looks like it has a html doctype.Zhtml)r;   )r)      &r   html_doctype_matchesr=      s    4))r
   c                s   \         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_rer9   Zhash_looks_like_xml_cacheZKeyErrorr7   r4   tag_re)r)   Zkeyr:   r*   s   &   r   looks_like_xmlrA      s}    
t*C$S)) $$T*=]]4;'t3%'c"	s   7 $B
)B
	B
c                sB    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   )Zcr<   r   surrogatepairrB      s!     a2g1u9!577r
   c                s   . 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 = (Z,Z"NZ)r.   ir/   )r%   Zreprr   )	Zvar_nameZseqZrawZindent_levelZlinesZbase_indentZinner_indentiZrs	   &&&&     r   format_linesrD      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                s    . 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.
)Zsetr%   Zadd)ZitZalready_seenZlstZseenrC   s   &&   r   duplicates_removedrE      sD     C5D9)

1	 
 Jr
   c                   s*   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                s    \         hN)ZNotImplementedErrorZselfr<   r   r   Z
Future.get  s    !!r
   r   N)r   r   r   r   r   r   r	   __classdictcell__Z__classdict__   @r   rF   rF   	  s     
" "r
   rF   c                s     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-8NZlatin1)decodeUnicodeDecodeErrorlocalegetpreferredencodingZLookupError)r)   rN   Zprefencodingr&   r   guess_decoderP     s    "{{7#W} "	"!668L;;=D%%"K0 	";;x(D>!	""s,    A;&A	A;&A72A;6A77A;c                s    \        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)getattrrL   rQ   rM   rP   )r)   terms   &&r   guess_decode_from_terminalrT   (  sX     tZ&&	';;t}}-D &&	 " 		s   A AAc                sh    \        V RR4      '       d   V P                  # ^ RIpVP                  4       # )z7Return our best guess of encoding for the given *term*.rQ   N)rR   rQ   rN   rO   )rS   rN   s   & r   terminal_encodingrU   9  s-    tZ&&}}&&((r
   c                   s&   a  ] tR tRt o R tRtV tR# )UnclosingTextIOWrapperiA  c                s&    V P                  4        R # rG   )ZflushrH   r<   r   closeZUnclosingTextIOWrapper.closeC  s    

r
   r   N)r   r   r   r   rW   r	   rI   rJ   rK   r   rV   rV   A  s      r
   rV   )NFrG   )Fi    )r   )%r   r1   Zior    r2   r0   ZDOTALLZ	MULTILINEZVERBOSEr7   r3   r@   r8   r>   r   r   r(   r   r   r   r    r"   r'   r-   r6   r;   r=   r?   rA   rB   rD   rE   rF   rP   rT   rU   rV   r   r
   r   <module>rX      s   
  

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

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