ó
…¾^Yc           @   sW  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	 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 m Z e e ƒ Z d e f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d „  Z d „  Z d „  Z e d k rSd d l Z e e j d ƒ n  d S(   s   Coverage data for coverage.py.iÿÿÿÿN(   t   env(   t   iitemst   string_class(   t   _TEST_NAME_FILE(   t   PathAliases(   t   CoverageExceptiont   file_be_gonet   isolate_modulet   CoverageDatac           B   s=  e  Z d  Z d  d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z e d	 „ Z d
 „  Z e Z d „  Z d „  Z d Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z d „  Z d „  Z d „  Z d „  Z d d „ Z d „  Z d „  Z d „  Z d  d „ Z d „  Z  d „  Z! d „  Z" d „  Z# d „  Z$ RS(!   sÜ
  Manages collected coverage data, including file storage.

    This class is the public supported API to the data coverage.py collects
    during program execution.  It includes information about what code was
    executed. It does not include information from the analysis phase, to
    determine what lines could have been executed, or what lines were not
    executed.

    .. note::

        The file format is not documented or guaranteed.  It will change in
        the future, in possibly complicated ways.  Do not read coverage.py
        data files directly.  Use this API to avoid disruption.

    There are a number of kinds of data that can be collected:

    * **lines**: the line numbers of source lines that were executed.
      These are always available.

    * **arcs**: pairs of source and destination line numbers for transitions
      between source lines.  These are only available if branch coverage was
      used.

    * **file tracer names**: the module names of the file tracer plugins that
      handled each file in the data.

    * **run information**: information about the program execution.  This is
      written during "coverage run", and then accumulated during "coverage
      combine".

    Lines, arcs, and file tracer names are stored for each source file. File
    names in this API are case-sensitive, even on platforms with
    case-insensitive file systems.

    To read a coverage.py data file, use :meth:`read_file`, or
    :meth:`read_fileobj` if you have an already-opened file.  You can then
    access the line, arc, or file tracer data with :meth:`lines`, :meth:`arcs`,
    or :meth:`file_tracer`.  Run information is available with
    :meth:`run_infos`.

    The :meth:`has_arcs` method indicates whether arc data is available.  You
    can get a list of the files in the data with :meth:`measured_files`.
    A summary of the line data is available from :meth:`line_counts`.  As with
    most Python containers, you can determine if there is any data at all by
    using this object as a boolean value.


    Most data files will be created by coverage.py itself, but you can use
    methods here to create data files if you like.  The :meth:`add_lines`,
    :meth:`add_arcs`, and :meth:`add_file_tracers` methods add data, in ways
    that are convenient for coverage.py.  The :meth:`add_run_info` method adds
    key-value pairs to the run information.

    To add a file without any measured data, use :meth:`touch_file`.

    You write to a named file with :meth:`write_file`, or to an already opened
    file with :meth:`write_fileobj`.

    You can clear the data in memory with :meth:`erase`.  Two data collections
    can be combined by using :meth:`update` on one :class:`CoverageData`,
    passing it the other.

    c         C   s1   | |  _  d |  _ d |  _ i  |  _ g  |  _ d S(   sh   Create a CoverageData.

        `debug` is a `DebugControl` object for writing debug messages.

        N(   t   _debugt   Nonet   _linest   _arcst   _file_tracerst   _runs(   t   selft   debug(    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt   __init__s   s
    				c         C   s    d j  d |  j j d |  j d  k r* d n d j  t |  j ƒ ƒ d |  j d  k rW d n d j  t |  j ƒ ƒ d d j  t |  j ƒ ƒ d d	 j  t |  j ƒ ƒ ƒ S(
   NsA   <{klass} lines={lines} arcs={arcs} tracers={tracers} runs={runs}>t   klasst   linesR
   s   {{{0}}}t   arcst   tracerst   runss   [{0}](	   t   formatt	   __class__t   __name__R   R
   t   lenR   R   R   (   R   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt   __repr__“   s    	--c         C   s
   |  j  ƒ  S(   sš   Does this data have arcs?

        Arc data is only available if branch coverage was used during
        collection.

        Returns a boolean.

        (   t	   _has_arcs(   R   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt   has_arcs    s    	c         C   s   |  j  d k	 r\ |  j  j | ƒ } | d k	 r{ t j j | ƒ } t t d „  | Dƒ ƒ ƒ Sn |  j d k	 r{ |  j j | ƒ Sd S(   sc  Get the list of lines executed for a file.

        If the file was not measured, returns None.  A file might be measured,
        and have no lines executed, in which case an empty list is returned.

        If the file was executed, returns a list of integers, the line numbers
        executed in the file. The list is in no particular order.

        c         s   s!   |  ] } | d  k r | Vq d S(   i    N(    (   t   .0t   l(    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pys	   <genexpr>¹   s    N(	   R   R
   t   gett	   itertoolst   chaint   from_iterablet   listt   setR   (   R   t   filenameR   t	   all_lines(    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyR   «   s    
c         C   s0   |  j  d k	 r, | |  j  k r, |  j  | Sn  d S(   sÆ  Get the list of arcs executed for a file.

        If the file was not measured, returns None.  A file might be measured,
        and have no arcs executed, in which case an empty list is returned.

        If the file was executed, returns a list of 2-tuples of integers. Each
        pair is a starting line number and an ending line number for a
        transition from one line to another. The list is in no particular
        order.

        Negative numbers have special meaning.  If the starting line number is
        -N, it represents an entry to the code object that starts at line N.
        If the ending ling number is -N, it's an exit from the code object that
        starts at line N.

        N(   R   R
   (   R   R&   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyR   ¾   s    c         C   s5   | |  j  p |  j p i  k r1 |  j j | d ƒ Sd S(   s  Get the plugin name of the file tracer for a file.

        Returns the name of the plugin that handles this file.  If the file was
        measured, but didn't use a plugin, then "" is returned.  If the file
        was not measured, then None is returned.

        t    N(   R   R   R   R    R
   (   R   R&   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt   file_tracerÔ   s    c         C   s   |  j  S(   së   Return the list of dicts of run information.

        For data collected during a single run, this will be a one-element
        list.  If data has been combined, there will be one element for each
        original data file.

        (   R   (   R   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt	   run_infosã   s    c         C   s   t  |  j p |  j p i  ƒ S(   s+   A list of all files that had been measured.(   R$   R   R   (   R   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt   measured_filesí   s    c         C   s^   i  } | r d „  } n t  j j } x3 |  j ƒ  D]% } t |  j | ƒ ƒ | | | ƒ <q1 W| S(   s\  Return a dict summarizing the line coverage data.

        Keys are based on the file names, and values are the number of executed
        lines.  If `fullpath` is true, then the keys are the full pathnames of
        the files, otherwise they are the basenames of the files.

        Returns a dict mapping file names to counts of lines.

        c         S   s   |  S(   N(    (   t   f(    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt   <lambda>ý   s    (   t   ost   patht   basenameR+   R   R   (   R   t   fullpatht   summt   filename_fnR&   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt   line_countsñ   s    
#c         C   s   t  |  j p |  j ƒ S(   N(   t   boolR   R   (   R   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt   __nonzero__  s    c         C   s¥   |  j  | ƒ } d |  _ |  _ d | k r; | d |  _ n  d | k rm t d „  t | d ƒ Dƒ ƒ |  _ n  | j d i  ƒ |  _ | j d g  ƒ |  _ |  j	 ƒ  d S(   sz   Read the coverage data from the given file object.

        Should only be used on an empty CoverageData object.

        R   R   c         s   s:   |  ]0 \ } } | g  | D] } t  | ƒ ^ q f Vq d  S(   N(   t   tuple(   R   t   fnameR   t   pair(    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pys	   <genexpr>  s   t   file_tracersR   N(
   t   _read_raw_dataR
   R   R   t   dictR   R    R   R   t	   _validate(   R   t   file_objt   data(    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt   read_fileobj	  s    c         C   s—   |  j  r5 |  j  j d ƒ r5 |  j  j d | f ƒ n  y) |  j | ƒ  } |  j | ƒ Wd QXWn2 t k
 r’ } t d | | j j | f ƒ ‚ n Xd S(   s8   Read the coverage data from `filename` into this object.t   dataios   Reading data from %rNs$   Couldn't read data from '%s': %s: %s(	   R	   t   shouldt   writet   _open_for_readingR@   t	   ExceptionR   R   R   (   R   R&   R,   t   exc(    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt	   read_file  s    s?   !coverage.py: This is a private format, don't read it directly!c         C   s   t  | d ƒ S(   s+   Open a file appropriately for reading data.t   r(   t   open(   t   clsR&   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyRD   /  s    c         C   sC   | j  t |  j ƒ ƒ } | |  j k r6 t d ƒ ‚ n  t j | ƒ S(   s%   Read the raw data from a file object.s*   Doesn't seem to be a coverage.py data file(   t   readR   t   _GO_AWAYR   t   jsont   load(   RJ   R>   t   go_away(    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyR;   4  s    c         C   s)   |  j  | ƒ  } |  j | ƒ SWd QXd S(   s-   Read the raw data from a file, for debugging.N(   RD   R;   (   RJ   R&   R,   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt   _read_raw_data_file<  s    c         C   s   |  j  rT |  j  j d ƒ rT |  j  j d t | ƒ t d „  | j ƒ  Dƒ ƒ f ƒ n  |  j ƒ  ro t d ƒ ‚ n  |  j d k rŠ i  |  _ n  xe t
 | ƒ D]W \ } } | |  j k rÛ t |  j | ƒ } | j | ƒ | } n  t | ƒ |  j | <q— W|  j ƒ  d S(   s    Add measured line data.

        `line_data` is a dictionary mapping file names to dictionaries::

            { filename: { lineno: None, ... }, ...}

        t   dataops&   Adding lines: %d files, %d lines totalc         s   s   |  ] } t  | ƒ Vq d  S(   N(   R   (   R   R   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pys	   <genexpr>P  s    s$   Can't add lines to existing arc dataN(   R	   RB   RC   R   t   sumt   valuesR   R   R   R
   R   R%   t   updateR$   R=   (   R   t	   line_dataR&   t   linenost   new_linenos(    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt	   add_linesF  s    -	c         C   s   |  j  rT |  j  j d ƒ rT |  j  j d t | ƒ t d „  | j ƒ  Dƒ ƒ f ƒ n  |  j ƒ  ro t d ƒ ‚ n  |  j d k rŠ i  |  _ n  xe t
 | ƒ D]W \ } } | |  j k rÛ t |  j | ƒ } | j | ƒ | } n  t | ƒ |  j | <q— W|  j ƒ  d S(   sŸ   Add measured arc data.

        `arc_data` is a dictionary mapping file names to dictionaries::

            { filename: { (l1,l2): None, ... }, ...}

        RQ   s$   Adding arcs: %d files, %d arcs totalc         s   s   |  ] } t  | ƒ Vq d  S(   N(   R   (   R   R   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pys	   <genexpr>j  s    s$   Can't add arcs to existing line dataN(   R	   RB   RC   R   RR   RS   t
   _has_linesR   R   R
   R   R%   RT   R$   R=   (   R   t   arc_dataR&   R   t   new_arcs(    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt   add_arcs`  s    -	c         C   só   |  j  r; |  j  j d ƒ r; |  j  j d t | ƒ f ƒ n  |  j pP |  j pP i  } x t | ƒ D] \ } } | | k rŽ t d | f ƒ ‚ n  |  j j	 | ƒ } | d k	 rÔ | | k rÔ t d | | | f ƒ ‚ n  | |  j | <q` W|  j ƒ  d S(   sd   Add per-file plugin information.

        `file_tracers` is { filename: plugin_name, ... }

        RQ   s   Adding file tracers: %d filess3   Can't add file tracer data for unmeasured file '%s's/   Conflicting file tracer name for '%s': %r vs %rN(   R	   RB   RC   R   R   R   R   R   R   R    R
   R=   (   R   R:   t   existing_filesR&   t   plugin_namet   existing_plugin(    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt   add_file_tracersz  s     c         K   so   |  j  r5 |  j  j d ƒ r5 |  j  j d | f ƒ n  |  j sM i  g |  _ n  |  j d j | ƒ |  j ƒ  d S(   sø   Add information about the run.

        Keywords are arbitrary, and are stored in the run dictionary. Values
        must be JSON serializable.  You may use this function more than once,
        but repeated keywords overwrite each other.

        RQ   s   Adding run info: %ri    N(   R	   RB   RC   R   RT   R=   (   R   t   kwargs(    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt   add_run_info”  s    	R(   c         C   s³   |  j  r5 |  j  j d ƒ r5 |  j  j d | f ƒ n  |  j ƒ  r^ |  j ƒ  r^ t d ƒ ‚ n  |  j ƒ  rv |  j } n	 |  j } | j | g  ƒ | r¥ | |  j	 | <n  |  j
 ƒ  d S(   sÍ   Ensure that `filename` appears in the data, empty if needed.

        `plugin_name` is the name of the plugin resposible for this file. It is used
        to associate the right filereporter, etc.
        RQ   s   Touching %rs*   Can't touch files in an empty CoverageDataN(   R	   RB   RC   R   RY   R   R   R   t
   setdefaultR   R=   (   R   R&   R^   t   where(    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt
   touch_file£  s    	c         C   sš   i  } |  j  ƒ  r" |  j | d <n  |  j ƒ  r> |  j | d <n  |  j rW |  j | d <n  |  j rp |  j | d <n  | j |  j ƒ t j	 | | d d	 ƒd S(
   s&   Write the coverage data to `file_obj`.R   R   R:   R   t
   separatorst   ,t   :N(   Rg   Rh   (
   R   R   RY   R   R   R   RC   RL   RM   t   dump(   R   R>   t	   file_data(    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt   write_fileobj¹  s    		c         C   s^   |  j  r5 |  j  j d ƒ r5 |  j  j d | f ƒ n  t | d ƒ  } |  j | ƒ Wd QXd S(   s&   Write the coverage data to `filename`.RA   s   Writing data to %rt   wN(   R	   RB   RC   RI   Rk   (   R   R&   t   fdata(    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt
   write_fileÏ  s    c         C   s2   d |  _ d |  _ i  |  _ g  |  _ |  j ƒ  d S(   s   Erase the data in this object.N(   R
   R   R   R   R   R=   (   R   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt   eraseÖ  s
    				c   
      C   sW  |  j  ƒ  r' | j ƒ  r' t d ƒ ‚ n  |  j ƒ  rN | j  ƒ  rN t d ƒ ‚ n  | pZ t ƒ  } xŽ | j ƒ  D]€ } | j | ƒ } | j | ƒ } |  j | ƒ } | d k rÂ | rê | |  j | <qê qj | | k rj t d | | | f ƒ ‚ qj qj W|  j	 j
 | j	 ƒ | j  ƒ  r¥|  j d k r(i  |  _ n  xz t | j ƒ D]f \ } } | j | ƒ } | |  j k r‘t |  j | ƒ } | j | ƒ t | ƒ } n  | |  j | <q8Wn  | j ƒ  rI|  j d k rÌi  |  _ n  xz t | j ƒ D]f \ } } | j | ƒ } | |  j k r5t |  j | ƒ }	 |	 j | ƒ t |	 ƒ } n  | |  j | <qÜWn  |  j ƒ  d S(   sÃ   Update this data with data from another `CoverageData`.

        If `aliases` is provided, it's a `PathAliases` object that is used to
        re-map paths to match the local machine's.

        s%   Can't combine arc data with line datas%   Can't combine line data with arc datas/   Conflicting file tracer name for '%s': %r vs %rN(   RY   R   R   R   R+   R)   t   mapR
   R   R   t   extendR   R   R%   RT   R$   R   R=   (
   R   t
   other_datat   aliasesR&   t   other_plugint   this_plugint
   file_linesR   t	   file_arcsR   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyRT   Þ  sL    c         C   s   t  j r |  j ƒ  n  d S(   s>   If we are in paranoid mode, validate that everything is right.N(   R    t   TESTINGt   _validate_invariants(   R   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyR=     s    	c         C   sì  |  j  ƒ  o |  j ƒ  s% t d ƒ ‚ |  j  ƒ  r¢ xn t |  j ƒ D]Z \ } } t | t ƒ so t d | f ƒ ‚ t d „  | Dƒ ƒ sA t d | | f ƒ ‚ qA Wn  |  j ƒ  rxn t |  j ƒ D]Z \ } } t | t ƒ sì t d | f ƒ ‚ t d „  | Dƒ ƒ s¾ t d | | f ƒ ‚ q¾ Wn  xj t |  j	 ƒ D]Y \ } } t | t ƒ s]t d | f ƒ ‚ | rrt | t ƒ s/t d	 | | f ƒ ‚ q/WxY |  j
 D]N } t | t ƒ s±t ‚ x0 | D]( } t | t ƒ s¸t d
 | f ƒ ‚ q¸Wq–Wd S(   s   Validate internal invariants.s$   Shouldn't have both _lines and _arcss   Key in _lines shouldn't be %rc         s   s   |  ] } t  | t ƒ Vq d  S(   N(   t
   isinstancet   int(   R   t   x(    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pys	   <genexpr>.  s    s   _lines[%r] shouldn't be %rs   Key in _arcs shouldn't be %rc         s   s3   |  ]) \ } } t  | t ƒ o* t  | t ƒ Vq d  S(   N(   Rz   R{   (   R   R|   t   y(    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pys	   <genexpr>6  s    s   _arcs[%r] shouldn't be %rs$   Key in _file_tracers shouldn't be %rs    _file_tracers[%r] shoudn't be %rs   Key in _runs shouldn't be %rN(   RY   R   t   AssertionErrorR   R   Rz   R   t   allR   R   R   R<   (   R   R8   R   R   t   plugint   valt   key(    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyRy   #  s*    	""c         C   sm   |  j  ƒ  r1 | j t |  j | ƒ p' g  ƒ ƒ n" | j t |  j | ƒ pL g  ƒ ƒ | j |  j | ƒ ƒ d S(   sÚ   Contribute `filename`'s data to the `hasher`.

        `hasher` is a `coverage.misc.Hasher` instance to be updated with
        the file's data.  It should only get the results data, not the run
        data.

        N(   R   RT   t   sortedR   R   R)   (   R   R&   t   hasher(    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt   add_to_hashI  s    %"c         C   s   |  j  d k	 S(   s   Do we have data in self._lines?N(   R   R
   (   R   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyRY   [  s    c         C   s   |  j  d k	 S(   s   Do we have data in self._arcs?N(   R   R
   (   R   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyR   _  s    N(%   R   t
   __module__t   __doc__R
   R   R   R   R   R   R)   R*   R+   t   FalseR4   R6   t   __bool__R@   RG   RL   t   classmethodRD   R;   RP   RX   R\   R`   Rb   Re   Rk   Rn   Ro   RT   R=   Ry   R…   RY   R   (    (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyR      s@   ? 						
				
							@		&		t   CoverageDataFilesc           B   sS   e  Z d  Z d d d d „ Z e d „ Z d „  Z d d „ Z d d e d „ Z	 RS(   s&   Manage the use of coverage data files.c         C   s1   | |  _  | |  _ t j j | p$ d ƒ |  _ d S(   s÷   Create a CoverageDataFiles to manage data files.

        `warn` is the warning function to use.

        `basename` is the name of the file to use for storing data.

        `debug` is a `DebugControl` object for writing debug messages.

        s	   .coverageN(   t   warnR   R.   R/   t   abspathR&   (   R   R0   RŒ   R   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyR   g  s    
		c         C   sñ   |  j  r8 |  j  j d ƒ r8 |  j  j d |  j f ƒ n  t |  j ƒ | rí t j j |  j ƒ \ } } | d } t j j t j j	 | ƒ | ƒ } xY t
 j
 | ƒ D]E } |  j  rÜ |  j  j d ƒ rÜ |  j  j d | f ƒ n  t | ƒ q¡ Wn  d S(   s    Erase the data from the file storage.

        If `parallel` is true, then also deletes data files created from the
        basename by parallel-mode.

        RA   s   Erasing data file %rs   .*s   Erasing parallel data file %rN(   R   RB   RC   R&   R   R.   R/   t   splitt   joinR   t   glob(   R   t   parallelt   data_dirt   localt   localdott   patternR&   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyRo   w  s    
!c         C   s,   t  j j |  j ƒ r( | j |  j ƒ n  d S(   s   Read the coverage data.N(   R.   R/   t   existsR&   RG   (   R   R?   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyRK   Š  s    c         C   sÀ   |  j  } | t k r˜ d } t rO t t ƒ  } | j ƒ  } Wd QXd | } n  t j t j d ƒ ƒ j	 d d ƒ } d t
 j ƒ  | t j ƒ  | f } n  | r¯ | d | 7} n  | j | ƒ d S(   s7  Write the collected coverage data to a file.

        `suffix` is a suffix to append to the base file name. This can be used
        for multiple or parallel execution, so that many coverage data files
        can exist simultaneously.  A dot will be used to join the base name and
        the suffix.

        R(   Nt   .i   i    i?B s   %s%s.%s.%06d(   R&   t   TrueR   RI   RK   t   randomt   RandomR.   t   urandomt   randintt   sockett   gethostnamet   getpidRn   (   R   R?   t   suffixR&   t   extraR,   t	   test_namet   dice(    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyRC     s    		$%c         C   s³  t  j j |  j ƒ \ } } | d } | p1 | g } g  } x› | D]“ }	 t  j j |	 ƒ ru | j t  j j |	 ƒ ƒ qA t  j j |	 ƒ rÁ t  j j t  j j |	 ƒ | ƒ }
 | j	 t
 j
 |
 ƒ ƒ qA t d |	 f ƒ ‚ qA W| rô | rô t d ƒ ‚ n  x¸ | D]° } t d |  j ƒ } y | j | ƒ Wn2 t k
 rX} |  j r«|  j t | ƒ ƒ q«qû X| j | d | ƒ|  j r¡|  j j d ƒ r¡|  j j d | f ƒ n  t | ƒ qû Wd S(	   s¿  Combine a number of data files together.

        Treat `self.filename` as a file prefix, and combine the data from all
        of the data files starting with that prefix plus a dot.

        If `aliases` is provided, it's a `PathAliases` object that is used to
        re-map paths to match the local machine's.

        If `data_paths` is provided, it is a list of directories or files to
        combine.  Directories are searched for files that start with
        `self.filename` plus dot as a prefix, and those files are combined.

        If `data_paths` is not provided, then the directory portion of
        `self.filename` is used as the directory to search for data files.

        Every data file found and combined is then deleted from disk. If a file
        cannot be read, a warning will be issued, and the file will not be
        deleted.

        If `strict` is true, and no files are found to combine, an error is
        raised.

        s   .*s,   Couldn't combine from non-existent path '%s's   No data to combineR   Rs   RA   s   Deleting combined data file %rN(   R.   R/   RŽ   R&   t   isfilet   appendR   t   isdirR   Rq   R   R   R   R   RG   RŒ   t   strRT   RB   RC   R   (   R   R?   Rs   t
   data_pathst   strictR’   R“   R”   t   files_to_combinet   pR•   R,   t   new_dataRF   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt   combine_parallel_dataª  s0    
!	N(
   R   R†   R‡   R
   R   Rˆ   Ro   RK   RC   R­   (    (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyR‹   d  s   	c         C   s~   x: t  |  j d i  ƒ ƒ D]  \ } } t | ƒ |  d | <q Wx: t  |  j d i  ƒ ƒ D]  \ } } t | ƒ |  d | <qV Wd S(   s1   Canonicalize our JSON data so it can be compared.R   R   N(   R   R    Rƒ   (   R?   R8   R   R   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt   canonicalize_json_dataå  s    %%c         C   sI   t  j |  d d d t ƒ} t j d d | ƒ } t j d d | ƒ } | S(   sL   Format data as JSON, but as nicely as possible.

    Returns a string.

    t   indenti   t	   sort_keyss   \[\s+(-?\d+),\s+(-?\d+)\s+]s   [\1, \2]s   (?m)\s+$R(   (   RM   t   dumpsR˜   t   ret   sub(   R?   t   out(    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt   pretty_dataí  s    c         C   s™   t  j ƒ  } | j d d d d d d ƒ| j |  ƒ \ } }  xU |  pL d g D]D } d j | ƒ GHt j | ƒ } | j r† t | ƒ n  t	 | ƒ GHqM Wd	 S(
   se   Dump the raw data from data files.

    Run this as::

        $ python -m coverage.data [FILE]

    s   -cs   --canonicalt   actiont
   store_truet   helps    Sort data into a canonical orders	   .coverages&   --- {0} ------------------------------N(
   t   optparset   OptionParsert
   add_optiont
   parse_argsR   R   RP   t	   canonicalR®   Rµ   (   t   argst   parsert   optionsR&   R?   (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt
   debug_mainü  s    	t   __main__i   (    R‡   R   R!   RM   R¹   R.   t   os.pathR™   R²   R   t   coverageR    t   coverage.backwardR   R   t   coverage.debugR   t   coverage.filesR   t   coverage.miscR   R   R   t   objectR   R‹   R®   Rµ   RÁ   R   t   syst   argv(    (    (    s/   /tmp/pip-build-hU8Cw8/coverage/coverage/data.pyt   <module>   s2   ÿ ÿ M			