o
    ÄíY(  ã                   @   s\   d 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	 eeƒZG dd„ de	ƒZ
dS )z'Source file annotation for coverage.py.é    N)Úflat_rootname)Úisolate_module)ÚReporterc                       sF   e Zd ZdZ‡ fdd„Ze d¡Ze d¡Zddd„Z	d	d
„ Z
‡  Z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 '-'.

    c                    s   t t| ƒ ||¡ d | _d S ©N)Úsuperr   Ú__init__Ú	directory)ÚselfÚcoverageÚconfig©Ú	__class__© úC/var/www/html/env/lib/python3.10/site-packages/coverage/annotate.pyr   '   s   
zAnnotateReporter.__init__z\s*(#|$)z\s*else\s*:\s*(#|$)Nc                 C   s   |   | j||¡ dS )zIRun the report.

        See `coverage.report()` for arguments.

        N)Úreport_filesÚannotate_file)r
   Úmorfsr	   r   r   r   Úreport.   s   zAnnotateReporter.reportc                 C   s@  t |jƒ}t |jƒ}t |jƒ}| jr0tj | jt| 	¡ ƒ¡}| 
d¡r+|dd… d }|d7 }n|jd }tj|ddd��Ø}d	}d	}	d
}
| ¡ }t| d
¡dd�D ]»\}}|t|ƒk rq|| |k rq|d7 }|t|ƒk rq|| |k sa|	t|ƒk r�||	 |k r�|	d7 }	|	t|ƒk r�||	 |k s}|t|ƒk r¥|| |kr¥|	t|ƒkp¤||	 |k}
| j |¡r±| d¡ nV| j |¡rï|t|ƒkrÉ|	t|ƒkrÉ| d¡ n>|t|ƒksÕ|	t|ƒkrÛ| d¡ n,|| ||	 kré| d¡ n| d¡ n||v rù| d¡ n|
�r| d¡ n| d¡ | |¡ qQW d  ƒ dS 1 �sw   Y  dS )z]Annotate a single file.

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

        Ú_pyNéýÿÿÿz.pyz,coverÚwÚutf8)Úencodingr   Té   )Ústartz  z! z> z- )ÚsortedÚ
statementsÚmissingÚexcludedr	   ÚosÚpathÚjoinr   Úrelative_filenameÚendswithÚfilenameÚioÚopenÚsourceÚ	enumerateÚ
splitlinesÚlenÚblank_reÚmatchÚwriteÚelse_re)r
   ÚfrÚanalysisr   r   r   Ú	dest_fileÚdestÚiÚjÚcoveredr(   ÚlinenoÚliner   r   r   r   6   sR   





ÿÿ
æ$ûzAnnotateReporter.annotate_filer   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚreÚcompiler,   r/   r   r   Ú__classcell__r   r   r   r   r      s    


r   )r<   r&   r    r=   Úcoverage.filesr   Úcoverage.miscr   Úcoverage.reportr   r   r   r   r   r   Ú<module>   s   