HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: sport3497 (1034)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib64/python3.10/site-packages/botocore/__pycache__/serialize.cpython-310.pyc
o

�hY��@sdZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZmZmZmZdZd	Zd
Ze�d�Zdd
d�ZGdd�d�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�dee�ZGdd�de�Zeeeeed�Z dS)a�Protocol input serializes.

This module contains classes that implement input serialization
for the various AWS protocol types.

These classes essentially take user input, a model object that
represents what the expected input should look like, and it returns
a dictionary that contains the various parts of a request.  A few
high level design decisions:


* Each protocol type maps to a separate class, all inherit from
  ``Serializer``.
* The return value for ``serialize_to_request`` (the main entry
  point) returns a dictionary that represents a request.  This
  will have keys like ``url_path``, ``query_string``, etc.  This
  is done so that it's a) easy to test and b) not tied to a
  particular HTTP library.  See the ``serialize_to_request`` docstring
  for more details.

Unicode
-------

The input to the serializers should be text (str/unicode), not bytes,
with the exception of blob types.  Those are assumed to be binary,
and if a str/unicode type is passed in, it will be encoded as utf-8.
�N)�ElementTree)�validate)�
formatdate)�ParamValidationError)�
has_header�is_json_value_header�parse_to_aware_datetime�percent_encode�iso8601z%Y-%m-%dT%H:%M:%SZz%Y-%m-%dT%H:%M:%S.%fZz^[A-Za-z0-9\.\-]+$TcCs&t|�}|rt��}t�||�}|S�N)�SERIALIZERSr�ParamValidator�ParamValidationDecorator)�
protocol_name�include_validation�
serializer�	validator�r�E/usr/local/CyberCP/lib/python3.10/site-packages/botocore/serialize.py�create_serializerBs

rc@sbeZdZdZeZdZdd�Zdd�Zdd�Z	d	d
�Z
dd�Zddd�Zdd�Z
dd�Zdd�Zd
S)�
Serializer�POSTzutf-8cC�td��)a�Serialize parameters into an HTTP request.

        This method takes user provided parameters and a shape
        model and serializes the parameters to an HTTP request.
        More specifically, this method returns information about
        parts of the HTTP request, it does not enforce a particular
        interface or standard for an HTTP request.  It instead returns
        a dictionary of:

            * 'url_path'
            * 'host_prefix'
            * 'query_string'
            * 'headers'
            * 'body'
            * 'method'

        It is then up to consumers to decide how to map this to a Request
        object of their HTTP library of choice.  Below is an example
        return value::

            {'body': {'Action': 'OperationName',
                      'Bar': 'val2',
                      'Foo': 'val1',
                      'Version': '2014-01-01'},
             'headers': {},
             'method': 'POST',
             'query_string': '',
             'host_prefix': 'value.',
             'url_path': '/'}

        :param parameters: The dictionary input parameters for the
            operation (i.e the user input).
        :param operation_model: The OperationModel object that describes
            the operation.
        �serialize_to_request��NotImplementedError)�self�
parameters�operation_modelrrrrTs$zSerializer.serialize_to_requestcCsdd|jidd�}|S)N�/��)�url_path�query_string�method�headers�body)�DEFAULT_METHOD)r�
serializedrrr�_create_default_requestzs�z"Serializer._create_default_requestcCs|jdkrt}nt}|�|�S)Nr)�microsecond�
ISO8601_MICRO�ISO8601�strftime)r�value�timestamp_formatrrr�_timestamp_iso8601�s

zSerializer._timestamp_iso8601cCstt�|����Sr)�int�calendar�timegm�	timetuple�rr.rrr�_timestamp_unixtimestamp��z#Serializer._timestamp_unixtimestampcCs"t|tj�r|�|�}t|dd�S)NT)�usegmt)�
isinstance�datetimer6rr5rrr�_timestamp_rfc822�s
zSerializer._timestamp_rfc822NcCs:|dur|j}|��}t|�}t|d|���}||�}|S)N�_timestamp_)�TIMESTAMP_FORMAT�lowerr�getattr)rr.r/�datetime_obj�	converter�final_valuerrr�_convert_timestamp_to_str�sz$Serializer._convert_timestamp_to_strcCs|j�d|�S�N�name��
serialization�get)r�shape�default_namerrr�_get_serialized_name�szSerializer._get_serialized_namecCs,t|t�r|�|j�}t�|����|j�Sr)r9�str�encode�DEFAULT_ENCODING�base64�	b64encode�strip�decoder5rrr�_get_base64�s
zSerializer._get_base64cCs�|j}|dusd|vr
dS|d}|jj}dd�|��D�}i}g}|D]}	||	}
t�|
�s4|�|	�|
||	<q$|rGtdd�|��d�d��|j	di|��S)	N�
hostPrefixcSs g|]\}}|j�d�r|�qS)�	hostLabelrF)�.0�memberrIrrr�
<listcomp>�s
��z2Serializer._expand_host_prefix.<locals>.<listcomp>z Invalid value for parameter(s): z, z?. Must contain only alphanumeric characters, hyphen, or period.)�reportr)
�endpoint�input_shape�members�items�HOST_PREFIX_RE�match�appendr�join�format)rrr�operation_endpoint�host_prefix_expression�
input_members�host_labels�
format_kwargs�
bad_labelsrE�paramrrr�_expand_host_prefix�s*�


�zSerializer._expand_host_prefixr)�__name__�
__module__�__qualname__r'�dict�MAP_TYPErNrr)r0r6r;rCrKrSrjrrrrrKs&
	rc@speZdZdZdd�Zddd�Zddd�Zdd	d
�Zddd�Zdd
d�Z	ddd�Z
ddd�Zddd�Zdd�Z
dS)�QuerySerializerr
cCs�|j}|��}|j�d|j�|d<ddi|d<|��}|j|d<|jd|d<|dur2|�|||�||d<|�	||�}|durD||d	<|S)
Nr$�Content-Typez0application/x-www-form-urlencoded; charset=utf-8r%�Action�
apiVersion�Versionr&�host_prefix)
r[r)�httprHr'rorE�metadata�
_serializerj)rrrrIr(�body_paramsrurrrr�s"��
z$QuerySerializer.serialize_to_requestr cCs*t|d|j��|j�}|||||d�dS)N�_serialize_type_)�prefix�r?�	type_name�_default_serialize)rr(r.rIr{r$rrrrx�s
�zQuerySerializer._serializec	CsR|j}|��D]\}}||}|�||�}|r|�d|��}|�||||�qdS)N�.)r\r]rKrx)	rr(r.rIr{r\�key�member_shape�
member_prefixrrr�_serialize_type_structure�s�z)QuerySerializer._serialize_type_structurecCs�|sd||<dS|�|�r.|}|jj�d�r-|j|jdd�}d�|�d�dd�|g�}n|jj�dd�}|�d|��}t|d�D]\}}	|�d|��}
|j}|�||	||
�qBdS)Nr rE�rJr���rW�)	�_is_shape_flattenedrWrGrHrKra�split�	enumeraterx)rr(r.rIr{�list_prefixrE�	list_name�i�element�element_prefix�
element_shaperrr�_serialize_type_lists 
��z$QuerySerializer._serialize_type_listcCs�|�|�r|}n|�d�}|d}|j}|j}|j|dd�}	|�|d�}
t|d�D]$\}}|j||	d�}
|j||
d�}|�||||
�|�|||||�q)dS)Nz.entryz
.{i}.{suffix}r�r�r.r�)r��suffix)r�r�r.rKr�rbrx)rr(r.rIr{�full_prefix�template�	key_shape�value_shape�
key_suffix�value_suffixr�r��
key_prefix�value_prefixrrr�_serialize_type_maps

�z#QuerySerializer._serialize_type_mapcC�|�|�||<dSr�rS�rr(r.rIr{rrr�_serialize_type_blob%sz$QuerySerializer._serialize_type_blobcC�|�||j�d��||<dS�N�timestampFormat�rCrGrHr�rrr�_serialize_type_timestamp)��z)QuerySerializer._serialize_type_timestampcCs|rd||<dSd||<dS�N�true�falserr�rrr�_serialize_type_boolean.sz'QuerySerializer._serialize_type_booleancC�|||<dSrrr�rrrr~4�z"QuerySerializer._default_serializecCs|j�d�S)N�	flattenedrF�rrIrrrr�7r�z#QuerySerializer._is_shape_flattenedN�r )rkrlrmr=rrxr�r�r�r�r�r�r~r�rrrrrp�s


	




rpc@s"eZdZdZdd�Zddd�ZdS)	�
EC2SerializeraUEC2 specific customizations to the query protocol serializers.

    The EC2 model is almost, but not exactly, similar to the query protocol
    serializer.  This class encapsulates those differences.  The model
    will have be marked with a ``protocol`` of ``ec2``, so you don't need
    to worry about wiring this class up correctly.

    cCsDd|jvr
|jdSd|jvr |jd}|d��|dd�S|S)N�	queryNamerErr�)rG�upper)rrIrJrErrrrKEs



z"EC2Serializer._get_serialized_namer c	Cs<t|d�D]\}}|�d|��}|j}|�||||�qdS)Nr�r)r�rWrx)	rr(r.rIr{r�r�r�r�rrrr�Rs
�z"EC2Serializer._serialize_type_listNr�)rkrlrm�__doc__rKr�rrrrr�;s	
r�c@sReZdZdZdd�Zddd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�JSONSerializer�
unixtimestampc	Cs�d�|jd|j�}|jd}|��}|j�d|j�|d<|d|��d�|d<|��}|j}|dur9|�	|||�t
�|��|j
�|d<|�||�}|durR||d	<|S)
Nz{}.{}�targetPrefix�jsonVersionr$zapplication/x-amz-json-)zX-Amz-Targetrqr%r&ru)rbrwrEr)rvrHr'ror[rx�json�dumpsrMrNrj)	rrr�target�json_versionr(r&r[rurrrr\s*�
�
�z#JSONSerializer.serialize_to_requestNcCs(t|d|j��|j�}|||||�dS�Nrzr|)rr(r.rIr�r$rrrrxv�
�zJSONSerializer._serializec
Csv|jr	|||<dS|dur|��}|||<|}|j}|��D]\}}||}	d|	jvr0|	jd}|�|||	|�qdSrD)�is_document_typeror\r]rGrx)
rr(r.rIr��new_serializedr\�
member_key�member_valuer�rrrr�~s

��z(JSONSerializer._serialize_type_structurecCs8|��}|||<|��D]
\}}|�|||j|�qdSr)ror]rxr.)rr(r.rIr��map_obj�sub_key�	sub_valuerrrr��s
�z"JSONSerializer._serialize_type_mapcCs>g}|||<|D]}i}|�|||jd�|�|d�qdS)N�__current__)rxrWr`)rr(r.rIr��list_obj�	list_item�wrapperrrrr��s�z#JSONSerializer._serialize_type_listcCr�rr�rr(r.rIr�rrrr~�r�z!JSONSerializer._default_serializecCr�r�r�r�rrrr��r�z(JSONSerializer._serialize_type_timestampcCr�rr�r�rrrr��r7z#JSONSerializer._serialize_type_blobr)rkrlrmr=rrxr�r�r�r~r�r�rrrrr�Ys
r�c@s�eZdZdZdZdZgd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS)�BaseRestSerializera=Base class for rest protocols.

    The only variance between the various rest protocols is the
    way that the body is serialized.  All other aspects (headers, uri, etc.)
    are the same and logic for serializing those aspects lives here.

    Subclasses must implement the ``_serialize_body_params`` method.

    r
�rfc822)�uri�querystring�headerr%c
Cs*|��}|j�d|j�|d<|j}|dur|jd|d<|S|j}|��|��|��|��d�}|��D]\}}|dur=q4|�||||�q4|�	|jd|d�|d<d|jvre|�	|jd|d�|d<|d|d	<|d
ru|d
|d
<|�
|||||�|�|||�|�||�}	|	dur�|	|d<|S)Nr$�
requestUrir")�uri_path_kwargs�query_string_kwargs�body_kwargsr%r��authPath�	auth_pathr�r#r%ru)
r)rvrHr'r[r\ror]�_partition_parameters�_render_uri_template�_serialize_payload�_serialize_content_typerj)
rrrr(rI�
shape_members�partitioned�
param_name�param_valuerurrrr�sN����
�
�z'BaseRestSerializer.serialize_to_requestcCs^i}t�d|�D]}|�d�rt||dd�dd�||<qt||�||<q|jdi|��S)Nz{(.*?)}�+r�z/~)�safer)�re�findall�endswithr	rb)r�uri_template�params�encoded_params�template_paramrrrr��s
�
�z'BaseRestSerializer._render_uri_templatec	Cs�|j�d�}|�||�r|�|d�}|�|�}||d<dS|dur>|�|�}|dur6|�|||�|d<dS|��|d<dS|drN|�|d|�|d<dS|�|�r[|��|d<dSdS)N�payloadr!r&r�)rGrH�_has_streaming_payload�_encode_payload�_serialize_body_params�_serialize_empty_body�_requires_empty_body)	rr�rr(rIr��payload_member�body_payloadryrrrr�s&

��
�z%BaseRestSerializer._serialize_payloadcC�dS)Nr!r�rrrrr�2�z(BaseRestSerializer._serialize_empty_bodycCr�)z�
        Some protocols require varied Content-Type headers
        depending on user input. This allows subclasses to apply
        this conditionally.
        Nr)rr(rIr�rrrr�5sz*BaseRestSerializer._serialize_content_typecCr�)z�
        Some protocols require a specific body to represent an empty
        payload. This allows subclasses to apply this conditionally.
        Frr�rrrr�=sz'BaseRestSerializer._requires_empty_bodycCs|duo
||jdvS)z5Determine if payload is streaming (a blob or string).N)�blob�string)r})rr�r�rrrr�Dsz)BaseRestSerializer._has_streaming_payloadcCst|t�r|�|j�S|Sr)r9rLrMrN)rr&rrrr�Ks
z"BaseRestSerializer._encode_payloadcCs>||}|j�d�}|j�d|�}|dkr||d|<dS|dkret|t�r/|d�|�dSt|t�rBt|���}||d|<dS|jdkr]|j�d|j	�}	|�
||	�}
|
|d|<dS||d|<dS|d	kr�||}|sv|jd
krvdS|�||�}t|�|d|<dS|dkr�|}
|�|
|d|�dS||d|<dS)
N�locationrEr�r�r�r��	timestampr�r��listr%r�)
rGrHr9rn�update�boolrLr>r}�QUERY_STRING_TIMESTAMP_FORMATrC�_convert_header_value�_do_serialize_header_map)rr�r�r�r�rWr��key_name�bool_strr/r�rIr.�
header_prefixrrrr�Ps@


��
�z(BaseRestSerializer._partition_parameterscCs&|��D]\}}||}|||<qdSr)r])rr�r%�
user_inputr��val�full_keyrrrr��s
�z+BaseRestSerializer._do_serialize_header_mapcCr)Nr�r)rr�rIrrrr��sz)BaseRestSerializer._serialize_body_paramscs��jdkrt|�}t�|���}�j�d�j�}��||�S�jdkr2��fdd�|D�}d�	|�St
��r@��tj
|dd��S|S)	Nr�r�r�cs"g|]
}|dur���j|��qSr)r�rW)rV�vr�rrrX�s
�z<BaseRestSerializer._convert_header_value.<locals>.<listcomp>�,)r�:)�
separators)r}rr2r3�utctimetuplerGrH�HEADER_TIMESTAMP_FORMATrCrarrSr�r�)rrIr.r@r�r/�converted_valuerr�rr��s
�
�
z(BaseRestSerializer._convert_header_valueN)rkrlrmr�r�r�KNOWN_LOCATIONSrr�r�r�r�r�r�r�r�r�r�r�rrrrr��s"
; 1r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�RestJSONSerializercCr�)Ns{}rr�rrrr��r�z(RestJSONSerializer._serialize_empty_bodycCs(|j��D]\}}d|jvrdSqdS)zq
        Serialize an empty JSON object whenever the shape has
        members not targeting a location.
        r�TF)r\r]rG)rrIrWr�rrrr��s

�z'RestJSONSerializer._requires_empty_bodycCsV|j�d�}|�||�rdS|ddk}td|d�}|r'|s)d|dd<dSdSdS)z?Set Content-Type to application/json for all structured bodies.r�Nr&r!rqr%zapplication/json)rGrHr�r)rr(rIr�r��has_body�has_content_typerrrr��s�z*RestJSONSerializer._serialize_content_typecCs(|��}|�|||�t�|��|j�Sr)rorxr�r�rMrN)rr�rI�serialized_bodyrrrr��sz)RestJSONSerializer._serialize_body_paramsN)rkrlrmr�r�r�r�rrrrr�s

rc@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)�RestXMLSerializerr
cCs@|jd}t�d�}|�||||�t|�d}tj||jd�S)NrEr r)�encoding)rGr�Elementrxr��tostringrN)rr�rI�	root_name�pseudo_root�	real_rootrrrr��s


z(RestXMLSerializer._serialize_body_paramscCs(t|d|j��|j�}|||||�dSr�r|)rrIr��xmlnoderEr$rrrrx�r�zRestXMLSerializer._serializec
Cs�t�||�}d|jvr'|jd}d}|�d�r |d|d��7}|d|j|<|��D]0\}}	|j|}
|
j�d|�}|	durBdS|
j�d�rS|
jd}|	|j|<q+|�|
|	||�q+dS)N�xmlNamespace�xmlnsr{rr�rE�xmlAttribute)r�
SubElementrGrH�attribr]r\rx)
rrr�rIrE�structure_node�namespace_metadata�attribute_namer�r.r��member_name�xml_attribute_namerrrr��s$





�z+RestXMLSerializer._serialize_type_structurec	CsT|j}|j�d�r|}|}n
|j�dd�}t�||�}|D]
}|�||||�qdS)Nr�rErW)rWrGrHrrrx)	rrr�rIrEr��element_name�	list_node�itemrrrr��s�z&RestXMLSerializer._serialize_type_listcCsrt�||�}|��D],\}}t�|d�}|j|jdd�}	|j|jdd�}
|�|j|||	�|�|j|||
�q
dS)N�entryr�r�r.)rrr]rKr�r.rx)rrr�rIrE�noder�r.�
entry_noder��val_namerrrr��s	��z%RestXMLSerializer._serialize_type_mapcCs$t�||�}|rd}nd}||_dSr�)rr�text)rrr�rIrEr!�	str_valuerrrr�s

z)RestXMLSerializer._serialize_type_booleancCst�||�}|�|�|_dSr)rrrSr$�rrr�rIrEr!rrrr�sz&RestXMLSerializer._serialize_type_blobcCs&t�||�}|�||j�d��|_dSr�)rrrCrGrHr$r&rrrr�s
�z+RestXMLSerializer._serialize_type_timestampcCst�||�}t|�|_dSr)rrrLr$r&rrrr~ sz$RestXMLSerializer._default_serializeN)
rkrlrmr=r�rxr�r�r�r�r�r�r~rrrrr�sr)�ec2�queryr�z	rest-jsonzrest-xml)T)!r�rOr2r:r�r��	xml.etreer�botocorer�botocore.compatr�botocore.exceptionsr�botocore.utilsrrrr	�DEFAULT_TIMESTAMP_FORMATr,r+�compiler^rrrpr�r�r�rrrrrrr�<module>s>

	lYo f
�