https://t.me/RX1948
Server : nginx/1.24.0
System : Linux ip-172-31-33-48 6.14.0-1011-aws #11~24.04.1-Ubuntu SMP Fri Aug 1 02:07:25 UTC 2025 x86_64
User : www-data ( 33)
PHP Version : 8.3.6
Disable Function : NONE
Directory :  /lib/python3/dist-packages/botocore/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/botocore/__pycache__/eventstream.cpython-312.pyc
�

P��e�O��<�dZddlmZddlmZddlmZdZdZdZ	Gd�d	e
�ZGd
�de�ZGd�d
e�Z
Gd�de�ZGd�de�ZGd�de�ZGd�d�Zd"d�ZGd�d�ZGd�d�ZGd�d�ZGd�d�ZGd�d �Zy!)#zBinary Event Stream Decoding �)�crc32)�unpack)�EventStreamError�iic��eZdZdZy)�ParserErrorz,Base binary flow encoding parsing exception.N)�__name__�
__module__�__qualname__�__doc__���6/usr/lib/python3/dist-packages/botocore/eventstream.pyrrs��6�rrc�"��eZdZdZ�fd�Z�xZS)�DuplicateHeaderz$Duplicate header found in the event.c�.��d|z}t�|�|�y)NzDuplicate header present: "%s"��super�__init__)�self�header�message�	__class__s   �rrzDuplicateHeader.__init__#s���2�V�;��
����!r�r	r
rrr�
__classcell__�rs@rrr s���.�"�"rrc�"��eZdZdZ�fd�Z�xZS)�InvalidHeadersLengthz*Headers length is longer than the maximum.c�P��dj|t�}t�|�
|�y)Nz.Header length of {} exceeded the maximum of {})�format�_MAX_HEADERS_LENGTHrr�r�lengthrrs   �rrzInvalidHeadersLength.__init__+s(���B�I�I���
��	����!rrrs@rrr(����4�"�"rrc�"��eZdZdZ�fd�Z�xZS)�InvalidPayloadLengthz*Payload length is longer than the maximum.c�P��dj|t�}t�|�
|�y)Nz/Payload length of {} exceeded the maximum of {})r �_MAX_PAYLOAD_LENGTHrrr"s   �rrzInvalidPayloadLength.__init__6s(���C�J�J���
��	����!rrrs@rr&r&3r$rr&c�"��eZdZdZ�fd�Z�xZS)�ChecksumMismatchz8Calculated checksum did not match the expected checksum.c�H��dj||�}t�|�	|�y)Nz9Checksum mismatch: expected 0x{:08x}, calculated 0x{:08x})r rr)r�expected�
calculatedrrs    �rrzChecksumMismatch.__init__As+���G�N�N���
�	�	����!rrrs@rr*r*>s���B�"�"rr*c�"��eZdZdZ�fd�Z�xZS)�NoInitialResponseErrorz�An event of type initial-response was not received.

    This exception is raised when the event stream produced no events or
    the first event in the stream was not of the initial-response type.
    c�(��d}t�|�|�y)Nz0First event was not of the initial-response typer)rrrs  �rrzNoInitialResponseError.__init__Rs���D��
����!rrrs@rr/r/Ks����"�"rr/c��eZdZdZdZdZdZdZdZdZ	dZ
d	Zeeed
�Ze
d��Ze
d��Ze
d
��Ze
d��Ze
d��Ze
d��Ze
d��Ze
d��Ze
dd��Ze
dd��Ze
d��Ze
d��Zy)�DecodeUtilsz�Unpacking utility functions used in the decoder.

    All methods on this class take raw bytes and return  a tuple containing
    the value parsed from the bytes and the number of bytes consumed to parse
    that value.
    z!Bz!Hz!Iz!bz!hz!iz!qz!III)���c��y)aThis method consumes none of the provided bytes and returns True.

        :type data: bytes
        :param data: The bytes to parse from. This is ignored in this method.

        :rtype: tuple
        :rtype: (bool, int)
        :returns: The tuple (True, 0)
        )Trr
��datas r�unpack_truezDecodeUtils.unpack_trueos��rc��y)aThis method consumes none of the provided bytes and returns False.

        :type data: bytes
        :param data: The bytes to parse from. This is ignored in this method.

        :rtype: tuple
        :rtype: (bool, int)
        :returns: The tuple (False, 0)
        )Frr
r7s r�unpack_falsezDecodeUtils.unpack_false|s��rc�J�ttj|dd�d}|dfS)z�Parse an unsigned 8-bit integer from the bytes.

        :type data: bytes
        :param data: The bytes to parse from.

        :rtype: (int, int)
        :returns: A tuple containing the (parsed integer value, bytes consumed)
        Nr3r)rr2�UINT8_BYTE_FORMAT�r8�values  r�unpack_uint8zDecodeUtils.unpack_uint8�s*���{�4�4�d�2�A�h�?��B���a�x�rc�J�ttj|dd�d}|dfS)z�Parse an unsigned 32-bit integer from the bytes.

        :type data: bytes
        :param data: The bytes to parse from.

        :rtype: (int, int)
        :returns: A tuple containing the (parsed integer value, bytes consumed)
        Nr5r)rr2�UINT32_BYTE_FORMATr>s  r�
unpack_uint32zDecodeUtils.unpack_uint32�s*���{�5�5�t�B�Q�x�@��C���a�x�rc�J�ttj|dd�d}|dfS)z�Parse a signed 8-bit integer from the bytes.

        :type data: bytes
        :param data: The bytes to parse from.

        :rtype: (int, int)
        :returns: A tuple containing the (parsed integer value, bytes consumed)
        Nr3r)rr2�INT8_BYTE_FORMATr>s  r�unpack_int8zDecodeUtils.unpack_int8�s*���{�3�3�T�"�1�X�>�q�A���a�x�rc�J�ttj|dd�d}|dfS)aParse a signed 16-bit integer from the bytes.

        :type data: bytes
        :param data: The bytes to parse from.

        :rtype: tuple
        :rtype: (int, int)
        :returns: A tuple containing the (parsed integer value, bytes consumed)
        Nr4r)rr2�INT16_BYTE_FORMATr>s  r�unpack_int16zDecodeUtils.unpack_int16��*���{�4�4�d�2�A�h�?��B���a�x�rc�J�ttj|dd�d}|dfS)aParse a signed 32-bit integer from the bytes.

        :type data: bytes
        :param data: The bytes to parse from.

        :rtype: tuple
        :rtype: (int, int)
        :returns: A tuple containing the (parsed integer value, bytes consumed)
        Nr5r)rr2�INT32_BYTE_FORMATr>s  r�unpack_int32zDecodeUtils.unpack_int32�rJrc�J�ttj|dd�d}|dfS)aParse a signed 64-bit integer from the bytes.

        :type data: bytes
        :param data: The bytes to parse from.

        :rtype: tuple
        :rtype: (int, int)
        :returns: A tuple containing the (parsed integer value, bytes consumed)
        N�r)rr2�INT64_BYTE_FORMATr>s  r�unpack_int64zDecodeUtils.unpack_int64�rJrc�h�tj|}t||d|�d}||z}|||}||fS)a�Parse a variable length byte array from the bytes.

        The bytes are expected to be in the following format:
            [ length ][0 ... length bytes]
        where length is an unsigned integer represented in the smallest number
        of bytes to hold the maximum length of the array.

        :type data: bytes
        :param data: The bytes to parse from.

        :type length_byte_size: int
        :param length_byte_size: The byte size of the preceding integer that
        represents the length of the array. Supported values are 1, 2, and 4.

        :rtype: (bytes, int)
        :returns: A tuple containing the (parsed byte array, bytes consumed).
        Nr)r2�UINT_BYTE_FORMATr)r8�length_byte_size�uint_byte_formatr#�	bytes_end�array_bytess      r�unpack_byte_arrayzDecodeUtils.unpack_byte_array�sT��&'�7�7�8H�I���(�$�/@�0@�*A�B�1�E���-�-�	��+�I�6���I�%�%rc�Z�tj||�\}}|jd�|fS)a�Parse a variable length utf-8 string from the bytes.

        The bytes are expected to be in the following format:
            [ length ][0 ... length bytes]
        where length is an unsigned integer represented in the smallest number
        of bytes to hold the maximum length of the array and the following
        bytes are a valid utf-8 string.

        :type data: bytes
        :param bytes: The bytes to parse from.

        :type length_byte_size: int
        :param length_byte_size: The byte size of the preceding integer that
        represents the length of the array. Supported values are 1, 2, and 4.

        :rtype: (str, int)
        :returns: A tuple containing the (utf-8 string, bytes consumed).
        zutf-8)r2rX�decode)r8rTrW�consumeds    r�unpack_utf8_stringzDecodeUtils.unpack_utf8_string�s7��(!,� =� =��"�!
���X��!�!�'�*�H�4�4rc��|dddfS)z�Parse a 16-byte uuid from the bytes.

        :type data: bytes
        :param data: The bytes to parse from.

        :rtype: (bytes, int)
        :returns: A tuple containing the (uuid bytes, bytes consumed).
        N�r
r7s r�unpack_uuidzDecodeUtils.unpack_uuids���C�R�y�"�}�rc�B�ttj|�tfS)a�Parse the prelude for an event stream message from the bytes.

        The prelude for an event stream message has the following format:
            [total_length][header_length][prelude_crc]
        where each field is an unsigned 32-bit integer.

        :rtype: ((int, int, int), int)
        :returns: A tuple of ((total_length, headers_length, prelude_crc),
        consumed)
        )rr2�PRELUDE_BYTE_FORMAT�_PRELUDE_LENGTHr7s r�unpack_preludezDecodeUtils.unpack_preludes���{�6�6��=��O�OrN)r4)r	r
rrr=�UINT16_BYTE_FORMATrBrErHrLrPrarS�staticmethodr9r;r@rCrFrIrMrQrXr\r_rcr
rrr2r2Ws>����������������� ��������
��
��
��
��
��
��
��
��
��
��������������&��&�0�5��5�0�	��	��P��Prr2c�D�t||�dz}||k7rt||��y)Nl��)rr*)r8�checksum�crc�computed_checksums    r�_validate_checksumrj's2���d�C�(�:�5���$�$��x�):�;�;�%rc�F�eZdZdZd�Zed��Zed��Zed��Zy)�MessagePreludez2Represents the prelude of an event stream message.c�.�||_||_||_y�N)�total_length�headers_lengthrh)rrorprhs    rrzMessagePrelude.__init__2s��(���,�����rc�H�|j|jz
tz
dz
S)z�Calculates the total payload length.

        The extra minus 4 bytes is for the message CRC.

        :rtype: int
        :returns: The total payload length.
        r5)rorprb�rs r�payload_lengthzMessagePrelude.payload_length7s%��� � �4�#6�#6�6��H�1�L�Lrc� �|jdz
S)a	Calculates the byte offset for the end of the message payload.

        The extra minus 4 bytes is for the message CRC.

        :rtype: int
        :returns: The byte offset from the beginning of the event stream
        message to the end of the payload.
        r5)rorrs r�payload_endzMessagePrelude.payload_endBs��� � �1�$�$rc�(�t|jzS)z�Calculates the byte offset for the end of the message headers.

        :rtype: int
        :returns: The byte offset from the beginning of the event stream
        message to the end of the headers.
        )rbrprrs r�headers_endzMessagePrelude.headers_endNs����!4�!4�4�4rN)	r	r
rrr�propertyrsrurwr
rrrlrl/sH��<��
�M��M��	%��	%��5��5rrlc��eZdZdZd�Zdd�Zy)�EventStreamMessagez#Represents an event stream message.c�<�||_||_||_||_yrn)�prelude�headers�payloadrh)rr|r}r~rhs     rrzEventStreamMessage.__init__\s�������������rc��|jjd�}|dk(s|dk(rd}||j|jd�S)Nz
:message-type�error�	exceptioni�)�status_coder}�body)r}�getr~)rr��message_types   r�to_response_dictz#EventStreamMessage.to_response_dictbsE���|�|�'�'��8���7�"�l�k�&A��K�&��|�|��L�L�
�	
rN)��)r	r
rrrr�r
rrrzrzYs��-��
rrzc�"�eZdZdZej
ejejejejejejejejejd�
Zd�Zd�Zd�Zd�Zd�Zd�Zd	�Zd
�Zy)�EventStreamHeaderParseraParses the event headers from an event stream message.

    Expects all of the header data upfront and creates a dictionary of headers
    to return. This object can be reused multiple times to parse the headers
    from multiple event stream messages.
    )
rr3r4�r5���rO�	c��d|_yrn��_datarrs rrz EventStreamHeaderParser.__init__�s	����
rc�0�||_|j�S)aParses the event stream headers from an event stream message.

        :type data: bytes
        :param data: The bytes that correspond to the headers section of an
        event stream message.

        :rtype: dict
        :returns: A dictionary of header key, value pairs.
        )r��_parse_headers�rr8s  r�parsezEventStreamHeaderParser.parse�s����
��"�"�$�$rc��i}|jr4|j�\}}||vrt|��|||<|jr�4|Srn)r��
_parse_headerr)rr}�namer?s    rr�z&EventStreamHeaderParser._parse_headers�sK�����j�j��,�,�.�K�D�%��w��%�d�+�+�!�G�D�M�	�j�j�
�rc�J�|j�}|j�}||fSrn)�_parse_name�_parse_value)rr�r?s   rr�z%EventStreamHeaderParser._parse_header�s(�����!���!�!�#���U�{�rc�n�tj|jd�\}}|j|�|S)Nr3)r2r\r��
_advance_data)rr�r[s   rr�z#EventStreamHeaderParser._parse_name�s/��$�7�7��
�
�A�F���h����8�$��rc�l�tj|j�\}}|j|�|Srn)r2r@r�r�)r�typer[s   r�_parse_typez#EventStreamHeaderParser._parse_type�s-��$�1�1�$�*�*�=���h����8�$��rc��|j�}|j|}||j�\}}|j|�|Srn)r��_HEADER_TYPE_MAPr�r�)r�header_type�value_unpackerr?r[s     rr�z$EventStreamHeaderParser._parse_value�sE���&�&�(���.�.�{�;��(����4���x����8�$��rc�,�|j|d|_yrnr�)rr[s  rr�z%EventStreamHeaderParser._advance_data�s���Z�Z��	�*��
rN)r	r
rrr2r9r;rFrIrMrQrXr\r_r�rr�r�r�r�r�r�r�r
rrr�r�ms�����"�"��#�#��"�"��#�#��#�#��#�#��(�(��)�)��#�#��"�"�)��.�%���
�
�
�+rr�c�d�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zy)�EventStreamBufferz�Streaming based event stream buffer

    A buffer class that wraps bytes from an event stream providing parsed
    messages as they become available via an iterable interface.
    c�>�d|_d|_t�|_y)Nr)r��_preluder��_header_parserrrs rrzEventStreamBuffer.__init__�s����
���
�5�7��rc�.�|xj|z
c_y)z�Add data to the buffer.

        :type data: bytes
        :param data: The bytes to add to the buffer to be used when parsing
        Nr�r�s  r�add_datazEventStreamBuffer.add_data�s��	
�
�
�d��
rc��|jtkDrt|j��|jtkDrt|j��yrn)rpr!rrsr(r&)rr|s  r�_validate_preludez#EventStreamBuffer._validate_prelude�sG���!�!�$7�7�&�w�'=�'=�>�>��!�!�$7�7�&�w�'=�'=�>�>�8rc���|jdt}tj|�\}}t	|�}|j|�t
|dtdz
|j�|S�Nr5)r�rbr2rcrlr�rjrh)r�
prelude_bytes�raw_prelude�_r|s     r�_parse_preludez EventStreamBuffer._parse_prelude�s_���
�
�#3�O�4�
�$�3�3�M�B���Q� �+�.�����w�'��=�)>�?�Q�+>�?����M��rc��|jt|jj}|jj|�Srn)r�rbr�rwr�r�)r�header_bytess  rr�z EventStreamBuffer._parse_headers�s3���z�z�/�D�M�M�4M�4M�N���"�"�(�(��6�6rc�d�|j}|j|j|j}|Srn)r�r�rwru)rr|�
payload_bytess   r�_parse_payloadz EventStreamBuffer._parse_payload�s-���-�-���
�
�7�#6�#6��9L�9L�M�
��rc��|j}|j|j|j}tj|�\}}|Srn)r�r�ruror2rC)rr|�	crc_bytes�message_crcr�s     r�_parse_message_crcz$EventStreamBuffer._parse_message_crc�sA���-�-���J�J�w�2�2�W�5I�5I�J�	�$�2�2�9�=���Q��rc�Z�|jtdz
|jj}|Sr�)r�rbr�ru)r�
message_bytess  r�_parse_message_bytesz&EventStreamBuffer._parse_message_bytes�s,���
�
��a��$�-�-�";�";�
�
��rc��|j�}|j�}t|||jj��|S)N)rh)r�r�rjr�rh)rr�r�s   r�_validate_message_crcz'EventStreamBuffer._validate_message_crc�s:���-�-�/���1�1�3�
��=�+�4�=�=�;L�;L�M��rc��|j�}|j�}|j�}t|j|||�}|j�|Srn)r�r�r�rzr��_prepare_for_next_message)rrhr}r~rs     r�_parse_messagez EventStreamBuffer._parse_messagesQ���(�(�*���%�%�'���%�%�'��$�T�]�]�G�W�c�J���&�&�(��rc�b�|j|jjd|_d|_yrn)r�r�rorrs rr�z+EventStreamBuffer._prepare_for_next_message	s&���Z�Z��
�
� :� :� <�=��
���
rc��t|j�tkr
t��|j�|j�|_t|j�|jjkr
t��|j�S)z�Provides the next available message parsed from the stream

        :rtype: EventStreamMessage
        :returns: The next event stream message
        )�lenr�rb�
StopIterationr�r�ror�rrs r�nextzEventStreamBuffer.nextsg���t�z�z�?�_�,��/�!��=�=� � �/�/�1�D�M��t�z�z�?�T�]�]�7�7�7��/�!��"�"�$�$rc�"�|j�Srn)r�rrs r�__next__zEventStreamBuffer.__next__s���y�y�{�rc��|Srnr
rrs r�__iter__zEventStreamBuffer.__iter__"s���rN)r	r
rrrr�r�r�r�r�r�r�r�r�r�r�r�r�r
rrr�r��sM���8�
�?��7��
�����
%�"�rr�c�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	y)	�EventStreama�Wrapper class for an event stream body.

    This wraps the underlying streaming body, parsing it for individual events
    and yielding them as they come available through the iterator interface.

    The following example uses the S3 select API to get structured data out of
    an object stored in S3 using an event stream.

    **Example:**
    ::
        from botocore.session import Session

        s3 = Session().create_client('s3')
        response = s3.select_object_content(
            Bucket='bucketname',
            Key='keyname',
            ExpressionType='SQL',
            RequestProgress={'Enabled': True},
            Expression="SELECT * FROM S3Object s",
            InputSerialization={'CSV': {}},
            OutputSerialization={'CSV': {}},
        )
        # This is the event stream in the response
        event_stream = response['Payload']
        end_event_received = False
        with open('output', 'wb') as f:
            # Iterate over events in the event stream as they come
            for event in event_stream:
                # If we received a records event, write the data to a file
                if 'Records' in event:
                    data = event['Records']['Payload']
                    f.write(data)
                # If we received a progress event, print the details
                elif 'Progress' in event:
                    print(event['Progress']['Details'])
                # End event indicates that the request finished successfully
                elif 'End' in event:
                    print('Result is complete')
                    end_event_received = True
        if not end_event_received:
            raise Exception("End event not received, request incomplete.")
    c�f�||_||_||_||_|j	�|_yrn)�_raw_stream�
_output_shape�_operation_name�_parser�_create_raw_event_generator�_event_generator)r�
raw_stream�output_shape�parser�operation_names     rrzEventStream.__init__Rs2��%���)���-������ $� @� @� B��rc#�^K�|jD]}|j|�}|s�|���y�wrn)r��_parse_event)r�event�parsed_events   rr�zEventStream.__iter__Ys4�����*�*�	#�E��,�,�U�3�L��"�"�	#�s�#-�-c#�K�t�}|jj�D]}|j|�|Ed{����y7��wrn)r�r��streamr�)r�event_stream_buffer�chunks   rr�z'EventStream._create_raw_event_generator_sG����/�1���%�%�,�,�.�	+�E��(�(��/�*�*�*�	+�*�s�>A
�A�A
c��|j�}|jj||j�}|ddk(r|St	||j
��)Nr�r�)r�r�r�r�rr�)rr��
response_dict�parsed_responses    rr�zEventStream._parse_eventesR���.�.�0�
��,�,�,�,�]�D�<N�<N�O����'�3�.�"�"�"�?�D�4H�4H�I�Irc��	t|j�}|jjd�}|dk(r|S	t��#t$rYt��wxYw)Nz:event-typezinitial-response)r�r�r}r�r�r/)r�
initial_event�
event_types   r�get_initial_responsez EventStream.get_initial_responsemsi��	� ��!6�!6�7�M�&�.�.�2�2�=�A�J��/�/�$�$�0�%�&�&���	��$�&�&�	�s�6A�	A�Ac�8�|jj�y)z%Closes the underlying streaming body.N)r��closerrs rr�zEventStream.closews������� rN)
r	r
rrrr�r�r�r�r�r
rrr�r�&s(��)�VC�#�+�J�'�!rr�N)r)r�binasciir�structr�botocore.exceptionsrrbr!r(�	Exceptionrrrr&r*r/r2rjrlrzr�r�r�r
rr�<module>r�s���$���0��� ��"��	�)�	�"�k�"�"�;�"�"�;�"�
"�{�
"�	"�[�	"�MP�MP�`<�'5�'5�T
�
�(Q+�Q+�hb�b�JS!�S!r

https://t.me/RX1948 - 2025