
    V.jJ#                    6   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-y)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)Coveragec                    t        | d      5 }|j                         }ddd       j                  dd      j                  dd      S # 1 sw Y   +xY w)zFRead the Python source text from `filename`.

    Returns bytes.

    rbNs   
   
   )openreadreplace)filenamefsources      QC:\xampp\htdocs\tradingbinance\backend\.venv\Lib\site-packages\coverage/python.pyread_python_sourcer$   !   sI     
h	 
 >>'5)11%?? 
	s   AAc                   t         j                  j                  |       \  }}|dk(  rt        j                  rddg}n|g}|D ]B  }||z   }t         j                  j                  |      rt        |      } n"t        |      }|B n t        d|  dd      |j                  dd      }|j                  t        |      d	      }|r|d
   dk7  r|dz  }|S )z#Return the source code, as unicode..pyz.pywz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_sourcer8   -   s      *ID#
e|vu cz77>>,'-l;L %\2#  .xj;+NN  ''t4L  !>	JF &*$$M    c                    t        |       }|/|\  }}	 t        j                  |      }	 |j	                  |      }|S y# t        j                  $ r Y yw xY w# t
        $ r Y yw xY w)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#   r1   r1   P   s|     !*M &	&&w/B	;;u%D  '' 		  		s    > A AA	A#"A#c                
   | j                  d      r| S | j                  d      r^| dd }t        j                  j                  |      r|S t        j
                  r&|dz   }t        j                  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,   r-   r0   r   r/   )r    py_filenamepyw_filenames      r#   source_for_filerJ   g   s{     			+	,sm77>>+&;;&,Lww~~l+## Or9   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)hasattrrL   
isinstancetypes
ModuleTyper   rJ   )morfr    s     r#   source_for_morfrR      sU    tZ T]]==	D%**	+  '$| <==x(HOr9   c                       e Zd ZdZdd fdZddZddZedd       ZddZ	ddZ
ddZdd	Zdd
ZddZddZddZ	 d	 	 	 	 	 	 	 ddZd dZddZd!dZd"dZd#dZd$dZ xZS )%PythonFileReporterz!Report support for a Python file.c                   || _         t        |      }|}d}| j                   "| j                   j                  j                  rd}|rt	        |      }t
        |   |       t        |d      rt|j                  j                  dt        j                        }t        j                  j                  |      j                  d      r|t        j                  dz   z  }|dz  }nt        |      }|| _        d | _        d | _        d | _        y )NTF__name__.z	__init__.__init__r&   )coveragerR   configrelative_filesr	   superrX   rM   rV   r   r,   sepr-   basename
startswithr
   relname_source_parser	_excluded)selfrQ   rY   r    fnamecanonicalizename	__class__s          r#   rX   zPythonFileReporter.__init__   s     "4(==$}}##22$&x0E4$==((bff5Dww)44[A++EMD$X.D#',0r9   c                "    d| j                   dS )Nz<PythonFileReporter >)r    rd   s    r#   __repr__zPythonFileReporter.__repr__   s    %dmm%6a88r9   c                    | j                   S N)r`   rk   s    r#   r
   z$PythonFileReporter.relative_filename   s    ||r9   c                    | j                   J | j                  Ot        | j                  | j                   j	                  d            | _        | j                  j                          | j                  S )z&Lazily create a :class:`PythonParser`.exclude)r    rp   )rY   rb   r   r    _exclude_regexparse_sourcerk   s    r#   parserzPythonFileReporter.parser   s_     }}(((<<'44Y?DL LL%%'||r9   c                .    | j                   j                  S )z2Return the line numbers of statements in the file.)rs   
statementsrk   s    r#   lineszPythonFileReporter.lines   s    {{%%%r9   c                .    | j                   j                  S )z>A map of line numbers to first-line in a multi-line statement.)rs   multiline_maprk   s    r#   rx   z PythonFileReporter.multiline_map   s    {{(((r9   c                .    | j                   j                  S )z;Return the line numbers of excluded statements in the file.)rs   excludedrk   s    r#   excluded_linesz!PythonFileReporter.excluded_lines   s    {{###r9   c                8    | j                   j                  |      S rn   )rs   translate_lines)rd   rv   s     r#   r}   z"PythonFileReporter.translate_lines   s    {{**511r9   c                8    | j                   j                  |      S rn   )rs   translate_arcs)rd   arcss     r#   r   z!PythonFileReporter.translate_arcs   s    {{))$//r9   c                    | j                   J | j                  j                  t        | j                   j                  j
                  | j                   j                  j                  z               }|S rn   )rY   rs   lines_matchingr   rZ   partial_listpartial_always_list)rd   	no_branchs     r#   no_branch_linesz"PythonFileReporter.no_branch_lines   s[    }}(((KK..t}}++884==;O;O;c;ccd
	 r9   c                6    | j                   j                         S rn   )rs   r   rk   s    r#   r   zPythonFileReporter.arcs   s    {{!!r9   c                6    | j                   j                         S rn   )rs   exit_countsrk   s    r#   r   zPythonFileReporter.exit_counts   s    {{&&((r9   c                :    | j                   j                  ||      S rn   )rs   missing_arc_description)rd   startendexecuted_arcss       r#   r   z*PythonFileReporter.missing_arc_description   s     {{225#>>r9   c                :    | j                   j                  ||      S rn   )rs   arc_description)rd   r   r   s      r#   r   z"PythonFileReporter.arc_description   s    {{**5#66r9   c                f    | j                   t        | j                        | _         | j                   S rn   )ra   r8   r    rk   s    r#   r"   zPythonFileReporter.source   s&    <<,T]];DL||r9   c                    t         j                  j                  | j                        \  }}|j	                  d      ry|syy)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,   r-   r.   r    r_   )rd   _r4   s      r#   should_be_pythonz#PythonFileReporter.should_be_python   s:     !!$--03 >>% r9   c                4    t        | j                               S rn   )r   r"   rk   s    r#   r   z%PythonFileReporter.source_token_lines  s    !$++-00r9   c                4    t        | j                               S rn   )r   r"   rk   s    r#   r   zPythonFileReporter.code_regions	  s    DKKM**r9   c                
    ddgS )N)function	functions)classclasses rk   s    r#   code_region_kindsz$PythonFileReporter.code_region_kinds  s    % 
 	
r9   rn   )rQ   r   rY   zCoverage | NonereturnNone)r   str)r   r   )r   set[TLineNo])r   zdict[TLineNo, TLineNo])rv   zIterable[TLineNo]r   r   )r   zIterable[TArc]r   	set[TArc])r   r   )r   zdict[TLineNo, int])r   r   r   r   r   zIterable[TArc] | Noner   r   )r   r   r   r   r   r   )r   bool)r   r   )r   zIterable[CodeRegion])r   zIterable[tuple[str, str]])rV   
__module____qualname____doc__rX   rl   r
   propertyrs   rv   rx   r{   r}   r   r   r   r   r   r   r"   r   r   r   r   __classcell__)rh   s   @r#   rT   rT      s    +69 	 	&)$20") 04	?? ? -	?
 
?7
(1+
r9   rT   )r    r   r   bytes)r    r   r   r   )r    r   r   zbytes | None)rQ   r   r   r   ).r   
__future__r   os.pathr,   rO   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$   r8   r1   rJ   rR   rT   r   r9   r#   <module>r      s}    . "    $    ; N N 4 ( C 4 ) B B! B	@ F.:}
 }
r9   