Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/pip/_vendor/pygments/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/pip/_vendor/pygments/__pycache__/util.cpython-312.pyc

�

4Μg/'���dZddlZddlmZejd�Zejdejejzejz�Z	ejdejejzejz�Zejdej�Z
Gd�d	e�ZGd
�de�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-2024 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��eZdZdZy)�
ClassNotFoundzCRaised if one of the lookup functions didn't find a matching class.N��__name__�
__module__�__qualname__�__doc__���D/usr/local/lib/python3.12/site-packages/pip/_vendor/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.
    Nrrrr
rr"s��rrc���|j||�}|r|j�}||vr8tdj|dj	tt|�����|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��RV�R[�R[�\_�`c�el�\m�Rn�o�p�p��Mrc�4�|j||�}t|t�r|St|t�rt|�St|t�std|�d|�d���|j
�dvry|j
�dvrytd|�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.5s����[�[��'�
*�F��&�$���
�	�F�C�	 ��F�|��
���
$��M�&��<��y�I<�<�=�	=�	����5�	5��	����6�	6���N�6�*�L��	�J<�<�=�	=r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.rr z ; you must give an integer valuer))rr,�	TypeErrorr�
ValueErrorr-s    r
�get_int_optr2Rs���
�[�[��'�
*�F�8��6�{����8��M�&��<��y�I7�7�8�	8��8��N�6�*�L��	�J7�7�8�	8�8�s	�
�6Ac���|j||�}t|t�r|j�St|tt
f�rt	|�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.
    rr z; you must give a list value)rr*r�split�list�tupler)rrr�vals    r
�get_list_optr8^sf���+�+�g�w�
'�C��#�s���y�y�{��	�C�$���	'��C�y���M�#���W�I�F3�3�4�	4r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_headlinerCnsm���;�;��
�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�floatr1r0)�text�rv�fs  �r
�text_analysez%make_analysator.<locals>.text_analyse|sb���	��4��B���	��s�C��U�2�Y�/�0�0���	��	���I�&�	��	�s�.�=�	:�:�A�A)r
�staticmethod)rLrMs` r
�make_analysatorrOzs!���
��9�9�L����%�%rc���|jd�}|dk\r|d|j�}n|j�}|jd�r�	tj	|ddj��D�cgc]}|r|jd�s|��c}d}tjd	|�d
�tj�}|j|��yycc}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#!��-���F�^z(\.(exe|cmd|bat|bin))?$T)�findr�
startswith�
split_path_rer4r<�
IndexError�re�compile�
IGNORECASE�search)rJ�regex�index�
first_line�x�founds      r
�shebang_matchesrc�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��
�
�a��w�&=�>��
�
�N���<�<���*����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]�grouprZr[�I�matchr<)rJr^�m�doctypes    r
�doctype_matchesrl�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)rl)rJs r
�html_doctype_matchesro�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_reri�hash�_looks_like_xml_cache�KeyErrorrfr]�tag_re)rJ�keyrjrKs    r
�looks_like_xmlrw�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
�
surrogatepairr{�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�dj|�S)z)Formats a sequence of strings for output.r;�rez = (�,�"N���rT�)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�	�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
rrr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)rJr��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�)rJ�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�9s*���t�Z��&��}�}����&�&�(�(rc��eZdZd�Zy)�UnclosingTextIOWrapperc�$�|j�yr�)�flushr�s r
�closezUnclosingTextIOWrapper.closeCs���
�
�rN)rrr	r�rrr
r�r�As��rr�)NFr�)Fr)r)%r
rZ�iorr[rX�DOTALL�	MULTILINE�VERBOSErfr\rurhrqr1rrFrrr.r2r8rCrOrcrlrorsrwr{r�r�r�r�r�r�r�rrr
�<module>r�s$���
����
�
�9�%�
��B�J�J� ��Y�Y������
�
�*�,��
����/��M�M�B�I�I�-����<�
>���b�j�j�-�r�t�t�4��N�J�N��)��
�=�:
8�
4� 	!�&�"*�Z
F�*�
��
� 8��&
� "�"�"�*�")��]�r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists