L idZddlmZddlZddlZddlmZddlmZddl m Z ddl m Z m Z ddlmZdd lmZdd lmZdd lmZerdd lmZe eZGd dZy)z'Source file annotation for coverage.py.) annotationsN)Iterable) TYPE_CHECKING) flat_rootname) ensure_dirisolate_module) FileReporter)get_analysis_to_report)Analysis)TMorf)CoveragecreZdZdZddZej dZej dZd d dZ d dZ y) AnnotateReporteraGenerate 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 "-". cV||_|jj|_d|_yN)coverageconfig directory)selfrs W/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/coverage/annotate.py__init__zAnnotateReporter.__init__0s!  mm** %)z\s*(#|$)z\s*else\s*:\s*(#|$)Nc||_|jjt|j|D]\}}|j ||y)zIRun the report. See `coverage.report()` for arguments. N)rrget_datar annotate_file)rmorfsrfranalysiss rreportzAnnotateReporter.report8sI #  24==%H -LB   r8 , -rcJt|j}t|j}t|j}|jrrt |jt jj|jt|j}|jdsJ|dddz}n |j}|dz }t|dd5}d x}} d } |j} t| j!d d D]{\} } |t#|kr$||| kr|d z }|t#|kr ||| kr| t#|kr$|| | kr| d z } | t#|kr || | kr|t#|kr ||| k(r| t#|k\xs|| | kD} |j$j'| r|j)d n|j*j'| rO| t#|k\r|j)dnj|||| k(r|j)dnM|j)dn;| |vr|j)dn%| r|j)dn|j)d|j)| ~ dddy#1swYyxYw)z]Annotate a single file. `fr` is the FileReporter for the file to annotate. _pyNz.pyz,coverwzutf-8)encodingrT)startz z> z! z- )sorted statementsmissingexcludedrrospathjoinrrelative_filenameendswithfilenameopensource enumerate splitlineslenblank_rematchwriteelse_re)rrrr(r)r* dest_filedestijcoveredr2linenolines rrzAnnotateReporter.annotate_fileCsU H//0 ))*(++, >> t~~ & T^^]2CWCWCY5Z[I%%e, ,,!#2.I IX )S7 3 !tIAGYY[F )&*;*;D*A K ! #j/)jmf.DFA#j/)jmf.D#g,&71:+>FA#g,&71:+>s:&:a=F+B3w</F71:3FG==&&t,JJt$\\''-CL( 4(#A'!*4 4( 4(x'JJt$JJt$JJt$ 4 1 !  ! ! !sA+J 1J;DJJ")rr returnNoner)rzIterable[TMorf] | Nonerz str | NonerArB)rr rr rArB) __name__ __module__ __qualname____doc__rrecompiler6r9rrrrrrs9** rzz+&Hbjj/0G -/!rr)rF __future__rr+rGcollections.abcrtypingrcoverage.filesr coverage.miscrrcoverage.pluginr coverage.report_corer coverage.resultsr coverage.typesr rr rrIrrrSsG." $ (4(7% !BX!X!r