
    ^hj                     <    S r SSKJrJrJr  SSKJr   " S S5      rg)zBProvides access to variables pertaining to specific call contexts.    )Context
ContextVarcopy_context)Anyc                       \ rS rSr% SrSr\\S'   Sr\	" \5      r
\	\\\4      \S'   \S\S\4S j5       r\S\S\SS	4S
 j5       r\S\\   4S j5       r\S\\\4   4S j5       rSrg	)CallContext	   a&  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                 >    [         R                  5       nX;   a  X!   $ g)aI  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      Z/home/james-whalen/.local/lib/python3.13/site-packages/jupyter_server/base/call_context.pygetCallContext.get   s$      %--/!!''    valueNc                 4    [         R                  5       nX#U'   g)a	  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   setCallContext.set1   s     %--/$tr   c                 \    [         R                  5       n[        UR                  5       5      $ )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_names"CallContext.context_variable_namesC   s&     %--/N'')**r   c                     [        5       n[        R                  U;  a  [        R                  R                  0 5        [        R                  R	                  5       $ )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   CallContext._get_mapO   sB     $~&&c1''++B/**..00r    )__name__
__module____qualname____firstlineno____doc__r
   str__annotations___NAME_VALUE_MAPr   r   dictr   classmethodr   r   r   r   r   __static_attributes__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>r1      s    H : 9 O1 O1r   