
    Mh-                        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	Z	d dl
Z
d dlmZmZmZ dZ	  ej        d          Z	 dZ	  ej                    Z ej                    Zi Z e            ad Z G d de          Z G d	 d
e          Zd$dZefdZ d Z! ej"        e!d          Z# ej"        e!d          Z$ ej"        e!d          Z%d Z&d%dZ'd%dZ(d%dZ)ddefdZ*ej+        d             Z,d Z-d Z. edej/         ej        dd          0                                d          Z/e j1        d             Z2d  Z3d! Z4d" Z5d# Z6dS )&    N)json	timestamputil)debuginfowarningerrorDEBUGPY_LOG_DIRz09.3fc                  f    t          d t                                          D                       ad S )Nc              3   .   K   | ]}|j         D ]}|V  d S N)levels).0filelevels      R/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/debugpy/common/log.py	<genexpr>z!_update_levels.<locals>.<genexpr>)   s1      SS$t{SSeSSSSSSS    )	frozenset_filesvalues_levels r   r   _update_levelsr   '   s*    SS&--//SSSSSGGGr   c                   h    e Zd ZedfdZed             Zej        d             Zd Zd Z	d Z
d Zd	S )
LogFileTc                    t          dt          j        |                     || _        || _        || _        t          |          | _        t          5  | t          | j        <   t                       t          dt          j                    t          j                    t          j                    t          j                    t          j        dk    rdndt"          j        | g           d d d            d S # 1 swxY w Y   d S )NzAlso logging to {0}.z%{0} {1}
{2} {3} ({4}-bit)
debugpy {5}l        @       )	_to_files)r   r   reprfilenamer   
close_filer   r   _lockr   r   platformmachinepython_implementationpython_versionsysmaxsizedebugpy__version__)selfr"   r   r   r#   s        r   __init__zLogFile.__init__-   s+   #TYx%8%8999 	$ (( 	 	$(F4=!9!## "".00'))kE))r#&	 	 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   BC66C:=C:c                     | j         S r   )r   r-   s    r   r   zLogFile.levelsB   s
    |r   c                     t           5  t          |t          u rt          n|          | _        t                       d d d            d S # 1 swxY w Y   d S r   )r$   r   allLEVELSr   r   )r-   values     r   r   zLogFile.levelsF   s     	 	$u||VVGGDL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   3AAAc                     || j         v rG	 | j                            |           | j                                         d S # t          $ r Y d S w xY wd S r   )r   r   writeflush	Exception)r-   r   outputs      r   r6   zLogFile.writeL   sj    DK	'''	!!!!!   	  s   3A   
AAc                 0   t           5  t          | j        = t                       d d d            n# 1 swxY w Y   t	          dt          j        | j                             | j        r-	 | j        	                                 d S # t          $ r Y d S w xY wd S )NzNot logging to {0} anymore.)r$   r   r"   r   r   r   r!   r#   r   closer8   r0   s    r   r;   zLogFile.closeT   s     	 	t}%	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	*DIdm,D,DEEE? 		!!!!!   	 	s   044*B 
BBc                     | S r   r   r0   s    r   	__enter__zLogFile.__enter__`       r   c                 .    |                                   d S r   )r;   r-   exc_typeexc_valexc_tbs       r   __exit__zLogFile.__exit__c   s    

r   N)__name__
__module____qualname__r3   r.   propertyr   setterr6   r;   r=   rD   r   r   r   r   r   ,   s        .4    *   X ]  ]
  
 
 
      r   r   c                   2    e Zd ZdxZZd xZZd Zd Zd Z	dS )NoLogNc                     dS )NFr   r0   s    r   <lambda>zNoLog.<lambda>j   s    % r   c                     d S r   r   r0   s    r   r;   zNoLog.closel       r   c                     | S r   r   r0   s    r   r=   zNoLog.__enter__o   r>   r   c                     d S r   r   r@   s       r   rD   zNoLog.__exit__r   rO   r   )
rE   rF   rG   r   r"   __bool____nonzero__r;   r=   rD   r   r   r   rK   rK   g   sX        D8///H{        r   rK   r   c                 |    t           5  t                              | d           d d d            d S # 1 swxY w Y   d S )N
)r$   stderrr6   r   s    r   newlinerX   x   s    	 " "UD!!!" " " " " " " " " " " " " " " " " "s   155c                 .   | t           v sJ t          j                    }dt          z   dz   }|                    | d                                         |          }t          t          dd          |z   }ddt          |          z  z   }|	                    |
                    d                    }||z   dz   }t          5  |t          u rt                                          }|D ]}|                    | |           	 d d d            n# 1 swxY w Y   |S )	Nz{0}+{1:z}: r   prefix rU    

)r3   r   currenttimestamp_formatformatuppergetattr_tlslenjoinsplitr$   r2   r   r   r6   )	r   textr    tformat_stringrZ   indentr9   r   s	            r   r6   r6   }   sK   F????A 0058M!!%(.."2"2A66F42&&-DS3v;;&'F[[D))**Ff_v%F	 & &I 	& 	&DJJuf%%%%	&& & & & & & & & & & & & & & & Ks   ?>D

DDc                     | dk    r| t           vrd S 	  |j        |i |}n# t          $ r t                       Y nw xY wt	          | ||                    dt                              S )Nr	   r    )r   r`   r8   reraise_exceptionr6   popr2   )r   ri   argskwargsrg   s        r   write_formatrp      s     E00#}#T4V44    fjjc::;;;s   ! <<r   r   c                  <    t          t          dg| R i |          S )zLogs an error.

    Returns the output wrapped in AssertionError. Thus, the following::

        raise log.error(s, ...)

    has the same effect as::

        log.error(...)
        assert False, (s.format(...))
    r	   )AssertionErrorrp   )rn   ro   s     r   r	   r	      s*     ,w@@@@@@AAAr   r[   c                    |                     dd          }|                     dt          j                              }| r| dz  } | dz  } d                    t	          j        |           }t          j                    }|r|j        n|}	 d                    t	          j	        |                    }~n# ~w xY wt          || g|R ||d| d S )Nr   r	   exc_infor]   z'{exception}
Stack where logged:
{stack}r[   )	exceptionstack)rm   r)   rt   re   	tracebackformat_exceptioninspectcurrentframef_backformat_stackrp   )ri   rn   ro   r   rt   ru   frv   s           r   
_exceptionr~      s    JJw((Ezz*clnn55H  @@M	2H=>>IA1A	.q1122AA}# /8 IO    s   
'B3 3B6c                 &    t          | g|R i | dS )a  Logs an exception with full traceback.

    If format_string is specified, it is formatted with format(*args, **kwargs), and
    prepended to the exception traceback on a separate line.

    If exc_info is specified, the exception it describes will be logged. Otherwise,
    sys.exc_info() - i.e. the exception being handled currently - will be logged.

    If level is specified, the exception will be logged as a message of that level.
    The default is "error".
    Nr~   ri   rn   ro   s      r   swallow_exceptionr      s(     }.t...v.....r   c                 0    d|vsJ t          | g|R i |  )zOLike swallow_exception(), but re-raises the current exception after logging it.rt   r   r   s      r   rl   rl      s6     V####}.t...v...	r   c                 v   | du|duz  sJ | at           t                      S 	 t          j        t                      n# t          $ r Y nw xY wt            d| dt          j                     d} t                              |           }|'t          | t          j
        | dd          |          }n||_        |S )a  Starts logging all messages at the specified levels to the designated file.

    Either filename or prefix must be specified, but not both.

    If filename is specified, it designates the log file directly.

    If prefix is specified, the log file is automatically created in options.log_dir,
    with filename computed as prefix + os.getpid(). If log_dir is None, no log file
    is created, and the function returns immediately.

    If the file with the specified or computed name is already being used as a log
    file, it is not overwritten, but its levels are updated as specified.

    The function returns an object with a close() method. When the object is closed,
    logs are not written into that file anymore. Alternatively, the returned object
    can be used in a with-statement:

        with log.to_file("some.log"):
            # now also logging to some.log
        # not logging to some.log anymore
    N/-z.logwzutf-8)encoding)log_dirrK   osmakedirsOSErrorgetpidr   getr   ioopenr   )r"   rZ   r   r   s       r   to_filer      s    . D V4%78888?77N	K     	 	 	D	:::::::::hD|x3!I!I!I6RRKs   > 
A
Ac              /      K    | j         |i |}t          t          dd          }||z   t          _        	 dV  |t          _        dS # |t          _        w xY w)znAdds a prefix to all messages logged from the current thread for the duration
    of the context manager.
    rZ   r[   N)r`   rb   rc   rZ   )ri   rn   ro   rZ   
old_prefixs        r   prefixedr     sh      
 "]!42622Fx,,J:%DK! j    s   A Ac                 d  	
 dd l }dd l}| dg		fddfd	} d            |d            |d            |d            |d	            |d
            |d           d t          j        D             
 |
fdd           |                                D ]"}d                    |          } ||           # |d            |d            |d            d           d }	 dd l}n(# t          $ r 	 ddlm	} n# t          $ r Y nw xY wY nw xY w| d           n\ d           	 |
                                D ]} d|j        |j                   n!# t          $ r t          dd           Y nw xY wd                    	                              d          S )Nr   r]   c                 H                          | j        |i |           d S r   )appendr`   )srn   ro   results      r   reportz+get_environment_description.<locals>.report   s,    hah///00000r   c                 :   d|p|  d}d t          |           s| fd} 	  |             }n^# t          $ r  d|           Y d S t          $ r9 t          drt	                    nt          j        |           d           Y d S w xY wt          |t          t          f          s|g}t          |          D ]_} d||           |1t          j                            |          }||k    r d	|            d
           dt          |          z  }`d S )Nz    z: c                  ,    t          j                   S r   )r   evaluate)exprs   r   rM   zCget_environment_description.<locals>.report_paths.<locals>.<lambda>)  s    d 3 3 r   z{0}<missing>
zError evaluating {0}r   rW   z{0}{1}z({0})rU   r\   )callableAttributeErrorr8   r   r!   r   	srcnameof
isinstancelisttuplesortedr   pathrealpathrd   )	get_pathslabelrZ   pathsprpr   r   s         @r   report_pathsz1get_environment_description.<locals>.report_paths#  s   .*...	"" 	4D3333I	IKKEE 	 	 	F#V,,,FF 	 	 	&"AT


y(A(A   
 FF	 %$// 	GE 	' 	'AF8VQ'''}W%%a((77F7B'''F4LLL3v;;&FF	' 	's   
/ B
>B
	B
zSystem paths:
zsys.executablez
sys.prefixzsys.base_prefixzsys.real_prefixzsite.getsitepackages()zsite.getusersitepackages()c                     g | ]F}t           j                            |          r%t           j                            |          d k    D|GS )zsite-packages)r   r   existsbasename)r   r   s     r   
<listcomp>z/get_environment_description.<locals>.<listcomp>L  sU       7>>! "$!1!1!!4!4!G!G 	
!G!G!Gr   c                       S r   r   )site_packagess   r   rM   z-get_environment_description.<locals>.<lambda>Q  s     r   zsys.path (site-packages)zsysconfig.get_path({0!r})zos.__file__zthreading.__file__zdebugpy.__file__rU   )metadatazACannot enumerate installed packages - missing importlib_metadata.zInstalled packages:
z    {0}=={1}
z+Error while enumerating installed packages.r   rW   r[   r   )	sysconfigsiter)   r   get_path_namesr`   importlib_metadataImportError	importlibr   distributionsnameversionr8   r   re   rstrip)headerr   r   r   r   r   r   pkgr   r   r   s           @@@r   get_environment_descriptionr     s   KKKfF1 1 1 1 1' ' ' ' ' 'B FL!"""LL"###L"###L)***L-...   M
 L&&&&(BCCC((**  *11$77TLL%&&&L#$$$
F4LLL!!!!!   	@@@@@@@ 	 	 	D	
 !RSSSS&'''	)7799 @ @'3;????@ 	 	 	=V     	
 776??!!$'''sH   3C8 8
DD
	D

DDDDD:.E) )FFc                 @    t          dt          |                      d S )Nz{0})r   r   )r   s    r   describe_environmentr   s  s!    +F3344444r   z<stderr>DEBUGPY_LOG_STDERRzwarning errorF)r   r#   c                      t          t                                                    D ]} |                                  d S r   )r   r   r   r;   )r   s    r   _close_filesr     s:    fmmoo&&  

 r   c                 &    t          d|            d S )Nz$REPR {0!r})r   )r4   s    r   _reprr     s    M5!!!!!r   c                      t          j                    j        j        | rfd| D             t	          d           d S )Nc                 *    i | ]}|v ||         S r   r   )r   r   localss     r   
<dictcomp>z_vars.<locals>.<dictcomp>  s$    III$&..$t...r   z$VARS {0!r})ry   rz   r{   f_localsr   )namesr   s    @r   _varsr     sO    !##*3F JIIIIIIIM6"""""r   c                  r    d                     t          j                              } t          d|            d S )NrU   z$STACK:

{0})re   rw   r|   r   )rv   s    r   _stackr     s3    IIi,..//Ee$$$$$r   c                      d                     d t          j                    D                       } t          d|            d S )NrU   c                 ,    g | ]}t          |          S r   )str)r   rh   s     r   r   z_threads.<locals>.<listcomp>  s    >>>1A>>>r   z$THREADS:

{0})re   	threading	enumerater   )r9   s    r   _threadsr     sB    YY>>	(;(=(=>>>??F'''''r   )r   )r[   )7atexit
contextlib	functoolsry   r   r   r%   r)   r   rw   r+   debugpy.commonr   r   r   r3   getenvr   r_   RLockr$   localrc   r   setr   r   objectr   rK   rX   r2   r6   rp   partialr   r   r   r	   r~   r   rl   r   contextmanagerr   r   r   rV   rf   registerr   r   r   r   r   r   r   r   <module>r      s(  
           				 				  



          0 0 0 0 0 0 0 0 0 0 
/ ")%
&
&   		y	
#%%T T T
8 8 8 8 8f 8 8 8v    F   "" " " "
 "%    *< < < 		,00yv..
)
L)
4
4B B B   ,/ / / / 
 
 
 
 $v ' ' ' 'T 
! 
! 
!V( V( V(r5 5 5 
J29)?;;AACC	
 
 
   " " "# # #% % %
( ( ( ( (r   