HEX
Server: Apache
System: Linux srv1.prosuiteplus.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: prosuiteplus (1001)
PHP: 8.3.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/pygments/__pycache__/util.cpython-38.pyc
U

`a�[|.�@s�dZddlZddlZe�d�Ze�dejejBejB�Ze�dej	ej
BejBejB�Ze�dej�Z
Gdd�de�ZGd	d
�d
e�Zd9dd
�Zd:dd�Zd;dd�Zd<dd�Zdd�Zdd�Zdd�Zdd�Zdd�ZiZdd�Zd d!�Zd"d#�Zd=d$d%�Zd>d'd(�Z Gd)d*�d*e!�Z"d+d,�Z#d-d.�Z$d/d0�Z%ej&d1k�r|e'Z'e(Z(e)e*fZ+e*Z,d2Z-e.j/Z/e.j0Z0ddl1Z1ddl2Z2e1j1Z1e2j1Z3nFe4Z'e5Z(e)fZ+e)Z,d3Z-e.j6Z/e.j7Z0dd4l8m1Z1m3Z3m9Z9Gd5d6�d6e9�Z:d7d8�Z;dS)?z�
    pygments.util
    ~~~~~~~~~~~~~

    Utility functions.

    :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
�Nz[/\\ ]z�
    (<\?.*?\?>)?\s*
    <!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__�rr�//usr/lib/python3/dist-packages/pygments/util.pyr src@seZdZdS)�OptionErrorN)rrrrrrrr	$sr	FcCs@|�||�}|r|��}||kr<td|d�tt|��f��|S)Nz%Value for option %s must be one of %sz, )�get�lowerr	�join�map�str)�options�optnameZallowed�default�normcase�stringrrr�get_choice_opt(s�rcCs||�||�}t|t�r|St|t�r,t|�St|t�sHtd||f��n0|��dkrXdS|��dkrhdStd||f��dS)NzBInvalid type %r for option %s; use 1/0, yes/no, true/false, on/off)�1Zyes�trueZonT)�0ZnoZfalseZoffFzCInvalid value %r for option %s; use 1/0, yes/no, true/false, on/off)r
�
isinstance�bool�int�string_typesr	r�rrrrrrr�get_bool_opt2s(


����rcCsb|�||�}z
t|�WStk
r:td||f��Yn$tk
r\td||f��YnXdS)Nz=Invalid type %r for option %s; you must give an integer valuez>Invalid value %r for option %s; you must give an integer value)r
r�	TypeErrorr	�
ValueErrorrrrr�get_int_optFs
��
��r cCsH|�||�}t|t�r|��St|ttf�r4t|�Std||f��dS)Nz9Invalid type %r for option %s; you must give a list value)r
rr�split�list�tupler	)rrr�valrrr�get_list_optTs
��r%cCsP|js
dSg}|j����D]$}|��r<|�d|���qqBqd�|���S)N�� )r�strip�
splitlines�appendr�lstrip)�obj�res�linerrr�docstring_headline`sr/cs�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�floatrr)�text�rv��frr�text_analysensz%make_analysator.<locals>.text_analyse)r�staticmethod)r7r8rr6r�make_analysatorlsr:cCs�|�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�xrrr�
<listcomp>�s
�z#shebang_matches.<locals>.<listcomp>����Fz^%s(\.(exe|cmd|bat|bin))?$T)�findrr=�
split_path_rer!r(�
IndexError�re�compile�
IGNORECASE�search)r4�regex�indexZ
first_line�foundrrr�shebang_matches}s

�rMcCs<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"'
    NFrA)�doctype_lookup_re�match�grouprFrG�Ir()r4rJ�mZdoctyperrr�doctype_matches�s


rScCs
t|d�S)z3Check if the file looks like it has a html doctype.Zhtml)rS)r4rrr�html_doctype_matches�srTcCstt�|�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_rerO�hash�_looks_like_xml_cache�KeyErrorrN�tag_rerI)r4�keyrRr5rrr�looks_like_xml�s


r[cCsd|d?d|d@fS)Ni���
��i�r)�crrr�_surrogatepair�sr_cCs,||krtd��|dks |dkr(td��tjdkrFdt|�t|�fSt|�\}}t|�\}}||kr�dt|�t|�t|�fSg}|�dt|�t|�||kr�t|�p�td�f�||d	kr�|�d
t|d	�t|d	�td�td��||k�r|�dt|�td�t|�f�dd
�|�dSdS)zEReturns a regular expression string to match the given non-BMP range.zBad character rangeiz+unirange is only defined for non-BMP rangesi��z[%s-%s]z
(?:%s[%s-%s])z	%s[%s-%s]i���z[%s-%s][%s-%s]r]z(?:�|�)N)r�sys�
maxunicode�unichrr_r*r)�a�bZahZalZbhZblZbufrrr�unirange�s:
��
�
�
�rhc	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'�r`z = (�,�"N���rBrbr;)r*�reprr)	Zvar_name�seq�rawZindent_level�linesZbase_indentZinner_indent�i�rrrr�format_liness$rsrcCs>g}t�}|D]*}||ks||kr$q|�|�|�|�q|S)za
    Returns a list with duplicates removed from the iterable `it`.

    Order is preserved.
    )�setr*�add)�itZalready_seenZlst�seenrqrrr�duplicates_removeds
rxc@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��selfrrrr
*sz
Future.getN)rrrrr
rrrrry$sryc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)r4r�Zprefencodingrrr�guess_decode.s


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)�getattrrr�r�r�)r4�termrrr�guess_decode_from_terminalCs
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�rrr�terminal_encodingTsr�)�r�ur&)�StringIO�BytesIO�
TextIOWrapperc@seZdZdd�ZdS)�UnclosingTextIOWrappercCs|��dSrz)�flushr|rrr�closewszUnclosingTextIOWrapper.closeN)rrrr�rrrrr�usr�cs�fdd�}|S)z6Class decorator for creating a class with a metaclass.csN|j��}|�dd�|�dd�|�dd�D]}|�|�q.�|j|j|�S)N�__dict__�__weakref__�	__slots__r)r��copy�popr
r�	__bases__)�clsZ	orig_varsZ	slots_var��	metaclassrr�wrapper}s
zadd_metaclass.<locals>.wrapperr)r�r�rr�r�
add_metaclass{sr�)NF)N)N)N)Fr)r)<rrFrcrGrD�DOTALL�	MULTILINE�VERBOSErN�UNICODErHrYrQrUrrr0r	rrr r%r/r:rMrSrTrWr[r_rhrsrx�objectryr�r�r��version_inforeZxrangerZunicoderZ	text_typeZu_prefix�dictZ	iteritemsZ
itervaluesr��	cStringIOr��chr�range�items�values�ior�r�r�rrrr�<module>sj

	�
�




-
	'