o
    Jh                     @   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   p/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/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 )zReset 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   	