ó
…¾^Yc           @   sÔ   d  Z  d d l Z d d l Z d d l Z d d l Z d d l m Z m Z m Z d d l	 m
 Z
 m Z m Z e e ƒ Z d e j f d „  ƒ  YZ d g Z d g Z d	 d
 g Z d e f d „  ƒ  YZ d „  Z d S(   s   Config file for coverage.pyiÿÿÿÿN(   t   configparsert   iitemst   string_class(   t   contractt   CoverageExceptiont   isolate_modulet   HandyConfigParserc           B   s_   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z RS(
   s#   Our specialization of ConfigParser.c         C   s   t  j j |  ƒ | |  _ d  S(   N(   R    t   RawConfigParsert   __init__t   section_prefix(   t   selfR	   (    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pyR      s    c         C   s8   i  } t  j d k r" d | d <n  t j j |  | |  S(   s-   Read a file name as UTF-8 configuration data.i   i   s   utf-8t   encoding(   i   i   (   t   syst   version_infoR    R   t   read(   R
   t	   filenamest   kwargs(    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pyR      s    c         C   s#   |  j  | } t j j |  | | ƒ S(   N(   R	   R    R   t
   has_option(   R
   t   sectiont   option(    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pyR      s    c         C   s    |  j  | } t j j |  | ƒ S(   N(   R	   R    R   t   has_section(   R
   R   (    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pyR   #   s    c         C   s    |  j  | } t j j |  | ƒ S(   N(   R	   R    R   t   options(   R
   R   (    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pyR   '   s    c         C   s:   i  } x- |  j  | ƒ D] } |  j | | ƒ | | <q W| S(   s/   Get the contents of a section, as a dictionary.(   R   t   get(   R
   R   t   dt   opt(    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pyt   get_section+   s    c         O   sP   |  j  | } t j j |  | | | Ž } d „  } d } t j | | | ƒ } | S(   s   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.

        c         S   sC   t  d „  |  j ƒ  Dƒ ƒ } | d k r, d St j j | d ƒ Sd S(   s   Called for each $replacement.c         s   s!   |  ] } | d  k	 r | Vq d  S(   N(   t   None(   t   .0t   w(    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pys	   <genexpr>A   s    t   $t    N(   t   nextt   groupst   ost   environR   (   t   mt   word(    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pyt   dollar_replace>   s    s$  (?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.
            )
            (   R	   R    R   R   t   ret   sub(   R
   R   t   argsR   t   vR%   t   dollar_pattern(    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pyR   2   s    
	c         C   sr   |  j  | | ƒ } g  } xS | j d ƒ D]B } x9 | j d ƒ D]( } | j ƒ  } | r> | j | ƒ q> q> Wq( W| S(   sâ   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.

        s   
t   ,(   R   t   splitt   stript   append(   R
   R   R   t
   value_listt   valuest
   value_linet   value(    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pyt   getlistQ   s    	c         C   s›   |  j  | | ƒ } g  } x| | j ƒ  D]n } | j ƒ  } y t j | ƒ Wn2 t j k
 r| } t d | | | | f ƒ ‚ n X| r% | j | ƒ q% q% W| S(   sà   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.

        s   Invalid [%s].%s value %r: %s(   R   t
   splitlinesR-   R&   t   compilet   errorR   R.   (   R
   R   R   t	   line_listR/   R2   t   e(    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pyt   getregexlistc   s    	(   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   R   R3   R9   (    (    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pyR      s   								s3   #\s*(pragma|PRAGMA)[:\s]?\s*(no|NO)\s*(cover|COVER)s5   #\s*(pragma|PRAGMA)[:\s]?\s*(no|NO)\s*(branch|BRANCH)s   while (True|1|False|0):s   if (True|1|False|0):t   CoverageConfigc           B   s×   e  Z d  Z d „  Z d d d d d d g Z d „  Z e d	 e ƒ d
 d „ ƒ Z dF dG dH dI dJ dK dL dM dN dO dP dQ dR dS dT dU dV dW dX dY dZ d[ d\ d] d^ d_ d` da db g Z	 d
 dB „ Z
 dC „  Z dD „  Z dE „  Z RS(c   sŠ   Coverage.py configuration.

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

    c         C   s  g  |  _  g  |  _ t |  _ d |  _ t |  _ d |  _ g  |  _ g  |  _	 d |  _
 t |  _ g  |  _ d |  _ t |  _ t |  _ d |  _ t |  _ d |  _ d |  _ t |  _ t |  _ d |  _ t |  _ t |  _ d |  _ d |  _ d |  _ d |  _ d |  _  i  |  _! i  |  _" d S(   s:   Initialize the configuration attributes to their defaults.s	   .coveragei    t   htmlcovs   Coverage reports   coverage.xmlic   N(#   t   attempted_config_filest   config_filest   Falset   branchR   t   concurrencyt   cover_pylibt	   data_filet   debugt   disable_warningst   notet   parallelt   pluginst   sourcet   timidt   DEFAULT_EXCLUDEt   exclude_listt
   fail_undert   ignore_errorst   includet   omitt   DEFAULT_PARTIAL_ALWAYSt   partial_always_listt   DEFAULT_PARTIALt   partial_listt	   precisiont   show_missingt   skip_coveredt	   extra_csst   html_dirt
   html_titlet
   xml_outputt   xml_package_deptht   pathst   plugin_options(   R
   (    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pyR   •   s<    													
				

									RC   RF   RG   RQ   RR   RJ   c         K   sj   xc t  | ƒ D]U \ } } | d k	 r | |  j k rO t | t ƒ rO | g } n  t |  | | ƒ q q Wd S(   s!   Read config values from `kwargs`.N(   R   R   t   MUST_BE_LISTt
   isinstanceR   t   setattr(   R
   R   t   kR)   (    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pyt	   from_argsÅ   s
    t   filenameR   c         C   sN  |  j  j | ƒ t | ƒ } y | j | ƒ } Wn, t j k
 r] } t d | | f ƒ ‚ n X| sh t S|  j j	 | ƒ t } y9 x2 |  j
 D]' } |  j | | Œ } | r‹ t } q‹ q‹ WWn) t k
 râ } t d | | f ƒ ‚ n Xt j t ƒ }	 x; |  j
 D]0 } | d j d ƒ \ }
 } |	 |
 j | ƒ qü Wx| t |	 ƒ D]n \ }
 } | j |
 ƒ r=xP t | j |
 ƒ ƒ | D]2 } | r‹| |
 }
 n  t d |
 | | f ƒ ‚ qrWq=q=W| j d ƒ rúx9 | j d ƒ D]% } | j d | ƒ |  j | <t } qÎWn  x? |  j D]4 } | j | ƒ r| j | ƒ |  j | <t } qqW| rF| St Sd S(   sÍ   Read configuration from a .rc file.

        `filename` is a file name to read.

        Returns True or False, whether the file could be read, and it had some
        coverage.py settings in it.

        s    Couldn't read config file %s: %si   t   :s0   Unrecognized option '[%s] %s=' in config file %sR_   N(   R?   R.   R   R   R    t   ErrorR   RA   R@   t   extendt   CONFIG_FILE_OPTIONSt   _set_attr_from_config_optiont   Truet
   ValueErrort   collectionst   defaultdictt   setR,   t   addR   R   R   R3   R_   RJ   R   R`   (   R
   Rf   R	   t   cpt
   files_readt   errt   any_sett   option_spect   was_sett   all_optionsR   R   R   t   unknownt   plugin(    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pyt	   from_fileÍ   sP    
 RB   s
   run:brancht   booleans   run:concurrencyt   listRD   s   run:cover_pylibRE   s   run:data_files	   run:debugs   run:disable_warningss   run:includeRH   s   run:notes   run:omitRI   s   run:parallels   run:pluginsRK   s
   run:sourceRL   s	   run:timidRN   s   report:exclude_linest	   regexlistRO   s   report:fail_undert   intRP   s   report:ignore_errorss   report:includes   report:omitRT   s   report:partial_branches_alwaysRV   s   report:partial_branchesRW   s   report:precisionRX   s   report:show_missingRY   s   report:skip_coveredt   sorts   report:sortRZ   s   html:extra_cssR[   s   html:directoryR\   s
   html:titleR]   s
   xml:outputR^   s   xml:package_depthc         C   s[   | j  d ƒ \ } } | j | | ƒ rW t | d | ƒ } t |  | | | | ƒ ƒ t St S(   st   Set an attribute on self if it exists in the ConfigParser.

        Returns True if the attribute was set.

        Rg   R   (   R,   R   t   getattrRc   Rl   RA   (   R
   Rr   t   attrt   wheret   type_R   R   t   method(    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pyRk   ?  s    c         C   s   |  j  j | i  ƒ S(   s:   Get a dictionary of options for the plugin named `plugin`.(   R`   R   (   R
   Rz   (    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pyt   get_plugin_optionsL  s    c   	      C   s¢   xA |  j  D]6 } | d  \ } } | | k r
 t |  | | ƒ d Sq
 W| j d ƒ \ } } } | rŽ | |  j k rŽ | |  j j | i  ƒ | <d St d | ƒ ‚ d S(   sB  Set 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.

        i   NRg   s   No such option: %r(   Rj   Rc   t	   partitionRJ   R`   t
   setdefaultR   (	   R
   t   option_nameR2   Rv   R‚   Rƒ   t   plugin_namet   _t   key(    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pyt
   set_optionP  s    c         C   sš   x: |  j  D]/ } | d  \ } } | | k r
 t |  | ƒ Sq
 W| j d ƒ \ } } } | r† | |  j k r† |  j j | i  ƒ j | ƒ St d | ƒ ‚ d S(   s<  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.

        i   Rg   s   No such option: %rN(   Rj   R   R‡   RJ   R`   R   R   (   R
   R‰   Rv   R‚   Rƒ   RŠ   R‹   RŒ   (    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pyt
   get_optionk  s    (   s   branchs
   run:branchs   boolean(   s   concurrencys   run:concurrencys   list(   s   cover_pylibs   run:cover_pylibs   boolean(   s	   data_files   run:data_file(   s   debugs	   run:debugs   list(   s   disable_warningss   run:disable_warningss   list(   s   includes   run:includes   list(   s   notes   run:note(   s   omits   run:omits   list(   s   parallels   run:parallels   boolean(   s   pluginss   run:pluginss   list(   s   sources
   run:sources   list(   s   timids	   run:timids   boolean(   s   exclude_lists   report:exclude_linesR~   (   s
   fail_unders   report:fail_unders   int(   s   ignore_errorss   report:ignore_errorss   boolean(   s   includes   report:includes   list(   s   omits   report:omits   list(   s   partial_always_lists   report:partial_branches_alwaysR~   (   s   partial_lists   report:partial_branchesR~   (   s	   precisions   report:precisions   int(   s   show_missings   report:show_missings   boolean(   s   skip_covereds   report:skip_covereds   boolean(   s   sorts   report:sort(   s	   extra_csss   html:extra_css(   s   html_dirs   html:directory(   s
   html_titles
   html:title(   s
   xml_outputs
   xml:output(   s   xml_package_depths   xml:package_depths   int(   R:   R;   R<   R   Ra   Re   R   t   strR{   Rj   Rk   R†   R   RŽ   (    (    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pyR=   Ž   sN   	.	L			c   
      K   s2  t  ƒ  } |  r¹ |  d k r$ t }  n  |  t k	 } | s? d }  n  xw |  d f d d g D]] \ } } | j | d | ƒ} | |  k } | r¨ | r¨ | r¨ t d | ƒ ‚ n  | rU PqU qU Wn  t j j d ƒ } | rÝ | | _ n  t j j d	 ƒ }	 |	 r| j j	 d
 „  |	 j
 d ƒ Dƒ ƒ n  | j |   |  | f S(   s  Read the coverage.py configuration.

    Arguments:
        config_file: a boolean or string, see the `Coverage` class for the
            tricky details.
        all others: keyword arguments from the `Coverage` class, used for
            setting values in the configuration.

    Returns:
        config_file, config:
            config_file is the value to use for config_file in other
            invocations of coverage.

            config is a CoverageConfig object read from the appropriate
            configuration file.

    s   .coveragercR   s	   setup.cfgs	   coverage:s   tox.iniR	   s#   Couldn't read '%s' as a config filet   COVERAGE_FILEt   COVERAGE_DEBUGc         s   s   |  ] } | j  ƒ  Vq d  S(   N(   R-   (   R   R   (    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pys	   <genexpr>¶  s    R+   (   s	   setup.cfgs	   coverage:(   s   tox.inis	   coverage:(   R=   Rl   R{   R   R!   R"   R   RE   RF   Ri   R,   Re   (
   t   config_fileR   t   configt   specified_filet   fnamet   prefixt   config_readt   is_config_filet   env_data_filet   debugs(    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pyt   read_coverage_config„  s0    			&(   R<   Rn   R!   R&   R   t   coverage.backwardR    R   R   t   coverage.miscR   R   R   R   R   RM   RU   RS   t   objectR=   R›   (    (    (    s1   /tmp/pip-build-hU8Cw8/coverage/coverage/config.pyt   <module>   s   l			ö