HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/coverage/__pycache__/python.cpython-310.pyc
o

!we��@s&dZddlmZddlZddlZddlZddlmZm	Z	m
Z
mZmZddl
mZddlmZmZddlmZmZmZddlmZmZmZdd	lmZdd
lmZmZddlm Z ddl!m"Z"m#Z#m$Z$m%Z%erldd
l
m&Z&ee�Zd!dd�Z'd"dd�Z(d#dd�Z)d"dd�Z*d$dd�Z+Gdd �d e �Z,dS)%z'Python source expertise for coverage.py�)�annotationsN)�Dict�Iterable�Optional�Set�
TYPE_CHECKING)�env)�CoverageException�NoSource)�canonical_filename�relative_filename�zip_location)�	expensive�isolate_module�
join_regex)�PythonParser)�source_token_lines�source_encoding)�FileReporter)�TArc�TLineNo�TMorf�TSourceTokenLines)�Coverage�filename�str�return�bytescCsFt|d��}|��}Wd�n1swY|�dd��dd�S)zFRead the Python source text from `filename`.

    Returns bytes.

    �rbNs
�
�
)�open�read�replace)r�f�source�r&�H/home/arjun/projects/env/lib/python3.10/site-packages/coverage/python.py�read_python_sources
�r(cCs�tj�|�\}}|dkrtjrddg}n|g}|D]}||}tj�|�r+t|�}nt|�}|dur5n	qtd|�d���|�	dd�}|�
t|�d�}|rX|d	d
krX|d
7}|S)z#Return the source code, as unicode.�.pyz.pywNzNo source for code: 'z'.�� r#����
)�os�path�splitextr�WINDOWS�existsr(�
get_zip_bytesr
r#�decoder)r�base�ext�exts�try_filename�source_bytesr%r&r&r'�get_python_source)s&
�r:�Optional[bytes]cCsht|�}|dur2|\}}zt�|�}WntjyYdSwz|�|�}W|Sty1YdSwdS)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.

    N)r
�	zipimport�zipimporter�ZipImportError�get_data�OSError)r�
zipfile_inner�zipfile�inner�zi�datar&r&r'r3Ls���r3cCsZ|�d�r|S|�d�r+|dd�}tj�|�r|Stjr)|d}tj�|�r)|S|S|S)z�Return the source filename for `filename`.

    Given a file name being traced, return the best guess as to the source
    file to attribute it to.

    r))z.pycz.pyoNr,�w)�endswithr.r/r2rr1)r�py_filename�pyw_filenamer&r&r'�source_for_filecs

rJ�morfrcCsDt|d�r|jr|j}nt|tj�rtd|�d���|}t|�}|S)z6Get the source filename for the module-or-file `morf`.�__file__zModule z has no file)�hasattrrL�
isinstance�types�
ModuleTyper	rJ)rKrr&r&r'�source_for_morf�srQcs�eZdZdZd7d8�fd	d
�
Zd9dd
�Zd9dd�Zed:dd��Zd;dd�Z	d;dd�Z
d<dd�Zd=dd �Ze
d;d!d"��Ze
d>d#d$��Ze
d?d&d'��Z	d7d@d-d.�Zd9d/d0�ZdAd2d3�ZdBd5d6�Z�ZS)C�PythonFileReporterz!Report support for a Python file.NrKr�coverage�Optional[Coverage]r�Nonecs�||_t|�}|}d}|jdur|jjjrd}|rt|�}t��|�t|d�rE|j�	dt
j�}t
j�
|��d�r@|t
jd7}|d7}nt|�}||_d|_d|_d|_dS)NTF�__name__�.z	__init__.�__init__r))rSrQ�config�relative_filesr�superrXrMrVr#r.�sepr/�basename�
startswithr�relname�_source�_parser�	_excluded)�selfrKrSr�fname�canonicalize�name��	__class__r&r'rX�s(




zPythonFileReporter.__init__rcCsd|j�d�S)Nz<PythonFileReporter �>)r�rcr&r&r'�__repr__�szPythonFileReporter.__repr__cCs|jS�N)r_rjr&r&r'r�sz$PythonFileReporter.relative_filenamercCs@|jdusJ�|jdurt|j|j�d�d�|_|j��|jS)z&Lazily create a :class:`PythonParser`.N�exclude)rrm)rSrarr�_exclude_regex�parse_sourcerjr&r&r'�parser�s

�
zPythonFileReporter.parser�Set[TLineNo]cC�|jjS�z2Return the line numbers of statements in the file.)rp�
statementsrjr&r&r'�lines��zPythonFileReporter.linescCrrrs)rp�excludedrjr&r&r'�excluded_lines�rvz!PythonFileReporter.excluded_linesru�Iterable[TLineNo]cC�|j�|�Srl)rp�translate_lines)rcrur&r&r'r{��z"PythonFileReporter.translate_lines�arcs�Iterable[TArc]�	Set[TArc]cCrzrl)rp�translate_arcs)rcr}r&r&r'r��r|z!PythonFileReporter.translate_arcscCs4|jdusJ�|j�t|jjj�t|jjj��}|Srl)rSrp�lines_matchingrrY�partial_list�partial_always_list)rc�	no_branchr&r&r'�no_branch_lines�s�z"PythonFileReporter.no_branch_linescC�
|j��Srl)rpr}rjr&r&r'r}��
zPythonFileReporter.arcs�Dict[TLineNo, int]cCr�rl)rp�exit_countsrjr&r&r'r��r�zPythonFileReporter.exit_counts�startr�end�
executed_arcs�Optional[Iterable[TArc]]cCs|j�|||�Srl)rp�missing_arc_description)rcr�r�r�r&r&r'r��sz*PythonFileReporter.missing_arc_descriptioncCs|jdurt|j�|_|jSrl)r`r:rrjr&r&r'r%�s
zPythonFileReporter.source�boolcCs,tj�|j�\}}|�d�rdS|sdSdS)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.

        r)TF)r.r/r0rr^)rc�_r6r&r&r'�should_be_python�s	
z#PythonFileReporter.should_be_pythonrcCst|���Srl)rr%rjr&r&r'r�r|z%PythonFileReporter.source_token_linesrl)rKrrSrTrrU)rr)rr)rrq)ruryrrq)r}r~rr)rr)rr�)r�rr�rr�r�rr)rr�)rr)rV�
__module__�__qualname__�__doc__rXrkr�propertyrprurxr{r�rr�r}r�r�r%r�r�
__classcell__r&r&rgr'rR�s,





�

rR)rrrr)rrrr)rrrr;)rKrrr)-r��
__future__r�os.pathr.rOr<�typingrrrrrrSr�coverage.exceptionsr	r
�coverage.filesrrr
�
coverage.miscrrr�coverage.parserr�coverage.phystokensrr�coverage.pluginr�coverage.typesrrrrrr(r:r3rJrQrRr&r&r&r'�<module>s.


#