o
    è’OjÆ  ã                   @   s’   d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	 ddl
mZ eG dd„ dƒƒZed	ƒZd
d„ Zdd„ Zdd„ Zeddd„ƒZddd„ZdS )z”
NOTE: All classes and functions in this module are considered private and are
subject to abrupt breaking changes. Please do not use them directly.
é    )Úcontextmanager)Ú
ContextVar)Údeepcopy)Ú	dataclassÚfield©Úwrapsc                   @   s(   e Zd ZU dZeed�Zee ed< dS )ÚClientContexta
  
    Encapsulation of objects tracked within the ``_context`` context variable.

    ``features`` is a set responsible for storing features used during
    preparation of an AWS request. ``botocore.useragent.register_feature_id``
    is used to add to this set.
    )Údefault_factoryÚfeaturesN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úsetr   ÚstrÚ__annotations__© r   r   úV/var/www/html/pharmsmart-cdr-gen/venv/lib/python3.10/site-packages/botocore/context.pyr	      s   
 r	   Ú_contextc                   C   s
   t  d¡S )z@Get the current ``_context`` context variable if set, else None.N)r   Úgetr   r   r   r   Úget_context)   s   
r   c                 C   s   t  | ¡}|S )a2  Set the current ``_context`` context variable.

    :type ctx: ClientContext
    :param ctx: Client context object to set as the current context variable.

    :rtype: contextvars.Token
    :returns: Token object used to revert the context variable to what it was
        before the corresponding set.
    )r   r   )ÚctxÚtokenr   r   r   Úset_context.   s   

r   c                 C   s   t  | ¡ dS )z—Reset the current ``_context`` context variable.

    :type token: contextvars.Token
    :param token: Token object to reset the context variable.
    N)r   Úreset)r   r   r   r   Úreset_context<   s   r   Nc                 c   sL   � | pt ƒ }|du rtƒ }nt|ƒ}t|ƒ}z
dV  W t|ƒ dS t|ƒ w )aƒ  
    Context manager that copies the passed or current context object and sets
    it as the current context variable. If no context is found, a new
    ``ClientContext`` object is created. It mainly ensures the context variable
    is reset to the previous value once the executed code returns.

    Example usage:

        def my_feature():
            with start_as_current_context():
                register_feature_id('MY_FEATURE')
                pass

    :type ctx: ClientContext
    :param ctx: The client context object to set as the new context variable.
        If not provided, the current or a new context variable is used.
    N)r   r	   r   r   r   )r   ÚcurrentÚnewr   r   r   r   Ústart_as_current_contextE   s   €
r   c                    s   ‡ fdd„}|S )aû  
    Decorator that wraps ``start_as_current_context`` and optionally invokes a
    hook within the newly-set context. This is just syntactic sugar to avoid
    indenting existing code under the context manager.

    Example usage:

        @with_current_context(partial(register_feature_id, 'MY_FEATURE'))
        def my_feature():
            pass

    :type hook: callable
    :param hook: A callable that will be invoked within the scope of the
        ``start_as_current_context`` context manager.
    c                    s   t ˆ ƒ‡ ‡fdd„ƒ}|S )Nc                     sB   t ƒ � ˆr	ˆƒ  ˆ | i |¤ŽW  d   ƒ S 1 sw   Y  d S ©N)r   )ÚargsÚkwargs)ÚfuncÚhookr   r   Úwrapperv   s
   $ýz8with_current_context.<locals>.decorator.<locals>.wrapperr   )r#   r%   ©r$   )r#   r   Ú	decoratoru   s   z'with_current_context.<locals>.decoratorr   )r$   r'   r   r&   r   Úwith_current_contextd   s   
r(   r    )r   Ú
contextlibr   Úcontextvarsr   Úcopyr   Údataclassesr   r   Ú	functoolsr   r	   r   r   r   r   r   r(   r   r   r   r   Ú<module>   s   	