
    L-Ph)L                    <   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mZ ddl	m
Z
 ddlmZmZmZmZ ddlmZ ddlmZ dd	lmZ dd
lm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"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*  ee          Z ed          Z+ G d d          Z,dS )z#Raw data collector for coverage.py.    )annotationsN)Mapping)	FrameType)castAnyCallableTypeVar)env)CoverageConfig)Core)CoverageData)short_stack)ConfigError)human_sorted_itemsisolate_module)CoveragePlugin)	TArcTCheckIncludeFnTFileDispositionTShouldStartContextFnTShouldTraceFn
TTraceDataTTraceFnTracerTWarnFnTc                      e Zd ZU dZg Zded<   h dZdBdZdCdZdDdZ	dCdZ
dEd ZdEd!ZdEd"ZdEd#ZdFd%ZdGd+ZdEd,ZdEd-ZdEd.ZdEd/ZdEd0ZdHd1ZdId3ZdJd6Zej        dKd8            ZdLd<ZdMd?ZdHd@ZdAS )N	Collectora  Collects trace data.

    Creates a Tracer object for each thread, since they track stack
    information.  Each Tracer points to the same shared data, contributing
    traced data points.

    When the Collector is started, it creates a Tracer for the current thread,
    and installs a function to create Tracers for each new thread started.
    When the Collector is stopped, all active Tracers are stopped.

    Threads started while the Collector is stopped will never have Tracers
    associated with them.

    zlist[Collector]_collectors>   geventeventletgreenletcorer   should_tracer   check_includer   should_start_contextTShouldStartContextFn | Nonefile_mapperCallable[[str], str]branchboolwarnr   concurrency	list[str]returnNonec	                   || _         || _        || _        || _        || _        || _        || _        || _        t          | j        t                    sJ d| j                    t          j                    | _        |  d| _        d| _        t                      | _        d| _        t%          | j                  }	|	t&          j        z
  }
|
r4d                    t-          |
                    }t/          d|           |	| j        z  }t3          |          dk    r4d                    t-          |                    }t/          d|           d}d}	 d	|	v rd	}d
dl}|j        | _        n2d|	v rd}d
dl}|j        j        | _        nd|	v rd}d
dl}|j        | _        d|	v rd}n(# t>          $ r}d| d}t/          |          |d}~ww xY w| j        rJtA          |j!        d          s5t/          d"                    || #                                                    |s|	sd
dl}|| _        | $                                 dS )a  Create a collector.

        `should_trace` is a function, taking a file name and a frame, and
        returning a `coverage.FileDisposition object`.

        `check_include` is a function taking a file name and a frame. It returns
        a boolean: True if the file should be traced, False if not.

        `should_start_context` is a function taking a frame, and returning a
        string. If the frame should be the start of a new context, the string
        is the new context. If the frame should not be the start of a new
        context, return None.

        `file_mapper` is a function taking a filename, and returning a Unicode
        filename.  The result is the name that will be recorded in the data
        file.

        If `branch` is true, then branches will be measured.  This involves
        collecting data on which statements followed each other (arcs).  Use
        `get_arc_data` to get the arc data.

        `warn` is a warning function, taking a single string message argument
        and an optional slug argument which will be a string or None, to be
        used if a warning needs to be issued.

        `concurrency` is a list of strings indicating the concurrency libraries
        in use.  Valid values are "greenlet", "eventlet", "gevent", or "thread"
        (the default).  "thread" can be combined with one of the other three.
        Other values are ignored.

        zExpected a list: Nz, zUnknown concurrency choices:    z"Conflicting concurrency settings: Fnothingr"   r   r!   r    threadTz Couldn't trace with concurrency=z, the module isn't installed.concur_id_funczACan't support concurrency={} with {}, only threads are supported.)%r#   r$   r%   r&   r(   r*   r,   r-   
isinstancelistosgetpidpid	threadingstatic_contextr   originr5   setr   CONCURRENCY_CHOICESjoinsortedr   LIGHT_THREADSlenr"   
getcurrenteventlet.greenthreadgreenthreadr    ImportErrorhasattrtracer_classformattracer_namereset)selfr#   r$   r%   r&   r(   r*   r,   r-   concurrenciesunknownshowlight_threadsdo_threadingtriedr"   r!   r    exmsgr;   s                        R/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/coverage/collector.py__init__zCollector.__init__C   s   T 	(*$8!&	&$*D11[[3[tGW3[3[[[[9;;"*.!mm" D,--."DD 	F99VG__--DDdDDEEE%(::}!!99VM2233DI4IIJJJ	+]**"&.&9##},,"++++&.&:&E##]** &,&7#=((# 	+ 	+ 	+YUYYYCc""*	+  	wt/@BR'S'S 	SZZ4++--     	'} 	' &DN

s   AF& &
G0GGstrc                T    dt          |           dd|                                  dS )Nz<Collector at z#x: >)idrK   rM   s    rV   __repr__zCollector.__repr__   s0    D4DDDt/?/?/A/ADDDD    covdatar   context
str | Nonec                `    || _         || _        | j                             | j                   dS )z!Use `covdata` for recording data.N)r`   r<   set_context)rM   r`   ra   s      rV   use_datazCollector.use_data   s0    %  !455555r_   c                $    | j         j        j        S )z0Return the class name of the tracer we're using.)r#   rI   __name__r]   s    rV   rK   zCollector.tracer_name   s    y%..r_   c                   | j         pt          j                    5  | j                                        D ]}|                                 	 ddd           n# 1 swxY w Y   | j        D ]}|                                 dS )z<Clear out existing data, but stay ready for more collection.N)	data_lock
contextlibnullcontextdatavaluescleartracersreset_activity)rM   dtracers      rV   _clear_datazCollector._clear_data   s    
 ^7z577 	 	Y%%''  					 	 	 	 	 	 	 	 	 	 	 	 	 	 	 l 	$ 	$F!!####	$ 	$s   1AA Ac                0   | j         r| j                                         nd| _        i | _        i | _        t                      | _        t          j        rddl	}|
                    d          | _        ni | _        g | _        |                                  dS )z2Clear collected data, and prepare to collect more.Nr   module)r;   Lockri   rl   file_tracersr>   disabled_pluginsr
   PYPY__pypy__newdictshould_trace_cachero   rs   )rM   rz   s     rV   rL   zCollector.reset   s    26.J,,...d !#	 -/*-%% 8 	)OOO '/&6&6x&@&@D##&(D# &(r_   c                J    | j         | j                                          dS dS )z-Lock self.data_lock, for use by the C tracer.N)ri   acquirer]   s    rV   	lock_datazCollector.lock_data   ,    >%N""$$$$$ &%r_   c                J    | j         | j                                          dS dS )z/Unlock self.data_lock, for use by the C tracer.N)ri   releaser]   s    rV   unlock_datazCollector.unlock_data   r   r_   TTraceFn | Nonec                    | j         j        di | j         j        }| j        |_        | j        |_        | j        |_        | j        |_        | j        |_        | j	        |_	        | j
        |_
        t          |d          r| j        |_        t          |d          r| j        |_        t          |d          r| j        |_        t          |d          r| j        |_        t          |d          r| j        |_        t          |d          r| j        |_        t          |d          r| j        |_        |                                }| j                            |           |S )	z8Start a new Tracer object, and store it in self.tracers.r5   rw   r;   r%   r&   switch_contextdisable_plugin )r#   rI   tracer_kwargsrl   r   r   r*   
trace_arcsr$   r|   r,   rH   r5   rw   r;   r%   r&   r   r   startro   append)rM   rr   fns      rV   _start_tracerzCollector._start_tracer  s_   ''BB$)*ABBi>!- K"/$($;!i6+,, 	8$($7F!6>** 	4"&"3F6;'' 	.#~F6?++ 	6#'#5F 6122 	D*.*CF'6+,, 	8$($7F!6+,, 	8$($7F!\\^^F###	r_   framer   eventargr   c                t    t          j        d           |                                 }|r ||||          }|S )z0Called on new threads, installs the real tracer.N)syssettracer   )rM   r   r   r   r   s        rV   _installation_tracezCollector._installation_trace*  sG     	T"0022  	'E5#&&B	r_   c                (   g }| j         D ]<}|j        | j        k    r|                    |           (|                                 =|| j         dd<   | j         r| j         d                                          g | _        	 |                                  n,#  | j         r| j         d                                           xY w| j                             |            | j        j	        r(| j
        r#| j
                            | j                   dS dS dS )z#Start collecting trace information.N)r   r:   r   	post_forkpausero   r   resumer#   systracer;   r   r   )rM   keep_collectorscs      rV   r   zCollector.start7  s<   
 ! 	 	Au  &&q))))- 	)R &&(((	    	 . $++--- 	%%% 9 	>$. 	>N##D$<=====	> 	> 	> 	>s   B )B?c                   | j         sJ | j         d         | ur3t          d           | j         D ]}t          d|d|j                    | j         d         | u sJ d| d| j         d                     |                                  | j                                          | j         r!| j         d                                          dS dS )z"Stop collecting trace information.r   zself._collectors:z  
z!Expected current collector to be z, but it's N)r   printr=   r   popr   )rM   r   s     rV   stopzCollector.stopZ  s   Bt++%&&&% . .,1,,!(,,----#t+++[[[4CSTVCW[[ ,++ 	

 	 	*R '')))))	* 	*r_   c                f   | j         D ]}|                                 |                                }|rYt          d|j        j         d           t          |                                          D ]\  }}t          |dd|            | j        r| j        	                    d           dS dS )z+Pause tracing, but be prepared to `resume`.z
Coverage.py z stats:z>20rZ   N)
ro   r   	get_statsr   	__class__rg   r   itemsr;   r   )rM   rr   statskvs        rV   r   zCollector.pausel  s    l 	+ 	+FKKMMM$$&&E +Iv'7'@IIIJJJ.u{{}}== + +DAqQ///a//****> 	*N##D)))))	* 	*r_   c                    | j         D ]}|                                 | j        j        r>| j        r!| j                            | j                   dS |                                  dS dS )zResume tracing after a `pause`.N)ro   r   r#   r   r;   r   r   r   rM   rr   s     rV   r   zCollector.resumex  sz    l 	 	FLLNNNN9 	%~ %''(@AAAAA""$$$$$		% 	%r_   c                b    | j         D ]&}t          |d          r|                                 'dS )z+After a fork, tracers might need to adjust.r   N)ro   rH   r   r   s     rV   r   zCollector.post_fork  sB    l 	# 	#Fv{++ #  """	# 	#r_   c                >    t          d | j        D                       S )zkHas any activity been traced?

        Returns a boolean, True if any trace function was invoked.

        c              3  >   K   | ]}|                                 V  d S )N)activity).0rr   s     rV   	<genexpr>z&Collector._activity.<locals>.<genexpr>  s,      @@6??$$@@@@@@r_   )anyro   r]   s    rV   	_activityzCollector._activity  s#     @@4<@@@@@@r_   new_contextc                    |                                   | j        r| j        }|r|d|z   z  }n|}| j                            |           dS )z Switch to a new dynamic context.|N)
flush_datar<   r`   rd   )rM   r   ra   s      rV   r   zCollector.switch_context  s`     	 	")G -3,,!G  )))))r_   dispositionr   c                    |j         }|J |j        }|j        }|                     d|d           d|_        d|_        dS )z.Disable the plugin mentioned in `disposition`.NzDisabling plug-in z due to previous exceptionF)file_tracer_coverage_plugin_coverage_plugin_namer,   _coverage_enabledtrace)rM   r   r   pluginplugin_names        rV   r   zCollector.disable_plugin  sZ    !-&&&-2		P{PPPQQQ#( !r_   filenamec                ,    |                      |          S )zBA locally cached version of file names mapped through file_mapper.)r(   )rM   r   s     rV   cached_mapped_filezCollector.cached_mapped_file  s     )))r_   rq   Mapping[str, T]dict[str, T]c                     d}t          d          D ]>}	 t          |                                          } n2# t          $ r}|}Y d}~7d}~ww xY wt	          |t
                    sJ | fd|D             S )z<Return a dict like d, but with keys modified by file_mapper.N   c                F    i | ]\  }}|                     |          |S r   )r   r   r   r   rM   s      rV   
<dictcomp>z.Collector.mapped_file_dict.<locals>.<dictcomp>  s2    EEE$!Q1E''**AEEEr_   )ranger7   r   RuntimeErrorr6   	Exception)rM   rq   runtime_err_r   rT   s   `     rV   mapped_file_dictzCollector.mapped_file_dict  s     q 		 		AQWWYY    ! ! ! !
 k955555EEEE%EEEEs   !9
AA

Ar   r   c                D    | j                             |j                   dS )z1Record that `plugin` was disabled during the run.N)rx   addr   )rM   r   s     rV   plugin_was_disabledzCollector.plugin_was_disabled  s"    !!&">?????r_   c                                                      sdS  j        r# j        j        ri }t	          t
          t          t          t                   f          j	                  }t          |                                          D ]V\  }}g }t          |          D ]:}|dz  }|dz  dz	  }|dz  r|dz  }|dz  r|dz  }|                    ||f           ;|||<   Wn7t	          t
          t          t          t                   f          j	                  } j                                                 |                     ndt	          t
          t          t          t                   f          j	                  }	 j                                                 |	                      fd j                                        D             }
 j                                                 |
                                                       d	S )
zSave the collected data to our associated `CoverageData`.

        Data may have also been saved along the way. This forces the
        last of the data to be saved.

        Returns True if there was data to save, False if not.
        Fi l        l        r   l        c                .    i | ]\  }}|j         v||S r   )rx   r   s      rV   r   z(Collector.flush_data.<locals>.<dictcomp>  s7     
 
 
Q--- q---r_   T)r   r*   r#   packed_arcsr   dictrX   r>   intrl   r7   r   r   r   r`   add_arcsr   	add_linesrw   add_file_tracersrs   )rM   arc_datapacked_datafnamepackedstuplespackedl1l2	line_datarw   s   `          rV   r   zCollector.flush_data  s    ~~ 	5; 	Ey$ B 35"4SX#6	BB '+;+<+<+>+>&?&? 
- 
-NE7F"&w-- 0 0#g-$62=!W- %"HB!W- %"HBr2h////&,HUOO
-  S$t*_ 5tyAAL!!$"7"7"A"ABBBBT#s3x-0$)<<IL""4#8#8#C#CDDD
 
 
 
!.4466
 
 
 	%%d&;&;L&I&IJJJtr_   N)r#   r   r$   r   r%   r   r&   r'   r(   r)   r*   r+   r,   r   r-   r.   r/   r0   )r/   rX   )r`   r   ra   rb   r/   r0   )r/   r0   )r/   r   )r   r   r   rX   r   r   r/   r   )r/   r+   )r   rb   r/   r0   )r   r   r/   r0   )r   rX   r/   rX   )rq   r   r/   r   )r   r   r/   r0   )rg   
__module____qualname____doc__r   __annotations__rB   rW   r^   re   rK   rs   rL   r   r   r   r   r   r   r   r   r   r   r   r   	functoolscacher   r   r   r   r   r_   rV   r   r   +   s         $ $&K%%%% 766Mm m m m^E E E E6 6 6 6/ / / /
$ 
$ 
$ 
$, , , ,\% % % %
% % % %
   N   !> !> !> !>F* * * *$
* 
* 
* 
*% % % %# # # #A A A A
* 
* 
* 
*" " " " _* * * _*F F F F(@ @ @ @. . . . . .r_   r   )-r   
__future__r   rj   r   r8   r   collections.abcr   typesr   typingr   r   r   r	   coverager
   coverage.configr   coverage.corer   coverage.datar   coverage.debugr   coverage.exceptionsr   coverage.miscr   r   coverage.pluginr   coverage.typesr   r   r   r   r   r   r   r   r   r   r   r   r_   rV   <module>r      s   * ) " " " " " "         				 



 # # # # # #       / / / / / / / / / / / /       * * * * * *       & & & & & & & & & & & & + + + + + + < < < < < < < < * * * * * *
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 ^B GCLLF F F F F F F F F Fr_   