HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib64/python3.10/site-packages/coverage/__pycache__/html.cpython-310.pyc
o

!weXZ�@s0dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZmZmZmZmZmZmZmZddlZddlmZmZddlmZddlmZdd	lmZm Z m!Z!m"Z"m#Z#dd
lm$Z$m%Z%m&Z&ddl'm(Z(ddl)m*Z*m+Z+dd
l,m-Z-ddl.m/Z/m0Z0ddl1m2Z2er�ddlm3Z3ddl4m5Z5ddl
m6Z6Gdd�de6�Z7Gdd�de6�Z8e"e�Zd;dd�Z9d;dd�Z:d<d d!�Z;eGd"d#�d#��Z<eGd$d%�d%��Z=Gd&d'�d'�Z>Gd(d)�d)�Z?e
j@e
jAd*ZBejCdd+�d=d.d/��ZDGd0d1�d1�ZEGd2d3�d3�ZFd>d5d6�ZGd?d9d:�ZHdS)@zHTML reporting for coverage.py.�)�annotationsN)�	dataclass)�Any�Dict�Iterable�List�Optional�Tuple�
TYPE_CHECKING�cast)�CoverageData�add_data_to_hash)�NoDataError)�
flat_rootname)�
ensure_dir�file_be_gone�Hasher�isolate_module�format_local_datetime)�human_sorted�plural�stdout_link)�get_analysis_to_report)�Analysis�Numbers)�Templite)�TLineNo�TMorf)�__url__)�Coverage)�FileReporter)�	TypedDictc@s*eZdZUdZded<ded<ded<dS)�
IndexInfoDictz4Information for each file, to render the index file.r�nums�str�
html_filename�relative_filenameN��__name__�
__module__�__qualname__�__doc__�__annotations__�r-r-�F/home/arjun/projects/env/lib/python3.10/site-packages/coverage/html.pyr")s

r"c@s"eZdZUdZded<ded<dS)�FileInfoDictzHSummary of the information from last rendering, to avoid duplicate work.r$�hashr"�indexNr'r-r-r-r.r//s
r/�fnamer$�returncCs(tj�tj�t�d�}tj�||�}|S)z9Return the path to an "htmlfiles" data file of ours.
    �	htmlfiles)�os�path�join�dirname�__file__)r2�
static_dir�static_filenamer-r-r.�
data_filename8sr<cCs8tt|���}|��Wd�S1swYdS)z+Return the contents of a data file of ours.N)�openr<�read)r2�	data_filer-r-r.�	read_data@s$�r@�html�NonecCsZtjdd|tjd�d}t|d��}|�|�dd��Wd�dS1s&wYdS)	z*Write `html` to `fname`, properly encoded.z(\A\s+)|(\s+$)�)�flags�
�wb�ascii�xmlcharrefreplaceN)�re�sub�	MULTILINEr=�write�encode)r2rA�foutr-r-r.�
write_htmlFs"�rOc@s�eZdZUdZded<ded<ded<ded	<d
ed<ded<d
ed
<d
ed<d
ed<dZded<dZded<dZded<dZded<dZ	ded<dS)�LineDataz-The data for each source line of HTML output.zList[Tuple[str, str]]�tokensr�numberr$�category�bool�	statementz	List[str]�contexts�contexts_label�context_list�short_annotations�long_annotationsrCrANz
Optional[str]�context_str�annotate�
annotate_long�	css_class)
r(r)r*r+r,rAr[r\r]r^r-r-r-r.rPMs 
rPc@s*eZdZUdZded<ded<ded<dS)	�FileDataz-The data for each source file of HTML output.r$r&rr#zList[LineData]�linesNr'r-r-r-r.r_`s

r_c@s(eZdZdZdZddd�Zddd�ZdS)�HtmlDataGenerationz8Generate structured data to be turned into HTML reports.z(empty)�covrr3rBcCsX||_|jj|_|j��}|��|_|jjr#|��dhkr#|j�d�|�|jj�dS)NrCzNo contexts were measured)	�coverage�config�get_data�has_arcs�
show_contexts�measured_contexts�_warn�set_query_contexts�report_contexts)�selfrb�datar-r-r.�__init__ms


zHtmlDataGeneration.__init__�frr �analysisrr_csv�jr|��}|��}�jjr|j�|j�}g}t|�	�dd�D]�\}}d}	g}
g}||j
vr2d}	n;||jvr:d}	n3�jrf||vrfd}	||D]}|dkrS|
�d�n|
�t
|��|�|�|||��qGn||jvrmd	}	g}
d}g}|	r��jjr�t�fd
d�|�|d�D��}
|
�jgkr��j}n	t|
��d
�}|
}|�t|||	||jv|
|||
|d�	�q t|��|j|d�}|S)z.Produce the data needed for one file's report.���startrC�exc�mis�parr�exit�runc3s�|]}|p�jVqdS�N)�EMPTY)�.0�c�rlr-r.�	<genexpr>���z3HtmlDataGeneration.data_for_file.<locals>.<genexpr>r-z ctx)	rQrRrSrUrVrWrXrYrZ)r&r#r`)rf�missing_branch_arcs�
arcs_executedrdrgrm�contexts_by_lineno�filename�	enumerate�source_token_lines�excluded�missing�appendr$�missing_arc_description�
statementsr�getrz�lenrPr_r&�numbers)rlrorpr�r�r�r`�linenorQrSrYrZ�brVrWrX�	file_datar-r}r.�
data_for_filewsd

�

��z HtmlDataGeneration.data_for_fileN�rbrr3rB)ror rprr3r_)r(r)r*r+rzrnr�r-r-r-r.rahs


rac@seZdZdZddd	�Zd
S)�FileToReportz#A file we're considering reporting.ror rprr3rBcCs*||_||_t|���|_|jd|_dS)Nz.html)rorprr&�rootnamer%)rlrorpr-r-r.rn�szFileToReport.__init__N)ror rprr3rB)r(r)r*r+rnr-r-r-r.r��sr�z!#$%'()*+,-./:;=?@[]^_`{|}~)�maxsize�n�intcCsF|dkrtdSg}|rt|tt��\}}|�t|�|sd�|�S)zACreate a short HTML-safe string from an integer, using HTML_SAFE.rrC)�	HTML_SAFE�divmodr�r�r7)r��r�tr-r-r.�
encode_int�s�
r�c@s^eZdZdZgd�Zd!dd�Zd"dd
�Zd#dd�Zd#dd�Zd$dd�Z	d%dd�Z
d&dd�Zd S)'�HtmlReporterzHTML reporting.)z	style.csszcoverage_html.jszkeybd_closed.pngzkeybd_open.pngzfavicon_32.pngrbrr3rBcCsH||_|jj|_|jj|_|jj|_|jdur|jj|_|jj|_|jdur+|jj|_d|_d|_	|jj
}||jjrEtj
�|jj�|_nd|_|j��|_|j��|_g|_g|_t|j�|_t|j�|_t|jjd�|_d|_d|_d|_ttt t!tj"|t#t$j$�%��|j|j|jj&ddddd�d	�|_'t(d
�|_)t*|j)|j'�|_+dS)Nr)�	precisionFzexc show_exczmis show_miszpar run show_parrx)rtrurvrx)�escape�pairr�r�__version__�title�
time_stamp�	extra_cssrfrgrSzpyfile.html),rcrd�html_dir�	directory�html_skip_covered�skip_covered�html_skip_empty�
skip_empty�skipped_covered_count�skipped_empty_count�
html_titler�r5r6�basenamerermrf�file_summaries�all_files_nums�IncrementalChecker�incrra�datagenrr��totals�directory_was_empty�first_fr�final_frr�r�r�rr�r�datetime�nowrg�template_globalsr@�pyfile_html_sourcer�source_tmpl)rlrbr�r-r-r.rn�sX







��
zHtmlReporter.__init__�morfs�Optional[Iterable[TMorf]]�floatcCs6|j��|j�|j|j�g}t|j|�D]!\}}t||�}|�|�}|r,|�	|�qt
tj�
|j|j��qt|�D]+\}}|dkrGd}n||dj}|t|�dkrYd}	n||dj}	|�|||	�q<|jsotd��ttt|j��|_|r�|dj}
|dj}nd}
}|�|
|�|��|jjo�|jjS)zcGenerate an HTML report for `morfs`.

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

        r�
index.htmlrqzNo data to report.���)r�r>�check_global_datardr�rrcr��should_report_filer�rr5r6r7r�r%r�r��write_html_filer�rrr�sumr��
index_file�make_local_static_report_files�n_statements�
pc_covered)rlr��files_to_reportrorp�ftr�should�i�	prev_html�	next_html�
first_html�
final_htmlr-r-r.�reports6



zHtmlReporter.reportcCs$t|j�t�|j�sd|_dSdS)z'Make sure our htmlcov directory exists.TN)rr�r5�listdirr�r}r-r-r.�make_directoryKs

�zHtmlReporter.make_directorycCs�|jD]}t�t|�tj�|j|��q|jr7t	tj�|jd�d��
}|�
d�Wd�n1s2wY|jrS|jjdusBJ�t�|jjtj�|j|j��dSdS)z5Make local instances of static files for HTML report.z
.gitignore�wz# Created by coverage.py
*
N)
�STATIC_FILES�shutil�copyfiler<r5r6r7r�r�r=rLr�rd)rl�static�fgir-r-r.r�Qs
�"�z+HtmlReporter.make_local_static_report_filesr�r�rTcCsn|jj}|j�|�|jr$|jdk}|jdk}|r$|r$|jd7_dS|jr5|j	dkr5|j
d7_
dSdS)z$Determine if we'll report this file.rrqFT)rpr�r�r�r��	n_missing�n_partial_branchesr�r�r�r�)rlr�r#�no_missing_lines�no_missing_branchesr-r-r.r�cs


zHtmlReporter.should_report_filer�r$r�cs�|��|j�|j|j|j�r|j�|j�|j��dS|j	�
|j|j�}t�
dd�|jD��}dd�tdd�|��D��D���rQtjdd����D�dd	�}nd}|jD]��g}�jD]"\}}	|d
krm|�t|	��q]t|	�prd}
|�d|�d
|
�d��q]d�|��_�jr��fdd��jD�}tdd�|D���t��d��fdd�|D���_nd�_�jr�d��fdd��jD���_nd�_�jr�j}t|�dkr�|d�_ nd�!t|�d�dd�t|dd�D����_ nd�_ g}
�j"�r|
�|j#d�j"�d�|
��p	d�_$qVt%j&�|j'|j(�}|j)�*i|j+�|||d���}t,||�|jj-|j(|j�.�d �}|j�|�|j�/|j|�dS)!z*Generate an HTML file for one source file.Ncss �|]}|jD]}|VqqdSry)rV)r{�cliner|r-r-r.r~�s�z/HtmlReporter.write_html_file.<locals>.<genexpr>cSsi|]\}}||�qSr-r-)r{r��yr-r-r.�
<dictcomp>�sz0HtmlReporter.write_html_file.<locals>.<dictcomp>css�|]}|dVqdS)rNr-)r{�xr-r-r.r~���cSsi|]	\}}t|�|�qSr-�r�)r{�k�vr-r-r.r��s�)�indent�wsz&nbsp;z
<span class="z">z</span>rCcsg|]}t�|��qSr-r�)r{�	c_context)�
context_codesr-r.�
<listcomp>�s�z0HtmlReporter.write_html_file.<locals>.<listcomp>css�|]}t|�VqdSry)r��r{�ecr-r-r.r~�r�c3s�|]}|���VqdSry)�ljustr�)�
code_widthr-r.r~�rz,&nbsp;&nbsp; c3s �|]}�j�d|��VqdS)z&#x202F;&#x219B;&#x202F;N)rR)r{�d)�ldatar-r.r~�s
��
�rqrz{:d} missed branches: {}z, css$�|]
\}}|d�d|��VqdS)r�z) Nr-)r{�num�ann_longr-r-r.r~�s
��
�rrrS� �pln)�
contexts_jsonr�r�)r#r%r&)0r�r��
can_skip_filermror�r�r��
index_infor�r�rp�collections�Counterr`r��most_common�json�dumps�itemsrQr�r7rArX�maxr$r[rYr\rZr�r]�formatrSr�r^r5r6r�r%r��render�__dict__rOr�r&�set_index_info)rlr�r�r�r�rVr��
html_parts�tok_type�tok_text�tok_html�encoded_contexts�longs�css_classes�	html_pathrAr�r-)r�r�r�r.r�zs� �

����

����
�
�zHtmlReporter.write_html_filer�r�c
	Cs�|��ttd�|j�}d}}|jr |j}|�dt|��d�}|jr0|j}|�dt|��d�}|�|j|j	||||d��}t
j�|j
d�}t||�t|dt
j�|����}	|j�d	|	���|j��d
S)z*Write the index.html file for this report.r�rCz filez" skipped due to complete coverage.z empty filez	 skipped.)�filesr��skipped_covered_msg�skipped_empty_msgr�r�zfile://zWrote HTML report to N)r�rr@r�r�rr�rr�r�r5r6r7r�rOr�abspathrc�_messager�rL)
rlr�r��
index_tmplrrr�rAr��
print_hrefr-r-r.r��s,�	
zHtmlReporter.index_fileNr�)r�r�r3r��r3rB)r�r�r3rT)r�r�r�r$r�r$r3rB)r�r$r�r$r3rB)r(r)r*r+r�rnr�r�r�r�r�r�r-r-r-r.r��s

=
2


^r�c@s|eZdZdZdZdZd(dd	�Zd)d
d�Zd)dd
�Zd)dd�Z	d*dd�Z
d+dd�Zd,dd�Zd-dd �Z
d.d"d#�Zd/d%d&�Zd'S)0r�z0Logic and data to support incremental reporting.zstatus.jsonr�r�r$r3rBcCs||_|��dSry)r��reset)rlr�r-r-r.rnszIncrementalChecker.__init__cCsd|_i|_dS)z5Initialize to empty. Causes all files to be reported.rCN)�globalsr
r}r-r-r.rs
zIncrementalChecker.resetc	Cs�d}z$tj�|j|j�}t|��
}t�|�}Wd�n1s wYWn
tt	fy3d}Ynwd}|d|j
kr@d}n	|dtjkrId}|rqi|_
|d��D]\}}t|dd�|dd<||j
|<qT|d	|_dS|��dS)
z)Read the information we stored last time.FNTr�versionr
r1r#r)r5r6r7r��STATUS_FILEr=r��load�OSError�
ValueError�
STATUS_FORMATrcr�r
r�rrr)rl�usable�status_file�fstatus�statusr��fileinfor-r-r.r>"s,
���zIncrementalChecker.readcCs�tj�|j|j�}i}|j��D]\}}|d}|d��|d<|||<q|jt	j
|j|d�}t|d��}t
j||dd�Wd�dS1sHwYdS)zWrite the current status.r1r#)rrrr
r�)�,�:)�
separatorsN)r5r6r7r�rr
r��	init_argsrrcr�rr=r��dump)rlrr
r�r!r1r rNr-r-r.rL;s
�"�zIncrementalChecker.writermrcGsBt�}|D]}|�|�q|��}|j|kr|��||_dSdS)z<Check the global data that can affect incremental reporting.N)r�update�	hexdigestrr)rlrm�mr��
these_globalsr-r-r.r�Ms

�z$IncrementalChecker.check_global_datarror r�rTcCsVt�}|�|���d��t||j|�|��}|�|�}||kr#dS|�||�dS)z�Can we skip reporting this file?

        `data` is a CoverageData object, `fr` is a `FileReporter`, and
        `rootname` is the name being used for the file.
        zutf-8TF)	rr'�sourcerMr
r�r(�	file_hash�
set_file_hash)rlrmror�r)�	this_hash�	that_hashr-r-r.r�Ws
z IncrementalChecker.can_skip_filer2cCs|j�|i��dd�S)z#Get the hash of `fname`'s contents.r0rC�r
r��rlr2r-r-r.r,k�zIncrementalChecker.file_hash�valcC�||j�|i�d<dS)z#Set the hash of `fname`'s contents.r0N�r
�
setdefault)rlr2r3r-r-r.r-or2z IncrementalChecker.set_file_hashr"cCs|j�|i��di�S)z/Get the information for index.html for `fname`.r1r0r1r-r-r.r�sr2zIncrementalChecker.index_info�infocCr4)z/Set the information for index.html for `fname`.r1Nr5)rlr2r7r-r-r.rwr2z!IncrementalChecker.set_index_infoN)r�r$r3rBr)rmrr3rB)rmrror r�r$r3rT�r2r$r3r$)r2r$r3r$r3rB)r2r$r3r")r2r$r7r"r3rB)r(r)r*r+rrrnrr>rLr�r�r,r-r�rr-r-r-r.r��s









r�r�cCs|�dd��dd�S)z\HTML-escape the text in `t`.

    This is only suitable for HTML text, not attributes.

    �&z&amp;�<z&lt;)�replace)r�r-r-r.r�~sr��ratio�Tuple[int, int]cCsd|S)zEFormat a pair of numbers so JavaScript can read them in an attribute.z%s %sr-)r<r-r-r.r��sr�r8)r2r$rAr$r3rB)r�r�r3r$)r�r$r3r$)r<r=r3r$)Ir+�
__future__rr�r��	functoolsr�r5rIr��string�dataclassesr�typingrrrrrr	r
rrc�
coverage.datarr
�coverage.exceptionsr�coverage.filesr�
coverage.miscrrrrrrrr�coverage.report_corer�coverage.resultsrr�coverage.templiter�coverage.typesrr�coverage.versionrr�coverage.pluginsr r!r"r/r<r@rOrPr_rar��
ascii_letters�digitsr��	lru_cacher�r�r�r�r�r-r-r-r.�<module>sb(


O	
+