ó
…¾^Yc           @  s‘  d  Z  d d l m 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 m Z d d l m Z m Z m Z d d	 l m Z d
 e f d „  ƒ  YZ d e j e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ e j  e j! e j" g Z# i	 e d e j$ e j% e j& e j' g e# d d d d ƒd 6e d e j( g e# d d d d ƒd 6e d e# d d d d ƒd 6e d e# d d ƒd 6e d e# d d  d d! ƒd 6e d" e j$ e j) e j% e j& e j' e j* e j+ g e# d d d d# ƒd" 6e d$ e j) e j% e j& e j' e j, e j+ g e# d d d d% ƒd$ 6e d& e j( e j- e j. e j& e j/ e j' e j0 e j1 e j2 e j3 g
 e# d d' d d( ƒd& 6e d) e j) e j% e j& e j' e j4 g e# d d d d* ƒd) 6Z5 d+ d, d- f \ Z6 Z7 Z8 d. e f d/ „  ƒ  YZ9 d0 „  Z: d1 „  Z; i d2 d 6d3 d4 6d5 d6 6Z< e= d7 „ Z> d S(8   s%   Command-line support for coverage.py.iÿÿÿÿ(   t   print_functionN(   t   env(   t   CTracer(   t   info_formattert   info_header(   t   run_python_filet   run_python_module(   t   BaseCoverageExceptiont   ExceptionDuringRunt   NoSource(   t   should_fail_undert   Optsc           B  së  e  Z d  Z e j d d d d d d ƒZ e j d d d d d d	 ƒZ d
 d d d d g Z e j d d d d d d d e d d d j e ƒ ƒZ	 e j d d d d d d d d ƒZ
 e j d d d d d d d d ƒZ e j d d d d d d d d  d d! ƒZ e j d" d# d d d d$ ƒZ e j d% d& d d d d' ƒZ e j d d( d d d d) d d* ƒZ e j d+ d, d d d d- ƒZ e j d. d/ d d d d0 ƒZ e j d1 d d d d2 ƒZ e j d d3 d d d d) d d4 ƒZ e j d5 d d d d6 d7 d d8 d d9 ƒZ e j d: d; d d d d< ƒZ e j d. d= d d d d> ƒZ e j d d? d d d d@ ƒZ e j d dA d d d dB d dC ƒZ e j d dD d d d dE ƒZ e j d dF d d d dG d dH ƒZ e j d dI d d d dJ ƒZ RS(K   sB   A namespace class for individual options we'll build parsers from.s   -as   --appendt   actiont
   store_truet   helpsG   Append coverage data to .coverage, otherwise it starts clean each time.t    s   --branchs:   Measure branch coverage in addition to statement coverage.t   threadt   geventt   greenlett   eventlett   multiprocessings   --concurrencyt   storet   metavart   LIBt   choicessH   Properly measure code using a concurrency library. Valid values are: %s.s   , s   --debugt   OPTSs"   Debug options, separated by commass   -ds   --directoryt   DIRs   Write the output files to DIR.s   --fail-undert   MINt   typet   ints?   Exit with a status of 2 if the total coverage is less than MIN.s   -hs   --helps   Get help on this command.s   -is   --ignore-errorss)   Ignore errors while reading source files.s	   --includes   PAT1,PAT2,...sp   Include only files whose paths match one of these patterns. Accepts shell-style wildcards, which must be quoted.s   -Ls   --pylibsW   Measure coverage even inside the Python installed library, which isn't done by default.s   -ms   --show-missingsE   Show line numbers of statements in each module that weren't executed.s   --skip-covereds   Skip files with 100% coverage.s   --omitsh   Omit files whose paths match one of these patterns. Accepts shell-style wildcards, which must be quoted.s   -ot   destt   outfilet   OUTFILEs=   Write the XML report to this file. Defaults to 'coverage.xml's   -ps   --parallel-modes†   Append the machine name, process id and random number to the .coverage data file name to simplify collecting data from many processes.s   --modulesb   <pyfile> is an importable Python module, not a script path, to be run as 'python -m' would run it.s   --rcfiles6   Specify configuration file.  Defaults to '.coveragerc's   --sources   SRC1,SRC2,...s9   A list of packages or directories of code to be measured.s   --timidsY   Use a simpler but slower trace method.  Try this if you get seemingly impossible results!s   --titlet   TITLEs.   A text string to use as the title on the HTML.s	   --versions%   Display version information and exit.(   t   __name__t
   __module__t   __doc__t   optparset   make_optiont   appendt   brancht   CONCURRENCY_CHOICESt   joint   concurrencyt   debugt	   directoryt
   fail_underR   t   ignore_errorst   includet   pylibt   show_missingt   skip_coveredt   omitt
   output_xmlt   parallel_modet   modulet   rcfilet   sourcet   timidt   titlet   version(    (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyR      sŒ   																			t   CoverageOptionParserc           B  sW   e  Z d  Z d „  Z d d d d „ Z d e f d „  ƒ  YZ d d d „ Z d „  Z	 RS(   s|   Base OptionParser for coverage.py.

    Problems don't exit the program.
    Defaults are initialized for all options.

    c      +   O  sÁ   t  t |  ƒ j d t | | Ž |  j d d  d d  d d  d d  d d  d d  d d  d	 d  d
 d  d d  d d  d d  d d  d d  d t d d  d d  d d  d d  d d  d d  ƒ |  j ƒ  |  j |  _	 d  S(   Nt   add_help_optionR   R'   R(   R+   R,   R-   R.   R   R/   R0   R7   R4   R6   R1   R8   R2   R3   R9   R:   R;   R<   (
   t   superR=   t   __init__t   Falset   set_defaultst   Nonet   Truet   disable_interspersed_argst	   help_noopt   help_fn(   t   selft   argst   kwargs(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyR@   •   s4    	
c         C  s   d S(   s   No-op help function.N(    (   RH   t   errort   topict   parser(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyRF   ´   s    t   OptionParserErrorc           B  s   e  Z d  Z RS(   s;   Used to stop the optparse error handler ending the process.(   R"   R#   R$   (    (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyRN   ¸   s   c         C  sS   y% t  t |  ƒ j | | ƒ \ } } Wn |  j k
 rE t d d f SXt | | f S(   sU   Call optparse.parse_args, but return a triple:

        (ok, options, args)

        N(   R?   R=   t
   parse_argsRN   RA   RC   RD   (   RH   RI   t   options(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyt   parse_args_ok¼   s
    %c         C  s   |  j  | ƒ |  j ‚ d S(   s7   Override optparse.error so sys.exit doesn't get called.N(   RG   RN   (   RH   t   msg(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyRK   É   s    N(
   R"   R#   R$   R@   RC   RF   t	   ExceptionRN   RQ   RK   (    (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyR=      s   	t   GlobalOptionParserc           B  s   e  Z d  Z d „  Z RS(   s<   Command-line parser for coverage.py global option arguments.c         C  s0   t  t |  ƒ j ƒ  |  j t j t j g ƒ d  S(   N(   R?   RT   R@   t   add_optionsR   R   R<   (   RH   (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyR@   Ò   s    (   R"   R#   R$   R@   (    (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyRT   Ï   s   t   CmdOptionParserc           B  s8   e  Z d  Z d d d d „ Z d „  Z d Z d „  Z RS(   s4   Parse one of the new-style commands for coverage.py.c         C  se   | r d | } n  t  t |  ƒ j d | d | ƒ |  j d | | pG i   |  j | ƒ | |  _ d S(   so  Create an OptionParser for a coverage.py command.

        `action` is the slug to put into `options.action`.
        `options` is a list of Option's for the command.
        `defaults` is a dict of default value for options.
        `usage` is the usage string to display in help.
        `description` is the description of the command, for the help text.

        s   %prog t   usaget   descriptionR   N(   R?   RV   R@   RB   RU   t   cmd(   RH   R   RP   t   defaultsRW   RX   (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyR@   Þ   s    
c         C  s   | d |  j  k S(   Ns   <CmdOptionParser:%s>(   RY   (   RH   t   other(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyt   __eq__ò   s    c         C  s.   t  t |  ƒ j ƒ  } d j d | d |  j ƒ S(   s>   Override of an undocumented function in optparse.OptionParser.s   {command} {subcommand}t   commandt
   subcommand(   R?   RV   t   get_prog_namet   formatRY   (   RH   t   program_name(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyR_   ù   s    N(   R"   R#   R$   RC   R@   R\   t   __hash__R_   (    (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyRV   Û   s
   	t   annotateRW   s   [options] [modules]RX   s|   Make annotated copies of the given files, marking statements that are executed with > and statements that are missed with !.t   combines%   [options] <path1> <path2> ... <pathN>s?  Combine data from multiple coverage files collected with 'run -p'.  The combined results are written to a single file representing the union of the data. The positional arguments are data files or directories containing data files. If no paths are provided, data files in the default data file's directory are combined.R,   s   <topic>s³   Display information on the internals of coverage.py, for diagnosing problems. Topics are 'data' to show a summary of the collected data, or 'sys' to show installation information.t   erases)   Erase previously collected coverage data.R   s	   [command]s   Describe how to use coverage.pyt   htmls™   Create an HTML report of the coverage of the files.  Each file gets its own page, with the source decorated to show executed, excluded, and missed lines.t   reports&   Report coverage statistics on modules.t   runs$   [options] <pyfile> [program options]s/   Run a Python program, measuring code execution.t   xmls+   Generate an XML report of coverage results.i    i   i   t   CoverageScriptc           B  s\   e  Z d  Z d d d d d d „ Z d „  Z d d d d „ Z d „  Z d „  Z d „  Z	 RS(   s*   The command-line interface to coverage.py.c         C  s÷   | r | |  _  n d d  l } | |  _  | p0 t |  _ | p? t |  _ | pQ |  j |  _ | pf t j j |  _	 t
 |  _ d  |  _ t j j t j d ƒ |  _ |  j d k rµ d |  _ n  t j ró d } |  j j | ƒ ró |  j t | ƒ  |  _ qó n  d  S(   Niÿÿÿÿi    s   __main__.pyt   coverages
   -script.py(   t   covpkgRk   R   R   R   RG   t   ost   patht   existst   path_existsRA   t   global_optionRC   t   basenamet   syst   argvRa   R   t   WINDOWSt   endswitht   len(   RH   t   _covpkgt   _run_python_filet   _run_python_modulet   _help_fnt   _path_existsRk   t   auto_suffix(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyR@   …  s"    				c         C  s—  | s |  j  d d ƒ t S| d j d ƒ |  _ |  j rE t ƒ  } n< t j | d ƒ } | sw |  j  d | d ƒ t S| d } |  j  | _  | j | ƒ \ } } } | s¯ t S|  j	 | | | ƒ rÈ t Sd t
 j d <t | j ƒ } t | j ƒ } t | j ƒ } t | j ƒ }	 |  j j d | j d	 | j d
 | j d | j d | j d | d | d | d |	 d | j ƒ 
|  _ | j d k r|  j | ƒ S| j d k r­|  j j ƒ  t S| j d k rÌ|  j | | ƒ S| j d k r'| j rô|  j j ƒ  n  | pýd" }
 |  j j! |
 d t" ƒ|  j j# ƒ  t St$ d t% | ƒ d | j& d | d | ƒ } |  j j ƒ  d" } | j d k rš|  j j' d | j( d | j) |  } n | j d k rÅ|  j j* d | j+ |  nr | j d k r|  j j, d | j+ d | j- d | j) |  } n3 | j d k r7| j. } |  j j/ d  | |  } n  | d" k	 r“| j0 d" k	 rk|  j j1 d! | j0 ƒ n  |  j j2 d! ƒ } t3 | | ƒ r“t4 Sn  t S(#   s¯   The bulk of the command line interface to coverage.py.

        `argv` is the argument list to process.

        Returns 0 if all is well, 1 if something went wrong.

        RL   t   minimum_helpi    t   -s   Unknown command: '%s'i   R   t   data_suffixt   cover_pylibR:   R(   t   config_fileR9   R4   R0   R,   R+   Re   Rh   Rd   t   strictt   morfsR/   Rg   R2   R3   Rc   R-   Rf   R;   Ri   R   s   report:fail_underN(5   RG   t   OKt
   startswithRq   RT   t   CMDSt   gett   ERRRQ   t   do_helpRs   Rn   t   unshell_listR9   R4   R0   R,   Rl   t   CoverageR6   R1   R:   R(   R8   R+   Rk   R   t   do_debugRe   t   do_runR'   t   loadRC   Rd   RD   t   savet   dictt   unglob_argsR/   Rg   R2   R3   Rc   R-   t   html_reportR;   R   t
   xml_reportR.   t
   set_optiont
   get_optionR
   t
   FAIL_UNDER(   RH   Rt   RM   t   okRP   RI   R9   R4   R0   R,   t	   data_dirst   report_argst   totalR   R.   (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyt   command_line¤  s–    		
										c         C  s  | s | s | s t  ‚ | rQ t | d t j ƒt d |  j f d t j ƒn¬ | rp t | j ƒ  j ƒ  ƒ n t |  j j	 ƒ } |  j | d <t
 d	 k	 r¨ d | d <n
 d | d <t j t j | d ƒ ƒ j ƒ  } | rï t | j |   ƒ n t d | ƒ d	 S(
   s-   Display an error message, or the named topic.t   files   Use '%s help' for help.Ra   s   with C extensiont   extension_modifiers   without C extensionR   s   Don't know topic %rN(   t   AssertionErrort   printRs   t   stderrRa   t   format_helpt   stripR‘   Rl   t   __dict__R   RC   t   textwrapt   dedentt   HELP_TOPICSRˆ   R`   (   RH   RK   RL   RM   t   help_paramst   help_msg(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyR     s     
!c         C  sÏ   | j  r9 |  j r% |  j d d ƒ n |  j d | ƒ t S| j d k r® | rš xY | D]> } t j | ƒ } | rƒ |  j d | ƒ qU |  j d | ƒ qU Wn |  j d d ƒ t S| j rË |  j d d ƒ t St S(   s`   Deal with help requests.

        Return True if it handled the request, False if not.

        RL   R   RM   R<   (	   R   Rq   RG   RD   R   R‡   Rˆ   R<   RA   (   RH   RP   RI   RM   t   a(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyRŠ   +  s$    			c         C  s¯  | s |  j  d ƒ t S| j rC |  j j d ƒ rC |  j  d ƒ t S| j d k rž xI d d d d d	 d
 g D], } t | | ƒ d k	 rk |  j  d ƒ t Sqk Wn  |  j j d ƒ sÌ | j sÌ |  j j ƒ  qÌ n  |  j j	 ƒ  t
 } z_ y> | j r|  j | d | ƒ n | d } |  j | | ƒ Wn t k
 r<t } ‚  n XWd |  j j ƒ  | rª| j rš|  j j d ƒ } |  j | ƒ rš|  j j d | g ƒ qšn  |  j j ƒ  n  Xt S(   s!   Implementation of 'coverage run'.s   Nothing to do.s   run:parallels,   Can't append to data files in parallel mode.R   R(   R0   R4   R1   R9   R:   sL   Options affecting multiprocessing must be specified in a configuration file.i    Ns   run:data_filet
   data_paths(   RG   R‰   R'   Rk   R–   R+   t   getattrRC   Re   t   startRD   R7   R   R   R	   RA   t   stopRp   Rd   R   R…   (   RH   RP   RI   t   opt_namet   code_rant   filenamet	   data_file(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyRŽ   L  sD    	 	
	c         C  sð  | s |  j  d ƒ t SxÒ| D]Ê} | d k rw |  j j ƒ  } t t d ƒ ƒ x–t | ƒ D] } t d | ƒ q\ Wq | d k rz|  j j ƒ  |  j j } t t d ƒ ƒ t d |  j j	 j
 ƒ | rmt d | j ƒ  ƒ | j d t ƒ } t | j ƒ  ƒ } t d t | ƒ ƒ x_ | D]J } d	 | | | f } | j | ƒ }	 |	 r\| d
 |	 7} n  t | ƒ qWqèt d ƒ q | d k rÓt t d ƒ ƒ |  j j j j ƒ  }
 x: t |
 ƒ D] } t d | ƒ q¸Wq |  j  d | ƒ t Sq Wt S(   s#   Implementation of 'coverage debug'.s3   What information would you like: config, data, sys?Rs   s    %st   datas   path: %ss   has_arcs: %rt   fullpaths
   
%d files:s   %s: %d liness    [%s]s   No data collectedt   configs   Don't know what you mean by %r(   RG   R‰   Rk   t   sys_infoR    R   R   R   R³   t
   data_filesR±   t   has_arcst   line_countsRD   t   sortedt   keysRw   t   file_tracerRµ   R¤   t   itemsR…   (   RH   RI   t   infoR¶   t   lineR³   t   summaryt	   filenamest   ft   plugint   config_info(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyR     sD    N(
   R"   R#   R$   RC   R@   Rœ   R   RŠ   RŽ   R   (    (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyRj   ‚  s   	r	!	3c         C  s2   |  s
 d St j r% |  j d ƒ }  n  |  j d ƒ S(   s)   Turn a command-line argument into a list.t   't   ,N(   RC   R   Ru   R£   t   split(   t   s(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyR‹   ª  s
    	c         C  sk   t  j rg g  } xL |  D]D } d | k s4 d | k rM | j t j | ƒ ƒ q | j | ƒ q W| }  n  |  S(   s5   Interpret shell wildcards for platforms that need it.t   ?t   *(   R   Ru   t   extendt   globR'   (   RI   t   globbedt   arg(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyR’   ¸  s    		sG          Coverage.py, version {__version__} {extension_modifier}
        Measure, collect, and report on code coverage in Python programs.

        usage: {program_name} <command> [options] [args]

        Commands:
            annotate    Annotate source files with execution information.
            combine     Combine a number of data files.
            erase       Erase previously collected coverage data.
            help        Get help on using coverage.py.
            html        Create an HTML report.
            report      Report coverage stats on modules.
            run         Run a Python program and measure code execution.
            xml         Create an XML report of coverage results.

        Use "{program_name} help <command>" for detailed help on any command.
        For full documentation, see {__url__}
    sK           Code coverage for Python.  Use '{program_name} help' for help.
    R~   sg           Coverage.py, version {__version__} {extension_modifier}
        Documentation at {__url__}
    R<   c         C  sµ   |  d k r t j d }  n  y t ƒ  j |  ƒ } Wn| t k
 r] } t j | j Œ  t	 } nT t
 k
 r } t | ƒ t	 } n2 t k
 r° } | j r§ | j d } q± d } n X| S(   s\   The main entry point to coverage.py.

    This is installed as the script entry point.

    i   i    N(   RC   Rs   Rt   Rj   Rœ   R   t	   tracebackt   print_exceptionRI   R‰   R   R    t
   SystemExit(   Rt   t   statust   err(    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyt   mainå  s    	
		
(?   R$   t
   __future__R    RÌ   R%   t   os.pathRm   Rs   R¥   RÏ   Rk   R   t   coverage.collectorR   t   coverage.debugR   R   t   coverage.execfileR   R   t   coverage.miscR   R   R	   t   coverage.resultsR
   t   objectR   t   OptionParserR=   RT   RV   R,   R   R8   t   GLOBAL_ARGSR-   R/   R0   R4   R'   R.   R;   R3   R2   R(   R+   R7   R1   R6   R9   R:   R5   R‡   R…   R‰   R—   Rj   R‹   R’   R§   RC   RÔ   (    (    (    s2   /tmp/pip-build-hU8Cw8/coverage/coverage/cmdline.pyt   <module>   sÒ   vB'	
	
		
	
	
	
	
	
	ÿ )		
