
    V.j                        d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	m
Z
mZ ddlmZ ddlmZ ddlmZmZmZ dd	lmZmZ e
rdd
lmZ ddlmZ ddlmZ eeef   ZdZ G d d      Z 	 	 	 	 ddZ!y)zJson reporting for coverage.py    )annotationsN)Iterable)IOTYPE_CHECKINGAny)__version__)get_analysis_to_report)AnalysisAnalysisNarrowerNumbers)TLineNoTMorfs)Coverage)CoverageData)FileReporter   c                  d    e Zd ZdZdZd
dZddZddZddZ	 	 	 	 	 	 	 	 ddZ		 	 	 	 	 	 	 	 ddZ
y	)JsonReporterz-A reporter for writing JSON coverage results.zJSON reportc                    || _         | j                   j                  | _        t        | j                  j                        | _        i | _        y N)coverageconfigr   	precisiontotalreport_data)selfr   s     UC:\xampp\htdocs\tradingbinance\backend\.venv\Lib\site-packages\coverage/jsonreport.py__init__zJsonReporter.__init__'   s8     mm**T[[223
$&    c           	         |j                   |j                  |j                  |j                  |j                  |j
                  |j                  |j                  dS )z!Create a dict summarizing `nums`.)covered_linesnum_statementspercent_coveredpercent_covered_displaymissing_linesexcluded_linespercent_statements_covered"percent_statements_covered_display)
n_executedn_statements
pc_coveredpc_covered_str	n_missing
n_excludedpc_statementspc_statements_strr   numss     r   make_summaryzJsonReporter.make_summary-   sN     "__"//#'+':':!^^"oo*.*<*<262H2H	
 		
r   c                    |j                   |j                  |j                  |j                  |j                  |j
                  dS )z4Create a dict summarizing the branch info in `nums`.)num_branchesnum_partial_branchescovered_branchesmissing_branchespercent_branches_covered percent_branches_covered_display)
n_branchesn_partial_branchesn_executed_branchesn_missing_branchespc_branchespc_branches_strr1   s     r   make_branch_summaryz JsonReporter.make_branch_summary:   sB     !OO$($;$; $ 8 8 $ 7 7(,(8(8040D0D
 	
r   c                   |xs t         j                  }| j                  j                         }|j	                  | j
                  j                         t        t        t        j                  j                         j                         |j                         | j
                  j                  d| j                  d<   i }t        | j                  |      D ])  \  }}| j!                  |||      ||j#                         <   + || j                  d<   | j%                  | j&                        | j                  d<   |j                         r7| j                  d   j)                  | j+                  | j&                               t-        j.                  | j                  || j
                  j0                  rdnd       | j&                  j2                  xr | j&                  j4                  S )zGenerate a json report for `morfs`.

        `morfs` is a list of modules or file names.

        `outfile` is a file object to write the json to.

        )formatversion	timestampbranch_coverageshow_contextsmetafilestotals   N)indent)sysstdoutr   get_dataset_query_contextsr   report_contextsFORMAT_VERSIONr   datetimenow	isoformathas_arcsjson_show_contextsr   r	   report_one_filerelative_filenamer3   r   updaterA   jsondumpjson_pretty_printr*   r+   )r   morfsoutfilecoverage_datameasured_filesfile_reporteranalysiss          r   reportzJsonReporter.reportE   s    'SZZ..0(()D)DE$"!**..0::<,557![[;;$
  '=dmmU'S#M8@D@T@TAN=::<= (T %3!%)%6%6tzz%B"!!#X&--d.F.Ftzz.RS		66AD	
 zz&&@4::+@+@@r   c           	        |j                   }| xj                  |z  c_        | j                  |      }t        |j                        |t        |j
                        t        |j                        d}| j                  j                  r|j                  |j                        |d<   |j                         rj|j                  | j                  |             t        t        |j!                                     |d<   t        t        |j#                                     |d<   t%        |j'                         j)                               }|j+                         }|j-                         D ]  \  }	t/        t1        d|dz               }
|D ]!  }|j2                  k7  r|
|j4                  z  }
# t7        |      }|j9                  fd|D               |j9                  |
g       i x||	<   }|D ]U  }|j2                  k7  r| j;                  ||j=                  |j4                        |j>                        ||j@                  <   W | j;                  ||j=                  |
      tC        |
d            |d<    |S )	z3Extract the relevant report data for a single file.)executed_linessummaryr%   r&   contextsexecuted_branchesr8      c              3  V   K   | ]   }|j                   k(  s|j                   " y wr   )kindlines).0rnouns     r   	<genexpr>z/JsonReporter.report_one_file.<locals>.<genexpr>   s       L'QQVVt^'s   )))default )"numbersr   r3   sortedexecutedmissingexcludedr   rW   contexts_by_linenofilenamerV   rZ   rA   list_convert_branch_arcsexecuted_branch_arcsmissing_branch_arcslensource
splitlinescode_regionscode_region_kindssetrangerl   rm   r   add_regionsmake_region_datanarrowstartnamemin)r   r`   rc   rb   r2   rg   reported_file	num_linesregionspluraloutside_linesregionnarrowerregion_datarp   s                 @r   rX   zJsonReporter.report_one_filen   s4    

d
##D)$X%6%67#H$4$45$X%6%67	"
 ;;))(5(H(HIZIZ([M*%!!#NN433D9:15$X%B%B%DE2M-. 15$X%A%A%CD1M,- ,,.99;<	,,.);;=LD&aQ 78M!;;$&- "
 (1H   L' LL  -1244M&!K!;;$&+/+@+@!OOFLL1LL,FKK( " #33.M1-KO+ >4 r   c                "   |j                   }| j                  |      }t        |j                        |t        |j                        t        |j
                        |d}| j                  j                  r |j                  |j                        }||d<   |j                         rj|j                  | j                  |             t        t        |j                                     |d<   t        t        |j!                                     |d<   |S )z0Create the data object for one region of a file.)rf   rg   r%   r&   
start_linerh   ri   r8   )rt   r3   ru   rv   rw   rx   r   rW   ry   rz   rV   rZ   rA   r{   r|   r}   r~   )r   r`   narrowed_analysisr   narrowed_numsnarrowed_summarythis_regionrh   s           r   r   zJsonReporter.make_region_data   s     *11,,];$%6%?%?@'#$5$=$=>$%6%?%?@$
 ;;))$778I8R8RSH&.K
#!!###D$<$<]$KL/3$%6%K%K%MN0K+, /3$%6%J%J%LM/K*+ r   N)r   r   returnNone)r2   r   r   JsonObj)r^   r   r_   zIO[str]r   float)r`   r   rc   r
   rb   r   r   r   )r`   r   r   r
   r   intr   r   )__name__
__module____qualname____doc__report_typer   r3   rA   rd   rX   r    r   r   r   r   "   sq    7K'
	
'AR4)45=4NZ4	4l# $ 	
 
r   r   c              #  V   K   | j                         D ]  \  }}|D ]  }||f 
  yw)z4Convert branch arcs to a list of two-element tuples.N)items)branch_arcsr   targetstargets       r   r|   r|      s3      ',,.F&.   /s   '))r   zdict[TLineNo, list[TLineNo]]r   z!Iterable[tuple[TLineNo, TLineNo]])"r   
__future__r   rS   r[   rM   collections.abcr   typingr   r   r   r   r   coverage.report_corer	   coverage.resultsr
   r   r   coverage.typesr   r   r   coverage.datar   coverage.pluginr   dictstrr   rR   r   r|   r   r   r   <module>r      sr    % "   
 $ ) )   7 @ @ *!*, sCx.
 ] ]@!-!&!r   