
    龙h                     n    d dl 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mZ d dlmZ  G d de      Zy)	    N)DictOptionalUnioncast)TracingGroupLocation)Artifact)ChannelOwnerfrom_nullable_channel)locals_to_paramsc                   <    e Zd Zdededededdf
 fdZ	 	 	 	 	 dded	ed
edededdfdZdd	ededdfdZ	deddfdZ
ddeej                  ef   ddfdZddeej                  ef   ddfdZddeej                  ef   ddfdZddZddededdfdZddZ xZS )TracingparenttypeguidinitializerreturnNc                 b    t         |   ||||       d| _        d | _        d| _        d | _        y NF)super__init___include_sources
_stacks_id_is_tracing_traces_dir)selfr   r   r   r   	__class__s        U/var/www/Befach/backend/env/lib/python3.12/site-packages/playwright/_impl/_tracing.pyr   zTracing.__init__   s7     	t[9&+)-!&*.    nametitle	snapshotsscreenshotssourcesc                 *  K   t        t                     }t        |      | _        | j                  j                  dd |       d {    | j                  j                  dd ||d       d {   }| j                  |       d {    y 7 F7  7 	w)NtracingStarttracingStartChunk)r    r   )r   localsboolr   _channelsend_start_collecting_stacks)r   r   r    r!   r"   r#   params
trace_names           r   startzTracing.start"   s      "&(+ $Wmm  v>>>==--'E
 

 ++J777	 	?
 	8s6   ABB'B.B/BBBBBc                    K   t        t                     }| j                  j                  dd |       d {   }| j	                  |       d {    y 7 7 w)Nr&   )r   r'   r)   r*   r+   )r   r    r   r,   r-   s        r   start_chunkzTracing.start_chunk3   sL     !&(+==--.A4PP
++J777 Q7s!   4AAAAAAr-   c                    K   | j                   s"d| _         | j                  j                  d       | j                  j                  j	                  | j
                  |       d {   | _        y 7 
w)NT)r   _connectionset_is_tracinglocal_utilstracing_startedr   r   )r   r-   s     r   r+   z Tracing._start_collecting_stacks8   s^     #D++D1 $ 0 0 < < L Lj!
 
 
s   A"A1$A/%A1pathc                 B   K   | j                  |       d {    y 7 wN)_do_stop_chunkr   r6   s     r   
stop_chunkzTracing.stop_chunk@   s     !!$'''s   c                    K   | j                  |       d {    | j                  j                  dd        d {    y 7 )7 w)NtracingStop)r9   r)   r*   r:   s     r   stopzTracing.stopC   sG     !!$'''mm  
 	
 	
 	(	
s   AA#AAAA	file_pathc                   K   | j                          |sk| j                  j                  dd ddi       d {    | j                  r7| j                  j
                  j                  | j                         d {    y | j                  j                   }|r{| j                  j                  dd ddi       d {   }| j                  j
                  j                  t        |      |d   | j                  d| j                  d       d {    y | j                  j                  dd ddi       d {   }t        t        t           t        |j!                  d                  }|sD| j                  r7| j                  j
                  j                  | j                         d {    y |j#                  |       d {    |j%                          d {    | j                  j
                  j                  t        |      g | j                  d	| j                  d       d {    y 7 7 7 }7 -7 7 7 ~7 h7 w)
NtracingStopChunkmodediscardentrieswrite)zipFilerD   stacksIdrB   includeSourcesarchiveartifactappend)_reset_stack_counterr)   r*   r   r2   r4   trace_discarded	is_remotesend_return_as_dictzipstrr   r   r   r   r
   getsave_asdelete)r   r?   is_localresultrJ   s        r   r9   zTracing._do_stop_chunkJ   s    !!#--$$%7	?RSSS&&22BB4??SSS''111==<<"D69*= F ""..22"9~%i0 $#&*&;&;   }}88	
 
 X!&**Z"89
 &&22BB4??SSS y)))oo**..y> OO "&"7"7
 	
 	
[ TS
  T 	*	
s   5I	H2AI	:H5;A I	;H8<AI	H;'I	6H>7A3I	*I+I	II	IAI	,I-I	5I	8I	;I	>I	I	I	I	I	c                 b    | j                   r#d| _         | j                  j                  d       y y r   )r   r2   r3   r   s    r   rL   zTracing._reset_stack_counter   s,    $D++E2 r   locationc                 |   K   | j                   j                  dd t        t                            d {    y 7 w)NtracingGroup)r)   r*   r   r'   )r   r   rY   s      r   groupzTracing.group   s*     mm  7G7QRRRs   2<:<c                 X   K   | j                   j                  dd        d {    y 7 w)NtracingGroupEnd)r)   r*   rX   s    r   	group_endzTracing.group_end   s(     mm  
 	
 	
s    *(*)NNNNN)NNr8   )r   N)__name__
__module____qualname__r	   rQ   r   r   r(   r.   r0   r+   r   pathlibPathr;   r>   r9   rL   r   r\   r_   __classcell__)r   s   @r   r   r      s;   /"/*-/58/GK/	/  88 8 	8
 8 8 
8"8s 8 8 8

 
 
(U7<<+<%= ( (
uW\\3%67 
4 
:
eGLL#4E.F :
RV :
x3
S S/C St S
r   r   )rc   typingr   r   r   r    playwright._impl._api_structuresr   playwright._impl._artifactr   playwright._impl._connectionr	   r
   playwright._impl._helperr   r    r   r   <module>rl      s*     . . A / L 5z
l z
r   