o
    g                     @  s   d Z ddlmZ ddlZddlZddlmZmZ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rHddlmZ eeZG dd dZdS )z'Source file annotation for coverage.py.    )annotationsN)IterableOptionalTYPE_CHECKING)flat_rootname)
ensure_dirisolate_module)FileReporter)get_analysis_to_report)Analysis)TMorf)Coveragec                   @  sD   e Zd ZdZdddZedZed	ZddddZ	d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                 C  s   || _ | j j| _d | _d S N)r   config	directory)selfr    r   Q/var/www/html/bloggers_ems/venv/lib/python3.10/site-packages/coverage/annotate.py__init__0   s   

zAnnotateReporter.__init__z\s*(#|$)z\s*else\s*:\s*(#|$)NmorfsOptional[Iterable[TMorf]]r   Optional[str]c                 C  s6   || _ | j  t| j|D ]
\}}| || qdS )zIRun the report.

        See `coverage.report()` for arguments.

        N)r   r   get_datar
   annotate_file)r   r   r   franalysisr   r   r   report8   s
   
zAnnotateReporter.reportr   r	   r   r   c                 C  s  t |j}t |j}t |j}| jr5t| j tj| jt	|
 }|dr0|dd d }|d7 }n|jd }t|ddd}d	 }}	d
}
| }t|d
ddD ]\}}|t|k ru|| |k ru|d7 }|t|k ru|| |k se|	t|k r||	 |k r|	d7 }	|	t|k r||	 |k s|t|k r|| |kr|	t|kp||	 |k}
| j|r|d n=| j|r|	t|kr|d n+|| ||	 kr|d n|d n||v r|d n|
r|d n|d || qUW d   dS 1 s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coveredr2   linenoliner   r   r   r   C   sN   







$zAnnotateReporter.annotate_file)r   r   r   r   r   )r   r   r   r   r   r   )r   r	   r   r   r   r   )__name__
__module____qualname____doc__r   recompiler6   r9   r    r   r   r   r   r   r      s    


r   )rD   
__future__r   r+   rE   typingr   r   r   coverage.filesr   coverage.miscr   r   coverage.pluginr	   coverage.report_corer
   coverage.resultsr   coverage.typesr   r   r   r   r   r   r   r   <module>   s   