HEX
Server: nginx/1.24.0
System: Linux webserver 6.8.0-85-generic #85-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 18 15:26:59 UTC 2025 x86_64
User: wpuser (1002)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/botocore/__pycache__/paginate.cpython-312.pyc
�

P��ek����ddlZddlZddlZddlmZddlZddlmZddlm	Z	m
Z
eje�Z
Gd�d�ZGd�d�ZGd	�d
�ZGd�d�ZGd
�d�ZGd�d�Zy)�N)�tee)�PaginationError)�merge_dicts�set_value_from_jmespathc�.�eZdZdZd�Zd�Zd�Zd�Zd�Zy)�TokenEncoderabEncodes dictionaries into opaque strings.

    This for the most part json dumps + base64 encoding, but also supports
    having bytes in the dictionary in addition to the types that json can
    handle by default.

    This is intended for use in encoding pagination tokens, which in some
    cases can be complex structures and / or contain bytes.
    c��	tj|�}tj|jd��jd�S#ttf$r2|j	|g�\}}||d<tj|�}Y�swxYw)a.Encodes a dictionary to an opaque string.

        :type token: dict
        :param token: A dictionary containing pagination information,
            particularly the service pagination token(s) but also other boto
            metadata.

        :rtype: str
        :returns: An opaque string
        �boto_encoded_keys�utf-8)	�json�dumps�	TypeError�UnicodeDecodeError�_encode�base64�	b64encode�encode�decode)�self�token�json_string�
encoded_token�encoded_keyss     �3/usr/lib/python3/dist-packages/botocore/paginate.pyrzTokenEncoder.encode&s���
	4��*�*�U�+�K����� 2� 2�7� ;�<�C�C�G�L�L���-�.�		4�*.�,�,�u�b�*A�'�M�<�2>�M�-�.��*�*�]�3�K�		4�s�A
�
>B�
Bc���t|t�r|j||�St|t�r|j	||�St|t
�r|j
||�S|gfS)z@Encode bytes in given data, keeping track of the path traversed.)�
isinstance�dict�_encode_dict�list�_encode_list�bytes�
_encode_bytes�r�data�paths   rrzTokenEncoder._encodeCsb���d�D�!��$�$�T�4�0�0�
��d�
#��$�$�T�4�0�0�
��e�
$��%�%�d�D�1�1���8�O�c��g}g}t|�D]B\}}||gz}|j||�\}}	|j|�|j|	��D||fS)z@Encode any bytes in a list, noting the index of what is encoded.)�	enumerater�append�extend)
rr$r%�new_data�encoded�i�value�new_path�	new_value�new_encodeds
          rr zTokenEncoder._encode_listNsh������!�$��	(�H�A�u��q�c�z�H�%)�\�\�%��%B�"�I�{��O�O�I�&��N�N�;�'�		(�
�� � r&c��i}g}|j�D]6\}}||gz}|j||�\}}	|||<|j|	��8||fS)z@Encode any bytes in a dict, noting the index of what is encoded.)�itemsrr*)
rr$r%r+r,�keyr.r/r0r1s
          rrzTokenEncoder._encode_dictYsg�������*�*�,�	(�J�C���s�e�|�H�%)�\�\�%��%B�"�I�{�%�H�S�M��N�N�;�'�		(�
�� � r&c�P�tj|�jd�|gfS)zBase64 encode a byte string.r)rrrr#s   rr"zTokenEncoder._encode_bytesds%������%�,�,�W�5��v�=�=r&N)	�__name__�
__module__�__qualname__�__doc__rrr rr"�r&rrrs!���M�:	�	!�	!�>r&rc�(�eZdZdZd�Zd�Zd�Zd�Zy)�TokenDecoderz�Decodes token strings back into dictionaries.

    This performs the inverse operation to the TokenEncoder, accepting
    opaque strings and decoding them into a useable form.
    c���tj|jd��jd�}t	j
|�}|j
dd�}|�|S|j||�S)adDecodes an opaque string to a dictionary.

        :type token: str
        :param token: A token string given by the botocore pagination
            interface.

        :rtype: dict
        :returns: A dictionary containing pagination information,
            particularly the service pagination token(s) but also other boto
            metadata.
        rr
N)r�	b64decoderrr�loads�pop�_decode)rrr�
decoded_tokenrs     rrzTokenDecoder.decodepsh���&�&�u�|�|�G�'<�=�D�D�W�M���
�
�;�/�
�%�(�(�)<�d�C���� � ��<�<�
�|�<�<r&c��|D]K}|j||�}tj|jd��}|j	|||��M|S)z&Find each encoded value and decode it.r)�	_path_getrr>r�	_path_set)rrrr4r,�decodeds      rrAzTokenDecoder._decode�sQ���	0�C��n�n�U�C�0�G��&�&�w�~�~�g�'>�?�G��N�N�5�#�w�/�	0��r&c�"�|}|D]}||}�	|S)z�Return the nested data at the given path.

        For instance:
            data = {'foo': ['bar', 'baz']}
            path = ['foo', 0]
            ==> 'bar'
        r:)rr$r%�d�steps     rrDzTokenDecoder._path_get�s&��
���	�D��$��A�	��r&c�>�|j||dd�}|||d<y)z�Set the value of a key in the given data.

        Example:
            data = {'foo': ['bar', 'baz']}
            path = ['foo', 1]
            value = 'bin'
            ==> data = {'foo': ['bar', 'bin']}
        N���)rD)rr$r%r.�	containers     rrEzTokenDecoder._path_set�s(���N�N�4��c�r��3�	�#�	�$�r�(�r&N)r6r7r8r9rrArDrEr:r&rr<r<is���=�.��"
$r&r<c��eZdZd�Zd�Zy)�PaginatorModelc��|d|_y)N�
pagination)�_paginator_config)r�paginator_configs  r�__init__zPaginatorModel.__init__�s��!1�,�!?��r&c�\�	|j|}|S#t$rtd|z��wxYw)Nz*Paginator for operation does not exist: %s)rQ�KeyError�
ValueError)r�operation_name�single_paginator_configs   r�
get_paginatorzPaginatorModel.get_paginator�sF��	�&*�&<�&<�^�&L�#�
'�&��	�	��<�~�M��
�	�s��+N)r6r7r8rSrYr:r&rrNrN�s
��@�'r&rNc���eZdZdZd�Zed��Zed��Zejd��Zed��Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�PageIteratorz�An iterable object to paginate API results.
    Please note it is NOT a python iterator.
    Use ``iter`` to wrap this as a generator.
    c��||_||_||_||_||_||_||_|	|_|
|_||_	d|_
||_i|_t�|_t�|_y�N)�_method�_input_token�
_output_token�
_more_results�_result_keys�
_max_items�
_limit_key�_starting_token�
_page_size�
_op_kwargs�
_resume_token�_non_aggregate_key_exprs�_non_aggregate_partr�_token_encoderr<�_token_decoder)r�method�input_token�output_token�more_results�result_keys�non_aggregate_keys�	limit_key�	max_items�starting_token�	page_size�	op_kwargss            rrSzPageIterator.__init__�s{�����'���)���)���'���#���#���-���#���#���!���(:��%�#%�� �*�n���*�n��r&c��|jSr]�rb�rs rrqzPageIterator.result_keys����� � � r&c��|jS)z&Token to specify to resume pagination.)rhrzs r�resume_tokenzPageIterator.resume_token�s���!�!�!r&c�>�t|t�std|z��d|vrt|jdgz�}nt|j�}t|j��}||k(r!|jj|�|_ytd|z��)N�Bad starting token: %s�boto_truncate_amount)	rrrV�sortedr_�keysrkrrh)rr.�
token_keys�	dict_keyss    rr}zPageIterator.resume_token�s����%��&��5��=�>�>�!�U�*��� 1� 1�5K�4L� L�M�J��� 1� 1�2�J��5�:�:�<�(�	���"�!%�!4�!4�!;�!;�E�!B�D���5��=�>�>r&c��|jSr])rjrzs r�non_aggregate_partzPageIterator.non_aggregate_part�s���'�'�'r&c#�xK�|j}d}|jD�cic]}|d��}}|j�|j�d}d}d}|jd}d}|j|�	|j
|�}	|j|	�}
|r3|j�|j|
||�}d}|j|
�nd}|j|
�}|�g}t|�}d}
|j�||z|jz
}
|
dkDr|j|
||
||�|	��y|	��||z
}|j|
�}td�|j!�D��ry|j�||jk(r||_y|�||k(rd|��}t%|���|j'||�|}��Dcc}w�w)NrTFc3�$K�|]}|du���
y�wr]r:)�.0�ts  r�	<genexpr>z(PageIterator.__iter__.<locals>.<genexpr>5s����>�Q�q�D�y�>�s�z(The same next token was received twice: ��message)rgr_re�_parse_starting_tokenrq�_inject_starting_params�
_make_request�_extract_parsed_response�_handle_first_request� _record_non_aggregate_key_values�search�lenrc�_truncate_response�_get_next_token�all�valuesr}r�_inject_token_into_kwargs)r�current_kwargs�previous_next_tokenr4�
next_token�total_items�
first_request�primary_result_key�starting_truncation�response�parsed�current_response�num_current_response�truncate_amountr�s               r�__iter__zPageIterator.__iter__�s��������"��+/�+<�+<�=�C�c�4�i�=�
�=����+�
�3�3�5�a�8�J����
�!�-�-�a�0�����$�$�^�4���)�)�.�9�H��2�2�8�<�F���'�'�3�*.�*D�*D�� 2�4G�+�'�!&�
��5�5�f�=�
'(�#�1�8�8��@���'�#%� �#&�'7�#8� ��O����*��"6�6����H� ���"��'�'��&�#�'���������3�3��!�1�1�&�9�
��>�*�*;�*;�*=�>�>���O�O�/�#�t���6�)3�D�%��'�3�+�z�9�"�",��/��*�'�:�:��.�.�~�z�J�&0�#�{��>�s�F:�
F5�FF:c#�K�tj|�}|D]2}|j|�}t|t�r|Ed{����/|���4y7��w)a�Applies a JMESPath expression to a paginator

        Each page of results is searched using the provided JMESPath
        expression. If the result is not a list, it is yielded
        directly. If the result is a list, each element in the result
        is yielded individually (essentially implementing a flatmap in
        which the JMESPath search is the mapping function).

        :type expression: str
        :param expression: JMESPath expression to apply to each page.

        :return: Returns an iterator that yields the individual
            elements of applying a JMESPath expression to each page of
            results.
        N)�jmespath�compiler�rr)r�
expression�compiled�page�resultss     rr�zPageIterator.searchKsT���� �#�#�J�/���	�D��o�o�d�+�G��'�4�(�"�"�"��
�
	�#�s�AA�A�
Ac�&�|jdi|��S)Nr:)r^)rr�s  rr�zPageIterator._make_requestds���t�|�|�-�n�-�-r&c��|Sr]r:)rr�s  rr�z%PageIterator._extract_parsed_responsegs���r&c��i}|jD]*}|j|�}t||j|��,||_yr])rir�rr�rj)rr�rrr��results     rr�z-PageIterator._record_non_aggregate_key_valuesjsL�����7�7�	�J��&�&�x�0�F�#�"�J�$9�$9�6�
�	�
$6�� r&c��|j�%|j�d}|j||�|j�|j||j<yy)Nr)rer�r�rfrd)rrwr�s   rr�z$PageIterator._inject_starting_paramsssX�����+��3�3�5�a�8�J��*�*�9�j�A��?�?�&�*.���I�d�o�o�&�'r&c�^�|j�D]\}}|�|dk7r|||<�||vs�||=�y)N�None)r3)rrwr��namers     rr�z&PageIterator._inject_token_into_kwargs�sB��%�+�+�-�	$�K�D�%��!����"'�	�$����"��d�O�		$r&c��|j�d}|j|�}t|ttf�r||d}nd}t||j|�|jD]q}||k(r�	|j|�}t|t�rg}n.t|t�rd}nt|ttf�rd}nd}t||j|��s|S)N��r)
r�r�rr�strrr�rq�int�float)	rr�r�r��all_datar$r�sample�empty_values	         rr�z"PageIterator._handle_first_request�s���
#�8�8�:�1�=��%�,�,�V�4���h��s��,��/�0�1�D��D���(:�(E�(E�t�L��%�%�	K�E��*�*���\�\�&�)�F��&�$�'� ���F�C�(� ���F�S�%�L�1���"��#�F�E�,<�,<�k�J�	K�#�"r&c��|j|�}|�g}t|�|z
}|d|}t||j|�||z|d<||_y)Nr�)r�r�rr�r})	rr�r�r�r�r��original�amount_to_keep�	truncateds	         rr�zPageIterator._truncate_response�so��&�,�,�V�4�����H��X���8���_�n�-�	���&�1�1�9�	
�
�0�0�	�)�*�'��r&c���|j�|jj|�siSi}t|j|j�D]#\}}|j|�}|r|||<�d||<�%|Sr])rar��zipr`r_)rr��next_tokensro�	input_keyr�s      rr�zPageIterator._get_next_token�s������)��%�%�,�,�V�4��	���'*����� 1� 1�(
�		.�#�L�)�&�,�,�V�4�J��)3��I�&�)-��I�&�		.��r&c��t|t|j��}t||j�D��cgc]\}}t	||���c}}Scc}}wr])rr�rqr��ResultKeyIterator)r�teed_resultsr-�
result_keys    r�result_key_iterszPageIterator.result_key_iters�sS���4��T�%5�%5�!6�7��"%�\�4�3C�3C�!D�
���:�
�a��,�
�	
��
s�Ac��i}|D]�}|}t|t�rt|�dk(r|d}|jD]�}|j	|�}|��|j	|�}|�t||j|��Bt|t�r|j|��dt|tttf�s��t||j||z�����t||j�|j�|j|d<|S)N�r��	NextToken)r�tupler�rqr�rr�rr*r�r�r�rr�r})r�complete_resultr�r��result_expression�result_value�existing_values       r�build_full_resultzPageIterator.build_full_result�s�����)	�H��D��(�E�*�s�8�}��/A���{��
&*�%5�%5�
�!� 1�7�7��=���'��!2�!9�!9�/�!J��!�)�+�'�)�4�4�$��
��l�D�1�"�)�)�,�7���s�E�3�.?�@�+�'�)�4�4�&��5��1
�)	�T	�O�T�%<�%<�=����(�+/�+<�+<�O�K�(��r&c��|j�y|j}	|jj|�}d}d|vr|jd�}|d=||fS#tt
f$r|j
�\}}Y||fSwxYw)Nrr�)rerlr�getrVr� _parse_starting_token_deprecated)rr��indexs   rr�z"PageIterator._parse_starting_tokens������'���)�)�
�	H��,�,�3�3�J�?�J��E�%��3�"���'=�>���5�6��5� � ���I�&�	H� $� E� E� G��J���5� � �	H�s�5A�"A<�;A<c���tjd|jz�|j�y|jjd�}g}d}t	|�t	|j
�dzk(r	t
|j��}|D]*}|dk(r|jd��|j|��,|j|�|fS#t$r|jg}Y�ZwxYw)z|
        This handles parsing of old style starting tokens, and attempts to
        coerce them into the new style.
        zCAttempting to fall back to old starting token parser. For token: %sN�___rr�r�)�log�debugre�splitr�r_r�r@rVr)�"_convert_deprecated_starting_token)r�partsr�r��parts     rr�z-PageIterator._parse_starting_token_deprecateds���
	�	�	�
��.�.�
/�	
����'���$�$�*�*�5�1���
����u�:��T�.�.�/�!�3�3�
/��E�I�I�K�(���	(�D��v�~��!�!�$�'��!�!�$�'�		(�
�6�6�z�B�E�I�I���
/��-�-�.��
/�s�4C�C(�'C(c�6�t|�}t|j�}||kDrtd|jz��||kr9tjd�t
||z
�D]}|jd��tt|j|��S)zb
        This attempts to convert a deprecated starting token into the new
        style.
        rzaOld format starting token does not contain all input tokens. Setting the rest, in order, as None.N)
r�r_rVrer�r��ranger)rr�)r�deprecated_token�len_deprecated_token�len_input_tokenr-s     rr�z/PageIterator._convert_deprecated_starting_token<s���
 #�#3�4���d�/�/�0���/�1��5��8L�8L�L�M�M�
!�O�
3��I�I�?�
��?�-A�A�B�
.�� �'�'��-�
.��C��)�)�+;�<�=�=r&N)r6r7r8r9rS�propertyrqr}�setterr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r:r&rr[r[�s����
-�<�!��!��"��"����
?��
?��(��(�M1�^�2.��6�9�$�#�<'�@�"
�/�b!� J�<>r&r[c�V�eZdZeZd�Zed��Zd�Zd�Z	d�Z
d�Zd�Zd�Z
d	�Zd
�Zy)�	Paginatorc��||_||_||_|j|j�|_|j|j�|_|j|j�|_|j|j�|_
|j|j�|_|j|j�|_yr])�_modelr^�_pagination_cfg�_get_output_tokensr`�_get_input_tokensr_�_get_more_results_tokenra�_get_non_aggregate_keys�_non_aggregate_keys�_get_result_keysrb�_get_limit_keyrd)rrm�pagination_config�models    rrSzPaginator.__init__Rs���������0���!�4�4�T�5I�5I�J��� �2�2�4�3G�3G�H���!�9�9�$�:N�:N�O���#'�#?�#?�� � �$
�� �!�1�1�$�2F�2F�G����-�-�d�.B�.B�C��r&c��|jSr]ryrzs rrqzPaginator.result_keys_r{r&c��g}|jdg�D]&}|jtj|���(|S)Nrr)r�r)r�r�)r�configr�r4s    rr�z!Paginator._get_non_aggregate_keyscs>�����:�:�2�B�7�	/�C��K�K��(�(��-�.�	/��r&c��g}|d}t|t�s|g}|D]&}|jtj|���(|S)Nro)rrr)r�r�)rr��outputros    rr�zPaginator._get_output_tokensisM�����n�-���,��-�(�>�L�"�	4�F��M�M�(�*�*�6�2�3�	4��
r&c�J�|jd}t|t�s|g}|S)Nrn)r�rr)rr�rns   rr�zPaginator._get_input_tokensrs)���*�*�=�9���+�t�,�&�-�K��r&c�T�|jd�}|�tj|�Sy)Nrp)r�r�r�)rr�rps   rr�z!Paginator._get_more_results_tokenxs,���z�z�.�1���#��#�#�L�1�1�$r&c��|jd�}|�7t|t�s|g}|D�cgc]}tj|���}}|Sycc}w)Nr�)r�rrr�r�)rr�r��rks    rr�zPaginator._get_result_keys}sV���Z�Z��-�
��!��j�$�/�(�\�
�9C�D�2�(�*�*�2�.�D�J�D���	"��Es�Ac�$�|jd�S)Nrs)r�)rr�s  rr�zPaginator._get_limit_key�s���z�z�+�&�&r&c
��|j|�}|j|j|j|j|j
|j|j|j|d|d|d|�S)z�Create paginator object for an operation.

        This returns an iterable object.  Iterating over
        this object will yield a single page of a response
        at a time.

        �MaxItems�
StartingToken�PageSize)	�_extract_paging_params�PAGE_ITERATOR_CLSr^r_r`rarbr�rd)r�kwargs�page_paramss   r�paginatezPaginator.paginate�s}���1�1�&�9���%�%��L�L��������������$�$��O�O��
�#���(��
�#��
�	
r&c���|jdi�}|jdd�}|�t|�}|jdd�}|��|j�t	d���|j
jj}|j|j�}|jdk(rt|t�st|�}nt|�}||jdd�|d�S)	N�PaginationConfigrrzTPageSize parameter is not supported for the pagination interface for this operation.r��stringr)rrr)r@r�r�rdrr��input_shape�members�	type_namerr�)rrr�rtrv�
input_members�limit_key_shapes       rrz Paginator._extract_paging_params�s���"�J�J�'9�2�>��%�)�)�*�d�;�	�� ��I��I�%�)�)�*�d�;�	�� ����&�%�?���!�K�K�3�3�;�;�M�+�/�/����@�O��(�(�H�4�!�)�S�1� #�I��I��	�N�	�!�.�2�2�?�D�I�!�
�	
r&N)r6r7r8r[rrSr�rqr�r�r�r�r�r�r	rr:r&rr�r�OsJ��$��D��!��!����2�
�'�
�.
r&r�c��eZdZdZd�Zd�Zy)r�a�Iterates over the results of paginated responses.

    Each iterator is associated with a single result key.
    Iterating over this object will give you each element in
    the result key list.

    :param pages_iterator: An iterator that will give you
        pages of results (a ``PageIterator`` class).
    :param result_key: The JMESPath expression representing
        the result key.

    c� �||_||_yr])�_pages_iteratorr�)r�pages_iteratorr�s   rrSzResultKeyIterator.__init__�s��-���$��r&c#�K�|jD]+}|jj|�}|�g}|Ed{����-y7��wr])rr�r�)rr�r�s   rr�zResultKeyIterator.__iter__�sG�����(�(�	�D��o�o�,�,�T�2�G��������		�
�s�4A�>�AN)r6r7r8r9rSr�r:r&rr�r��s���%�r&r�)rr�logging�	itertoolsrr��botocore.exceptionsr�botocore.utilsrr�	getLoggerr6r�rr<rNr[r�r�r:r&r�<module>rsv�������/�?��g����!��K>�K>�\A$�A$�H'�'�Q>�Q>�hg
�g
�T�r&