
     h!                    F   S r SSKJr  SSKrSSKrSSKrSSKJr  SSK	J
r
  SSKJr  SSKJrJr  SSKJrJrJr  SS	KJrJr  SS
KJr  SSKJrJr  SSKJrJr  SSKJ r   SSK!J"r"J#r#J$r$J%r%  \
(       a  SSKJ&r&  \" \5      rSS jr'SS jr(SS jr)SS jr*SS jr+ " S S\5      r,g)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                    [        U S5       nUR                  5       nSSS5        WR                  SS5      R                  SS5      $ ! , (       d  f       N0= f)z>Read the Python source text from `filename`.

Returns bytes.

rbNs   
   
   )openreadreplace)filenamefsources      m/root/racknerd_01/codex-conversation/amazon-q-terraform/.venv/lib/python3.13/site-packages/coverage/python.pyread_python_sourcer$      sI     
h	 
 >>'5)11%?? 
	s   A
Ac                   [         R                  R                  U 5      u  pUS:X  a  [        R                  (       a  SS/nOU/nU HH  nX-   n[         R                  R                  U5      (       a  [        U5      n  O"[        U5      nUc  MH    O   [        SU  S3SS9eUR                  SS5      nUR                  [        U5      S	5      nU(       a  US
   S:w  a  US-  nU$ )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 z77>>,''-l;L %\2#  .xj;+NN  ''t4L  !>	JF &*$$M    c                    [        U 5      nUb/  Uu  p# [        R                  " U5      n UR	                  U5      nU$ g! [        R                   a     gf = f! [
         a     gf = f)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   M   sz     !*M &	&&w/B	;;u%D  '' 		  		s    ? A AA
A&%A&c                <   U R                  S5      (       a  U $ U R                  S5      (       am  U SS n[        R                  R                  U5      (       a  U$ [        R
                  (       a+  US-   n[        R                  R                  U5      (       a  U$ U$ U $ )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   d   s     			+	,	,sm77>>+&&;;&,Lww~~l++## Or9   c                    [        U S5      (       a  U R                  (       a  U R                  nO0[        U [        R                  5      (       a  [        SU  S35      eU n[        U5      nU$ )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      s[    tZ  T]]==	D%**	+	+  '$| <==x(HOr9   c                    ^  \ rS rSrSrSSU 4S jjjrSS jrSS jr\SS j5       r	SS jr
SS jrSS	 jrSS
 jrSS jrSS jrSS jrS S jr S       S!S jjrS"S jrSS jrS#S jrS$S jrS%S jrS&S jrSrU =r$ )'PythonFileReporter   z!Report support for a Python file.c                :  > X l         [        U5      nUnSnU R                   b'  U R                   R                  R                  (       a  SnU(       a  [	        U5      n[
        TU ]  U5        [        US5      (       ay  UR                  R                  S[        R                  5      n[        R                  R                  U5      R                  S5      (       a  U[        R                  S-   -  nUS-  nO[        U5      nX`l        S U l        S U l        S U l        g )NTF__name__.z	__init__.__init__r&   )coveragerR   configrelative_filesr	   superrY   rM   rW   r   r,   sepr-   basename
startswithr
   relname_source_parser	_excluded)selfrQ   rZ   r    fnamecanonicalizename	__class__s          r#   rY   PythonFileReporter.__init__   s     "4(==$}}##22$&x0E4$$==((bff5Dww)44[AA++EMD$X.D#',0r9   c                $    SU R                   < S3$ )Nz<PythonFileReporter >)r    re   s    r#   __repr__PythonFileReporter.__repr__   s    %dmm%6a88r9   c                    U R                   $ N)ra   rm   s    r#   r
   $PythonFileReporter.relative_filename   s    ||r9   c                    U R                   c   eU R                  cL  [        U R                  U R                   R	                  S5      S9U l        U R                  R                  5         U R                  $ )z&Lazily create a :class:`PythonParser`.exclude)r    rt   )rZ   rc   r   r    _exclude_regexparse_sourcerm   s    r#   parserPythonFileReporter.parser   s_     }}(((<<'44Y?DL LL%%'||r9   c                .    U R                   R                  $ z2Return the line numbers of statements in the file.)rw   
statementsrm   s    r#   linesPythonFileReporter.lines       {{%%%r9   c                .    U R                   R                  $ )z>A map of line numbers to first-line in a multi-line statement.)rw   
_multilinerm   s    r#   multiline_map PythonFileReporter.multiline_map   r~   r9   c                .    U R                   R                  $ rz   )rw   excludedrm   s    r#   excluded_lines!PythonFileReporter.excluded_lines   s    {{###r9   c                8    U R                   R                  U5      $ rq   )rw   translate_lines)re   r|   s     r#   r   "PythonFileReporter.translate_lines   s    {{**511r9   c                8    U R                   R                  U5      $ rq   )rw   translate_arcs)re   arcss     r#   r   !PythonFileReporter.translate_arcs   s    {{))$//r9   c                    U R                   c   eU R                  R                  [        U R                   R                  R
                  U R                   R                  R                  -   5      5      nU$ rq   )rZ   rw   lines_matchingr   r[   partial_listpartial_always_list)re   	no_branchs     r#   no_branch_lines"PythonFileReporter.no_branch_lines   s[    }}(((KK..t}}++884==;O;O;c;ccd
	 r9   c                6    U R                   R                  5       $ rq   )rw   r   rm   s    r#   r   PythonFileReporter.arcs   s    {{!!r9   c                6    U R                   R                  5       $ rq   )rw   exit_countsrm   s    r#   r   PythonFileReporter.exit_counts   s    {{&&((r9   c                8    U R                   R                  X5      $ rq   )rw   missing_arc_description)re   startendexecuted_arcss       r#   r   *PythonFileReporter.missing_arc_description   s     {{225>>r9   c                8    U R                   R                  X5      $ rq   )rw   arc_description)re   r   r   s      r#   r   "PythonFileReporter.arc_description   s    {{**566r9   c                h    U R                   c  [        U R                  5      U l         U R                   $ rq   )rb   r8   r    rm   s    r#   r"   PythonFileReporter.source   s&    <<,T]];DL||r9   c                    [         R                  R                  U R                  5      u  pUR	                  S5      (       a  gU(       d  gg)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`   )re   _r4   s      r#   should_be_python#PythonFileReporter.should_be_python   s;     !!$--0 >>%  r9   c                4    [        U R                  5       5      $ rq   )r   r"   rm   s    r#   r   %PythonFileReporter.source_token_lines  s    !$++-00r9   c                4    [        U R                  5       5      $ rq   )r   r"   rm   s    r#   r   PythonFileReporter.code_regions  s    DKKM**r9   c                
    SS/$ )N)function	functions)classclasses rm   s    r#   code_region_kinds$PythonFileReporter.code_region_kinds	  s    % 
 	
r9   )rd   rc   rb   rZ   ra   rq   )rQ   r   rZ   zCoverage | NonereturnNone)r   str)r   r   )r   set[TLineNo])r   zdict[TLineNo, TLineNo])r|   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]])rW   
__module____qualname____firstlineno____doc__rY   rn   r
   propertyrw   r|   r   r   r   r   r   r   r   r   r   r"   r   r   r   r   __static_attributes____classcell__)ri   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   rZ   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$   r8   r1   rJ   rR   rT   r   r9   r#   <module>r      sv    . "    $    ; N N 4 ( C 4 ) B B!B	@ F.:}
 }
r9   