Your IP : 216.73.216.74


Current Path : /opt/alt/python37/lib/python3.7/site-packages/pygments/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/pygments/__pycache__/util.cpython-37.opt-1.pyc

B

ν�\|.�@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-2019 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�>/opt/alt/python37/lib/python3.7/site-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)�1�yes�true�onT)�0�no�false�offFzCInvalid 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


r!cCs`|�||�}yt|�Stk
r8td||f��Yn$tk
rZtd||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	�
ValueError)rrrrrrr�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)cCsR|js
dSg}x4|j����D]"}|��r>|�d|���qPqWd�|���S)N�� )r�strip�
splitlines�appendr�lstrip)�obj�res�linerrr�docstring_headline`sr3cs�fdd�}�j|_t|�S)zAReturn a static text analyser function that returns float values.c	s\y�|�}Wntk
r dSX|s*dSytdtdt|���Sttfk
rVdSXdS)Ngg�?)�	Exception�min�max�floatr#r")�text�rv)�frr�text_analysensz%make_analysator.<locals>.text_analyse)r�staticmethod)r:r;r)r:r�make_analysatorlsr=cCs�|�d�}|dkr$|d|���}n|��}|�d�r�y(dd�t�|dd����D�d}Wntk
rrd	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>�sz#shebang_matches.<locals>.<listcomp>����Fz^%s(\.(exe|cmd|bat|bin))?$T)�findrr@�
split_path_rer%r,�
IndexError�re�compile�
IGNORECASE�search)r8�regex�indexZ
first_line�foundrrr�shebang_matches}s


rPcCs<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"'
    NFrD)�doctype_lookup_re�match�grouprIrJ�Ir,)r8rM�mZdoctyperrr�doctype_matches�s


rVcCs
t|d�S)z3Check if the file looks like it has a html doctype.Zhtml)rV)r8rrr�html_doctype_matches�srWcCslt�|�rdSt|�}yt|Stk
rft�|�}|dk	rDdSt�|dd��dk	}|t|<|SXdS)z2Check if a doctype exists or if we have some tags.TNi�)�xml_decl_rerR�hash�_looks_like_xml_cache�KeyErrorrQ�tag_rerL)r8�keyrUr9rrr�looks_like_xml�s

r^cCsd|d?d|d@fS)Ni���
i�i�r)�crrr�_surrogatepair�sracCs,||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]i�z(?:�|�)N)r#�sys�
maxunicode�unichrrar.r)�a�bZahZalZbhZblZbufrrr�unirange�s*
&
rjc	Cs�g}d|d}d|dd}|�||d�|rXx\|D]}|�||d�q<Wn<x:|D]2}t|d�}|�||dd�|d	d�q^W|�|d
�d�|�S)z)Formats a sequence of strings for output.r+�rbz = (�,�"N���rErdr>)r.�reprr)	�var_name�seq�rawZindent_level�linesZbase_indentZinner_indent�i�rrrr�format_liness

&rvrcCsBg}t�}x2|D]*}||ks||kr&q|�|�|�|�qW|S)za
    Returns a list with duplicates removed from the iterable `it`.

    Order is preserved.
    )�setr.�add)�itZalready_seenZlst�seenrtrrr�duplicates_removeds

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)�selfrrrr
*sz
Future.getN)rrrrr
rrrrr|$sr|cCsty|�d�}|dfStk
rny ddl}|��}|��}||fSttfk
rh|�d�}|dfSXYnXdS)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)r8r�Zprefencodingrrr�guess_decode.s

r�cCsDt|dd�r<y|�|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�)r8�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|��dS)N)�flush)r~rrr�closewszUnclosingTextIOWrapper.closeN)rrrr�rrrrr�usr�cs�fdd�}|S)z6Class decorator for creating a class with a metaclass.csR|j��}|�dd�|�dd�x|�dd�D]}|�|�q0W�|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�r)r�r�
add_metaclass{sr�)NF)N)N)N)Fr)r)<rrIrerJrG�DOTALL�	MULTILINE�VERBOSErQ�UNICODErKr\rTrXr#rr4r	rr!r$r)r3r=rPrVrWrZr^rarjrvr{�objectr|r�r�r��version_inforgZxrangerZunicoder Z	text_typeZu_prefix�dictZ	iteritemsZ
itervaluesr�Z	cStringIOr��chr�range�items�values�ior�r�r�rrrr�<module>
sf
	




-
	'