
    zi1"                    D   d Z ddlmZ ddlZddlZddlZddlmZ ddl	m
Z
 ddlmZ ddlmZmZ ddlmZmZmZ dd	lmZmZ dd
lmZ ddlmZmZ ddlmZmZ ddlm Z  ddl!m"Z"m#Z#m$Z$m%Z% e
rddlm&Z&  ee          Ze'Z'ddZ(ddZ)d dZ*ddZ+d!dZ, G d de          Z-dS )"z'Python source expertise for coverage.py    )annotationsN)Iterable)TYPE_CHECKING)env)CoverageExceptionNoSource)canonical_filenamerelative_filenamezip_location)isolate_module
join_regex)PythonParser)source_encodingsource_token_lines)
CodeRegionFileReporter)code_regions)TArcTLineNoTMorfTSourceTokenLines)Coveragefilenamestrreturnbytesc                    t          | d          5 }|                                }ddd           n# 1 swxY w Y   |                    dd                              dd          S )zFRead the Python source text from `filename`.

    Returns bytes.

    rbNs   
   
   )openreadreplace)r   fsources      Z/var/www/tmov.alphamb/tmov_inventario/venv/lib/python3.11/site-packages/coverage/python.pyread_python_sourcer'   !   s     
h		                >>'5))11%???s   266c                   t           j                            |           \  }}|dk    rt          j        rddg}n|g}|D ]J}||z   }t           j                            |          rt          |          } n)t          |          }| nKt          d|  dd          |	                    dd	          }|
                    t          |          d
          }|r|d         dk    r|dz  }|S )z#Return the source code, as unicode..pyz.pywNzNo source for code: 'z'.z	no-source)slug       r#   
)ospathsplitextr   WINDOWSexistsr'   get_zip_bytesr   r#   decoder   )r   baseextextstry_filenamesource_bytesr%   s          r&   get_python_sourcer;   -   s     **ID#
e|||vu  O Ocz7>>,'' 	-l;;LE %\22#E $ ;x;;;+NNNN  ''t44L  !>!>	JJF  &*$$$M    bytes | Nonec                    t          |           }|[|\  }}	 t          j        |          }n# t          j        $ r Y dS w xY w	 |                    |          }n# t
          $ r Y dS w xY w|S dS )zGet 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datas         r&   r4   r4   P   s     !**M &	&w//BB' 	 	 	44		;;u%%DD 	 	 	44	4s    - A A A 
A('A(c                   |                      d          r| S |                      d          r_| dd         }t          j                            |          r|S t          j        r&|dz   }t          j                            |          r|S |S | S )zReturn 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/   r0   r3   r   r2   )r   py_filenamepyw_filenames      r&   source_for_filerN   g   s      			+	,	, ssm7>>+&& 	; 	$&,Lw~~l++ $## Or<   morfr   c                    t          | d          r| j        r| j        }n/t          | t          j                  rt          d|  d          | }t          |          }|S )z6Get the source filename for the module-or-file `morf`.__file__zModule z has no file)hasattrrQ   
isinstancetypes
ModuleTyper   rN   )rO   r   s     r&   source_for_morfrV      sn    tZ   T] =	D%*	+	+    <$ < < <===x((HOr<   c                       e Zd ZdZd/d0 fd	Zd1dZd1dZed2d            Zd3dZ	d4dZ
d3dZd5dZd6dZd3dZd7dZd8dZ	 d/d9d$Zd:d%Zd1d&Zd;d(Zd<d*Zd=d,Zd>d.Z xZS )?PythonFileReporterz!Report support for a Python file.NrO   r   coverageCoverage | Noner   Nonec                (   || _         t          |          }|}d}| j         | j         j        j        rd}|rt	          |          }t                                          |           t          |d          ro|j        	                    dt          j                  }t          j                            |                              d          r|t          j        dz   z  }|dz  }nt          |          }|| _        d | _        d | _        d | _        d S )NTF__name__.z	__init__.__init__r)   )rY   rV   configrelative_filesr	   superr_   rR   r]   r#   r/   sepr0   basename
startswithr
   relname_source_parser	_excluded)selfrO   rY   r   fnamecanonicalizename	__class__s          r&   r_   zPythonFileReporter.__init__   s    "4((=$}#2 %$ 	1&x00E4$$ 	/=((bf55Dw))44[AA ,++EMDD$X..D#',0r<   r   c                    d| j         dS )Nz<PythonFileReporter >)r   rj   s    r&   __repr__zPythonFileReporter.__repr__   s    8dm8888r<   c                    | j         S N)rf   rq   s    r&   r
   z$PythonFileReporter.relative_filename   s
    |r<   r   c                    | j         J | j        Lt          | j        | j                             d                    | _        | j                                         | j        S )z&Lazily create a :class:`PythonParser`.Nexclude)r   rv   )rY   rh   r   r   _exclude_regexparse_sourcerq   s    r&   parserzPythonFileReporter.parser   sf     }(((<'44Y??  DL L%%'''|r<   set[TLineNo]c                    | j         j        S z2Return the line numbers of statements in the file.)ry   
statementsrq   s    r&   lineszPythonFileReporter.lines   s    {%%r<   dict[TLineNo, TLineNo]c                    | j         j        S )z>A map of line numbers to first-line in a multi-line statement.)ry   multiline_maprq   s    r&   r   z PythonFileReporter.multiline_map   s    {((r<   c                    | j         j        S r|   )ry   excludedrq   s    r&   excluded_linesz!PythonFileReporter.excluded_lines   s    {##r<   r~   Iterable[TLineNo]c                6    | j                             |          S rt   )ry   translate_lines)rj   r~   s     r&   r   z"PythonFileReporter.translate_lines   s    {**5111r<   arcsIterable[TArc]	set[TArc]c                6    | j                             |          S rt   )ry   translate_arcs)rj   r   s     r&   r   z!PythonFileReporter.translate_arcs   s    {))$///r<   c                    | j         J | j                            t          | j         j        j        | j         j        j        z                       }|S rt   )rY   ry   lines_matchingr   r`   partial_listpartial_always_list)rj   	no_branchs     r&   no_branch_linesz"PythonFileReporter.no_branch_lines   sO    }(((K..t}+84=;O;ccdd
 
	 r<   c                4    | j                                         S rt   )ry   r   rq   s    r&   r   zPythonFileReporter.arcs   s    {!!!r<   dict[TLineNo, int]c                4    | j                                         S rt   )ry   exit_countsrq   s    r&   r   zPythonFileReporter.exit_counts   s    {&&(((r<   startr   endexecuted_arcsIterable[TArc] | Nonec                8    | j                             ||          S rt   )ry   missing_arc_description)rj   r   r   r   s       r&   r   z*PythonFileReporter.missing_arc_description   s     {225#>>>r<   c                8    | j                             ||          S rt   )ry   arc_description)rj   r   r   s      r&   r   z"PythonFileReporter.arc_description   s    {**5#666r<   c                P    | j         t          | j                  | _         | j         S rt   )rg   r;   r   rq   s    r&   r%   zPythonFileReporter.source   s#    <,T];;DL|r<   boolc                    t           j                            | j                  \  }}|                    d          rdS |sdS dS )zDoes 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/   r0   r1   r   re   )rj   _r7   s      r&   should_be_pythonz#PythonFileReporter.should_be_python   sL     !!$-003 >>%   	4 	4ur<   r   c                D    t          |                                           S rt   )r   r%   rq   s    r&   r   z%PythonFileReporter.source_token_lines  s    !$++--000r<   Iterable[CodeRegion]c                D    t          |                                           S rt   )r   r%   rq   s    r&   r   zPythonFileReporter.code_regions	  s    DKKMM***r<   Iterable[tuple[str, str]]c                
    ddgS )N)function	functions)classclasses rq   s    r&   code_region_kindsz$PythonFileReporter.code_region_kinds  s    % 
 	
r<   rt   )rO   r   rY   rZ   r   r[   )r   r   )r   r   )r   rz   )r   r   )r~   r   r   rz   )r   r   r   r   )r   r   )r   r   )r   r   r   r   r   r   r   r   )r   r   r   r   r   r   )r   r   )r   r   )r   r   )r   r   )r]   
__module____qualname____doc__r_   rr   r
   propertyry   r~   r   r   r   r   r   r   r   r   r   r%   r   r   r   r   __classcell__)rn   s   @r&   rX   rX      s       ++      69 9 9 9    	 	 	 X	& & & &) ) ) )$ $ $ $2 2 2 20 0 0 0   " " " ") ) ) ) 04	? ? ? ? ?7 7 7 7   
   (1 1 1 1+ + + +
 
 
 
 
 
 
 
r<   rX   )r   r   r   r   )r   r   r   r   )r   r   r   r=   )rO   r   r   r   ).r   
__future__r   os.pathr/   rT   r?   collections.abcr   typingr   rY   r   coverage.exceptionsr   r   coverage.filesr	   r
   r   coverage.miscr   r   coverage.parserr   coverage.phystokensr   r   coverage.pluginr   r   coverage.regionsr   coverage.typesr   r   r   r   r   r!   r'   r;   r4   rN   rV   rX   r   r<   r&   <module>r      s   . - " " " " " "       $ $ $ $ $ $                   ; ; ; ; ; ; ; ; N N N N N N N N N N 4 4 4 4 4 4 4 4 ( ( ( ( ( ( C C C C C C C C 4 4 4 4 4 4 4 4 ) ) ) ) ) ) B B B B B B B B B B B B "!!!!!! ^B	@ 	@ 	@ 	@       F   .   :   }
 }
 }
 }
 }
 }
 }
 }
 }
 }
r<   