File: //usr/lib/python3/dist-packages/pygments/__pycache__/util.cpython-38.pyc
U
`a�[|. � @ s� d Z ddlZddlZe�d�Ze�dejejB ejB �Ze�dej ej
B ejB ejB �Ze�dej�Z
G dd� de�ZG d d
� d
e�Zd9dd
�Zd:dd�Zd;dd�Zd<dd�Zdd� Zdd� Zdd� Zdd� Zdd� Zi Zdd� Zd d!� Zd"d#� Zd=d$d%�Zd>d'd(�Z G d)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.j7Z0dd4l8m1Z1m3Z3m9Z9 G d5d6� 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 @ s e Zd ZdZdS )�
ClassNotFoundzCRaised if one of the lookup functions didn't find a matching class.N)�__name__�
__module__�__qualname__�__doc__� r r �//usr/lib/python3/dist-packages/pygments/util.pyr s r c @ s e Zd ZdS )�OptionErrorN)r r r r r r r r $ s r Fc C s@ | � ||�}|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�stringr r r �get_choice_opt( s �r c C s| | � ||�}t|t�r|S t|t�r,t|�S t|t�sHtd||f ��n0|�� dkrXdS |�� dkrhdS td||f ��d S )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 �r r r r r r r �get_bool_opt2 s(
�� ��r c C sb | � ||�}z
t|�W S tk
r: td||f ��Y n$ tk
r\ td||f ��Y nX d S )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 �
ValueErrorr r r r �get_int_optF s
��
��r c C sH | � ||�}t|t�r|�� S t|ttf�r4t|�S td||f ��d S )Nz9Invalid type %r for option %s; you must give a list value)r
r r �split�list�tupler )r r r �valr r r �get_list_optT s
��r% c C sP | j s
dS g }| j �� �� D ]$}|�� r<|�d|�� � q qBqd�|��� S )N� � )r �strip�
splitlines�appendr �lstrip)�obj�res�liner r r �docstring_headline` s r/ c s � fdd�}� j |_ t|�S )zAReturn a static text analyser function that returns float values.c sb z� | �}W n t k
r" Y dS X |s,dS ztdtdt|���W S ttfk
r\ Y dS X d S )Ng g �?)� Exception�min�max�floatr r )�text�rv��fr r �text_analysen s z%make_analysator.<locals>.text_analyse)r �staticmethod)r7 r8 r r6 r �make_analysatorl s r: c C s� | � d�}|dkr$| d|� �� }n| �� }|�d�r�z(dd� t�|dd� �� �D �d }W n tk
rt Y d S X t�d
| tj �}|�
|�dk r�dS d 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 ``'^$'``)
�
r Nz#!c S s g | ]}|r|� d �s|�qS )�-)�
startswith)�.0�xr r r �
<listcomp>� s
�z#shebang_matches.<locals>.<listcomp>� ���Fz^%s(\.(exe|cmd|bat|bin))?$T)�findr r= �
split_path_rer! r( �
IndexError�re�compile�
IGNORECASE�search)r4 �regex�indexZ
first_line�foundr r r �shebang_matches} s
�rM c C s<