
    eg'                        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-2023 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__     v/var/www/html/FastMealFinder_FlaskServer-InitialRelease/venv/lib/python3.12/site-packages/pip/_vendor/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r.t        d|d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 z must be one of z, )getlowerr   joinmapstr)optionsoptnamealloweddefaultnormcasestrings         r   get_choice_optr   (   sY    
 [['*FW"DIIc#w.?$@B C 	C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-   6   s     [['*F&$	FC	 F|$$g/ 0 	0 
5	5	6	6$g/ 0 	0r   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_optr1   U   sh    [['*F	06{ 0$g/ 0 	0  0$g/ 0 	00s	   
 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_optr7   c   sY     ++gw
'C#syy{	C$	'Cy!7, - 	-r   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_headlinerB   t   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floatr0   r/   )textrvfs     r   text_analysez%make_analysator.<locals>.text_analyse   sb    	4B 	sCU2Y/00  		 I& 		s   . = 	::AA)r
   staticmethod)rK   rL   s   ` r   make_analysatorrN      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	|z  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#!   -Fz^%s(\.(exe|cmd|bat|bin))?$T)findr   
startswithsplit_path_rer3   r;   
IndexErrorrecompile
IGNORECASEsearch)rI   regexindex
first_linexfounds         r   shebang_matchesra      s    8 IIdOEz&5\'')
ZZ\
T"	 - 3 3JqrN4H4H4J K 51!,,s"3  5579E 

85@"--P<<*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[   grouprX   rY   Imatchr;   )rI   r\   mdoctypes       r   doctype_matchesrj      sT     	  &AyggajG::eRTT"((9EEr   c                     t        | d      S )z3Check if the file looks like it has a html doctype.html)rj   )rI   s    r   html_doctype_matchesrm      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_rerg   hash_looks_like_xml_cacheKeyErrorrd   r[   tag_re)rI   keyrh   rJ   s       r   looks_like_xmlru      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   surrogatepairry      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:      rc   z = (,"NrS   )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	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)rI   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   )rI   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   ?  s*    tZ&}}&&((r   c                       e Zd Zd Zy)UnclosingTextIOWrapperc                 $    | j                          y r   )flushr   s    r   closezUnclosingTextIOWrapper.closeI  s    

r   N)r   r   r	   r   r   r   r   r   r   G  s    r   r   )NFr   )Fr   )r   )%r
   rX   ior   rY   rV   DOTALL	MULTILINEVERBOSErd   rZ   rs   rf   ro   r0   r   rE   r   r   r-   r1   r7   rB   rN   ra   rj   rm   rq   ru   ry   r   r   r   r   r   r   r   r   r   r   <module>r      s$   
  

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

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