Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/site-packages/coverage/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/site-packages/coverage/__pycache__/python.cpython-35.pyc



E�W��@sdZddlZddlZddlZddlmZmZddlm	Z	m
Z
mZmZm
Z
mZddlmZddlmZmZddlmZee�Ze	dd	�d
d��Ze	dd�d
d��Ze	dd�dd��ZGdd�de�ZdS)z'Python source expertise for coverage.py�N)�env�files)�contract�CoverageException�	expensive�NoSource�
join_regex�isolate_module)�PythonParser)�source_token_lines�source_encoding)�FileReporter�returns�bytesc
Cs?t|d��)}|j�jdd�jdd�SWdQRXdS)zFRead the Python source text from `filename`.

    Returns bytes.

    �rbs
s
s
N)�open�read�replace)�filename�f�r�B/opt/alt/python35/lib64/python3.5/site-packages/coverage/python.py�read_python_sourcesr�unicodecCs	tjj|�\}}|dkr<tjr<ddg}n	|g}xs|D]H}||}tjj|�r{t|�}Pt|�}|dk	rLPqLWd|f}|d7}t|��|j	dd�}|j
t|�d�}|r|dd
kr|d
7}|S)z#Return the source code, as unicode.z.pyz.pywNzNo source for code: '%s'.
z*Aborting report output, consider using -i.s� r��
���)�os�path�splitextrZWINDOWS�existsr�
get_zip_bytesrr�decoder)r�base�extZextsZtry_filename�source�exc_msgrrr�get_python_source s(	




r(z
bytes|NonecCs�dtjdtjg}x�|D]�}||kr!|j|�}y%tj|d|dd��}Wntjk
r�w!YnXy|j|d�}Wntk
r�w!YnX|Sq!WdS)z�Get data from `filename` if it is a zip file path.

    Returns the bytestring data read from the zip file, or None if no zip file
    could be found or `filename` isn't in it.  The data returned will be
    an empty string if the file is empty.

    z.zipz.eggrNrr)r�sep�split�	zipimport�zipimporter�ZipImportError�get_data�IOError)r�markers�marker�partsZzi�datarrrr"Es	
%
r"cseZdZdZd�fdd�Zedd�dd��Zed	d
��Zdd�Z	d
d�Z
dd�Zdd�Ze
dd��Ze
dd��Ze
dd��Zddd�Zedd�dd��Zdd�Zdd �Z�S)!�PythonFileReporterz!Report support for a Python file.NcsJ||_t|d�r$|j}n0t|tj�rNtdj|���n|}tj	|�}|j
d�r�|dd�}n#|j
d�r�|dd
�d}tt|�j
tj|��t|d	�r
|j}|jd
tj�d}tj	|�}ntj|�}||_d|_d|_d|_d|_dS)N�__file__zModule {0} has no file�.pyc�.pyorz	$py.class�	z.py�__name__�.)r6r7ri����)�coverage�hasattrr5�
isinstance�types�
ModuleTyper�formatrZunicode_filename�endswith�superr4�__init__Zcanonical_filenamer9rrr)�relative_filename�relname�_source�_parserZ_statementsZ	_excluded)�selfZmorfr;r�name)�	__class__rrrCas,						zPythonFileReporter.__init__rrcCs|jS)N)rE)rHrrrrD�sz$PythonFileReporter.relative_filenamecCsJ|jdkrCtd|jd|jjd��|_|jj�|jS)z&Lazily create a :class:`PythonParser`.Nr�exclude)rGr
rr;Z_exclude_regexZparse_source)rHrrr�parser�s	
zPythonFileReporter.parsercCs
|jjS)z2Return the line numbers of statements in the file.)rLZ
statements)rHrrr�lines�szPythonFileReporter.linescCs
|jjS)z2Return the line numbers of statements in the file.)rLZexcluded)rHrrr�excluded_lines�sz!PythonFileReporter.excluded_linescCs|jj|�S)N)rL�translate_lines)rHrMrrrrO�sz"PythonFileReporter.translate_linescCs|jj|�S)N)rL�translate_arcs)rH�arcsrrrrP�sz!PythonFileReporter.translate_arcscCs7|jjt|jjj�t|jjj��}|S)N)rLZlines_matchingrr;�configZpartial_listZpartial_always_list)rHZ	no_branchrrr�no_branch_lines�s	z"PythonFileReporter.no_branch_linescCs
|jj�S)N)rLrQ)rHrrrrQ�szPythonFileReporter.arcscCs
|jj�S)N)rL�exit_counts)rHrrrrT�szPythonFileReporter.exit_countscCs|jj|||�S)N)rL�missing_arc_description)rH�start�endZ
executed_arcsrrrrU�sz*PythonFileReporter.missing_arc_descriptioncCs(|jdkr!t|j�|_|jS)N)rFr(r)rHrrrr&�szPythonFileReporter.sourcecCs<tjj|j�\}}|jd�r.dS|s8dSdS)z�Does it seem like this file should contain Python?

        This is used to decide if a file reported as part of the execution of
        a program was really likely to have contained Python in the first
        place.

        z.pyTF)rrr r�
startswith)rH�_r%rrr�should_be_python�s	z#PythonFileReporter.should_be_pythoncCst|j��S)N)rr&)rHrrrr�sz%PythonFileReporter.source_token_lines)r9�
__module__�__qualname__�__doc__rCrrD�propertyrLrMrNrOrPrrSrQrTrUr&rZrrr)rJrr4^s#r4)r]�os.pathrr>r+r;rrZ
coverage.miscrrrrrr	Zcoverage.parserr
Zcoverage.phystokensrrZcoverage.pluginr
rr(r"r4rrrr�<module>s.%