ó
    Ú°›j7O  ã                   ó>  • S r SSKJr  SSKJr  SSKJr  SrSrSr	 " S S	\
5      r " S
 S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S5      rS"S jr " S S5      r " S S5      r " S S5      r " S S5      r " S S 5      rg!)#zBinary Event Stream Decodingé    )Úcrc32)Úunpack)ÚEventStreamErroré   i   i  €c                   ó   • \ rS rSrSrSrg)ÚParserErroré   z,Base binary flow encoding parsing exception.© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r
   ó    ÚQ/home/mande/repo/quber/.venv/lib/python3.13/site-packages/botocore/eventstream.pyr   r      s   † Ù6âr   r   c                   ó,   ^ • \ rS rSrSrU 4S jrSrU =r$ )ÚDuplicateHeaderé    z$Duplicate header found in the event.c                 ó0   >• SU S3n[         TU ]  U5        g )NzDuplicate header present: "Ú"©ÚsuperÚ__init__)ÚselfÚheaderÚmessageÚ	__class__s      €r   r   ÚDuplicateHeader.__init__#   s   ø€ Ø/°¨x°qÐ9ˆÜ‰Ñ˜Õ!r   r
   ©r   r   r   r   r   r   r   Ú__classcell__©r   s   @r   r   r       s   ø† Ù.÷"ó "r   r   c                   ó,   ^ • \ rS rSrSrU 4S jrSrU =r$ )ÚInvalidHeadersLengthé(   z*Headers length is longer than the maximum.c                 ó<   >• SU S[          3n[        TU ]	  U5        g )NzHeader length of ú exceeded the maximum of )Ú_MAX_HEADERS_LENGTHr   r   ©r   Úlengthr   r   s      €r   r   ÚInvalidHeadersLength.__init__+   s%   ø€ Ø% f XÐ-FÔGZÐF[Ð\ˆÜ‰Ñ˜Õ!r   r
   r    r"   s   @r   r$   r$   (   ó   ø† Ù4÷"ó "r   r$   c                   ó,   ^ • \ rS rSrSrU 4S jrSrU =r$ )ÚInvalidPayloadLengthé0   z*Payload length is longer than the maximum.c                 ó<   >• SU S[          3n[        TU ]	  U5        g )NzPayload length of r'   )Ú_MAX_PAYLOAD_LENGTHr   r   r)   s      €r   r   ÚInvalidPayloadLength.__init__3   s%   ø€ Ø& v hÐ.GÔH[ÐG\Ð]ˆÜ‰Ñ˜Õ!r   r
   r    r"   s   @r   r.   r.   0   r,   r   r.   c                   ó,   ^ • \ rS rSrSrU 4S jrSrU =r$ )ÚChecksumMismatché8   z8Calculated checksum did not match the expected checksum.c                 ó8   >• SUS SUS 3n[         TU ]  U5        g )NzChecksum mismatch: expected 0xÚ08xz, calculated 0xr   )r   ÚexpectedÚ
calculatedr   r   s       €r   r   ÚChecksumMismatch.__init__;   s)   ø€ Ø2°8¸C°.ÀÐPZÐ[^ÐO_Ð`ˆÜ‰Ñ˜Õ!r   r
   r    r"   s   @r   r4   r4   8   s   ø† ÙB÷"ó "r   r4   c                   ó,   ^ • \ rS rSrSrU 4S jrSrU =r$ )ÚNoInitialResponseErroré@   z¾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                 ó(   >• Sn[         TU ]  U5        g )Nz0First event was not of the initial-response typer   )r   r   r   s     €r   r   ÚNoInitialResponseError.__init__G   s   ø€ ØDˆÜ‰Ñ˜Õ!r   r
   r    r"   s   @r   r<   r<   @   s   ø† ñ÷"ó "r   r<   c                   ó  • \ rS rSrSrSrSrSrSrSr	Sr
S	rS
r\\\S.r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\SS j5       r\SS j5       r\S 5       r\S 5       rSrg)ÚDecodeUtilséL   zÐ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                 ó   • g)zÜ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)
)Tr   r
   ©Údatas    r   Úunpack_trueÚDecodeUtils.unpack_trued   s   € ð r   c                 ó   • g)zÞThis 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)
)Fr   r
   rG   s    r   Úunpack_falseÚDecodeUtils.unpack_falseq   s   € ð r   c                 óJ   • [        [        R                  U SS 5      S   nUS4$ )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)
NrC   r   )r   rA   ÚUINT8_BYTE_FORMAT©rH   Úvalues     r   Úunpack_uint8ÚDecodeUtils.unpack_uint8~   s*   € ô ”{×4Ñ4°d¸2¸A°hÓ?ÀÑBˆØ�aˆxˆr   c                 óJ   • [        [        R                  U SS 5      S   nUS4$ )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)
NrE   r   )r   rA   ÚUINT32_BYTE_FORMATrP   s     r   Úunpack_uint32ÚDecodeUtils.unpack_uint32‹   s*   € ô ”{×5Ñ5°t¸B¸Q°xÓ@ÀÑCˆØ�aˆxˆr   c                 óJ   • [        [        R                  U SS 5      S   nUS4$ )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)
NrC   r   )r   rA   ÚINT8_BYTE_FORMATrP   s     r   Úunpack_int8ÚDecodeUtils.unpack_int8˜   s*   € ô ”{×3Ñ3°T¸"¸1°XÓ>¸qÑAˆØ�aˆxˆr   c                 óJ   • [        [        R                  U SS 5      S   nUS4$ )zÑParse 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)
NrD   r   )r   rA   ÚINT16_BYTE_FORMATrP   s     r   Úunpack_int16ÚDecodeUtils.unpack_int16¥   ó*   € ô ”{×4Ñ4°d¸2¸A°hÓ?ÀÑBˆØ�aˆxˆr   c                 óJ   • [        [        R                  U SS 5      S   nUS4$ )zÑParse 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)
NrE   r   )r   rA   ÚINT32_BYTE_FORMATrP   s     r   Úunpack_int32ÚDecodeUtils.unpack_int32³   r`   r   c                 óJ   • [        [        R                  U SS 5      S   nUS4$ )zÑParse 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   )r   rA   ÚINT64_BYTE_FORMATrP   s     r   Úunpack_int64ÚDecodeUtils.unpack_int64Á   r`   r   c                 ó`   • [         R                  U   n[        X SU 5      S   nX1-   nXU nXT4$ )aC  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   )rA   ÚUINT_BYTE_FORMATr   )rH   Úlength_byte_sizeÚuint_byte_formatr*   Ú	bytes_endÚarray_bytess         r   Úunpack_byte_arrayÚDecodeUtils.unpack_byte_arrayÏ   sJ   € ô& '×7Ñ7Ð8HÑIÐÜÐ(Ð/@Ð0@Ð*AÓBÀ1ÑEˆØÑ-ˆ	Ø¨IÐ6ˆØÐ%Ð%r   c                 óV   • [         R                  X5      u  p#UR                  S5      U4$ )ap  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).
zutf-8)rA   rp   Údecode)rH   rl   ro   Úconsumeds       r   Úunpack_utf8_stringÚDecodeUtils.unpack_utf8_stringè   s2   € ô( !,× =Ñ =Øó!
Ñˆð ×!Ñ! 'Ó*¨HÐ4Ð4r   c                 ó   • U SS S4$ )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
   rG   s    r   Úunpack_uuidÚDecodeUtils.unpack_uuid  s   € ð �C�Rˆy˜"ˆ}Ðr   c                 óB   • [        [        R                  U 5      [        4$ )aM  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)
)r   rA   ÚPRELUDE_BYTE_FORMATÚ_PRELUDE_LENGTHrG   s    r   Úunpack_preludeÚDecodeUtils.unpack_prelude  s   € ô ”{×6Ñ6¸Ó=¼ÐOÐOr   r
   N)rD   )r   r   r   r   r   rO   ÚUINT16_BYTE_FORMATrU   rY   r]   rb   rg   r|   rk   ÚstaticmethodrI   rL   rR   rV   rZ   r^   rc   rh   rp   ru   ry   r~   r   r
   r   r   rA   rA   L   s>  † ñð ÐØÐØÐØÐØÐØÐØÐØ Ðð ØØñÐð ñ
ó ð
ð ñ
ó ð
ð ñ
ó ð
ð ñ
ó ð
ð ñ
ó ð
ð ñó ðð ñó ðð ñó ðð ó&ó ð&ð0 ó5ó ð5ð0 ñ	ó ð	ð ñPó óPr   rA   c                 ó@   • [        X5      S-  nX:w  a  [        X5      eg )Nl   ÿÿ )r   r4   )rH   ÚchecksumÚcrcÚcomputed_checksums       r   Ú_validate_checksumr†     s*   € ô ˜dÓ(¨:Ñ5ÐØÓ$Ü˜xÓ;Ð;ð %r   c                   óN   • \ rS rSrSrS r\S 5       r\S 5       r\S 5       r	Sr
g)	ÚMessagePreludei$  z2Represents the prelude of an event stream message.c                 ó(   • Xl         X l        X0l        g ©N)Útotal_lengthÚheaders_lengthr„   )r   r‹   rŒ   r„   s       r   r   ÚMessagePrelude.__init__'  s   € Ø(ÔØ,ÔØ�r   c                 óH   • U R                   U R                  -
  [        -
  S-
  $ )z‡Calculates the total payload length.

The extra minus 4 bytes is for the message CRC.

:rtype: int
:returns: The total payload length.
rE   )r‹   rŒ   r}   ©r   s    r   Úpayload_lengthÚMessagePrelude.payload_length,  s%   € ð × Ñ  4×#6Ñ#6Ñ6¼ÑHÈ1ÑLÐLr   c                 ó    • U R                   S-
  $ )zá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.
rE   )r‹   r�   s    r   Úpayload_endÚMessagePrelude.payload_end7  s   € ð × Ñ  1Ñ$Ð$r   c                 ó(   • [         U R                  -   $ )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.
)r}   rŒ   r�   s    r   Úheaders_endÚMessagePrelude.headers_endC  s   € ô  ×!4Ñ!4Ñ4Ð4r   )r„   rŒ   r‹   N)r   r   r   r   r   r   Úpropertyr�   r“   r–   r   r
   r   r   rˆ   rˆ   $  sH   † Ù<òð
 ñMó ðMð ñ	%ó ð	%ð ñ5ó ó5r   rˆ   c                   ó(   • \ rS rSrSrS rSS jrSrg)ÚEventStreamMessageiN  z#Represents an event stream message.c                 ó4   • Xl         X l        X0l        X@l        g rŠ   )ÚpreludeÚheadersÚpayloadr„   )r   rœ   r�   rž   r„   s        r   r   ÚEventStreamMessage.__init__Q  s   € ØŒØŒØŒØ�r   c                 óˆ   • U R                   R                  S5      nUS:X  d  US:X  a  SnUU R                   U R                  S.$ )Nz:message-typeÚerrorÚ	exceptioni�  )Ústatus_coder�   Úbody)r�   Úgetrž   )r   r£   Úmessage_types      r   Úto_response_dictÚ#EventStreamMessage.to_response_dictW  sE   € Ø—|‘|×'Ñ'¨Ó8ˆØ˜7Ó" l°kÓ&AØˆKà&Ø—|‘|Ø—L‘Lñ
ð 	
r   )r„   r�   rž   rœ   N)éÈ   )r   r   r   r   r   r   r§   r   r
   r   r   rš   rš   N  s   † Ù-ò÷
r   rš   c                   ó*  • \ rS rSrSr\R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  S.
rS rS rS rS rS rS	 rS
 rS rSrg)ÚEventStreamHeaderParserib  zñParses 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.
)
r   rC   rD   é   rE   é   é   é   rf   é	   c                 ó   • S U l         g rŠ   ©Ú_datar�   s    r   r   Ú EventStreamHeaderParser.__init__ƒ  s	   € Øˆ�
r   c                 ó.   • Xl         U R                  5       $ )zìParses 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©r   rH   s     r   ÚparseÚEventStreamHeaderParser.parse†  s   € ð Œ
Ø×"Ñ"Ó$Ð$r   c                 óž   • 0 nU R                   (       a9  U R                  5       u  p#X!;   a  [        U5      eX1U'   U R                   (       a  M9  U$ rŠ   )r³   Ú_parse_headerr   )r   r�   ÚnamerQ   s       r   r¶   Ú&EventStreamHeaderParser._parse_headers“  sG   € ØˆØ�j�jØ×,Ñ,Ó.‰KˆDØ‹Ü% dÓ+Ð+Ø!�D‰Mð	 �j�j‰jð
 ˆr   c                 óH   • U R                  5       nU R                  5       nX4$ rŠ   )Ú_parse_nameÚ_parse_value)r   r¼   rQ   s      r   r»   Ú%EventStreamHeaderParser._parse_headerœ  s&   € Ø×ÑÓ!ˆØ×!Ñ!Ó#ˆØˆ{Ðr   c                 ól   • [         R                  U R                  S5      u  pU R                  U5        U$ )NrC   )rA   ru   r³   Ú_advance_data)r   r¼   rt   s      r   r¿   Ú#EventStreamHeaderParser._parse_name¡  s-   € Ü$×7Ñ7¸¿
¹
ÀAÓF‰ˆØ×Ñ˜8Ô$Øˆr   c                 ój   • [         R                  U R                  5      u  pU R                  U5        U$ rŠ   )rA   rR   r³   rÃ   )r   Útypert   s      r   Ú_parse_typeÚ#EventStreamHeaderParser._parse_type¦  s+   € Ü$×1Ñ1°$·*±*Ó=‰ˆØ×Ñ˜8Ô$Øˆr   c                 óŽ   • U R                  5       nU R                  U   nU" U R                  5      u  p4U R                  U5        U$ rŠ   )rÇ   Ú_HEADER_TYPE_MAPr³   rÃ   )r   Úheader_typeÚvalue_unpackerrQ   rt   s        r   rÀ   Ú$EventStreamHeaderParser._parse_value«  sC   € Ø×&Ñ&Ó(ˆØ×.Ñ.¨{Ñ;ˆÙ(¨¯©Ó4‰ˆØ×Ñ˜8Ô$Øˆr   c                 ó,   • U R                   US  U l         g rŠ   r²   )r   rt   s     r   rÃ   Ú%EventStreamHeaderParser._advance_data²  s   € Ø—Z‘Z  	Ð*ˆ�
r   r²   N)r   r   r   r   r   rA   rI   rL   rZ   r^   rc   rh   rp   ru   ry   rÊ   r   r¸   r¶   r»   r¿   rÇ   rÀ   rÃ   r   r
   r   r   r«   r«   b  s“   † ñð ×"Ñ"à×#Ñ#à×"Ñ"à×#Ñ#à×#Ñ#à×#Ñ#à×(Ñ(à×)Ñ)à×#Ñ#à×"Ñ"ñ)Ðò.ò%òòò
ò
ò
õ+r   r«   c                   ól   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rSrg)ÚEventStreamBufferi¶  z¨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                 ó>   • SU l         S U l        [        5       U l        g )Nr   )r³   Ú_preluder«   Ú_header_parserr�   s    r   r   ÚEventStreamBuffer.__init__½  s   € ØˆŒ
ØˆŒÜ5Ó7ˆÕr   c                 ó.   • U =R                   U-  sl         g)zoAdd 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_dataÚEventStreamBuffer.add_dataÂ  s   € ð 	�
Š
�dÑŽ
r   c                 ó¨   • UR                   [        :”  a  [        UR                   5      eUR                  [        :”  a  [        UR                  5      eg rŠ   )rŒ   r(   r$   r�   r1   r.   )r   rœ   s     r   Ú_validate_preludeÚ#EventStreamBuffer._validate_preludeÊ  sG   € Ø×!Ñ!Ô$7Ó7Ü& w×'=Ñ'=Ó>Ð>à×!Ñ!Ô$7Ó7Ü& w×'=Ñ'=Ó>Ð>ð 8r   c                 óÌ   • U R                   S [         n[        R                  U5      u  p#[	        U6 n[        US [        S-
   UR                  5        U R                  U5        U$ ©NrE   )r³   r}   rA   r~   rˆ   r†   r„   rÚ   )r   Úprelude_bytesÚraw_preludeÚ_rœ   s        r   Ú_parse_preludeÚ EventStreamBuffer._parse_preludeÑ  s]   € ØŸ
™
Ð#3¤OÐ4ˆÜ$×3Ñ3°MÓB‰ˆÜ  +Ð.ˆä˜=Ð)>¬?¸QÑ+>Ð?ÀÇÁÔMØ×Ñ˜wÔ'Øˆr   c                 ó†   • U R                   [        U R                  R                   nU R                  R                  U5      $ rŠ   )r³   r}   rÓ   r–   rÔ   r¸   )r   Úheader_bytess     r   r¶   Ú EventStreamBuffer._parse_headersÚ  s3   € Ø—z‘z¤/°D·M±M×4MÑ4MÐNˆØ×"Ñ"×(Ñ(¨Ó6Ð6r   c                 ód   • U R                   nU R                  UR                  UR                   nU$ rŠ   )rÓ   r³   r–   r“   )r   rœ   Úpayload_bytess      r   Ú_parse_payloadÚ EventStreamBuffer._parse_payloadÞ  s-   € Ø—-‘-ˆØŸ
™
 7×#6Ñ#6¸×9LÑ9LÐMˆØÐr   c                 ó’   • U R                   nU R                  UR                  UR                   n[        R                  U5      u  p4U$ rŠ   )rÓ   r³   r“   r‹   rA   rV   )r   rœ   Ú	crc_bytesÚmessage_crcrà   s        r   Ú_parse_message_crcÚ$EventStreamBuffer._parse_message_crcã  s?   € Ø—-‘-ˆØ—J‘J˜w×2Ñ2°W×5IÑ5IÐJˆ	Ü$×2Ñ2°9Ó=‰ˆØÐr   c                 óZ   • U R                   [        S-
  U R                  R                   nU$ rÝ   )r³   r}   rÓ   r“   )r   Úmessage_bytess     r   Ú_parse_message_bytesÚ&EventStreamBuffer._parse_message_bytesé  s,   € àŸ
™
Ü˜aÑ $§-¡-×";Ñ";ð
ˆð Ðr   c                 ó‚   • U R                  5       nU R                  5       n[        X!U R                  R                  S9  U$ )N)r„   )rí   rñ   r†   rÓ   r„   )r   rì   rð   s      r   Ú_validate_message_crcÚ'EventStreamBuffer._validate_message_crcð  s8   € Ø×-Ñ-Ó/ˆØ×1Ñ1Ó3ˆÜ˜=¸4¿=¹=×;LÑ;LÒMØÐr   c                 ó´   • U R                  5       nU R                  5       nU R                  5       n[        U R                  X#U5      nU R                  5         U$ rŠ   )rô   r¶   rè   rš   rÓ   Ú_prepare_for_next_message)r   r„   r�   rž   r   s        r   Ú_parse_messageÚ EventStreamBuffer._parse_messageö  sO   € Ø×(Ñ(Ó*ˆØ×%Ñ%Ó'ˆØ×%Ñ%Ó'ˆÜ$ T§]¡]°GÀcÓJˆØ×&Ñ&Ô(Øˆr   c                 ób   • U R                   U R                  R                  S  U l         S U l        g rŠ   )r³   rÓ   r‹   r�   s    r   r÷   Ú+EventStreamBuffer._prepare_for_next_messageþ  s&   € à—Z‘Z §¡× :Ñ :Ð <Ð=ˆŒ
Øˆ�r   c                 ó"  • [        U R                  5      [        :  a
  [        5       eU R                  c  U R                  5       U l        [        U R                  5      U R                  R                  :  a
  [        5       eU R                  5       $ )zProvides the next available message parsed from the stream

:rtype: EventStreamMessage
:returns: The next event stream message
)Úlenr³   r}   ÚStopIterationrÓ   rá   r‹   rø   r�   s    r   ÚnextÚEventStreamBuffer.next  sg   € ô ˆt�z‰z‹?œ_Ó,Ü“/Ð!à�=‰=Ñ Ø ×/Ñ/Ó1ˆDŒMäˆt�z‰z‹?˜TŸ]™]×7Ñ7Ó7Ü“/Ð!à×"Ñ"Ó$Ð$r   c                 ó"   • U R                  5       $ rŠ   )rÿ   r�   s    r   Ú__next__ÚEventStreamBuffer.__next__  s   € Ø�y‰y‹{Ðr   c                 ó   • U $ rŠ   r
   r�   s    r   Ú__iter__ÚEventStreamBuffer.__iter__  s   € Øˆr   )r³   rÔ   rÓ   N)r   r   r   r   r   r   r×   rÚ   rá   r¶   rè   rí   rñ   rô   rø   r÷   rÿ   r  r  r   r
   r   r   rÑ   rÑ   ¶  sM   † ñò8ò
ò?òò7òò
òòòòò
%ò"õr   rÑ   c                   ó<   • \ rS rSrSrS rS rS rS rS r	S r
S	rg
)ÚEventStreami  a<  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                 ó^   • Xl         X l        X@l        X0l        U R	                  5       U l        g rŠ   )Ú_raw_streamÚ_output_shapeÚ_operation_nameÚ_parserÚ_create_raw_event_generatorÚ_event_generator)r   Ú
raw_streamÚoutput_shapeÚparserÚoperation_names        r   r   ÚEventStream.__init__G  s*   € Ø%ÔØ)ÔØ-ÔØŒØ $× @Ñ @Ó BˆÕr   c              #   ón   #   • U R                    H!  nU R                  U5      nU(       d  M  Uv •  M#     g 7frŠ   )r  Ú_parse_event)r   ÚeventÚparsed_events      r   r  ÚEventStream.__iter__N  s0   é € Ø×*Ô*ˆEØ×,Ñ,¨UÓ3ˆLßˆ|Ø"Ô"ò +ùs   ‚&5¬	5c              #   óœ   #   • [        5       nU R                  R                  5        H  nUR                  U5        U S h  v•N   M      g  N	7frŠ   )rÑ   r
  Ústreamr×   )r   Úevent_stream_bufferÚchunks      r   r  Ú'EventStream._create_raw_event_generatorT  sA   é € Ü/Ó1ÐØ×%Ñ%×,Ñ,Ö.ˆEØ×(Ñ(¨Ô/Ø*×*Ò*ò /á*ùs   ‚>AÁ A
Á
Ac                 ó¬   • UR                  5       nU R                  R                  X R                  5      nUS   S:X  a  U$ [	        X0R
                  5      e)Nr£   r©   )r§   r  r¸   r  r   r  )r   r  Úresponse_dictÚparsed_responses       r   r  ÚEventStream._parse_eventZ  sN   € Ø×.Ñ.Ó0ˆØŸ,™,×,Ñ,¨]×<NÑ<NÓOˆØ˜Ñ'¨3Ó.Ø"Ð"ä" ?×4HÑ4HÓIÐIr   c                 ó¼   •  [        U R                  5      nUR                  R                  S5      nUS:X  a  U$  [        5       e! [         a     [        5       ef = f)Nz:event-typezinitial-response)rÿ   r  r�   r¥   rþ   r<   )r   Úinitial_eventÚ
event_types      r   Úget_initial_responseÚ EventStream.get_initial_responseb  si   € ð	Ü  ×!6Ñ!6Ó7ˆMØ&×.Ñ.×2Ñ2°=ÓAˆJØÐ/Ó/Ø$Ð$ð 0ô %Ó&Ð&øô ó 	ØÜ$Ó&Ð&ð	ús   ‚7A Á
AÁAc                 ó8   • U R                   R                  5         g)z%Closes the underlying streaming body.N)r
  Úcloser�   s    r   r)  ÚEventStream.closel  s   € à×Ñ×ÑÕ r   )r  r  r  r  r
  N)r   r   r   r   r   r   r  r  r  r&  r)  r   r
   r   r   r  r    s(   † ñ)òVCò#ò+òJò'õ!r   r  N)r   )r   Úbinasciir   Ústructr   Úbotocore.exceptionsr   r}   r(   r1   Ú	Exceptionr   r   r$   r.   r4   r<   rA   r†   rˆ   rš   r«   rÑ   r  r
   r   r   Ú<module>r/     s½   ðñ #å Ý å 0ð €Ø Ð Ø&Ð ô	�)ô 	ô"�kô "ô"˜;ô "ô"˜;ô "ô"�{ô "ô	"˜[ô 	"÷MPñ MPô`<÷'5ñ '5÷T
ñ 
÷(Q+ñ Q+÷hbñ b÷JS!ò S!r   