a
    ö£Be&  ã                   @   s”   d dl Z d dlZd dlZedfdd„ZG dd„ deƒZG dd„ deƒZdd
d„Z	ddd„Z
ddd„Zddd„Zddd„Zdd„ Zdd„ Zdd„ ZdS ) é    NÚevalc                 C   s   t | |dƒ}t|i tjƒS )Nr   )Úcompiler   ÚsysÚmodules)ÚcodeÚpathÚmodeÚexpr© r
   úV/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/debugpy/common/util.pyÚevaluate
   s    r   c                       s,   e Zd ZdZdZdd„ Z‡ fdd„Z‡  ZS )Ú
Observablez$An object with change notifications.r
   c                 C   s
   g | _ d S ©N)Ú	observers)Úselfr
   r
   r   Ú__init__   s    zObservable.__init__c              
      sV   z8t ƒ  ||¡W | jD ]}|| |ƒ qS ]}|| |ƒ q(n| jD ]}|| |ƒ q@0 d S r   )ÚsuperÚ__setattr__r   )r   ÚnameÚvalueÚob©Ú	__class__r
   r   r      s    
ýÿ
zObservable.__setattr__)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   Ú__classcell__r
   r
   r   r   r      s   r   c                   @   s.   e Zd ZdZedd„ ƒZd	dd„Zdd„ ZdS )
ÚEnvz!A dict for environment variables.c                   C   s
   t tjƒS )z.Returns a snapshot of the current environment.)r   ÚosÚenvironr
   r
   r
   r   Úsnapshot&   s    zEnv.snapshotNc                 C   s   t | ƒ}|d ur| |¡ |S r   )r   Úupdate)r   Zupdated_fromÚresultr
   r
   r   Úcopy+   s    
zEnv.copyc                 C   s<   zt jj| |  }W n ty*   d}Y n0 || | |< dS )ztPrepends a new entry to a PATH-style environment variable, creating
        it if it doesn't exist already.
        Ú N)r   r   ÚpathsepÚKeyError)r   ÚkeyÚentryÚtailr
   r
   r   Ú
prepend_to1   s
    
zEnv.prepend_to)N)r   r   r   r   Ústaticmethodr!   r$   r+   r
   r
   r
   r   r   #   s
   

r   Ústrictc                 C   s   t | tƒr|  ||¡S t| ƒS )zcConverts s to str, using the provided encoding. If s is already str,
    it is returned as is.
    )Ú
isinstanceÚbytesÚdecodeÚstr©ÚsÚencodingÚerrorsr
   r
   r   Ú	force_str<   s    r6   c                 C   s:   t | tƒr|  ||¡S t| ƒ} |dkr2|  ||¡ | S dS )zìConverts s to bytes, using the provided encoding. If s is already bytes,
    it is returned as is.

    If errors="strict" and s is bytes, its encoding is verified by decoding it;
    UnicodeError is raised if it cannot be decoded.
    r-   N)r.   r1   Úencoder/   r0   r2   r
   r
   r   Úforce_bytesC   s    
r8   c                 C   s   t | d|ƒS )z'Same as force_bytes(s, "ascii", errors)Úascii©r8   ©r3   r5   r
   r
   r   Úforce_asciiT   s    r<   c                 C   s   t | d|ƒS )z&Same as force_bytes(s, "utf8", errors)Úutf8r:   r;   r
   r
   r   Ú
force_utf8Y   s    r>   Fc                 C   s–   z
| j }W nZ tyd   z
| j}W n< ty^   zt| ƒ}W n tyT   Y Y Y dS 0 d}Y n0 Y n0 |rŠzt|ƒ}W n tyˆ   Y n0 t|ddƒS )zßReturns the most descriptive name of a Python module, class, or function,
    as a Unicode string

    If quote=True, name is quoted with repr().

    Best-effort, but guaranteed to not fail - always returns something.
    z	<unknown>Fzutf-8Úreplace)r   Ú	Exceptionr   Úreprr6   )ÚobjÚquoter   r
   r
   r   Únameof^   s"    	

rD   c                 C   s|   t | dd�}zt | ¡}W n ty,   Y nL0 |d|›�7 }zt | ¡\}}W n ty`   Y n0 |d|› �7 }|d7 }|S )záReturns the most descriptive name of a Python module, class, or function,
    including source information (filename and linenumber), if available.

    Best-effort, but guaranteed to not fail - always returns something.
    T)rC   z (file z, line ú))rD   ÚinspectÚgetsourcefiler@   Úgetsourcelines)rB   r   Zsrc_fileÚ_Z
src_linenor
   r
   r   Ú	srcnameof~   s    rJ   c                   C   s
   dt jvS )z>Returns True if the caller should hide something from debugpy.ZDEBUGPY_TRACE_DEBUGPY)r   r    r
   r
   r
   r   Úhide_debugpy_internals™   s    rK   c                 C   s   t ƒ rd| _d| _dS )z�Disables tracing for the given thread if DEBUGPY_TRACE_DEBUGPY is not set.
    DEBUGPY_TRACE_DEBUGPY is used to debug debugpy with debugpy
    TN)rK   Zpydev_do_not_traceZis_pydev_daemon_thread)Úthreadr
   r
   r   Úhide_thread_from_debuggerž   s    rM   )r-   )r-   )r-   )r-   )F)rF   r   r   Ú__file__r   Úobjectr   Údictr   r6   r8   r<   r>   rD   rJ   rK   rM   r
   r
   r
   r   Ú<module>   s   	




 