%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/pygments/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/pygments/__pycache__/util.cpython-312.pyc

�

|�e�'���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-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��eZdZdZy)�
ClassNotFoundzCRaised if one of the lookup functions didn't find a matching class.N��__name__�
__module__�__qualname__�__doc__���//usr/lib/python3/dist-packages/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�}||vr.td|�ddjt	t
|������|S)z}
    If the key `optname` from the dictionary is not in the sequence
    `allowed`, raise an error, otherwise return it.
    zValue 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���"�D�I�I�c�#�w�.?�$@�B�C�	C��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-6s����[�[��'�
*�F��&�$���
�	�F�C�	 ��F�|��
���
$��$�g�/�0�	0�
����5�	5��	����6�	6���$�g�/�0�	0r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.rrz ; you must give an integer valuer()rr+�	TypeErrorr�
ValueErrorr,s    r
�get_int_optr1Ush��
�[�[��'�
*�F�	0��6�{����0��$�g�/�0�	0��0��$�g�/�0�	0�0�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.
    rrz; you must give a list value)rr)r�split�list�tupler)rrr�vals    r
�get_list_optr7csY���+�+�g�w�
'�C��#�s���y�y�{��	�C�$���	'��C�y���!�7�,�-�	-r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_headlinerBtsr���;�;��
�C����!�!�#�.�.�0����:�:�<��J�J�s�T�Z�Z�\�)�*��	�
�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�floatr0r/)�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)rKrLs` r
�make_analysatorrN�s!���
��9�9�L����%�%rc���|jd�}|dk\r|d|j�}n|j�}|jd�r�	tj	|ddj��D�cgc]}|r|jd�s|��c}d}tjd	|ztj�}|j|��y
ycc}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#!��-���Fz^%s(\.(exe|cmd|bat|bin))?$T)�findr�
startswith�
split_path_rer3r;�
IndexError�re�compile�
IGNORECASE�search)rI�regex�index�
first_line�x�founds      r
�shebang_matchesra�s���8
�I�I�d�O�E���z��&�5�\�'�'�)�
��Z�Z�\�
����T�"�	� -� 3� 3�J�q�r�N�4H�4H�4J� K�5�1��!�,�,�s�"3��5�57�9�E��
�
�8�5�@�"�-�-�P���<�<���*����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[�grouprXrY�I�matchr;)rIr\�m�doctypes    r
�doctype_matchesrj�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)rj)rIs r
�html_doctype_matchesrm�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_rerg�hash�_looks_like_xml_cache�KeyErrorrdr[�tag_re)rI�keyrhrJs    r
�looks_like_xmlru�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
�
surrogatepairry�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:�rcz = (�,�"N���rS�)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�	�L�L��x�'�&�0�1�
��	1�A��L�L���)�C�/�0�	1��	>�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��sM��
�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)rIr��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�)rI�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�?s*���t�Z��&��}�}����&�&�(�(rc��eZdZd�Zy)�UnclosingTextIOWrapperc�$�|j�yr�)�flushr�s r
�closezUnclosingTextIOWrapper.closeIs���
�
�rN)rrr	r�rrr
r�r�Gs��rr�)NFr�)Fr)r)%r
rX�iorrYrV�DOTALL�	MULTILINE�VERBOSErdrZrsrfror0rrErrr-r1r7rBrNrarjrmrqruryr�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��)���0�>0�-�"	!�&�"*�Z
F�*�
��
� 8��&
� "�"�"�*�")��]�r

Zerion Mini Shell 1.0