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__/plugin_support.cpython-35.pyc



E�W��@s�dZddlZddlZddlZddlmZmZddlmZm	Z	m
Z
ee�ZGdd�de�ZGdd�de�Z
Gd	d
�d
e�ZGdd�de	�ZGd
d�de
�ZdS)zSupport for plugins.�N)�CoverageException�isolate_module)�CoveragePlugin�
FileTracer�FileReporterc@s�eZdZdZdd�Zeddd��Zdd�Zd	d
�Zdd�Z	d
d�Z
e
Zdd�Zdd�Z
dS)�Pluginsz7The currently loaded collection of coverage.py plugins.cCs1g|_i|_g|_d|_d|_dS)N)�order�names�file_tracers�current_module�debug)�self�r�J/opt/alt/python35/lib64/python3.5/site-packages/coverage/plugin_support.py�__init__s
				zPlugins.__init__Nc	Cs�|�}||_xr|D]j}||_t|�tj|}t|dd�}|sgtd|��|j|�}|||�qWd|_|S)z`Load plugins from `modules`.

        Returns a list of loaded and configured plugins.

        �
coverage_initNz7Plugin module %r didn't define a coverage_init function)rr�
__import__�sys�modules�getattrrZget_plugin_options)	�clsr�configrZplugins�module�modr�optionsrrr�load_pluginss		
	


	zPlugins.load_pluginscCs|j||j�dS)z�Add a file tracer plugin.

        `plugin` is an instance of a third-party plugin class.  It must
        implement the :meth:`CoveragePlugin.file_tracer` method.

        N)�_add_pluginr
)r
�pluginrrr�add_file_tracer6szPlugins.add_file_tracercCs|j|d�dS)zfAdd a plugin that does nothing.

        This is only useful for testing the plugin support.

        N)r)r
rrrr�add_noop?szPlugins.add_noopcCs�d|j|jjf}|jr||jjd�r||jjd|j|f�td|jf|j�}t||�}||_d|_	|j
j|�||j|<|dk	r�|j|�dS)z�Add a plugin object.

        `plugin` is a :class:`CoveragePlugin` instance to add.  `specialized`
        is a list to append the plugin to.

        z%s.%srzLoaded plugin %r: %rz	plugin %rTN)
r�	__class__�__name__rZshould�write�
LabelledDebug�DebugPluginWrapperZ_coverage_plugin_nameZ_coverage_enabledr�appendr	)r
rZspecialized�plugin_nameZlabelledrrrrGs		
zPlugins._add_plugincCs
t|j�S)N)�boolr)r
rrr�__nonzero__\szPlugins.__nonzero__cCs
t|j�S)N)�iterr)r
rrr�__iter__aszPlugins.__iter__cCs|j|S)zReturn a plugin by name.)r	)r
r&rrr�getdszPlugins.get)r!�
__module__�__qualname__�__doc__r�classmethodrrrrr(�__bool__r*r+rrrrrs	rc@sIeZdZdZfdd�Zdd�Zdd�Zdd	�Zd
S)r#z?A Debug writer, but with labels for prepending to the messages.cCs#t|�|g|_||_dS)N)�list�labelsr)r
�labelrZprev_labelsrrrrlszLabelledDebug.__init__cCst||j|j�S)z<Add a label to the writer, and return a new `LabelledDebug`.)r#rr2)r
r3rrr�	add_labelpszLabelledDebug.add_labelcCs0|jdg}djdd�t|�D��S)z4The prefix to use on messages, combining the labels.�z:
css#|]\}}d||VqdS)z  Nr)�.0�ir3rrr�	<genexpr>wsz/LabelledDebug.message_prefix.<locals>.<genexpr>)r2�join�	enumerate)r
�prefixesrrr�message_prefixtszLabelledDebug.message_prefixcCs$|jjd|j�|f�dS)z/Write `message`, but with the labels prepended.z%s%sN)rr"r<)r
�messagerrrr"yszLabelledDebug.writeN)r!r,r-r.rr4r<r"rrrrr#is
r#csLeZdZdZ�fdd�Zdd�Zdd�Zdd	�Z�S)
r$z:Wrap a plugin, and use debug to report on what it's doing.cs)tt|�j�||_||_dS)N)�superr$rrr)r
rr)r rrr�s	zDebugPluginWrapper.__init__cCs^|jj|�}|jjd||f�|rZ|jjd|f�}t||�}|S)Nzfile_tracer(%r) --> %rzfile %r)r�file_tracerrr"r4�DebugFileTracerWrapper)r
�filename�tracerrrrrr?�szDebugPluginWrapper.file_tracercCsa|jj|�}|jjd||f�|r]|jjd|f�}t|||�}|S)Nzfile_reporter(%r) --> %rzfile %r)r�
file_reporterrr"r4�DebugFileReporterWrapper)r
rA�reporterrrrrrC�sz DebugPluginWrapper.file_reportercCs
|jj�S)N)r�sys_info)r
rrrrF�szDebugPluginWrapper.sys_info)r!r,r-r.rr?rCrFrr)r rr$~s
r$c@s^eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)r@zA debugging `FileTracer`.cCs||_||_dS)N)rBr)r
rBrrrrr�s	zDebugFileTracerWrapper.__init__cCs#dtjj|jj�|jfS)z7A short string identifying a frame, for debug messages.z%s@%d)�os�path�basename�f_code�co_filename�f_lineno)r
�framerrr�_show_frame�sz"DebugFileTracerWrapper._show_framecCs*|jj�}|jjd|f�|S)Nzsource_filename() --> %r)rB�source_filenamerr")r
Z	sfilenamerrrrO�sz&DebugFileTracerWrapper.source_filenamecCs*|jj�}|jjd|f�|S)Nz$has_dynamic_source_filename() --> %r)rB�has_dynamic_source_filenamerr")r
ZhasrrrrP�sz2DebugFileTracerWrapper.has_dynamic_source_filenamecCs?|jj||�}|jjd||j|�|f�|S)Nz&dynamic_source_filename(%r, %s) --> %r)rB�dynamic_source_filenamerr"rN)r
rArMZdynrrrrQ�sz.DebugFileTracerWrapper.dynamic_source_filenamecCs9|jj|�}|jjd|j|�|f�|S)Nzline_number_range(%s) --> %r)rB�line_number_rangerr"rN)r
rM�pairrrrrR�s#z(DebugFileTracerWrapper.line_number_rangeN)
r!r,r-r.rrNrOrPrQrRrrrrr@�sr@cs�eZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Z�S)rDzA debugging `FileReporter`.cs,tt|�j|�||_||_dS)N)r>rDrrEr)r
rArEr)r rrr�s	z!DebugFileReporterWrapper.__init__cCs*|jj�}|jjd|f�|S)Nzrelative_filename() --> %r)rE�relative_filenamerr")r
�retrrrrT�sz*DebugFileReporterWrapper.relative_filenamecCs*|jj�}|jjd|f�|S)Nzlines() --> %r)rE�linesrr")r
rUrrrrV�szDebugFileReporterWrapper.linescCs*|jj�}|jjd|f�|S)Nzexcluded_lines() --> %r)rE�excluded_linesrr")r
rUrrrrW�sz'DebugFileReporterWrapper.excluded_linescCs0|jj|�}|jjd||f�|S)Nztranslate_lines(%r) --> %r)rE�translate_linesrr")r
rVrUrrrrX�sz(DebugFileReporterWrapper.translate_linescCs0|jj|�}|jjd||f�|S)Nztranslate_arcs(%r) --> %r)rE�translate_arcsrr")r
�arcsrUrrrrY�sz'DebugFileReporterWrapper.translate_arcscCs*|jj�}|jjd|f�|S)Nzno_branch_lines() --> %r)rE�no_branch_linesrr")r
rUrrrr[�sz(DebugFileReporterWrapper.no_branch_linescCs*|jj�}|jjd|f�|S)Nzexit_counts() --> %r)rE�exit_countsrr")r
rUrrrr\�sz$DebugFileReporterWrapper.exit_countscCs*|jj�}|jjd|f�|S)Nz
arcs() --> %r)rErZrr")r
rUrrrrZ�szDebugFileReporterWrapper.arcscCs0|jj�}|jjdt|�f�|S)Nzsource() --> %d chars)rE�sourcerr"�len)r
rUrrrr]�szDebugFileReporterWrapper.sourcecCs6t|jj��}|jjdt|�f�|S)Nz"source_token_lines() --> %d tokens)r1rE�source_token_linesrr"r^)r
rUrrrr_�sz+DebugFileReporterWrapper.source_token_lines)r!r,r-r.rrTrVrWrXrYr[r\rZr]r_rr)r rrD�srD)r.rG�os.pathrZ
coverage.miscrrZcoverage.pluginrrr�objectrr#r$r@rDrrrr�<module>sY%