HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/botocore/__pycache__/waiter.cpython-310.pyc
o

*we�7�@s�ddlZddlZddlZddlmZddlmZddlmZddl	m
Z
mZmZe�
e�Zdd�Zd	d
�ZGdd�d�ZGd
d�d�ZGdd�d�ZGdd�d�ZGdd�d�ZdS)�N)�WaiterDocstring)�get_service_module_name�)�
xform_name)�ClientError�WaiterConfigError�WaiterErrorc	Cs||�|�}t|j�}tt||��}dd�}t||jj|jj|dd�|_	t
dt|jj�|f�}t|t
fd|i�}||||�S)a

    :type waiter_name: str
    :param waiter_name: The name of the waiter.  The name should match
        the name (including the casing) of the key name in the waiter
        model file (typically this is CamelCasing).

    :type waiter_model: botocore.waiter.WaiterModel
    :param waiter_model: The model for the waiter configuration.

    :type client: botocore.client.BaseClient
    :param client: The botocore client associated with the service.

    :rtype: botocore.waiter.Waiter
    :return: The waiter object.

    c[stj|fi|��dS�N)�Waiter�wait)�self�kwargs�r�H/home/arjun/projects/env/lib/python3.10/site-packages/botocore/waiter.pyr6sz'create_waiter_with_client.<locals>.waitF)�waiter_name�
event_emitter�
service_model�service_waiter_model�include_signaturez%s.Waiter.%sr)�
get_waiterr�	operation�NormalizedOperationMethod�getattrr�meta�eventsr�__doc__�strr�typer
)	r�waiter_model�client�single_waiter_config�operation_name�operation_methodr�waiter_class_name�documented_waiter_clsrrr�create_waiter_with_clients,

��	���r%cCs$|�d�}t|t�rd|vrdSdS)N�Error�CodeTF)�get�
isinstance�dict)�response�errorrrr�is_valid_waiter_errorPs
r-c@�eZdZdd�Zdd�ZdS)rcCs
||_dSr	)�_client_method)r�
client_methodrrr�__init__Xs
z"NormalizedOperationMethod.__init__c
Ks>z	|jdi|��WSty}z	|jWYd}~Sd}~ww)Nr)r/rr+)rr
�errr�__call__[s��z"NormalizedOperationMethod.__call__N)�__name__�
__module__�__qualname__r1r3rrrrrWsrc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�WaiterModel�cCs@|d|_|�dd�}|�|�||_tt|d����|_dS)a�

        Note that the WaiterModel takes ownership of the waiter_config.
        It may or may not mutate the waiter_config.  If this is a concern,
        it is best to make a copy of the waiter config before passing it to
        the WaiterModel.

        :type waiter_config: dict
        :param waiter_config: The loaded waiter config
            from the <service>*.waiters.json file.  This can be
            obtained from a botocore Loader object as well.

        �waiters�version�unknownN)�_waiter_configr(�_verify_supported_versionr:�list�sorted�keys�waiter_names)r�
waiter_configr:rrrr1es


zWaiterModel.__init__cCs"||jkrtd|j|fd��dS)Nz^Unsupported waiter version, supported version must be: %s, but version of waiter config is: %s��	error_msg)�SUPPORTED_VERSIONr)rr:rrrr=}s
���z%WaiterModel._verify_supported_versioncCs0z
|j|}Wt|�Stytd|��w)NzWaiter does not exist: %s)r<�KeyError�
ValueError�SingleWaiterConfig)rrr rrrr�s��zWaiterModel.get_waiterN)r4r5r6rEr1r=rrrrrr7bs

r7c@s$eZdZdZdd�Zedd��ZdS)rHz�Represents the waiter configuration for a single waiter.

    A single waiter is considered the configuration for a single
    value associated with a named waiter (i.e TableExists).

    cCs6||_|�dd�|_|d|_|d|_|d|_dS)N�description�r�delay�maxAttempts)�_configr(rIrrK�max_attempts)rr rrrr1�s


zSingleWaiterConfig.__init__cCs*g}|jdD]}t|�}|�|�q|S)N�	acceptors)rM�AcceptorConfig�append)rrO�acceptor_config�acceptorrrrrO�s
zSingleWaiterConfig.acceptorsN)r4r5r6rr1�propertyrOrrrrrH�s

rHc@sPeZdZdd�Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�ZdS)rPcCs8|d|_|d|_|d|_|�d�|_|��|_dS)N�state�matcher�expected�argument)rUrVrWr(rX�_create_matcher_func�matcher_func)r�configrrrr1�s



zAcceptorConfig.__init__cCs�|jdkr
d�|j|j�S|jdkrd|j|jfS|jdkr'd|j|jfS|jdkr1d|jS|jd	kr;d
|jSd|jS)N�pathz2For expression "{}" we matched expected path: "{}"�pathAllz;For expression "%s" all members matched excepted path: "%s"�pathAnyz@For expression "%s" we matched expected path: "%s" at least once�statusz%Matched expected HTTP status code: %sr,z'Matched expected service error code: %sz,No explanation for unknown waiter type: "%s")rV�formatrXrW�rrrr�explanation�s*
�

��

��



�zAcceptorConfig.explanationcCsj|jdkr	|��S|jdkr|��S|jdkr|��S|jdkr$|��S|jdkr-|��Std|jd��)Nr\r]r^r_r,zUnknown acceptor: %srC)rV�_create_path_matcher�_create_path_all_matcher�_create_path_any_matcher�_create_status_matcher�_create_error_matcherrrarrrrY�s
	



�z#AcceptorConfig._create_matcher_funcc�$t�|j��|j���fdd�}|S)Ncst|�rdS��|��kSr	)r-�search�r+�rW�
expressionrr�acceptor_matches�sz=AcceptorConfig._create_path_matcher.<locals>.acceptor_matches��jmespath�compilerXrW�rrmrrkrrc�sz#AcceptorConfig._create_path_matchercrh)NcsDt|�rdS��|�}t|t�r|sdS|D]	}|�krdSqdS�NFT�r-rir)r>�r+�result�elementrkrrrm��
�zAAcceptorConfig._create_path_all_matcher.<locals>.acceptor_matchesrnrqrrkrrd��z'AcceptorConfig._create_path_all_matchercrh)NcsDt|�rdS��|�}t|t�r|sdS|D]	}|�krdSqdSrrrsrtrkrrrmrwzAAcceptorConfig._create_path_any_matcher.<locals>.acceptor_matchesrnrqrrkrrerxz'AcceptorConfig._create_path_any_matcherc�|j��fdd�}|S)Ncs|�di��d�}|�kS)N�ResponseMetadata�HTTPStatusCode�r()r+�status_code�rWrrrms�z?AcceptorConfig._create_status_matcher.<locals>.acceptor_matchesr~rqrr~rrf�	z%AcceptorConfig._create_status_matchercry)Ncs|�di��dd��kS)Nr&r'rJr|rjr~rrrm*sz>AcceptorConfig._create_error_matcher.<locals>.acceptor_matchesr~rqrr~rrg'rz$AcceptorConfig._create_error_matcherN)r4r5r6r1rTrbrYrcrdrerfrgrrrrrP�s
rPc@r.)r
cCs||_||_||_dS)a�

        :type name: string
        :param name: The name of the waiter

        :type config: botocore.waiter.SingleWaiterConfig
        :param config: The configuration for the waiter.

        :type operation_method: callable
        :param operation_method: A callable that accepts **kwargs
            and returns a response.  For example, this can be
            a method from a botocore client.

        N)�_operation_method�namer[)rr�r[r"rrrr17s
zWaiter.__init__cKs,t|jj�}d}|�di�}|�d|jj�}|�d|jj�}d}d}	|jdi|��}	|d7}|D]}
|
�|	�r?|
}|
j	}nq1t
|	�r\t|jd|	d	�d
d�|	d	�dd�f|	d
��|dkrgt
�d�dS|dkrxd|
j}t|j||	d
��||kr�|dur�d}nd|
j}t|j||	d
��t�|�q#)N�waiting�WaiterConfig�Delay�MaxAttemptsrTrzAn error occurred (%s): %sr&r'�Unknown�Message)r��reason�
last_response�successz3Waiting complete, waiter matched the success state.�failurez/Waiter encountered a terminal failure state: %szMax attempts exceededz4Max attempts exceeded. Previously accepted state: %sr)r>r[rO�popr(rKrNr�rZrUr-rr��logger�debugrb�time�sleep)rr
rO�
current_stater[�sleep_amountrN�last_matched_acceptor�num_attemptsr+rSr�rrrrLsl
����	������
�zWaiter.waitN)r4r5r6r1rrrrrr
6sr
)�loggingr�ro�botocore.docs.docstringr�botocore.utilsrrJr�
exceptionsrrr�	getLoggerr4r�r%r-rr7rHrPr
rrrr�<module>s 
5-