
    bij                     <    d Z ddlmZmZmZ ddlmZ  G d d      Zy)zBProvides access to variables pertaining to specific call contexts.    )Context
ContextVarcopy_context)Anyc                       e Zd ZU dZdZeed<   dZ ee      Z	ee
eef      ed<   ededefd       Zedededdfd	       Zedee   fd
       Zede
eef   fd       Zy)CallContexta6  CallContext essentially acts as a namespace for managing context variables.

    Although not required, it is recommended that any "file-spanning" context variable
    names (i.e., variables that will be set or retrieved from multiple files or services) be
    added as constants to this class definition.
    JUPYTER_HANDLER_name_value_mapnamereturnc                 >    t         j                         }||v r||   S y)a  Returns the value corresponding the named variable relative to this context.

        If the named variable doesn't exist, None will be returned.

        Parameters
        ----------
        name : str
            The name of the variable to get from the call context

        Returns
        -------
        value: Any
            The value associated with the named variable for this call context
        Nr   _get_map)clsr   name_value_maps      [/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/jupyter_server/base/call_context.pygetzCallContext.get   s(      %--/>!!$''    valueNc                 6    t         j                         }|||<   y)aY  Sets the named variable to the specified value in the current call context.

        Parameters
        ----------
        name : str
            The name of the variable to store into the call context
        value : Any
            The value of the variable to store into the call context

        Returns
        -------
        None
        Nr   )r   r   r   r   s       r   setzCallContext.set1   s     %--/$tr   c                 \    t         j                         }t        |j                               S )zReturns a list of variable names set for this call context.

        Returns
        -------
        names: List[str]
            A list of variable names set for this call context.
        )r   r   listkeys)r   r   s     r   context_variable_namesz"CallContext.context_variable_namesC   s&     %--/N'')**r   c                     t               }t        j                  |vrt        j                  j                  i        t        j                  j	                         S )zGet the map of names to their values from the _NAME_VALUE_MAP context var.

        If the map does not exist in the current context, an empty map is created and returned.
        )r   r   r
   r   r   )r   ctxs     r   r   zCallContext._get_mapO   sB     $~&&c1''++B/**..00r   )__name__
__module____qualname____doc__r	   str__annotations___NAME_VALUE_MAPr   r
   dictr   classmethodr   r   r   r   r    r   r   r   r   	   s     -OS,
 (O2<_2MOZS#X/Ms s  * %s %3 %4 % %" 	+tCy 	+ 	+ 1c3h 1 1r   r   N)r!   contextvarsr   r   r   typingr   r   r'   r   r   <module>r*      s    H : 9 O1 O1r   