
^Yc           @   s  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l	 m
 Z
 d d l m Z d d l m Z m Z d d l m Z d d l m Z d d l m Z m Z d d	 l m Z m Z d d
 l m Z m Z d d l m Z m Z m Z d d l m  Z  m! Z! d d l m" Z" m# Z# d d l$ m% Z% d d l& m' Z' m( Z( m) Z) d d l& m* Z* m+ Z+ d d l, m- Z- d d l. m/ Z/ d d l0 m1 Z1 m2 Z2 d d l3 m4 Z4 m5 Z5 d d l6 m7 Z7 d d l8 m9 Z9 y d d l: m; Z; Wn e< k
 r!e= Z; n Xe+ e  Z e= Z> Z? e
 j@ ry d d l> Z> Wn e< k
 rdn Xy d d l? Z? Wn e< k
 rn Xn  d eA f d     YZB d   ZC d   ZD d   ZE d   ZF d S(   s#   Core control stuff for coverage.py.iN(   t   env(   t   AnnotateReporter(   t   string_classt   iitems(   t	   Collector(   t   read_coverage_config(   t   CoverageDatat   CoverageDataFiles(   t   DebugControlt   write_formatted_info(   t   TreeMatchert   FnmatchMatcher(   t   PathAliasest   find_python_filest   prep_patterns(   t   canonical_filenamet   set_relative_directory(   t   ModuleMatchert   abs_file(   t   HtmlReporter(   t   CoverageExceptiont   bool_or_nonet
   join_regex(   t   file_be_gonet   isolate_module(   t   FileReporter(   t   Plugins(   t   PythonFileReportert   source_for_file(   t   Analysist   Numbers(   t   SummaryReporter(   t   XmlReporter(   t   patch_multiprocessingt   Coveragec           B   s  e  Z d  Z d* d* d* e d* d* e d* d* d* d* d* d  Z d   Z d   Z e d  Z	 d   Z
 d   Z d   Z d   Z d	   Z d* d
  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d d  Z d d  Z d   Z d   Z d d  Z d   Z d* e d  Z d   Z d   Z  d   Z! d   Z" d   Z# d    Z$ d!   Z% d"   Z& d#   Z' d* d$  Z( d* d* d* d* d* d* d* d%  Z) d* d* d* d* d* d&  Z* d* d* d* d* d* d* d* d* d'  Z+ d* d* d* d* d* d(  Z, d)   Z- RS(+   s   Programmatic access to coverage.py.

    To use::

        from coverage import Coverage

        cov = Coverage()
        cov.start()
        #.. call your code ..
        cov.stop()
        cov.html_report(directory='covhtml')

    c         C   sp  t  d | d | d | d | d | d t |  d | d |	 d	 |
 d
 | d |  \ |  _ |  _ d |  _ | |  _ |  _ | |  _ d |  _	 d |  _
 d |  _ |  _ d |  _ |  _ t |  _ t |  _ g  |  _ d |  _ |  _ |  _ d |  _ d |  _ d |  _ |  _ |  _ d |  _ d |  _ |  _ d |  _ |  _ d |  _  d |  _! t" |  _# t" |  _$ t% j& slt'   n  d S(   sW
  
        `data_file` is the base name of the data file to use, defaulting to
        ".coverage".  `data_suffix` is appended (with a dot) to `data_file` to
        create the final file name.  If `data_suffix` is simply True, then a
        suffix is created with the machine and process identity included.

        `cover_pylib` is a boolean determining whether Python code installed
        with the Python interpreter is measured.  This includes the Python
        standard library and any packages installed with the interpreter.

        If `auto_data` is true, then any existing data file will be read when
        coverage measurement starts, and data will be saved automatically when
        measurement stops.

        If `timid` is true, then a slower and simpler trace function will be
        used.  This is important for some environments where manipulation of
        tracing functions breaks the faster trace function.

        If `branch` is true, then branch coverage will be measured in addition
        to the usual statement coverage.

        `config_file` determines what configuration file to read:

            * If it is ".coveragerc", it is interpreted as if it were True,
              for backward compatibility.

            * If it is a string, it is the name of the file to read.  If the
              file can't be read, it is an error.

            * If it is True, then a few standard files names are tried
              (".coveragerc", "setup.cfg", "tox.ini").  It is not an error for
              these files to not be found.

            * If it is False, then no configuration file is read.

        `source` is a list of file paths or package names.  Only code located
        in the trees indicated by the file paths or package names will be
        measured.

        `include` and `omit` are lists of file name patterns. Files that match
        `include` will be measured, files that match `omit` will not.  Each
        will also accept a single string argument.

        `debug` is a list of strings indicating what debugging information is
        desired.

        `concurrency` is a string indicating the concurrency library being used
        in the measured code.  Without this, coverage.py will get incorrect
        results if these libraries are in use.  Valid strings are "greenlet",
        "eventlet", "gevent", "multiprocessing", or "thread" (the default).
        This can also be a list of these strings.

        .. versionadded:: 4.0
            The `concurrency` parameter.

        .. versionadded:: 4.2
            The `concurrency` parameter can now be a list of strings.

        t   config_filet	   data_filet   cover_pylibt   timidt   brancht   parallelt   sourcet   omitt   includet   debugt   concurrencyN((   R   R   R#   t   configt   Nonet   _debug_filet
   _auto_loadt
   _auto_savet   _data_suffixt   source_matcht   source_pkgs_matcht   pylib_matcht   cover_matcht   include_matcht
   omit_matcht   Truet   _warn_no_datat   _warn_unimported_sourcet	   _warningsR*   R+   R)   t   source_pkgs_unmatchedt   source_pkgst   datat
   data_filest	   collectort   pluginst   pylib_pathst   cover_pathst   data_suffixt
   run_suffixt   _exclude_reR,   t   Falset   _initedt   _startedR    t   METACOVt    _prevent_sub_process_measurement(   t   selfR$   RF   R%   t	   auto_dataR&   R'   R#   R)   R*   R+   R,   R-   (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyt   __init__L   s:    B															c         C   s]  |  j  r d St |  _  |  j d k ra t j j d  } | rR t | d  |  _ qa t j	 |  _ n  t
 |  j j |  j  |  _ t j |  j j |  j |  j  |  _ i  |  _ |  j   t   g  |  _ g  |  _ xU |  j j p g  D]A } t j j |  r|  j j t |   q |  j j |  q W|  j |  _ t |  j j  |  _ t |  j j  |  _ |  j j pjg  } d | k rt st d   n  t d |  j   t |  j _! n  t" d |  j# d |  j$ d	 |  j j% d
 |  j j& d |  j' d |  |  _( |  j j) rg|  j( j* rg|  j' d d j+ d   |  j j) D  |  j( j,   f  x  |  j j) D] } t- | _. qQWn  |  j/ s||  j j! rt0 |  j/ t1  st |  _/ qn	 d |  _/ d |  _2 |  j/ |  _3 t4 d |  j  |  _5 t6 d |  j j7 d |  j' d |  j  |  _8 t9   |  _: |  j j; sxc t< t= t t> t? t@ tA tB f D]C } | d k	 r1tC | d  r1|  j: jD |  jE | d t  q1q1WtA rtC tA d  rtA jF } y | jG jH } Wn tI k
 r| jJ jH } n X|  j: jD |  jE |   qn  |  jE tK d t g |  _L tM jN r{|  jL j t j j+ |  jL d d   d d lO } d d lP }	 x0 | |	 g D] }
 |  jL j |  jE |
   qUWn  tQ jR |  j jS  t< jT |  jU  |  j s|  j rtV |  j  |  _W tX |  j  |  _Y n< |  jL rtV |  jL  |  _Z n  |  j: rtV |  j:  |  _[ n  |  j r1t\ |  j  |  _] n  |  j rOt\ |  j  |  _^ n  |  j_   d S(   s   Set all the initial state.

        This is called by the public methods to initialize state. This lets us
        construct a :class:`Coverage` object, then tweak its state before this
        function is called.

        Nt   COVERAGE_DEBUG_FILEt   at   multiprocessings/   multiprocessing is not supported on this Pythont   rcfilet   should_tracet   check_includeR&   R'   t   warnR-   s1   Plugin file tracers (%s) aren't supported with %ss   , c         s   s   |  ] } | j  Vq d  S(   N(   t   _coverage_plugin_name(   t   .0t   plugin(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pys	   <genexpr>
  s   R,   t   basenamet   __file__t	   directoryi    t   testsi(`   RJ   R:   R0   R/   t   ost   environt   gett   opent   syst   stderrR   R.   R,   R   t   load_pluginsRC   RH   t   _exclude_regex_staleR   R)   R?   t   patht   isdirt   appendR   R>   R   R*   R+   R-   R!   R   R#   R(   R   t   _should_tracet   _check_include_omit_etcR&   R'   t   _warnRB   t   file_tracerst   supports_pluginst   joint   tracer_nameRI   t   _coverage_enabledR3   t
   isinstanceR   RF   RG   R   R@   R   R$   RA   t   setRD   R%   t   atexitt   inspectt   platformt   _pypy_irc_topict   ret
   _structseqt	   tracebackt   hasattrt   addt   _canonical_patht   structseq_newt	   func_codet   co_filenamet   AttributeErrort   __code__R\   RE   R    t   TESTINGt	   contractst   sixR   t   set_precisiont	   precisiont   registert   _atexitR
   R4   R   R5   R7   R6   R   R8   R9   t   _write_startup_debug(   RN   t   debug_file_namet   srcR-   RZ   t   mR~   t   structseq_fileR   R   t   mod(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyt   _init   s    		$	
							$%&		& 				c      	   C   s   t  } |  j j    |  j j d  r\ t |  j j j    } t |  j d |  t	 } n  |  j j d  r t |  j d |  j
    x= |  j D]2 } d | j } | j
   } t |  j | |  q Wt	 } n  Wd QX| r t |  j d d  n  d S(   s*   Write out debug info at startup if needed.R.   Rc   s   sys: Nt   end(    (   RI   R,   t   without_callerst   shouldt   sortedR.   t   __dict__t   itemsR	   R:   t   sys_infoRC   RX   (   RN   t	   wrote_anyt   config_infoRZ   t   headert   info(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR   d  s    	c         C   sD   t  | |   j } | j d  s' | r@ t j j |  d } n  | S(   s  Return the canonical path of the module or file `morf`.

        If the module is a package, then return its directory. If it is a
        module, then return its file, unless `directory` is True, in which
        case return its enclosing directory.

        s   __init__.pyi    (   R   t   filenamet   endswithR_   Rg   t   split(   RN   t   morfR]   t	   morf_path(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR}   x  s    c         C   s   | d k r i  } n  | j d d  } t | t  rF | d k rF | S| j d d  } xQ d D]I } t | |  r_ t | |  } n q_ t | t  r_ | d k r_ | Sq_ Wt j |  } | d k	 r | S| Sd S(   s  Get the name of the module for a set of globals and file name.

        For configurability's sake, we allow __main__ modules to be matched by
        their importable name.

        If loaded via runpy (aka -m), we can usually recover the "original"
        full dotted module name, otherwise, we resort to interpreting the
        file name to get the module's name.  In the case that the module name
        can't be determined, None is returned.

        t   __name__t   __main__t
   __loader__t   fullnamet   nameN(   s   fullnames   name(   R/   Ra   Rr   t   strR{   t   getattrRu   t   getmodulename(   RN   t   module_globalsR   t   dunder_namet   loadert   attrnameR   t   inspectedname(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyt   _name_for_module  s     	c         C   s  | } t  |  j j |  } d   } | j o< | j j d  } | r t |  } | r | j d  r t j j	 |  } | t j j	 |  k r | } q q n  | s | | d  S| j d  r | | d  S| j d  r | | d  St
 j d |  r
| | d	  S| j d
  r*| d  d } n  t |  } | | _ d }	 x |  j j D] }	 |	 j sgqRn  yk |	 j |  }
 |
 d k	 r|	 |
 _ t | _ |
 | _ |
 j   rt | _ n t |
 j    | _ Pn  WqRt k
 r|  j d |	 j  t j   t |	 _ qRqRXqRWt | _ | | _ | j s| j sTt d |	 | j  f   n  |  j! | j |  } | r| | |  qn  | S(   s  Decide whether to trace execution in `filename`, with a reason.

        This function is called from the trace function.  As each new file name
        is encountered, this function determines whether it is traced or not.

        Returns a FileDisposition object.

        c         S   s   t  |  _ | |  _ |  S(   s+   Simple helper to make it easy to return NO.(   RI   t   tracet   reason(   t   dispR   (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyt   nope  s    		R\   t   <s   empty string isn't a file names   memory:s   memory isn't traceables   not a real file names   [/\\]Modules[/\\]pyexpat.cs   pyexpat lies about itselfs	   $py.classis   .pys(   Disabling plugin %r due to an exception:s+   Plugin %r didn't set source_filename for %rN("   t   _disposition_initRB   t   file_disposition_classt	   f_globalsRa   R   t
   startswithR_   Rg   R[   Rx   t   searchR   R   R/   RC   Rm   Rq   t   file_tracert   _coverage_pluginR:   R   t   has_dynamic_source_filenamet   has_dynamic_filenamet   source_filenamet	   ExceptionRl   RX   Rz   t	   print_excRI   R   t   original_filenamet    _check_include_omit_etc_internal(   RN   R   t   frameR   R   R   t   dunder_filet   origt	   canonicalRZ   R   R   (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyt   _should_trace_internal  sp    							
					c         C   s   |  j  | j |  } |  j ro |  j j |  rV | |  j k rR |  j j |  n  d S|  j j |  s d Sn` |  j r |  j j |  s d Sn> |  j	 r |  j	 j |  r d S|  j
 r |  j
 j |  r d S|  j r |  j j |  r d Sd S(   s   Check a file name against the include, omit, etc, rules.

        Returns a string or None.  String means, don't trace, and is the reason
        why.  None means no reason found to not trace.

        s    falls outside the --source treess!   falls outside the --include treess   is in the stdlibs   is part of coverage.pys   is inside an --omit patternN(   R   R   R4   R5   t   matchR>   t   removeR/   R8   R6   R7   R9   (   RN   R   R   t
   modulename(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR     s$    		c         C   sA   |  j  | |  } |  j j d  r= |  j j t |   n  | S(   s   Decide whether to trace execution in `filename`.

        Calls `_should_trace_internal`, and returns the FileDisposition.

        R   (   R   R,   R   t   writet   _disposition_debug_msg(   RN   R   R   R   (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyRj   C  s    c         C   sb   |  j  | |  } |  j j d  r] | s: d | f } n d | | f } |  j j |  n  | S(   s   Check a file name against the include/omit/etc, rules, verbosely.

        Returns a boolean: True if the file should be traced, False if not.

        R   s   Including %rs   Not including %r: %s(   R   R,   R   R   (   RN   R   R   R   t   msg(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyRk   N  s    c         C   s   | |  j  j k r d S|  j j |  | r? d | | f } n  |  j j d  rj d t j   | f } n  t j	 j
 d |  d S(   s_   Use `msg` as a warning.

        For warning suppression, use `slug` as the shorthand.
        Ns   %s (%s)t   pids   [%d] %ss   Coverage.py warning: %s
(   R.   t   disable_warningsR=   Ri   R,   R   R_   t   getpidRc   Rd   R   (   RN   R   t   slug(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyRl   ^  s    c         C   s   |  j  j |  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.

        .. versionadded:: 4.0

        (   R.   t
   get_option(   RN   t   option_name(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR   n  s    c         C   s   |  j  j | |  d S(   s  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.  This should be a Python
        value where appropriate.  For example, use True for booleans, not the
        string ``"True"``.

        As an example, calling::

            cov.set_option("run:branch", True)

        has the same effect as this configuration file::

            [run]
            branch = True

        .. versionadded:: 4.0

        N(   R.   t
   set_option(   RN   R   t   value(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR   |  s    c         C   s$   |  j    | s  |  j d  n  d S(   s   Obsolete method.s(   use_cache(False) is no longer supported.N(   R   Rl   (   RN   t   usecache(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyt	   use_cache  s    
c         C   s.   |  j    |  j j   |  j j |  j  d S(   s;   Load previously-collected coverage data from the data file.N(   R   RB   t   resetRA   t   readR@   (   RN   (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyt   load  s    
c         C   sR   |  j    |  j r" |  j |  _ n  |  j r8 |  j   n  |  j j   t |  _ d S(   sa  Start measuring code coverage.

        Coverage measurement only occurs in functions called after
        :meth:`start` is invoked.  Statements in the same scope as
        :meth:`start` won't be measured.

        Once you invoke :meth:`start`, you must also call :meth:`stop`
        eventually, or your process might not shut down cleanly.

        N(	   R   RG   RF   R1   R   RB   t   startR:   RK   (   RN   (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR     s    
		c         C   s&   |  j  r |  j j   n  t |  _  d S(   s   Stop measuring code coverage.N(   RK   RB   t   stopRI   (   RN   (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR     s    	c         C   s^   |  j  j d  r. |  j  j d j |    n  |  j rD |  j   n  |  j rZ |  j   n  d S(   s   Clean up on process shutdown.t   processs   atexit: {0!r}N(   R,   R   R   t   formatRK   R   R2   t   save(   RN   (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR     s    		c         C   sA   |  j    |  j j   |  j j   |  j j d |  j j  d S(   s   Erase previously-collected coverage data.

        This removes the in-memory data collected in this session as well as
        discarding the data file.

        R(   N(   R   RB   R   R@   t   eraseRA   R.   R(   (   RN   (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR     s    
t   excludec         C   s/   |  j    t |  j | d g   |  j   d S(   s   Clear the exclude list.t   _listN(   R   t   setattrR.   Rf   (   RN   t   which(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyt   clear_exclude  s    
c         C   s;   |  j    t |  j | d  } | j |  |  j   d S(   s|  Exclude source lines from execution consideration.

        A number of lists of regular expressions are maintained.  Each list
        selects lines that are treated differently during reporting.

        `which` determines which list is modified.  The "exclude" list selects
        lines that are not considered executable at all.  The "partial" list
        indicates lines with branches that are not taken.

        `regex` is a regular expression.  The regex is added to the specified
        list.  If any of the regexes in the list is found in a line, the line
        is marked for special treatment during reporting.

        R   N(   R   R   R.   Ri   Rf   (   RN   t   regexR   t	   excl_list(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR     s    
c         C   s   |  j  j   d S(   s=   Drop all the compiled exclusion regexes, a list was modified.N(   RH   t   clear(   RN   (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyRf     s    c         C   sF   | |  j  k r; t |  j | d  } t |  |  j  | <n  |  j  | S(   s5   Return a compiled regex for the given exclusion list.R   (   RH   R   R.   R   (   RN   R   R   (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyt   _exclude_regex  s    c         C   s   |  j    t |  j | d  S(   s   Return a list of excluded regex patterns.

        `which` indicates which list is desired.  See :meth:`exclude` for the
        lists that are available, and their meaning.

        R   (   R   R   R.   (   RN   R   (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyt   get_exclude_list  s    
c         C   s4   |  j    |  j   |  j j |  j d |  j d S(   s2   Save the collected coverage data to the data file.t   suffixN(   R   t   get_dataRA   R   R@   RF   (   RN   (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR     s    

c         C   s   |  j    |  j   d } |  j j r~ t   } xL |  j j j   D]5 } | d } x" | d D] } | j | |  q] WqB Wn  |  j j	 |  j
 d | d | d | d S(   s  Combine together a number of similarly-named coverage data files.

        All coverage data files whose name starts with `data_file` (from the
        coverage() constructor) will be read, and combined together into the
        current measurements.

        `data_paths` is a list of files or directories from which data should
        be combined. If no list is passed, then the data files from the
        directory indicated by the current data file (probably the current
        directory) will be combined.

        If `strict` is true, then it is an error to attempt to combine when
        there are no data files to combine.

        .. versionadded:: 4.0
            The `data_paths` parameter.

        .. versionadded:: 4.3
            The `strict` parameter.

        i    i   t   aliasest
   data_pathst   strictN(   R   R   R/   R.   t   pathsR   t   valuesR|   RA   t   combine_parallel_dataR@   (   RN   R   R   R   R   t   resultt   pattern(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyt   combine  s    

	
	c         C   s3   |  j    |  j j |  j  r, |  j   n  |  j S(   s   Get the collected data.

        Also warn about various problems collecting data.

        Returns a :class:`coverage.CoverageData`, the collected coverage data.

        .. versionadded:: 4.0

        (   R   RB   t	   save_dataR@   t   _post_save_work(   RN   (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR   ,  s    

c         C   s,  |  j  r- x! |  j D] } |  j |  q Wn  |  j rV |  j rV |  j d d d n  x |  j D]{ } | t j k s` t	 t j | d  s` t
 j j t j | j  r q` n  t t j | j  } |  j |  j |   q` Wx |  j D] } |  j |  q W|  j j r(|  j j d |  j j  n  d S(   s   After saving data, look for warnings, post-work, etc.

        Warn about things that should have happened but didn't.
        Look for unexecuted files.

        s   No data was collected.R   s   no-data-collectedR\   t   noteN(   R<   R>   t   _warn_about_unmeasured_codeR@   R;   Rl   R?   Rc   t   modulesR{   R_   Rg   t   existsR\   R   t   _find_unexecuted_filesR}   R)   R.   R   t   add_run_info(   RN   t   pkgt   pkg_fileR   (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR   =  s     		c         C   s   t  j j |  } | d k r9 |  j d | d d d St | d  oU t | d  } t | d  oy t j j | j	  } | r d S| s |  j d | d d d S|  j d	 | d d
 d S(   s}   Warn about a package or module that we never traced.

        `pkg` is a string, the name of the package or module.

        s   Module %s was never imported.R   s   module-not-importedNt   __path__R\   s   Module %s has no Python source.s   module-not-pythons4   Module %s was previously imported, but not measured.s   module-not-measured(
   Rc   R   Ra   R/   Rl   R{   R_   Rg   R   R\   (   RN   R   R   t   is_namespacet   has_file(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR   ]  s    $
c         c   s@   x9 |  j  D]. } x% | j |  D] } | | j f Vq  Wq
 Wd S(   s&   Get executable files from the plugins.N(   RC   t   find_executable_filesRX   (   RN   t   src_dirRZ   t   x_file(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyt   _find_plugin_files|  s    c         C   s   d   t  |  D } |  j |  } x` t j | |  D]L \ } } t |  } |  j rq |  j j |  rq q8 n  |  j j | |  q8 Wd S(   s   Find unexecuted files in `src_dir`.

        Search for files in `src_dir` that are probably importable,
        and add them as unexecuted files in `self.data`.

        c         s   s   |  ] } | d  f Vq d  S(   N(   R/   (   RY   t   py_file(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pys	   <genexpr>  s    N(	   R   R  t	   itertoolst   chainR   R9   R   R@   t
   touch_file(   RN   R  t   py_filest   plugin_filest	   file_patht   plugin_name(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR     s    c         C   s.   |  j  |  \ } } } } } | | | | f S(   s:   Like `analysis2` but doesn't return excluded line numbers.(   t	   analysis2(   RN   R   t   ft   st   _R   t   mf(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyt   analysis  s    c         C   sP   |  j    |  j |  } | j t | j  t | j  t | j  | j   f S(   sG  Analyze a module.

        `morf` is a module or a file name.  It will be analyzed to determine
        its coverage statistics.  The return value is a 5-tuple:

        * The file name for the module.
        * A list of line numbers of executable statements.
        * A list of line numbers of excluded statements.
        * A list of line numbers of statements not run (missing from
          execution).
        * A readable formatted string of the missing line numbers.

        The analysis uses the source file itself and the current measured
        coverage data.

        (   R   t   _analyzeR   R   t
   statementst   excludedt   missingt   missing_formatted(   RN   R   R  (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR    s    
c         C   s;   |  j    t | t  s+ |  j |  } n  t |  j |  S(   sT   Analyze a single morf or code unit.

        Returns an `Analysis` object.

        (   R   Rr   R   t   _get_file_reporterR   R@   (   RN   t   it(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR    s    
c         C   s   d } d } t | t  rW t |  } |  j j |  } | rW |  j j |  } qW n  | r | j |  } | d k r t	 d | j
 | f   q n  | d k r t | |   } n  | S(   s-   Get a FileReporter for a module or file name.t   pythons1   Plugin %r did not provide a file reporter for %r.N(   R/   Rr   R   R   R@   R   RC   Ra   t   file_reporterR   RX   R   (   RN   R   RZ   R  t   abs_morfR  (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR    s     c         C   sp   | s |  j  j   } n  t | t t f  s9 | g } n  g  } x* | D]" } |  j |  } | j |  qF W| S(   s  Get a list of FileReporters for a list of modules or file names.

        For each module or file name in `morfs`, find a FileReporter.  Return
        the list of FileReporters.

        If `morfs` is a single module or file name, this returns a list of one
        FileReporter.  If `morfs` is empty or None, then the list of all files
        measured is used to find the FileReporters.

        (   R@   t   measured_filesRr   t   listt   tupleR  Ri   (   RN   t   morfst   file_reportersR   R  (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyt   _get_file_reporters  s    c   	      C   sZ   |  j    |  j j d | d | d | d | d |  t |  |  j  } | j | d | S(   s  Write a summary report to `file`.

        Each module in `morfs` is listed, with counts of statements, executed
        statements, missing statements, and a list of lines missed.

        `include` is a list of file name patterns.  Files that match will be
        included in the report. Files matching `omit` will not be included in
        the report.

        If `skip_covered` is True, don't report on files with 100% coverage.

        Returns a float, the total percentage covered.

        t   ignore_errorsR*   R+   t   show_missingt   skip_coveredt   outfile(   R   R.   t	   from_argsR   t   report(	   RN   R!  R%  R$  t   fileR*   R+   R&  t   reporter(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR)    s    
c         C   sR   |  j    |  j j d | d | d |  t |  |  j  } | j | d | d S(   sz  Annotate a list of modules.

        Each module in `morfs` is annotated.  The source is written to a new
        file, named with a ",cover" suffix, with each line prefixed with a
        marker to indicate the coverage of the line.  Covered lines have ">",
        excluded lines have "-", and missing lines have "!".

        See :meth:`report` for other arguments.

        R$  R*   R+   R]   N(   R   R.   R(  R   R)  (   RN   R!  R]   R$  R*   R+   R+  (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyt   annotate  s
    
c	   
      C   s`   |  j    |  j j d | d | d | d | d | d | d |  t |  |  j  }	 |	 j |  S(   s  Generate an HTML report.

        The HTML is written to `directory`.  The file "index.html" is the
        overview starting point, with links to more detailed pages for
        individual modules.

        `extra_css` is a path to a file of other CSS to apply on the page.
        It will be copied into the HTML directory.

        `title` is a text string (not HTML) to use as the title of the HTML
        report.

        See :meth:`report` for other arguments.

        Returns a float, the total percentage covered.

        R$  R*   R+   t   html_dirt	   extra_csst
   html_titleR&  (   R   R.   R(  R   R)  (
   RN   R!  R]   R$  R*   R+   R.  t   titleR&  R+  (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyt   html_report#  s    
c      	   C   sa  |  j    |  j j d | d | d | d |  d
 } t } |  j j r |  j j d k re t j } q t j	 j
 |  j j  } | r t j	 j |  r t j |  n  i  }	 t j r d |	 d <n  t |  j j d |	  } | } n  zJ y) t |  |  j  }
 |
 j | d	 | SWn t k
 r+t }   n XWd
 | r\| j   | r\t |  j j  q\n  Xd
 S(   sb  Generate an XML report of coverage results.

        The report is compatible with Cobertura reports.

        Each module in `morfs` is included in the report.  `outfile` is the
        path to write the file to, "-" will write to stdout.

        See :meth:`report` for other arguments.

        Returns a float, the total percentage covered.

        R$  R*   R+   t
   xml_outputt   -t   utf8t   encodingt   wR'  N(   R   R.   R(  R/   RI   R2  Rc   t   stdoutR_   Rg   t   dirnameRh   t   makedirsR    t   PY3Rb   R    R)  R   R:   t   closeR   (   RN   R!  R'  R$  R*   R+   t   file_to_closet   delete_filet
   output_dirt   open_kwargsR+  (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyt
   xml_report@  s8    
		 
c   
      C   s  d d l  } |  j   g  } x@ |  j j D]2 } | j } | j sN | d 7} n  | j |  q) Wd | j f d | j f d |  j	 f d |  j
 f d |  j j   f d	 | f d
 |  j j f d |  j j f d |  j j f d t j j d d  f d t j   f d t j   f d t j f d t j   f d t j f d t d   t t j  D  f d d j t t d d g   f g } d d d d d d  g } xK | D]C } t |  |  } | r| j    }	 n d! }	 | j | |	 f  qW| S("   sA   Return a list of (key, value) pairs showing internal information.iNs    (disabled)t   versiont   coverageRE   RD   t   tracers   plugins.file_tracerst   config_filest   configs_readt	   data_pathR  s   
t    Rv   t   implementationt
   executablet   cwdRg   t   environmentc         s   s4   |  ]* \ } } | j  d  r d | | f Vq d S(   t   COVt   PYs   %s = %sN(   RL  RM  (   R   (   RY   t   kt   v(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pys	   <genexpr>  s   	t   command_linet    t   argvs   ???R4   R5   R8   R9   R7   R6   s   -none-(!   RB  R   RC   Rm   RX   Rq   Ri   t   __version__R\   RE   RD   RB   Rp   R.   t   attempted_config_filesRD  RA   R   Rc   RA  t   replaceRv   t   python_implementationRI  R_   t   getcwdRg   R   R   R`   Ro   R   R   (
   RN   t   covmodt
   ft_pluginst   ftt   ft_nameR   t   matcher_namest   matcher_namet   matchert   matcher_info(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR   s  sJ    
			'N(.   R   t
   __module__t   __doc__R/   RI   R:   RP   R   R   R}   R   R   R   Rj   Rk   Rl   R   R   R   R   R   R   R   R   R   R   Rf   R   R   R   R   R   R   R   R  R   R  R  R  R  R#  R)  R,  R1  R@  R   (    (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR"   >   sd   	r			(	l	*													
	%		 											1c         C   sL   |    } | | _  | | _ d | _ t | _ d | _ d | _ t | _ | S(   s6   Construct and initialize a new FileDisposition object.RG  N(	   R   R   R/   R   RI   R   R   R   R   (   t   clsR   R   (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR     s    								c         C   sS   |  j  r9 d |  j f } |  j rO | d |  j 7} qO n d |  j |  j f } | S(   s?   Make a nice debug message of what the FileDisposition is doing.s
   Tracing %rs   : will be traced by %rs   Not tracing %r: %s(   R   R   R   R   (   R   R   (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyR     s    		c          C   sp   t  j j d  }  |  s d St t d  r/ d St d |   } | t _ | j   t	 | _
 t	 | _ t | _ | S(   s  Call this at Python start-up to perhaps measure coverage.

    If the environment variable COVERAGE_PROCESS_START is defined, coverage
    measurement is started.  The value of the variable is the config file
    to use.

    There are two ways to configure your Python installation to invoke this
    function when Python starts:

    #. Create or append to sitecustomize.py to add these lines::

        import coverage
        coverage.process_startup()

    #. Create a .pth file in your Python installation containing::

        import coverage; coverage.process_startup()

    Returns the :class:`Coverage` instance that was started, or None if it was
    not started by this call.

    t   COVERAGE_PROCESS_STARTRB  R#   N(   R_   R`   Ra   R/   R{   t   process_startupR"   RB  R   RI   R;   R<   R:   R2   (   t   cpst   cov(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyRd    s    	
			c          C   s.   t  t d d  }  |  d k	 r* t |  _ n  d S(   s7   Stop any subprocess auto-measurement from writing data.RB  N(   R   Rd  R/   RI   R2   (   t   auto_created_coverage(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyRM     s    (G   Ra  Rt   Ru   R  R_   Rv   Rx   Rc   Rz   RB  R    t   coverage.annotateR   t   coverage.backwardR   R   t   coverage.collectorR   t   coverage.configR   t   coverage.dataR   R   t   coverage.debugR   R	   t   coverage.filesR
   R   R   R   R   R   R   R   R   t   coverage.htmlR   t   coverage.miscR   R   R   R   R   t   coverage.pluginR   t   coverage.plugin_supportR   t   coverage.pythonR   R   t   coverage.resultsR   R   t   coverage.summaryR   t   coverage.xmlreportR    t   coverage.multiprocR!   t   ImportErrorR/   Ry   Rw   t   PYPYt   objectR"   R   R   Rd  RM   (    (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/control.pyt   <module>   sh   

	    t			5