Format: application/x-python-code
⬇ Download File (6.7 KB)
   1  o
   2  
   3  ��hx�@sbddlZddlmZmZmZmZdZGdd�de�ZGdd�dej	�Z
   4  dd	�ZGd
   5  d�de�Z
   6  dS)�N)�json�log�	messaging�util�<cseZdZ�fdd�Z�ZS)�ComponentNotAvailablecst��|j�d��dS)Nz is not available)�super�__init__�__name__)�self�type��	__class__��Pc:\Users\shubh\Videos\agent\nova\Lib\site-packages\debugpy/adapter/components.pyr	szComponentNotAvailable.__init__)r
   7  �
   8  __module__�__qualname__r	�
   9  __classcell__rrr
  10  rr
  11  srcsjeZdZdZd�fdd�	Zdd�Zedd��Zed	d
  12  ��Zedd��Z	d
  13  d�Z
  14  edd��Zdd�Z
  15  �ZS)�	Componenta�A component managed by a debug adapter: client, launcher, or debug server.
  16  
  17      Every component belongs to a Session, which is used for synchronization and
  18      shared data.
  19  
  20      Every component has its own message channel, and provides message handlers for
  21      that channel. All handlers should be decorated with @Component.message_handler,
  22      which ensures that Session is locked for the duration of the handler. Thus, only
  23      one handler is running at any given time across all components, unless the lock
  24      is released explicitly or via Session.wait_for().
  25  
  26      Components report changes to their attributes to Session, allowing one component
  27      to wait_for() a change caused by another component.
  28      Ncs�|du|duAs
  29  J�z|jjdd�}|sJd��W|j��n|j��wt���|�_|durAt��|_t�	|��}|�
  30  �nt��|_|j_�|_|�_
  31  d�_�j�fdd�g7_dS)NF)�blockingz6__init__ of a Component subclass must lock its SessionTcs
  32  �j��S�N)�sessionZnotify_changed)�_�rrr�<lambda>:s
  33  z$Component.__init__.<locals>.<lambda>)�lock�acquire�releaserr	r�str�namerZJsonMessageChannel�start�stream�handlers�channel�is_connectedZ	observers)rrr!r#�	lock_heldr
  34  rrr	"s 
  35  
  36  
  37  zComponent.__init__cCst|�j�d|jj�d�S)N�[�])rr
  38  r�idrrrr�__str__<szComponent.__str__cC�|jjSr)r�clientrrrrr+?�zComponent.clientcCr*r)r�launcherrrrrr-Cr,zComponent.launchercCr*r)r�serverrrrrr.Gr,zComponent.servercOs|jj|i|��Sr)r�wait_for)r�args�kwargsrrrr/KszComponent.wait_forcst����fdd��}|S)aApplied to a message handler to automatically lock and unlock the session
  39          for its duration, and to validate the session state.
  40  
  41          If the handler raises ComponentNotAvailable or JsonIOError, converts it to
  42          Message.cant_handle().
  43          c
  44  s�z|j��||�Wd�WS1swYWdSty0}z|jd|dd��d}~wtjyN}z|j|ur>�|�|�WYd}~dSd}~wtjyd}z
  45  |jd|jj	dd��d}~ww)N�{0}T)Zsilentz{0} disconnected unexpectedly)
  46  rrZcant_handler�MessageHandlingError�cause�	propagateZJsonIOErrorr!r)r�message�exc��frr�lock_and_handleWs$(��
  47  �
  48  ���z2Component.message_handler.<locals>.lock_and_handle)�	functools�wraps)r9r:rr8r�message_handlerNs	zComponent.message_handlercCsD|j�d|_|j�d�|��Wd�dS1swYdS)NFz{0} has disconnected)rr$�finalize�formatrrrr�
  49  disconnectjs"�zComponent.disconnect)NN)r
  50  rr�__doc__r	r)�propertyr+r-r.r/�staticmethodr=r@rrrr
  51  rrs
  52  
  53  
  54  
  55  rcs(G�fdd�dt�}��fdd��|�S)Ncs,eZdZdZ�fdd�ZZdd�ZZdS)zmissing.<locals>.MissingzoA dummy component that raises ComponentNotAvailable whenever some
  56          attribute is accessed on it.
  57          cs��Srr)rr��reportrrrvsz!missing.<locals>.Missing.<lambda>cSsdS)NFrrrrrrwsN)r
  58  rrrA�__getattr__�__setattr__�__bool__�__nonzero__rrDrr�MissingqsrJc
  59  s>zt���ty}zt�d|��WYd}~dSd}~ww)Nz
  60  {0} in {1})r�	ExceptionrZreraise_exception)r7)rrrrrEys��zmissing.<locals>.report)�object)rrrJr)rErrr�missingpsrMc@s.eZdZdZiZ	dd�Zdd�Zdd�ZdS)	�Capabilitiesz�A collection of feature flags for a component. Corresponds to JSON properties
  61      in the DAP "initialize" request or response, other than those that identify the
  62      party.
  63      cCs�|�d�s|�d�sJ�||_|j}|j��D]?\}}|�|d�}t|�s*t�	|�}z||�}Wnt
  64  yF}z
  65  |�dt�|�|��d}~ww|dksRJ|�d���|||<qt
  66  �d|�dS)z�Parses an "initialize" request or response and extracts the feature flags.
  67  
  68          For every "X" in self.PROPERTIES, sets self["X"] to the corresponding value
  69          from message.payload if it's present there, or to the default value otherwise.
  70          Z
  71  initializerz{0} {1}Nz5 must provide a default value for missing properties.r2)Z
  72  is_requestZis_response�	component�payload�
  73  PROPERTIES�items�get�callabler�defaultrKZ
  74  isnt_valid�reprr�debug)rrOr6rPr�validate�valuer7rrrr	�s$
  75  ��
  76  �
  77  zCapabilities.__init__cCst|�j�dt�t|����S)Nz: )rr
  78  rrV�dictrrrr�__repr__�szCapabilities.__repr__cGs2|D]}||st�|j�dt�|�����qdS)Nz does not have capability )rr3rOrrV)r�keys�keyrrr�require�s���zCapabilities.requireN)r
  79  rrrArQr	r[r^rrrrrN�s	rN)r;Zdebugpy.commonrrrrZACCEPT_CONNECTIONS_TIMEOUTrKrZ
  80  ObservablerrMrZrNrrrr�<module>s^