Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/coverage/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/coverage/__pycache__/html.cpython-37.pyc

B

E�W�9�@s�dZddlZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZm
Z
mZddlmZddlmZdd	lmZee�Zd
ej�ej�e�d�gZdd
d�Zdd�Zdd�ZGdd�de�ZGdd�de�Zdd�Z dd�Z!dS)zHTML reporting for coverage.py.�N)�env)�iitems)�
flat_rootname)�CoverageException�Hasher�isolate_module)�Reporter)�Numbers)�Templitez/usr/share/javascriptZ	htmlfiles�cCs�g}xbtD]Z}tj�||�}tj�|�r,|S|�|�|r
tj�|||�}tj�|�rZ|S|�|�q
Wtd|t��|f��dS)aReturn the path to a data file of ours.

    The file is searched for on `STATIC_PATH`, and the first place it's found,
    is returned.

    Each directory in `STATIC_PATH` is searched as-is, and also, if `pkgdir`
    is provided, at that sub-directory.

    z/Couldn't find static file %r from %r, tried: %rN)�STATIC_PATH�os�path�join�exists�appendr�getcwd)�fname�pkgdirZtriedZ
static_dirZstatic_filename�r�@/opt/alt/python37/lib64/python3.7/site-packages/coverage/html.py�
data_filename!s


rc	Cs tt|���
}|��SQRXdS)z+Return the contents of a data file of ours.N)�openr�read)rZ	data_filerrr�	read_data=src	Cs,t|d��}|�|�dd��WdQRXdS)z*Write `html` to `fname`, properly encoded.�wb�ascii�xmlcharrefreplaceN)r�write�encode)r�html�foutrrr�
write_htmlCsr"c	s^eZdZdZdddddddd	d
g	Z�fdd�Zd
d�Zdd�Zdd�Zdd�Z	dd�Z
�ZS)�HtmlReporterzHTML reporting.)z	style.cssr)z
jquery.min.jsZjquery)zjquery.debounce.min.jszjquery-debounce)zjquery.hotkeys.jszjquery-hotkeys)zjquery.isonscreen.jszjquery-isonscreen)zjquery.tablesorter.min.jszjquery-tablesorter)zcoverage_html.jsr)zkeybd_closed.pngr)zkeybd_open.pngrcs�tt|��||�d|_|jj}tjr0|�d�}t	t
|tjtj
d�|_ttd�|j�|_||_g|_|jj��|_t�|_d|_t�|_tj���d�|_dS)N�utf8)�escape�pair�title�__url__�__version__zpyfile.htmlz%Y-%m-%d %H:%M)�superr#�__init__�	directory�configZ
html_titler�PY2�decoder%r&�coverager(r)�template_globalsr
r�source_tmpl�files�data�has_arcs�
HtmlStatus�status�	extra_cssr	�totals�datetime�now�strftime�
time_stamp)�selfZcovr-r')�	__class__rrr+Zs$
zHtmlReporter.__init__cCs�|jjstd��|j�|jj�t�}|�|j�|��}|j��|kr^|j�	�|j�
|�|jjrxtj
�|jj�|_|�|j||jj�|js�td��|��|��|jjo�|jjS)zcGenerate an HTML report for `morfs`.

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

        z(must give a directory for html reportingzNo data to report.)r-Zhtml_dir�AssertionErrorr7rr�update�	hexdigest�
settings_hash�reset�set_settings_hashr8r
r�basenameZreport_files�	html_filer3r�
index_file�make_local_static_report_filesr9Zn_statementsZ
pc_covered)r>Zmorfs�mZthese_settingsrrr�reportrs 
zHtmlReporter.reportcCsZx0|jD]&\}}t�t||�tj�|j|��qW|jrVt�|j	jtj�|j|j��dS)z5Make local instances of static files for HTML report.N)
�STATIC_FILES�shutil�copyfilerr
rrr,r8r-)r>�staticrrrrrI�sz+HtmlReporter.make_local_static_report_filescCs*t�}|�|�|jj�|j|�|��S)z@Compute a hash that changes if the file needs to be re-reported.)rrAr0r4Zadd_to_hash�filenamerB)r>�source�frrJrrr�	file_hash�s
zHtmlReporter.file_hashc
s�|��}t|���}|�|�d�|�}|j�|�}||krR|j�|j�|��dS|j�	||�|j
}|jr||��}|�
�}	d}
d}d}d|
}
g}�x�t|��dd�D�]�\�}g}d	}d	}�|jkr�|�d
��|jkr�|�|�n��|jkr�|�|�n�|j�rʈ|k�r�|�|
�g}g}xF|�D]:}|dk�rF|�d�n
|�|�|�|��||	���q,Wd
�d���fdd�|D��}t|�dk�r�|d}n(dt|�d�dd�t|dd�D��f}n�|jk�r�|�|
�g}xL|D]D\}}|dk�r|�t|��n t|��pd}|�d||f��q�W|�d	�|��d�|��pNd||d��q�W|j�|||
|
|j|j||||jd�
�}|d}tj�|j|�}t||�|||��d�}|j�|�|j�||�dS)z*Generate an HTML file for one source file.zutf-8Nzrun hide_run�excZmiszpar �)�startrZstmr�exitz%s&#x202F;&#x219B;&#x202F;%sz,&nbsp;&nbsp; c3s|]}��|fVqdS)Nr)�.0�d)�lineno�	short_fmtrr�	<genexpr>�sz)HtmlReporter.html_file.<locals>.<genexpr>z%d missed branches: %sz, css|]\}}d||fVqdS)z%d) %sNr)rX�numZann_longrrrr\�s�wsz&nbsp;z<span class="%s">%s</span>� Zpln)r �number�classZannotate�
annotate_long)
�c_exc�c_mis�c_par�c_runr5r8rR�nums�linesr=z.html)rg�
html_filename�relative_filename) rQrrjrSrr7r3r�
index_info�
set_file_hash�numbersr5�missing_branch_arcs�
arcs_executed�	enumerateZsource_token_linesZ
statementsZexcluded�missingZmissing_arc_descriptionr�lenr%r2�renderr8r=r
rr,r"�set_index_info)r>rRZanalysisrQZrootnameZ	this_hashZ	that_hashrgrnrorfrcrdrerh�lineZ
line_classZ
annotate_htmlrbZshortsZlongs�br �tok_typeZtok_textZtok_htmlriZ	html_pathrkr)rZr[rrG�s�











zHtmlReporter.html_filecCsnttd�|j�}tdd�|jD��|_|�|j|j|j|j|j	d��}t
tj�
|jd�|�|j�|j�dS)z*Write the index.html file for this report.z
index.htmlcss|]}|dVqdS)rgNr)rX�frrrr\!sz*HtmlReporter.index_file.<locals>.<genexpr>)r5r8r3r9r=N)r
rr1�sumr3r9rsr5r8r=r"r
rrr,r7r)r>Z
index_tmplr rrrrHszHtmlReporter.index_file)�__name__�
__module__�__qualname__�__doc__rLr+rKrIrSrGrH�
__classcell__rr)r?rr#Is #qr#c@sheZdZdZdZdZdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)r6z@The status information we keep to support incremental reporting.zstatus.jsonrUcCs|��dS)N)rD)r>rrrr+SszHtmlStatus.__init__cCsd|_i|_dS)zInitialize to empty.rN)�settingsr3)r>rrrrDVszHtmlStatus.resetc	Cs�d}y4tj�||j�}t|d��}t�|�}WdQRXWnttfk
rTd}Yn,Xd}|d|j	krnd}n|dt
jkr�d}|r�i|_x:t
|d�D]*\}}t|dd	�|dd	<||j|<q�W|d
|_n|��dS)z$Read the last status in `directory`.F�rNT�format�versionr3�indexrgr)r
rr�STATUS_FILEr�json�load�IOError�
ValueError�
STATUS_FORMATr0r)r3rr	rrD)r>r,Zusable�status_fileZfstatusr7rP�fileinforrrr[s&
zHtmlStatus.readc		Cs�tj�||j�}i}x6t|j�D](\}}|dd��|dd<|||<q W|jtj	|j
|d�}t|d��}t�
||�WdQRXdtjkr�ttj�|d�d��}|�d�WdQRXdS)	z(Write the current status to `directory`.r�rg)r�r�rr3�wNZJENKINS_URLz
status.datz3https://issues.jenkins-ci.org/browse/JENKINS-28428
)r
rrr�rr3Z	init_argsr�r0r)rrr��dump�environr)	r>r,r�r3rPr�r7r!Zdatrrrrts
zHtmlStatus.writecCs|jS)z)Get the hash of the coverage.py settings.)r)r>rrrrC�szHtmlStatus.settings_hashcCs
||_dS)z)Set the hash of the coverage.py settings.N)r)r>rrrrrE�szHtmlStatus.set_settings_hashcCs|j�|i��dd�S)z#Get the hash of `fname`'s contents.�hashr)r3�get)r>rrrrrS�szHtmlStatus.file_hashcCs||j�|i�d<dS)z#Set the hash of `fname`'s contents.r�N)r3�
setdefault)r>r�valrrrrl�szHtmlStatus.set_file_hashcCs|j�|i��di�S)z/Get the information for index.html for `fname`.r�)r3r�)r>rrrrrk�szHtmlStatus.index_infocCs||j�|i�d<dS)z/Set the information for index.html for `fname`.r�N)r3r�)r>r�inforrrrt�szHtmlStatus.set_index_infoN)rzr{r|r}r�r�r+rDrrrCrErSrlrkrtrrrrr61sr6cCs|�dd��dd�S)z\HTML-escape the text in `t`.

    This is only suitable for HTML text, not attributes.

    �&z&amp;�<z&lt;)�replace)�trrrr%�sr%cCsd|S)zEFormat a pair of numbers so JavaScript can read them in an attribute.z%s %sr)Zratiorrrr&�sr&)r)"r}r:r�r
rMr0rZcoverage.backwardrZcoverage.filesrZ
coverage.miscrrrZcoverage.reportrZcoverage.resultsr	Zcoverage.templiter
rr�dirname�__file__rrrr"r#�objectr6r%r&rrrr�<module>s.
iv