HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //proc/722141/root/lib/python3.6/site-packages/botocore/__pycache__/parsers.cpython-36.pyc
3

�T_=��@szdZddlZddlZddlZddlZddlmZmZmZddl	m
Z
mZddlm
Z
mZmZmZeje�Ze
ZGdd�de�Zdd	�Zd
d�ZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Z Gdd�de e�Z!Gdd�de e�Z"Gdd�de�Z#Gd d!�d!e�Z$Gd"d#�d#e$e�Z%Gd$d%�d%e$e�Z&eee#e%e&d&�Z'dS)'a�Response parsers for the various protocol types.

The module contains classes that can take an HTTP response, and given
an output shape, parse the response into a dict according to the
rules in the output shape.

There are many similarities amongst the different protocols with regard
to response parsing, and the code is structured in a way to avoid
code duplication when possible.  The diagram below is a diagram
showing the inheritance hierarchy of the response classes.

::



                                 +--------------+
                                 |ResponseParser|
                                 +--------------+
                                    ^    ^    ^
               +--------------------+    |    +-------------------+
               |                         |                        |
    +----------+----------+       +------+-------+        +-------+------+
    |BaseXMLResponseParser|       |BaseRestParser|        |BaseJSONParser|
    +---------------------+       +--------------+        +--------------+
              ^         ^          ^           ^           ^        ^
              |         |          |           |           |        |
              |         |          |           |           |        |
              |        ++----------+-+       +-+-----------++       |
              |        |RestXMLParser|       |RestJSONParser|       |
        +-----+-----+  +-------------+       +--------------+  +----+-----+
        |QueryParser|                                          |JSONParser|
        +-----------+                                          +----------+


The diagram above shows that there is a base class, ``ResponseParser`` that
contains logic that is similar amongst all the different protocols (``query``,
``json``, ``rest-json``, ``rest-xml``).  Amongst the various services there
is shared logic that can be grouped several ways:

* The ``query`` and ``rest-xml`` both have XML bodies that are parsed in the
  same way.
* The ``json`` and ``rest-json`` protocols both have JSON bodies that are
  parsed in the same way.
* The ``rest-json`` and ``rest-xml`` protocols have additional attributes
  besides body parameters that are parsed the same (headers, query string,
  status code).

This is reflected in the class diagram above.  The ``BaseXMLResponseParser``
and the BaseJSONParser contain logic for parsing the XML/JSON body,
and the BaseRestParser contains logic for parsing out attributes that
come from other parts of the HTTP response.  Classes like the
``RestXMLParser`` inherit from the ``BaseXMLResponseParser`` to get the
XML body parsing logic and the ``BaseRestParser`` to get the HTTP
header/status code/query string parsing.

Additionally, there are event stream parsers that are used by the other parsers
to wrap streaming bodies that represent a stream of events. The
BaseEventStreamParser extends from ResponseParser and defines the logic for
parsing values from the headers and payload of a message from the underlying
binary encoding protocol. Currently, event streams support parsing bodies
encoded as JSON and XML through the following hierarchy.


                                  +--------------+
                                  |ResponseParser|
                                  +--------------+
                                    ^    ^    ^
               +--------------------+    |    +------------------+
               |                         |                       |
    +----------+----------+   +----------+----------+    +-------+------+
    |BaseXMLResponseParser|   |BaseEventStreamParser|    |BaseJSONParser|
    +---------------------+   +---------------------+    +--------------+
                     ^                ^        ^                 ^
                     |                |        |                 |
                     |                |        |                 |
                   +-+----------------+-+    +-+-----------------+-+
                   |EventStreamXMLParser|    |EventStreamJSONParser|
                   +--------------------+    +---------------------+

Return Values
=============

Each call to ``parse()`` returns a dict has this form::

    Standard Response

    {
      "ResponseMetadata": {"RequestId": <requestid>}
      <response keys>
    }

    Error response

    {
      "ResponseMetadata": {"RequestId": <requestid>}
      "Error": {
        "Code": <string>,
        "Message": <string>,
        "Type": <string>,
        <additional keys>
      }
    }

�N)�six�ETree�
XMLParseError)�EventStream�NoInitialResponseError)�parse_timestamp�merge_dicts�is_json_value_header�lowercase_dictc@s$eZdZdd�Zdd�Zdd�ZdS)�ResponseParserFactorycCs
i|_dS)N)�	_defaults)�self�r�/usr/lib/python3.6/parsers.py�__init__�szResponseParserFactory.__init__cKs|jj|�dS)aOSet default arguments when a parser instance is created.

        You can specify any kwargs that are allowed by a ResponseParser
        class.  There are currently two arguments:

            * timestamp_parser - A callable that can parse a timetsamp string
            * blob_parser - A callable that can parse a blob type

        N)r�update)r
�kwargsrrr�set_parser_defaults�s
z)ResponseParserFactory.set_parser_defaultscCst|}|f|j�S)N)�PROTOCOL_PARSERSr)r
Z
protocol_nameZ
parser_clsrrr�
create_parser�sz#ResponseParserFactory.create_parserN)�__name__�
__module__�__qualname__rrrrrrrr�srcCst�j|�S)N)rr)Zprotocolrrrr�srcs�fdd�}|S)Ncs.t|d�r|j}|dkr"d}n|}�|||�S)N�text�)�hasattrr)r
�shapeZnode_or_stringr)�funcrr�_get_text_content�s
z(_text_content.<locals>._get_text_contentr)rrr)rr�
_text_content�src@seZdZdS)�ResponseParserErrorN)rrrrrrrr �sr c@s�eZdZdZdZdZddd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS)�ResponseParseraoBase class for response parsing.

    This class represents the interface that all ResponseParsers for the
    various protocols must implement.

    This class will take an HTTP response and a model shape and parse the
    HTTP response into a dictionary.

    There is a single public method exposed: ``parse``.  See the ``parse``
    docstring for more info.

    zutf-8NcCsH|dkrt}||_|dkr |j}||_d|_|jdk	rD|j||�|_dS)N)�DEFAULT_TIMESTAMP_PARSER�_timestamp_parser�_default_blob_parser�_blob_parser�_event_stream_parser�EVENT_STREAM_PARSER_CLS)r
�timestamp_parser�blob_parserrrrr�s
zResponseParser.__init__cCs
tj|�S)N)�base64�	b64decode)r
�valuerrrr$�sz#ResponseParser._default_blob_parsercCs�tjd|d�tjd|d�|ddkrj|j|�rB|j|�}qv|j|�r\|j||�}|S|j||�}n|j||�}|r�|jj	d�r�|St
|t�r�|j	di�}|d|d	<|d}t|�|d
<||d<|S)a>Parse the HTTP response given a shape.

        :param response: The HTTP response dictionary.  This is a dictionary
            that represents the HTTP request.  The dictionary must have the
            following keys, ``body``, ``headers``, and ``status_code``.

        :param shape: The model shape describing the expected output.
        :return: Returns a dictionary representing the parsed response
            described by the model.  In addition to the shape described from
            the model, each response will also have a ``ResponseMetadata``
            which contains metadata about the response, which contains at least
            two keys containing ``RequestId`` and ``HTTPStatusCode``.  Some
            responses may populate additional keys, but ``RequestId`` will
            always be present.

        zResponse headers: %s�headerszResponse body:
%s�body�status_codei-�eventstream�ResponseMetadataZHTTPStatusCodeZHTTPHeaders)
�LOG�debug�_is_generic_error_response�_do_generic_error_parse�_is_modeled_error_shape�_do_modeled_error_parse�_do_error_parse�	_do_parse�
serialization�get�
isinstance�dictr
)r
�responser�parsedZresponse_metadatar-rrr�parse�s&


zResponseParser.parsecCs|dk	o|jjdd�S)N�	exceptionF)�metadatar;)r
rrrrr6sz&ResponseParser._is_modeled_error_shapecCsD|ddkr@d|ks |ddkr$dS|dj�}|jd�p>|SdS)Nr/i�r.Ts<html>)�strip�
startswith)r
r>r.rrrr4s
z)ResponseParser._is_generic_error_responsecCs4tjd�t|d�tjjjj|dd�d�id�S)NzlReceived a non protocol specific error response from the service, unable to populate error code and message.r/r)�Code�Message)�Errorr1)r2r3�strr�moves�http_client�	responsesr;)r
r>rrrr5s



z&ResponseParser._do_generic_error_parsecCstd|jj��dS)Nz%s._do_parse)�NotImplementedError�	__class__r)r
r>rrrrr9*szResponseParser._do_parsecCstd|jj��dS)Nz%s._do_error_parse)rLrMr)r
r>rrrrr8-szResponseParser._do_error_parsecCstd|jj��dS)Nz%s._do_modeled_error_parse)rLrMr)r
r>rr?rrrr71sz&ResponseParser._do_modeled_error_parsecCst|d|j|j�}|||�S)Nz
_handle_%s)�getattr�	type_name�_default_handle)r
r�nodeZhandlerrrr�_parse_shape5szResponseParser._parse_shapecCs.g}|j}x|D]}|j|j||��qW|S)N)�member�appendrR)r
rrQr?�member_shape�itemrrr�_handle_list:s

zResponseParser._handle_listcCs|S)Nr)r
rr,rrrrPCszResponseParser._default_handlecCs&|j}|djd�}t|d|||�S)N�contextZoperation_namer.)r&r;r)r
r>r�parser�namerrr�_create_event_streamFsz#ResponseParser._create_event_stream)NN)rrr�__doc__�DEFAULT_ENCODINGr'rr$r@r6r4r5r9r8r7rRrWrPr[rrrrr!�s 
0	r!cs�eZdZd"�fdd�	Zdd�Zdd�Z�fdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Ze
dd��Ze
dd��Ze
dd��Ze
dd��Ze
dd��Ze
d d!��ZeZeZeZ�ZS)#�BaseXMLResponseParserNcs"tt|�j||�tjd�|_dS)Nz{.*})�superr^r�re�compile�
_namespace_re)r
r(r))rMrrrMszBaseXMLResponseParser.__init__c
Cs�i}|j}|j}|jjd�pd}|jjd�p.d}|jjd�rNt|t�rN|g}xd|D]\}xN|D]F}	|j|	�}
|
|kr�|j||	�}q^|
|kr�|j||	�}q^td|
��q^W|||<qTW|S)NrZ�keyr,�	flattenedzUnknown tag: %s)	rcr,r:r;r<�list�	_node_tagrRr )
r
rrQr?�	key_shape�value_shapeZkey_location_nameZvalue_location_nameZkeyval_nodeZsingle_pairZtag_nameZkey_nameZval_namerrr�_handle_mapRs"


z!BaseXMLResponseParser._handle_mapcCs|jjd|j�S)Nr)rb�sub�tag)r
rQrrrrfgszBaseXMLResponseParser._node_tagcs0|jjd�rt|t�r|g}tt|�j||�S)Nrd)r:r;r<rer_r^rW)r
rrQ)rMrrrWjsz"BaseXMLResponseParser._handle_listcCs�i}|j}|jjdd�r"|j|�}|j|�}x�|D]�}||}d|jks2|jjd�rVq2|j||�}|j|�}	|	dk	r�|j||	�||<q2|jjd�r2i}
|jd}x:|jj	�D],\}}
|j
j|jd�dd|�}|
|
|<q�W||
kr2|
|||<q2W|S)	NrAF�location�eventheaderZxmlAttributerZ�:r)
�membersrBr;�_get_error_root�_build_name_to_xml_noder:�_member_key_namerRZattrib�itemsrbrj�split)r
rrQr?ro�xml_dict�member_namerUZxml_nameZmember_nodeZattribsZ
location_namercr,Znew_keyrrr�_handle_structurets2





z'BaseXMLResponseParser._handle_structurecCs2|j|�dkr.x|D]}|j|�dkr|SqW|S)NZ
ErrorResponserG)rf)r
�
original_root�childrrrrp�s

z%BaseXMLResponseParser._get_error_rootcCsL|jdkr0|jjd�r0|jjjd�}|dk	r0|S|jjd�}|dk	rH|S|S)NrerdrZ)rOr:r;rS)r
rrvZlist_member_serialized_nameZserialized_namerrrrr�sz&BaseXMLResponseParser._member_key_namecCsxt|t�r|j|d�Si}xV|D]N}|j|�}||krht||t�rV||j|�qp|||g||<q"|||<q"W|S)Nr)r<rerqrfrT)r
Zparent_noderurVrcrrrrq�s


z-BaseXMLResponseParser._build_name_to_xml_nodecCsby*tjtj�|jd�}|j|�|j�}Wn2tk
r\}ztd||f��WYdd}~XnX|S)N)�target�encodingzTUnable to parse response (%s), invalid XML received. Further retries may succeed:
%s)rZ	XMLParserZTreeBuilderr]Zfeed�closerr )r
�
xml_stringrY�root�errr�_parse_xml_string_to_dom�s

z.BaseXMLResponseParser._parse_xml_string_to_domcCsFx@|j�D]4\}}t|�r4|j|�}|j|�||<q
|j||<q
W|S)N)rsrerq�_replace_nodesr)r
r?rcr,Zsub_dictrrrr��s
z$BaseXMLResponseParser._replace_nodescCs|dkrdSdSdS)N�trueTFr)r
rrrrr�_handle_boolean�sz%BaseXMLResponseParser._handle_booleancCst|�S)N)�float)r
rrrrr�
_handle_float�sz#BaseXMLResponseParser._handle_floatcCs
|j|�S)N)r#)r
rrrrr�_handle_timestamp�sz'BaseXMLResponseParser._handle_timestampcCst|�S)N)�int)r
rrrrr�_handle_integer�sz%BaseXMLResponseParser._handle_integercCs|S)Nr)r
rrrrr�_handle_string�sz$BaseXMLResponseParser._handle_stringcCs
|j|�S)N)r%)r
rrrrr�_handle_blob�sz"BaseXMLResponseParser._handle_blob)NN)rrrrrirfrWrwrprrrqr�r�rr�r�r�r�r�r�Z_handle_characterZ_handle_doubleZ_handle_long�
__classcell__rr)rMrr^Ls&
	r^c@s>eZdZdd�Zdd�Zdd�Zddd	�Zd
d�Zdd
�ZdS)�QueryParsercCs\|d}|j|�}|j|�}|j|�d|kr>|j|jd��d|krXd|jd�i|d<|S)Nr.�Errors�	RequestIdr1)r�rqr�r�pop)r
r>r�xml_contentsr~r?rrrr8�s


zQueryParser._do_error_parsecCs|j||dd�S)NF)�inject_metadata)�_parse_body_as_xml)r
r>rrrrr7sz#QueryParser._do_modeled_error_parsecCs|j||dd�S)NT)r�)r�)r
r>rrrrr9
szQueryParser._do_parseTcCs^|d}|j|�}i}|dk	rJ|}d|jkr>|j|jd|�}|j||�}|rZ|j||�|S)Nr.Z
resultWrapper)r�r:�_find_result_wrapped_shaperR�_inject_response_metadata)r
r>rr�r�r~r?�startrrrr�
s

zQueryParser._parse_body_as_xmlcCs|j|�}||S)N)rq)r
Zelement_nameZ
xml_root_node�mappingrrrr�s
z&QueryParser._find_result_wrapped_shapecCsR|j|�}|jd�}|dk	rN|j|�}x|j�D]\}}|j||<q0W||d<dS)Nr1)rqr;rsr)r
rQ�inject_intor��
child_nodeZsub_mappingrcr,rrrr� s


z%QueryParser._inject_response_metadataN)T)	rrrr8r7r9r�r�r�rrrrr��s
r�cs,eZdZdd�Z�fdd�Zdd�Z�ZS)�EC2QueryParsercCs.|j|�}|jd�}|dk	r*d|ji|d<dS)NZ	requestIdr�r1)rqr;r)r
rQr�r�r�rrrr�,s

z(EC2QueryParser._inject_response_metadatacs0tt|�j||�}d|kr,d|jd�i|d<|S)NZ	RequestIDr�r1)r_r�r8r�)r
r>rZoriginal)rMrrr82s
zEC2QueryParser._do_error_parsecCs@x:|D]2}|j|�dkrx|D]}|j|�dkr|SqWqW|S)Nr�rG)rf)r
rxryZerrors_childrrrrpFs

zEC2QueryParser._get_error_root)rrrr�r8rpr�rr)rMrr�*sr�c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�BaseJSONParserc	Csd|j}|dkrdSi}xH|D]@}||}|jjd|�}|j|�}|dk	r|j|||�||<qW|S)NrZ)ror:r;rR)	r
rr,�
member_shapes�final_parsedrvrUZ	json_nameZ	raw_valuerrrrwQs

z BaseJSONParser._handle_structurec	CsJi}|j}|j}x4|j�D](\}}|j||�}|j||�}|||<qW|S)N)rcr,rsrR)	r
rr,r?rgrhrcZ
actual_keyZactual_valuerrrricszBaseJSONParser._handle_mapcCs
|j|�S)N)r%)r
rr,rrrr�mszBaseJSONParser._handle_blobcCs
|j|�S)N)r#)r
rr,rrrr�psz BaseJSONParser._handle_timestampcCs�|j|d�}ddd�id�}|jd|jdd��|dd<|jd�}|jd	|oTt|��}|dk	r�d
|krx|jd
d�d}||dd<|j||d
�|S)Nr.r)rFrE)rGr1�messagerFrGr/Z__type�#�rEr-)�_parse_body_as_jsonr;rH�rsplitr�)r
r>rr.�errorZ
response_code�coderrrr8ss	
zBaseJSONParser._do_error_parsecCs d|kr|d|jdi�d<dS)Nzx-amzn-requestidr1r�)�
setdefault)r
r?r-rrrr��sz(BaseJSONParser._inject_response_metadatacCs@|siS|j|j�}ytj|�}|Stk
r:d|iSXdS)Nr�)�decoder]�json�loads�
ValueError)r
�
body_contentsr.�original_parsedrrrr��s
z"BaseJSONParser._parse_body_as_jsonN)
rrrrwrir�r�r8r�r�rrrrr�Os
r�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�BaseEventStreamParsercCshi}|jjd�r@|djd�}|jj|�}|rd|j||�||<n$|j|||j|�|j|||j|�|S)Nr0r-z:event-type)r:r;ror9�_parse_non_payload_attrs�_parse_payload)r
r>rr�Z
event_typeZevent_shaperrrr9�s
zBaseEventStreamParser._do_parsecCs�|djd�}|jj|�}|dk	r\|j|d�}|j||�}d||jd|jdd��d�i}n&d|djd	d�|djd
d�d�i}|S)Nr-z:exception-typer.rGrFr�r)rErFz:error-codez:error-message)r;ro�_initial_body_parserR)r
r>rZexception_typeZexception_shaper�r.r�rrrr8�sz%BaseEventStreamParser._do_error_parsecCs�|jjd�r�xr|D]j}||}|jjd�r|d}|jdkrB|}n.|jdkrZ|j|j�}n|j|�}	|j||	�}|||<dSqW|j|d�}
|j||
�}|j|�dS)N�eventZeventpayloadr.�blob�string)r:r;rOr�r]r�rRr)r
r>rr�r�rZrUr.Zparsed_bodyZ	raw_parser��body_parsedrrrr��s 



z$BaseEventStreamParser._parse_payloadc	Cs^|d}xP|D]H}||}|jjd�r||kr||}|jdkrN|j|d�}|||<qWdS)Nr-rmZ	timestampg@�@)r:r;rOr#)	r
r>rr�r�r-rZrUr,rrrr��s

z.BaseEventStreamParser._parse_non_payload_attrscCstd��dS)Nr�)rL)r
r�rrrr��sz)BaseEventStreamParser._initial_body_parseN)rrrr9r8r�r�r�rrrrr��s

r�c@seZdZdd�ZdS)�EventStreamJSONParsercCs
|j|�S)N)r�)r
r�rrrr��sz)EventStreamJSONParser._initial_body_parseN)rrrr�rrrrr��sr�c@seZdZdd�ZdS)�EventStreamXMLParsercCs|stjd�S|j|�S)Nr)r�Elementr�)r
r}rrrr��s
z(EventStreamXMLParser._initial_body_parseN)rrrr�rrrrr��sr�c@s0eZdZeZdd�Zdd�Zdd�Zdd�Zd	S)
�
JSONParsercCsJi}|dk	r6|j}|r&|j|||�}n|j|d|�}|j||d�|S)Nr.r-)Zevent_stream_name�_handle_event_stream�_handle_json_bodyr�)r
r>rr?�
event_namerrrr9szJSONParser._do_parsecCs|j|d|�S)Nr.)r�)r
r>rrrrr7sz"JSONParser._do_modeled_error_parsec	Cs^|j|}|j||�}y|j�}Wn tk
rBd}t|��YnX|j|j|�}|||<|S)Nz,First event was not of type initial-response)ror[Zget_initial_responserr r��payload)	r
r>rr�Zevent_stream_shapeZevent_streamr�Z	error_msgr?rrrr�s
zJSONParser._handle_event_streamcCs|j|�}|j||�S)N)r�rR)r
Zraw_bodyrZparsed_jsonrrrr�s
zJSONParser._handle_json_bodyN)	rrrr�r'r9r7r�r�rrrrr��s
r�c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�BaseRestParsercCs$i}|j|�|d<|j|||�|S)Nr1)�_populate_response_metadata�_add_modeled_parse)r
r>rr�rrrr9%s

zBaseRestParser._do_parsecCs6|dkr|S|j}|j||||�|j||||�dS)N)ror�r�)r
r>rr�r�rrrr�,sz!BaseRestParser._add_modeled_parsecCsi}|j|||�|S)N)r�)r
r>rr�rrrr74sz&BaseRestParser._do_modeled_error_parsecCsJi}|d}d|kr"|d|d<n$d|krF|d|d<|jdd�|d<|S)Nr-zx-amzn-requestidr�zx-amz-request-idz
x-amz-id-2r�HostId)r;)r
r>rBr-rrrr�9sz*BaseRestParser._populate_response_metadatac
Cs�d|jkr�|jd}||}|jjd�r>|j||�}|||<q�|jdkrp|d}t|t�rf|j|j�}|||<q�|j|d�}|j	||�||<n$|j|d�}|j	||�}	|j
|	�dS)Nr�r0r�r�r.)r�r�)r:r;r[rOr<�bytesr�r]r�rRr)
r
r>rr�r�Zpayload_member_nameZ
body_shaper.r�r�rrrr�Fs"





zBaseRestParser._parse_payloadc
Cs�|d}x�|D]�}||}|jjd�}|dkr2qq|dkrP|j||d�||<q|dkrj|j||�||<q|dkr|jjd|�}	|	|kr|j|||	�||<qWdS)Nr-rlZ
statusCoder/�headerrZ)r:r;rR�_parse_header_map)
r
r>rr�r�r-rZrUrl�header_namerrrr�^s"
z'BaseRestParser._parse_non_payload_attrscCsRi}|jjdd�j�}x6|D].}|j�j|�r|t|�d�}||||<qW|S)NrZr)r:r;�lowerrD�len)r
rr-r?�prefixr�rZrrrr�rs
z BaseRestParser._parse_header_mapcCstd��dS)Nr�)rL)r
r�rrrr�sz"BaseRestParser._initial_body_parsecCs,|}t|�r(tj|�j|j�}tj|�}|S)N)r	r*r+r�r]r�r�)r
rr,r?Zdecodedrrrr��s

zBaseRestParser._handle_stringN)rrrr9r�r7r�r�r�r�r�r�rrrrr�#s

r�cs0eZdZeZdd�Z�fdd�Zdd�Z�ZS)�RestJSONParsercCs
|j|�S)N)r�)r
r�rrrr��sz"RestJSONParser._initial_body_parsecs"tt|�j||�}|j||�|S)N)r_r�r8�_inject_error_code)r
r>rr�)rMrrr8�szRestJSONParser._do_error_parsecCsr|j|d�}d|dkrB|dd}|jd�d}||dd<n,d|ksRd|krn|jd|jdd	��|dd<dS)
Nr.zx-amzn-errortyper-rnrrGrEr�r)r�rtr;)r
r�r>r.r�rrrr��sz!RestJSONParser._inject_error_code)	rrrr�r'r�r8r�r�rr)rMrr��sr�csDeZdZeZdd�Zdd�Zdd�Zdd�Ze	�fd	d
��Z
�ZS)�
RestXMLParsercCs|stjd�S|j|�S)Nr)rr�r�)r
r}rrrr��s
z!RestXMLParser._initial_body_parsecCsN|drDy
|j|�Stk
rB}ztjddd�WYdd}~XnX|j|�S)Nr.z2Exception caught when parsing error response body:T)�exc_info)�_parse_error_from_bodyr r2r3�_parse_error_from_http_status)r
r>rrrrrr8�s
zRestXMLParser._do_error_parsecCsHt|d�tjjjj|dd�d�|djdd�|djdd�d�d�S)	Nr/r)rErFr-zx-amz-request-idz
x-amz-id-2)r�r�)rGr1)rHrrIrJrKr;)r
r>rrrr��s


z+RestXMLParser._parse_error_from_http_statuscCs�|d}|j|�}|j|�}|j|�|jdkr\|j|�}|jdd�|jdd�||d�Sd|krvd|jd�i|d<dddd�i}t||�|S)	Nr.rGr�rr�)rGr1r1)rFrE)r�rqr�rkr�r�r)r
r>r�r~r?rB�defaultrrrr��s






z$RestXMLParser._parse_error_from_bodycstt|�j||�}|S)N)r_r�r�)r
rr)rMrrr��szRestXMLParser._handle_string)rrrr�r'r�r8r�r�rr�r�rr)rMrr��s
r�)Zec2Zqueryr�z	rest-jsonzrest-xml)(r\r`r*r�ZloggingZbotocore.compatrrrZbotocore.eventstreamrrZbotocore.utilsrrr	r
Z	getLoggerrr2r"�objectrrr�	Exceptionr r!r^r�r�r�r�r�r�r�r�r�r�rrrrr�<module>ts@
*5%QN'kN