
    L-Ph                        d Z ddlm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 dd	lmZ dd
lmZ ddlmZ erddlmZ  ee          Z G d d          ZdS )z'Source file annotation for coverage.py.    )annotationsN)TYPE_CHECKING)Iterable)flat_rootname)
ensure_dirisolate_module)FileReporter)get_analysis_to_report)Analysis)TMorf)Coveragec                  l    e Zd ZdZddZ ej        d          Z ej        d          ZdddZ	ddZ
d	S )AnnotateReportera  Generate annotated source files showing line coverage.

    This reporter creates annotated copies of the measured source files. Each
    .py file is copied as a .py,cover file, with a left-hand margin annotating
    each line::

        > def h(x):
        -     if 0:   #pragma: no cover
        -         pass
        >     if x == 1:
        !         a = 1
        >     else:
        >         a = 2

        > h(2)

    Executed lines use ">", lines not executed use "!", lines excluded from
    consideration use "-".

    coverager   returnNonec                D    || _         | j         j        | _        d | _        d S N)r   config	directory)selfr   s     Q/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/coverage/annotate.py__init__zAnnotateReporter.__init__1   s      m*%)    z\s*(#|$)z\s*else\s*:\s*(#|$)NmorfsIterable[TMorf] | Noner   
str | Nonec                    || _         | j                                         t          | j        |          D ]\  }}|                     ||           dS )zIRun the report.

        See `coverage.report()` for arguments.

        N)r   r   get_datar
   annotate_file)r   r   r   franalysiss        r   reportzAnnotateReporter.report9   sa     #   24=%HH 	- 	-LBr8,,,,	- 	-r   r!   r	   r"   r   c                $   t          |j                  }t          |j                  }t          |j                  }| j        r}t          | j                   t          j                            | j        t          |
                                                    }|                    d          sJ |dd         dz   }n|j        }|dz  }t          |dd          5 }d	x}}	d
}
|                                }t          |                    d
          d          D ]\  }}|t#          |          k     r0||         |k     r$|dz  }|t#          |          k     r||         |k     $|	t#          |          k     r0||	         |k     r$|	dz  }	|	t#          |          k     r||	         |k     $|t#          |          k     r+||         |k    r|	t#          |          k    p||	         |k    }
| j                            |          r|                    d           n| j                            |          rg|	t#          |          k    r|                    d           n||         ||	         k    r|                    d           n]|                    d           nG||v r|                    d           n-|
r|                    d           n|                    d           |                    |           	 ddd           dS # 1 swxY w Y   dS )z]Annotate a single file.

        `fr` is the FileReporter for the file to annotate.

        _pyNz.pyz,coverwzutf-8)encodingr   T   )startz  z> z! z- )sorted
statementsmissingexcludedr   r   ospathjoinr   relative_filenameendswithfilenameopensource	enumerate
splitlineslenblank_rematchwriteelse_re)r   r!   r"   r,   r-   r.   	dest_filedestijcoveredr6   linenolines                 r   r    zAnnotateReporter.annotate_fileD   sW    H/00
)**(+,,> 	$t~&&&T^]2CWCWCYCY5Z5Z[[I%%e,,,,,!#2#.IIIX	)S7333 	!tIAGYY[[F )&*;*;D*A*A K K K ! !#j//))jmf.D.DFA #j//))jmf.D.D#g,,&&71:+>+>FA #g,,&&71:+>+>s:&&:a=F+B+B3w<</F71:3FG=&&t,, %JJt$$$$\''-- %CLL((

4((((#A'!*44

4((((

4((((x''JJt$$$$ %JJt$$$$JJt$$$

4    1!		! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!s   HLL	L	)r   r   r   r   r   )r   r   r   r   r   r   )r!   r	   r"   r   r   r   )__name__
__module____qualname____doc__r   recompiler:   r=   r#   r     r   r   r   r      s         ** * * *
 rz+&&Hbj/00G	- 	- 	- 	- 	-/! /! /! /! /! /!r   r   )rH   
__future__r   r/   rI   typingr   collections.abcr   coverage.filesr   coverage.miscr   r   coverage.pluginr	   coverage.report_corer
   coverage.resultsr   coverage.typesr   r   r   r   rK   r   r   <module>rU      s,   . - " " " " " " 				 				             $ $ $ $ $ $ ( ( ( ( ( ( 4 4 4 4 4 4 4 4 ( ( ( ( ( ( 7 7 7 7 7 7 % % % % % %             "!!!!!!^BX! X! X! X! X! X! X! X! X! X!r   