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



���W�1�@s�dZddlZddlZddlZddlZddlmZmZmZddl	m
Z
mZmZee�ZGdd�dej
�ZdgZdgZd	d
gZGdd�de�ZdS)
zConfig file for coverage.py�N)�configparser�iitems�string_class)�contract�CoverageException�isolate_modulec@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)�HandyConfigParserz#Our specialization of ConfigParser.cCstjj|�||_dS)N)r�RawConfigParser�__init__�section_prefix)�selfr�r
�B/opt/alt/python35/lib64/python3.5/site-packages/coverage/config.pyr
szHandyConfigParser.__init__cCs5i}tjdkrd|d<tjj|||�S)z-Read a file name as UTF-8 configuration data.��zutf-8�encoding)rr)�sys�version_inforr	�read)r�filename�kwargsr
r
rrs
zHandyConfigParser.readcCs#|j|}tjj|||�S)N)rrr	�
has_option)r�section�optionr
r
rrs
zHandyConfigParser.has_optioncCs |j|}tjj||�S)N)rrr	�has_section)rrr
r
rr#s
zHandyConfigParser.has_sectioncCs |j|}tjj||�S)N)rrr	�options)rrr
r
rr's
zHandyConfigParser.optionscCs:i}x-|j|�D]}|j||�||<qW|S)z/Get the contents of a section, as a dictionary.)r�get)rr�d�optr
r
r�get_section+szHandyConfigParser.get_sectioncOsS|j|}tjj||||�}dd�}d}tj|||�}|S)a Get a value, replacing environment variables also.

        The arguments are the same as `RawConfigParser.get`, but in the found
        value, ``$WORD`` or ``${WORD}`` are replaced by the value of the
        environment variable ``WORD``.

        Returns the finished value.

        cSsFtdd�|j�D��}|dkr/dStjj|d�SdS)zCalled for each $replacement.css!|]}|dk	r|VqdS)Nr
)�.0�wr
r
r�	<genexpr>Asz@HandyConfigParser.get.<locals>.dollar_replace.<locals>.<genexpr>�$�N)�next�groups�os�environr)�m�wordr
r
r�dollar_replace>sz-HandyConfigParser.get.<locals>.dollar_replacea$(?x)   # Use extended regex syntax
            \$(?:                   # A dollar sign, then
            (?P<v1>\w+) |           #   a plain word,
            {(?P<v2>\w+)} |         #   or a {-wrapped word,
            (?P<char>[$])           #   or a dollar sign.
            )
            )rrr	r�re�sub)rr�argsr�vr+Zdollar_patternr
r
rr2s

zHandyConfigParser.getcCso|j||�}g}xP|jd�D]?}x6|jd�D]%}|j�}|r>|j|�q>Wq(W|S)z�Read a list of strings.

        The value of `section` and `option` is treated as a comma- and newline-
        separated list of strings.  Each value is stripped of whitespace.

        Returns the list of strings.

        �
�,)r�split�strip�append)rrr�
value_list�valuesZ
value_line�valuer
r
r�getlistQs	zHandyConfigParser.getlistcCs�|j||�}g}x�|j�D]}}|j�}ytj|�WnDtjk
r�}z!td||||f��WYdd}~XnX|r%|j|�q%W|S)z�Read a list of full-line regexes.

        The value of `section` and `option` is treated as a newline-separated
        list of regexes.  Each value is stripped of whitespace.

        Returns the list of strings.

        zInvalid [%s].%s value %r: %sN)r�
splitlinesr3r,�compile�errorrr4)rrrZ	line_listr5r7�er
r
r�getregexlistcs	,zHandyConfigParser.getregexlistN)
�__name__�
__module__�__qualname__�__doc__r
rrrrrrr8r=r
r
r
rrsrz!(?i)#\s*pragma[:\s]?\s*no\s*coverz"(?i)#\s*pragma[:\s]?\s*no\s*branchzwhile (True|1|False|0):zif (True|1|False|0):c@s�eZdZdZdd�ZdddddgZd	d
�Zede�dd
d��Z	dMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhgZ
ddDdE�ZdFdG�ZdHdI�Z
dJdK�ZdLS)i�CoverageConfigz�Coverage.py configuration.

    The attributes of this class are the various settings that control the
    operation of coverage.py.

    cCs'g|_g|_d|_d|_d|_d|_g|_d|_d|_g|_	d|_
d|_tdd�|_
d|_d|_d|_d|_tdd�|_tdd�|_d|_d|_d|_d|_d|_d|_d|_d|_i|_i|_dS)	z:Initialize the configuration attributes to their defaults.FNz	.coveragerZhtmlcovzCoverage reportzcoverage.xml�c) �attempted_config_files�config_files�branch�concurrency�cover_pylib�	data_file�debug�note�parallel�plugins�source�timid�DEFAULT_EXCLUDE�exclude_list�
fail_under�
ignore_errors�include�omit�DEFAULT_PARTIAL_ALWAYS�partial_always_list�DEFAULT_PARTIAL�partial_list�	precision�show_missing�skip_covered�	extra_css�html_dir�
html_title�
xml_output�xml_package_depth�paths�plugin_options)rr
r
rr
�s:																									zCoverageConfig.__init__rUrTrJrMrGcKsdx]t|�D]O\}}|dk	r
||jkrLt|t�rL|g}t|||�q
WdS)z!Read config values from `kwargs`.N)r�MUST_BE_LIST�
isinstancer�setattr)rr�kr/r
r
r�	from_args�s
	zCoverageConfig.from_argsrr$c
#Cs5|jj|�t|�}y|j|�}Wn>tjk
ro}ztd||f��WYdd}~XnX|szdS|jj|�y(x!|j	D]}|j
||�q�WWn;tk
r�}ztd||f��WYdd}~XnXtj
t�}x;|j	D]0}|djd�\}}	||j|	�q	Wxvt|�D]h\}}
|j|�rJxJt|j|��|
D]/}|r�||}td|||f��qWqJW|jd�r�x0|jd�D]}	|jd|	�|j|	<q�Wx6|jD]+}|j|�r|j|�|j|<qWdS)	z�Read configuration from a .rc file.

        `filename` is a file name to read.

        Returns True or False, whether the file could be read.

        z Couldn't read config file %s: %sNF��:z0Unrecognized option '[%s] %s=' in config file %srbT)rDr4rrr�ErrorrrE�extend�CONFIG_FILE_OPTIONS�_set_attr_from_config_option�
ValueError�collections�defaultdict�setr2�addrrrr8rbrMrrc)
rrr�cpZ
files_read�err�option_specZall_optionsrrr�unknown�pluginr
r
r�	from_file�sB	)) 
zCoverageConfig.from_filerF�
run:branch�boolean�run:concurrency�listrH�run:cover_pylibrI�
run:data_file�	run:debug�run:includerK�run:note�run:omitrL�run:parallel�run:pluginsrN�
run:sourcerO�	run:timidrQ�report:exclude_lines�	regexlistrR�report:fail_under�intrS�report:ignore_errors�report:include�report:omitrW�report:partial_branches_alwaysrY�report:partial_branchesrZ�report:precisionr[�report:show_missingr\�report:skip_covered�sort�report:sortr]�html:extra_cssr^�html:directoryr_�
html:titler`�
xml:outputra�xml:package_depthcCsW|jd�\}}|j||�rSt|d|�}t|||||��dS)z:Set an attribute on self if it exists in the ConfigParser.rjrN)r2r�getattrrf)rrt�attr�where�type_rr�methodr
r
rrn2sz+CoverageConfig._set_attr_from_config_optioncCs|jj|i�S)z:Get a dictionary of options for the plugin named `plugin`.)rcr)rrxr
r
r�get_plugin_options9sz!CoverageConfig.get_plugin_optionsc	Cs�xG|jD]<}|dd�\}}||kr
t|||�dSq
W|jd�\}}}|r�||jkr�||jj|i�|<dStd|��dS)aBSet an option in the configuration.

        `option_name` is a colon-separated string indicating the section and
        option name.  For example, the ``branch`` option in the ``[run]``
        section of the config file would be indicated with `"run:branch"`.

        `value` is the new value for the option.

        NrrjzNo such option: %r)rmrf�	partitionrMrc�
setdefaultr)	r�option_namer7rvr�r��plugin_name�_�keyr
r
r�
set_option=szCoverageConfig.set_optioncCs�x@|jD]5}|dd�\}}||kr
t||�Sq
W|jd�\}}}|r�||jkr�|jj|i�j|�Std|��dS)a<Get an option from the configuration.

        `option_name` is a colon-separated string indicating the section and
        option name.  For example, the ``branch`` option in the ``[run]``
        section of the config file would be indicated with `"run:branch"`.

        Returns the value of the option.

        NrrjzNo such option: %r)rmr�r�rMrcrr)rr�rvr�r�r�r�r�r
r
r�
get_optionXszCoverageConfig.get_optionN)rFrzr{)rGr|r})rHr~r{)rIr)rJr�r})rTr�r})rKr�)rUr�r})rLr�r{)rMr�r})rNr�r})rOr�r{)rQr�r�)rRr�r�)rSr�r{)rTr�r})rUr�r})rWr�r�)rYr�r�)rZr�r�)r[r�r{)r\r�r{)r�r�)r]r�)r^r�)r_r�)r`r�)rar�r�)r>r?r@rAr
rdrhr�strryrmrnr�r�r�r
r
r
rrB�sL-A	rB)rArpr'r,rZcoverage.backwardrrrZ
coverage.miscrrrr	rrPrXrV�objectrBr
r
r
r�<module>sl