Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/site-packages/coverage/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/site-packages/coverage/__pycache__/html.cpython-35.pyc



E�W�9�@s`dZddlZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZm
Z
mZddlmZddlmZdd	lmZee�Zd
ejjejje�d�gZdd
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}x�tD]}tjj||�}tjj|�r>|S|j|�|r
tjj|||�}tjj|�r|S|j|�q
Wtd|tj�|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/python35/lib64/python3.5/site-packages/coverage/html.py�
data_filename!s


rc	Cs*tt|���}|j�SWdQRXdS)z+Return the contents of a data file of ours.N)�openr�read)rZ	data_filerrr�	read_data=srcCs6t|d�� }|j|jdd��WdQRXdS)z*Write `html` to `fname`, properly encoded.�wb�ascii�xmlcharrefreplaceN)r�write�encode)r�html�foutrrr�
write_htmlCsr"c
s�eZdZdZdddd d!d"d#d$d%g	Z�fdd�Zdd�Zdd�Zdd�Zdd�Z	dd�Z
�S)&�HtmlReporterzHTML reporting.�	style.cssr�
jquery.min.js�jquery�jquery.debounce.min.js�jquery-debounce�jquery.hotkeys.js�jquery-hotkeys�jquery.isonscreen.js�jquery-isonscreen�jquery.tablesorter.min.js�jquery-tablesorter�coverage_html.js�keybd_closed.png�keybd_open.pngc
s�tt|�j||�d|_|jj}tjrF|jd�}dt	dt
d|dtjdtj
i|_ttd�|j�|_||_g|_|jjj�|_t�|_d|_t�|_tjj�jd�|_dS)	N�utf8�escape�pair�title�__url__�__version__zpyfile.htmlz%Y-%m-%d %H:%M)�superr#�__init__�	directory�configZ
html_titler�PY2�decoder3r4�coverager6r7�template_globalsr
r�source_tmpl�files�data�has_arcs�
HtmlStatus�status�	extra_cssr	�totals�datetime�now�strftime�
time_stamp)�selfZcovr;r5)�	__class__rrr9Zs$						zHtmlReporter.__init__cCs|jjstd��|jj|jj�t�}|j|j�|j�}|jj�|kr�|jj	�|jj
|�|jjr�tj
j|jj�|_|j|j||jj�|js�td��|j�|j�|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�AssertionErrorrErr�update�	hexdigest�
settings_hash�reset�set_settings_hashrFr
r�basenameZreport_files�	html_filerAr�
index_file�make_local_static_report_filesrGZn_statementsZ
pc_covered)rLZmorfs�mZthese_settingsrrr�reportrs 	
	

zHtmlReporter.reportcCs}xB|jD]7\}}tjt||�tjj|j|��q
W|jrytj|j	jtjj|j|j��dS)z5Make local instances of static files for HTML report.N)
�STATIC_FILES�shutil�copyfilerr
rrr:rFr;)rL�staticrrrrrW�s		z+HtmlReporter.make_local_static_report_filescCs9t�}|j|�|jjj|j|�|j�S)z@Compute a hash that changes if the file needs to be re-reported.)rrOr>rBZadd_to_hash�filenamerP)rL�source�frrXrrr�	file_hash�s	
zHtmlReporter.file_hashcs
|j�}t|j��}|j|jd�|�}|jj|�}||krw|jj|jj|��dS|jj	||�|j
}|jr�|j�}|j
�}	d}
d}d}d|
}
g}xft|j�dd�D]L\�}g}d	}d	}�|jkr)|jd
��|jkrH|j|�nH�|jkrg|j|�n)|jrt�|krt|j|
�g}g}xW|�D]K}|dkr�|jd�n
|j|�|j|j�||	��q�Wd
�dj��fdd�|D��}t|�dkr9|d}q�dt|�djdd�t|dd�D��f}n�|jkr�|j|
�g}x_|D]W\}}|dkr�|jt|��q�t|�p�d}|jd||f�q�W|jdd	j|�d�ddj|�p(dd|d|i�q�W|jjd|d|d |
d!|
d"|jd#|jd$|d%|d&|d'|ji
�}|d(}tjj|j|�}t||�d%|d)|d*|j�i}|jj|�|jj||�dS)+z*Generate an HTML file for one source file.zutf-8Nzrun hide_run�excZmiszpar �start�rZstmr�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)rf�numZann_longrrrrj�s�wsz&nbsp;z<span class="%s">%s</span>r �number�class� ZplnZannotate�
annotate_long�c_exc�c_mis�c_par�c_runrCrFr`�nums�linesrKz.html�
html_filename�relative_filename) r_rrxrarrErAr�
index_info�
set_file_hash�numbersrC�missing_branch_arcs�
arcs_executed�	enumerateZsource_token_linesZ
statementsZexcluded�missingZmissing_arc_descriptionr�lenr3r@�renderrFrKr
rr:r"�set_index_info)rLr`Zanalysisr_ZrootnameZ	this_hashZ	that_hashrur|r}rtrqrrrsrv�lineZ
line_classZ
annotate_htmlrpZshortsZlongs�br �tok_typeZtok_textZtok_htmlrwZ	html_pathryr)rhrirrU�s�		
%


 %
	 
			

zHtmlReporter.html_filecCs�ttd�|j�}tdd�|jD��|_|jd|jd|jd|jd|jd|j	i�}t
tjj
|jd�|�|jj|j�d	S)
z*Write the index.html file for this report.z
index.htmlcss|]}|dVqdS)ruNr)rf�frrrrj!sz*HtmlReporter.index_file.<locals>.<genexpr>rCrFrArGrKN)r
rr?�sumrArGr�rCrFrKr"r
rrr:rEr)rLZ
index_tmplr rrrrVs				zHtmlReporter.index_file)r$r)r%r&)r'r()r)r*)r+r,)r-r.)r/r)r0r)r1r)�__name__�
__module__�__qualname__�__doc__rZr9rYrWrarUrVrr)rMrr#Is 	#qr#c@s�eZdZdZdZdZdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)rDz@The status information we keep to support incremental reporting.zstatus.jsonrdcCs|j�dS)N)rR)rLrrrr9SszHtmlStatus.__init__cCsd|_i|_dS)zInitialize to empty.rN)�settingsrA)rLrrrrRVs	zHtmlStatus.resetcCsd}yDtjj||j�}t|d��}tj|�}WdQRXWnttfk
rjd}Yn<Xd}|d|j	kr�d}n|dt
jkr�d}|ri|_xGt
|d�D]5\}}t|dd	�|dd	<||j|<q�W|d
|_n
|j�dS)z$Read the last status in `directory`.F�rNT�format�versionrA�indexrur�)r
rr�STATUS_FILEr�json�load�IOError�
ValueError�
STATUS_FORMATr>r7rArr	r�rR)rLr:Zusable�status_fileZfstatusrEr^�fileinforrrr[s&		zHtmlStatus.readc	Cs�tjj||j�}i}xCt|j�D]2\}}|ddj�|dd<|||<q.Wd|jdtj	d|j
d|i}t|d��}tj
||�WdQRXd	tjkr�ttjj|d
�d��}|jd�WdQRXdS)z(Write the current status to `directory`.r�rur�r�r�rA�wNZJENKINS_URLz
status.datz3https://issues.jenkins-ci.org/browse/JENKINS-28428
)r
rrr�rrAZ	init_argsr�r>r7r�rr��dump�environr)	rLr:r�rAr^r�rEr!Zdatrrrrts			!zHtmlStatus.writecCs|jS)z)Get the hash of the coverage.py settings.)r�)rLrrrrQ�szHtmlStatus.settings_hashcCs
||_dS)z)Set the hash of the coverage.py settings.N)r�)rLr�rrrrS�szHtmlStatus.set_settings_hashcCs|jj|i�jdd�S)z#Get the hash of `fname`'s contents.�hashr)rA�get)rLrrrrra�szHtmlStatus.file_hashcCs||jj|i�d<dS)z#Set the hash of `fname`'s contents.r�N)rA�
setdefault)rLr�valrrrrz�szHtmlStatus.set_file_hashcCs|jj|i�jdi�S)z/Get the information for index.html for `fname`.r�)rAr�)rLrrrrry�szHtmlStatus.index_infocCs||jj|i�d<dS)z/Set the information for index.html for `fname`.r�N)rAr�)rLr�inforrrr��szHtmlStatus.set_index_infoN)r�r�r�r�r�r�r9rRrrrQrSrarzryr�rrrrrD1srDcCs|jdd�jdd�S)z\HTML-escape the text in `t`.

    This is only suitable for HTML text, not attributes.

    �&z&amp;�<z&lt;)�replace)�trrrr3�sr3cCsd|S)zEFormat a pair of numbers so JavaScript can read them in an attribute.z%s %sr)Zratiorrrr4�sr4)"r�rHr�r
r[r>rZcoverage.backwardrZcoverage.filesrZ
coverage.miscrrrZcoverage.reportrZcoverage.resultsr	Zcoverage.templiter
rr�dirname�__file__rrrr"r#�objectrDr3r4rrrr�<module>s,$�v