
    ,h/'                        d Z ddlZddlmZ  ej                  d      Z ej                  dej                  ej                  z  ej                  z        Z	 ej                  dej                  ej                  z  ej                  z        Z ej                  dej                        Z G d d	e      Z G d
 de      Zd dZd!dZd!dZd!dZd Zd Zd Zd Zd Zi Zd Zd Zd"dZd#dZ G d d      Z d Z!d Z"d Z# G d de      Z$y)$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                       e Zd ZdZy)ClassNotFoundzCRaised if one of the lookup functions didn't find a matching class.N__name__
__module____qualname____doc__     O/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/pygments/util.pyr   r      s    Mr   r   c                       e Zd ZdZy)OptionErrorz
    This exception will be raised by all option processing functions if
    the type or value of the argument is not correct.
    Nr   r   r   r   r   r   "   s    r   r   c                     | j                  ||      }|r|j                         }||vr8t        dj                  |dj	                  t        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, )getlowerr   formatjoinmapstr)optionsoptnamealloweddefaultnormcasestrings         r   get_choice_optr   (   s^    
 [['*FWAHHRVR[R[\_`cel\mRnoppMr   c                 4   | j                  ||      }t        |t              r|S t        |t              rt        |      S t        |t              st        d|d| d      |j                         dv ry|j                         dv ryt        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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                     | j                  ||      }	 t        |      S # t        $ r t        d|d| d      t        $ r t        d|d| d      w xY w)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_optr2   R   s    [['*F86{ 8M&<y I7 7 8 	8 8N6*L	 J7 7 8 	88s	   
 6Ac                     | j                  ||      }t        |t              r|j                         S t        |t        t
        f      rt	        |      S t        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.
    r   r    z; you must give a list value)r   r*   r   splitlisttupler   )r   r   r   vals       r   get_list_optr8   ^   sf     ++gw
'C#syy{	C$	'CyM#WI F3 3 4 	4r   c                     | j                   syg }| j                   j                         j                         D ]6  }|j                         r#|j                  d|j                         z          6 n dj	                  |      j                         S )N  )r
   strip
splitlinesappendr   lstrip)objreslines      r   docstring_headlinerC   n   sr    ;;
C!!#..0 ::<JJsTZZ\)*	
 773<  r   c                 F      fd} j                   |_         t        |      S )zAReturn a static text analyser function that returns float values.c           	          	  |       }|sy	 t        dt        dt        |                  S # t         $ r Y yw xY w# t        t
        f$ r Y yw xY w)Ng        g      ?)	Exceptionminmaxfloatr1   r0   )textrvfs     r   text_analysez%make_analysator.<locals>.text_analyse|   sb    	4B 	sCU2Y/00  		 I& 		s   . = 	::AA)r
   staticmethod)rL   rM   s   ` r   make_analysatorrO   z   s!    
 99L%%r   c                    | j                  d      }|dk\  r| d| j                         }n| j                         }|j                  d      r	 t        j	                  |dd j                               D cg c]  }|r|j                  d      s| c}d   }t        j                  d	| d
t        j                        }|j                  |      yyc c}w # t        $ r Y yw xY w)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 ``'^$'``)
    
r   Nz#!   -F^z(\.(exe|cmd|bat|bin))?$T)findr   
startswithsplit_path_rer4   r<   
IndexErrorrecompile
IGNORECASEsearch)rJ   regexindex
first_linexfounds         r   shebang_matchesrc      s    8 IIdOEz&5\'')
ZZ\
T"	 - 3 3JqrN4H4H4J K 51!,,s"3  5579E 

aw&=>N<<*5 		s$   (C 5CC C 	C#"C#c                     t         j                  |       }|y|j                  d      }t        j                  |t        j
                        j                  |j                               duS )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]   grouprZ   r[   Imatchr<   )rJ   r^   mdoctypes       r   doctype_matchesrl      sT     	  &AyggajG::eRTT"((9EEr   c                     t        | d      S )z3Check if the file looks like it has a html doctype.html)rl   )rJ   s    r   html_doctype_matchesro      s    4))r   c                     t         j                  |       ryt        |       }	 t        |   S # t        $ rA t
        j                  |       }|Y yt        j                  | dd       du}|t        |<   |cY S w xY w)z2Check if a doctype exists or if we have some tags.TNi  )xml_decl_reri   hash_looks_like_xml_cacheKeyErrorrf   r]   tag_re)rJ   keyrj   rK   s       r   looks_like_xmlrw      s|    
t*C$S)) $$T*=]]4;'t3%'c"	s   ,  A6%A65A6c                 "    d| dz	  z   d| dz  z   fS )zoGiven 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   g }d|z  dz  }d|dz   z  dz  }|j                  || z   dz          |r|D ]  }|j                  ||z   dz           n5|D ]0  }t        |dz         }|j                  ||dd z   |d	   z   dz          2 |j                  |d
z          dj                  |      S )z)Formats a sequence of strings for output.r;      re   z = (,"NrT   )rQ   )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x'&01
 	1ALL)C/0	1  	>AQWALL#2.26<=	> 
LLs"#99Ur   c                     g }t               }| D ]-  }||v s||v r|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      sM     C5D 9\)

1	
 Jr   c                       e Zd ZdZd Zy)FuturezGeneric class to defer some work.

    Handled specially in RegexLexerMeta, to support regex string construction at
    first use.
    c                     t         N)NotImplementedErrorselfs    r   r   z
Future.get  s    !!r   N)r   r   r	   r
   r   r   r   r   r   r   	  s    
"r   r   c                     	 | j                  d      } | dfS # t        $ rX 	 ddl}|j                         }| j                         } | |fcY S # t        t        f$ r | j                  d      } | dfcY cY S w xY ww xY w)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-8r   Nlatin1)decodeUnicodeDecodeErrorlocalegetpreferredencodingLookupError)rJ   r   prefencodings      r   guess_decoder     s    "{{7#W} "	"!668L;;=D%%"K0 	";;x(D>!	""s,    	A8'AA8$A4/A83A44A8c                     t        |dd      r*	 | j                  |j                        } | |j                  fS t	        |       S # t        $ r Y t	        |       S w xY w)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   )rJ   terms     r   guess_decode_from_terminalr   (  sd     tZ&	';;t}}-D &&	 " 	 		s   A 	AAc                 \    t        | dd      r| j                  S ddl}|j                         S )z7Return our best guess of encoding for the given *term*.r   Nr   )r   r   r   r   )r   r   s     r   terminal_encodingr   9  s*    tZ&}}&&((r   c                       e Zd Zd Zy)UnclosingTextIOWrapperc                 $    | j                          y r   )flushr   s    r   closezUnclosingTextIOWrapper.closeC  s    

r   N)r   r   r	   r   r   r   r   r   r   A  s    r   r   )NFr   )Fr   )r   )%r
   rZ   ior   r[   rX   DOTALL	MULTILINEVERBOSErf   r\   ru   rh   rq   r1   r   rF   r   r   r.   r2   r8   rC   rO   rc   rl   ro   rs   rw   r{   r   r   r   r   r   r   r   r   r   r   <module>r      s$   
  

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

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