
    ziE                        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!dS )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                  F    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
dS )$JsonReporterz-A reporter for writing JSON coverage results.zJSON reportcoverager   returnNonec                    || _         | j         j        | _        t          | j        j                  | _        i | _        d S N)r   configr   	precisiontotalreport_data)selfr   s     ^/var/www/tmov.alphamb/tmov_inventario/venv/lib/python3.11/site-packages/coverage/jsonreport.py__init__zJsonReporter.__init__'   s7     m*T[233
$&    numsr   JsonObjc           	     h    |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   r"   s     r   make_summaryzJsonReporter.make_summary-   s?     "_"/#'+':!^"o*.*<262H	
 	
 		
r!   c                P    |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_strr5   s     r   make_branch_summaryz JsonReporter.make_branch_summary:   s6     !O$($; $ 8 $ 7(,(8040D
 
 	
r!   morfsr   outfileIO[str]floatc                \   |pt           j        }| j                                        }|                    | j        j                   t          t          t          j	        
                                                                |                                | j        j        d| j        d<   i }t          | j        |          D ]1\  }}|                     |||          ||                                <   2|| j        d<   |                     | j                  | j        d<   |                                r8| j        d                             |                     | j                             t-          j        | j        || j        j        rdnd           | j        j        o| j        j        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_filenamer6   r   updaterD   jsondumpjson_pretty_printr.   r/   )r   rE   rF   coverage_datameasured_filesfile_reporteranalysiss          r   reportzJsonReporter.reportE   s    'SZ..00(()DEEE$"!*..00::<<,5577![;$
 $
  '=dmU'S'S 	 	#M8@D@T@TA AN=::<<== %3!%)%6%6tz%B%B"!!## 	TX&--d.F.Ftz.R.RSSS	6@AAD	
 	
 	
 	
 z&@4:+@@r!   re   r   rh   r
   rg   r   c           	     P   |j         }| xj        |z  c_        |                     |          }t          |j                  |t          |j                  t          |j                  d}| j        j        r|	                    |j
                  |d<   |                                r|                    |                     |                     t          t          |                                                    |d<   t          t          |                                                    |d<   t%          |                                                                          }|                                }|                                D ]\  }	t/          t1          d|dz                       }
|D ]}|j        k    r|
|j        z  }
t7          |          }|                    fd|D                        |                    |
g           i x||	<   }|D ]J}|j        k    r|                     ||                    |j                  |j                  ||j         <   K|                     ||                    |
          tC          |
d                    |d<   |S )	z3Extract the relevant report data for a single file.)executed_linessummaryr)   r*   contextsexecuted_branchesr;      c              3  <   K   | ]}|j         k    |j        V  d S r   )kindlines).0rnouns     r   	<genexpr>z/JsonReporter.report_one_file.<locals>.<genexpr>   s+       L LQQVt^^^^^^ L Lr!   )default )"numbersr   r6   sortedexecutedmissingexcludedr   r^   contexts_by_linenofilenamer]   ra   rD   list_convert_branch_arcsexecuted_branch_arcsmissing_branch_arcslensource
splitlinescode_regionscode_region_kindssetrangerq   rr   r   add_regionsmake_region_datanarrowstartnamemin)r   re   rh   rg   r"   rl   reported_file	num_linesregionspluraloutside_linesregionnarrowerregion_dataru   s                 @r   r_   zJsonReporter.report_one_filen   s    

d

##D))$X%677#H$455$X%677	"
 "
 ;) 	\(5(H(HIZ([([M*%!!## 	NN433D99:::15$X%B%B%D%DEE2 2M-. 15$X%A%A%C%CDD1 1M,- ,,..99;;<<	,,..);;== 	 	LD&aQ 7 788M! . .;$&&-'11H   L L L L' L L LLLL  -111244M&!K!  ;$&&+/+@+@!OOFL11L, ,FK(( #33..M1--- KOO
 r!   narrowed_analysis
start_lineintc                L   |j         }|                     |          }t          |j                  |t          |j                  t          |j                  |d}| j        j        r|                    |j	                  }||d<   |
                                r|                    |                     |                     t          t          |                                                    |d<   t          t          |                                                    |d<   |S )z0Create the data object for one region of a file.)rk   rl   r)   r*   r   rm   rn   r;   )ry   r6   rz   r{   r|   r}   r   r^   r~   r   r]   ra   rD   r   r   r   r   )r   re   r   r   narrowed_numsnarrowed_summarythis_regionrm   s           r   r   zJsonReporter.make_region_data   s)    *1,,];;$%6%?@@'#$5$=>>$%6%?@@$
 
 ;) 	/$778I8RSSH&.K
#!!## 	##D$<$<]$K$KLLL/3$%6%K%K%M%MNN0 0K+, /3$%6%J%J%L%LMM/ /K*+ r!   N)r   r   r   r   )r"   r   r   r#   )rE   r   rF   rG   r   rH   )re   r   rh   r
   rg   r   r   r#   )re   r   r   r
   r   r   r   r#   )__name__
__module____qualname____doc__report_typer    r6   rD   ri   r_   r    r!   r   r   r   "   s        77K' ' ' '
 
 
 
	
 	
 	
 	
'A 'A 'A 'AR4 4 4 4l     r!   r   branch_arcsdict[TLineNo, list[TLineNo]]r   !Iterable[tuple[TLineNo, TLineNo]]c              #  T   K   |                                  D ]\  }}|D ]}||fV  	dS )z4Convert branch arcs to a list of two-element tuples.N)items)r   r   targetstargets       r   r   r      sX       ',,.. ! ! 	! 	!F&.    	!! !r!   )r   r   r   r   )"r   
__future__r   rZ   rb   rT   collections.abcr   typingr   r   r   r   r   coverage.report_corer	   coverage.resultsr
   r   r   coverage.typesr   r   r   coverage.datar   coverage.pluginr   dictstrr#   rY   r   r   r   r!   r   <module>r      sg   % $ " " " " " "   



 $ $ $ $ $ $ ) ) ) ) ) ) ) ) ) )             7 7 7 7 7 7 @ @ @ @ @ @ @ @ @ @ * * * * * * * * -!!!!!!******,,,,,, sCx.
 ] ] ] ] ] ] ] ]@! ! ! ! ! !r!   