Your IP : 216.73.216.213
B
E�Wq� � @ sV d Z ddlZddlZddlZddlZddlZddlZddlmZ ddl m
Z
ddl mZmZ ddl
mZ ddlmZ ddlmZmZmZmZ dd lmZmZmZ dd
lmZmZmZ G dd� de�ZG d
d� de�ZG dd� de�Z G dd� de�Z!G dd� de�Z"G dd� de�#dd��Z$eddd� � G dd� de�Z%dgZ&dd � Z'd#d!d"�Z(dS )$zCode parsing for coverage.py.� N)�env)�range)�
bytes_to_ints�string_class)�CodeObjects)�short_stack)�contract�new_contract� nice_pair�
join_regex)�CoverageException�NoSource� NotPython)�compile_unicode�generate_tokens�neuter_encoding_declarationc @ s� e Zd ZdZedd�ddd��Zedd� �Zd d
� Zdd� Z d
d� Z
dd� Zdd� Zdd� Z
dd� Zdd� Zdd� Zdd� Zd dd�ZdS )!�PythonParserz�Parse code to find executable lines, excluded lines, etc.
This information is all based on static analysis: no code execution is
involved.
zunicode|None)�textNc
C s� |s|st d��|pd| _|| _| jsxddlm} y|| j�| _W n4 tk
rv } ztd| j|f ��W dd}~X Y nX || _| j�d�| _ t
� | _t
� | _t
� | _
t
� | _t
� | _t
� | _d| _i | _d| _d| _d| _dS ) z�
Source can be provided as `text`, the text itself, or `filename`, from
which the text will be read. Excluded lines are those that match
`exclude`, a regex.
z*PythonParser needs either text or filenamez<code>r )�get_python_sourcezNo source for code: '%s': %sN�
F)�AssertionError�filenamer Zcoverage.pythonr �IOErrorr
�exclude�split�lines�set�
statements�excluded�raw_statements�raw_excluded�
raw_classdefs�raw_docstrings�show_tokens�
_multiline�_byte_parser� _all_arcs�_missing_arc_fragments)�selfr r r r �err� r* �B/opt/alt/python37/lib64/python3.7/site-packages/coverage/parser.py�__init__ s.
"zPythonParser.__init__c C s | j st| j| jd�| _ | j S )zCreate a ByteParser on demand.)r )r% �
ByteParserr r )r( r* r* r+ �byte_parser\ s zPythonParser.byte_parserc G s\ t |�}tjr|�d�}t�|�}t� }x.t| jdd�D ]\}}|� |�r8|�
|� q8W |S )z�Find the lines matching one of a list of regexes.
Returns a set of line numbers, the lines that contain a match for one
of the regexes in `regexes`. The entire line needn't match, just a
part of it.
�utf8� )�start)r r �PY2�decode�re�compiler � enumerater �search�add)r( ZregexesZcombinedZregex_c�matches�i�ltextr* r* r+ �lines_matchingc s
zPythonParser.lines_matchingc C sH | j r| �| j �| _d}d}d}d}tj}d}d}d}t| j�} �x�| D �]�\}
}\}}
\}}
}| jr�tdt j
�|
|
�t||f�||f � |
tjkr�|d7 }�n0|
tj
kr�|d8 }�n|
tjkr�|dkr�| j�|� n�|
tjk�rV|dk�r"|| jkp�|}|�sT|�rT| j�|� |}d}d}n2|d k�r�|�r�|| jk�rBd}|�r�| j�|� n||
tjk�r�|tjk�r�| j�t||d �� nL|
tjk�r�|dk �r�||k�r�x"t||d �D ]}|| j|<