HEX
Server: Apache
System: Linux sg2plmcpnl492417.prod.sin2.secureserver.net 4.18.0-553.58.1.lve.el8.x86_64 #1 SMP Fri Jul 4 12:07:06 UTC 2025 x86_64
User: nyiet8349bzl (9207396)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/python38/lib/python3.8/site-packages/pip/_vendor/pygments/__pycache__/util.cpython-38.pyc
U

��e�'�@s6dZddlZddlmZe�d�Ze�dejejBejB�Z	e�dej
ejBejB�Ze�dej�Z
Gdd	�d	e�ZGd
d�de�Zd2d
d�Zd3dd�Zd4dd�Zd5dd�Zdd�Zdd�Zdd�Zdd�Zdd�ZiZdd �Zd!d"�Zd6d#d$�Zd7d&d'�ZGd(d)�d)�Z d*d+�Z!d,d-�Z"d.d/�Z#Gd0d1�d1e�Z$dS)8z�
    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@seZdZdZdS)�
ClassNotFoundzCRaised if one of the lookup functions didn't find a matching class.N��__name__�
__module__�__qualname__�__doc__�r	r	�=/tmp/pip-unpacked-wheel-uzdrexel/pip/_vendor/pygments/util.pyrsrc@seZdZdZdS)�OptionErrorz�
    This exception will be raised by all option processing functions if
    the type or value of the argument is not correct.
    Nrr	r	r	r
r"srFcCs@|�||�}|r|��}||kr<td|d�tt|��f��|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 %s must be one of %sz, )�get�lowerr�join�map�str)�options�optname�allowed�default�normcase�stringr	r	r
�get_choice_opt(s�rcCs||�||�}t|t�r|St|t�r,t|�St|t�sHtd||f��n0|��dkrXdS|��dkrhdStd||f��dS)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).
    zBInvalid type %r for option %s; use 1/0, yes/no, true/false, on/off)�1�yes�true�onT)�0�no�false�offFzCInvalid value %r for option %s; use 1/0, yes/no, true/false, on/offN)r�
isinstance�bool�intrrr
�rrrrr	r	r
�get_bool_opt6s(


����r$cCsb|�||�}z
t|�WStk
r:td||f��Yn$tk
r\td||f��YnXdS)z?As :func:`get_bool_opt`, but interpret the value as an integer.z=Invalid type %r for option %s; you must give an integer valuez>Invalid value %r for option %s; you must give an integer valueN)rr"�	TypeErrorr�
ValueErrorr#r	r	r
�get_int_optUs
��
��r'cCsH|�||�}t|t�r|��St|ttf�r4t|�Std||f��dS)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.
    z9Invalid type %r for option %s; you must give a list valueN)rr r�split�list�tupler)rrr�valr	r	r
�get_list_optcs
��r,cCsP|js
dSg}|j����D]$}|��r<|�d|���qqBqd�|���S)N�� )r�strip�
splitlines�appendr�lstrip)�obj�res�liner	r	r
�docstring_headlinetsr6cs�fdd�}�j|_t|�S)zAReturn a static text analyser function that returns float values.c	sbz�|�}Wntk
r"YdSX|s,dSztdtdt|���WSttfk
r\YdSXdS)Ngg�?)�	Exception�min�max�floatr&r%)�text�rv��fr	r
�text_analyse�sz%make_analysator.<locals>.text_analyse)r�staticmethod)r>r?r	r=r
�make_analysator�srAcCs�|�d�}|dkr$|d|���}n|��}|�d�r�z(dd�t�|dd����D�d}Wntk
rtYd	SXt�d
|tj	�}|�
|�dk	r�dSd	S)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#!cSsg|]}|r|�d�s|�qS)�-)�
startswith)�.0�xr	r	r
�
<listcomp>�s
�z#shebang_matches.<locals>.<listcomp>����Fz^%s(\.(exe|cmd|bat|bin))?$T)�findr
rD�
split_path_rer(r/�
IndexError�re�compile�
IGNORECASE�search)r;�regex�index�
first_line�foundr	r	r
�shebang_matches�s

�rUcCs<t�|�}|dkrdS|�d�}t�|tj��|���dk	S)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_rerP�grouprMrN�I�matchr/)r;rQ�m�doctyper	r	r
�doctype_matches�s


r]cCs
t|d�S)z3Check if the file looks like it has a html doctype.�html)r])r;r	r	r
�html_doctype_matches�sr_cCstt�|�rdSt|�}z
t|WStk
rnt�|�}|dk	rHYdSt�|dd��dk	}|t|<|YSXdS)z2Check if a doctype exists or if we have some tags.TNi�)�xml_decl_rerZ�hash�_looks_like_xml_cache�KeyErrorrWrP�tag_re)r;�keyr[r<r	r	r
�looks_like_xml�s


rfcCsd|d?d|d@fS)zoGiven a unicode character code with length greater than 16 bits,
    return the two 16 bit surrogate pair.
    i���
i�i�r	)�cr	r	r
�
surrogatepair�sric	Cs�g}d|d}d|dd}|�||d�|rT|D]}|�||d�q:n8|D]2}t|d�}|�||dd�|d	d�qX|�|d
�d�|�S)z)Formats a sequence of strings for output.r.�rVz = (�,�"N���rI�)rB)r1�reprr)	�var_name�seq�raw�indent_level�linesZbase_indentZinner_indent�i�rr	r	r
�format_lines�s$rwr	cCs>g}t�}|D]*}||ks||kr$q|�|�|�|�q|S)za
    Returns a list with duplicates removed from the iterable `it`.

    Order is preserved.
    )�setr1�add)�itZalready_seen�lst�seenrur	r	r
�duplicates_removed�s
r}c@seZdZdZdd�ZdS)�Futurez�Generic class to defer some work.

    Handled specially in RegexLexerMeta, to support regex string construction at
    first use.
    cCst�dS�N)�NotImplementedError��selfr	r	r
rsz
Future.getN)rrrrrr	r	r	r
r~sr~cCs�z|�d�}|dfWStk
r~z&ddl}|��}|��}||fWYSttfk
rx|�d�}|dfYYSXYnXdS)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)r;r�Zprefencodingr	r	r
�guess_decodes


r�cCsDt|dd�r<z|�|j�}Wntk
r0YnX||jfSt|�S)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�)r;�termr	r	r
�guess_decode_from_terminal.s
r�cCs"t|dd�r|jSddl}|��S)z7Return our best guess of encoding for the given *term*.r�Nr)r�r�r�r�)r�r�r	r	r
�terminal_encoding?sr�c@seZdZdd�ZdS)�UnclosingTextIOWrappercCs|��dSr)�flushr�r	r	r
�closeIszUnclosingTextIOWrapper.closeN)rrrr�r	r	r	r
r�Gsr�)NF)N)N)N)Fr)r	)%rrM�iorrNrK�DOTALL�	MULTILINE�VERBOSErWrOrdrYr`r&rr7rrr$r'r,r6rArUr]r_rbrfrirwr}r~r�r�r�r�r	r	r	r
�<module>s>

�	�



-