ok

Mini Shell

Direktori : /opt/alt/python38/lib64/python3.8/site-packages/aiohttp/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/site-packages/aiohttp/__pycache__/formdata.cpython-38.pyc

U

'�7`��@s~ddlZddlmZmZmZmZddlmZddlm	Z	m
Z
ddlmZm
Z
mZddlmZddlmZd	ZGd
d�d�ZdS)�N)�Any�Iterable�List�Optional)�	urlencode)�	MultiDict�MultiDictProxy�)�hdrs�	multipart�payload)�guess_filename)�Payload)�FormDatac@s�eZdZdZdeeeeedd�dd�Z	e
ed�d	d
��Zdddd�eeeeeeeedd�d
d�Zedd�dd�Z
ejd�dd�Zejd�dd�Zed�dd�ZdS)rz_Helper class for multipart/form-data and
    application/x-www-form-urlencoded body generation.�TN)�fields�quote_fields�charset�returncCsdt�d�|_g|_d|_d|_||_||_t|t	�rBt
|���}nt|t
tf�sV|f}|j
|�dS)N�	form-dataF)r�MultipartWriter�_writer�_fields�
_is_multipart�
_is_processed�
_quote_fields�_charset�
isinstance�dict�list�items�tuple�
add_fields)�selfrrrrr�C/opt/alt/python38/lib64/python3.8/site-packages/aiohttp/formdata.py�__init__s
zFormData.__init__)rcCs|jS�N)r�r#rrr$�is_multipart%szFormData.is_multipart)�content_type�filename�content_transfer_encoding)�name�valuer)r*r+rcCst|tj�rd|_n$t|tttf�r8|dkr8|dkr8|}td|i�}|dk	rbt|t�sbt	d|��|dkr�t|tj�r�t
||�}|dk	r�||d<d|_i}|dk	r�t|t�s�t	d|��||tj<d|_|dk	r�t|t�s�t	d|��||tj
<d|_|j�|||f�dS)NTr,z,filename must be an instance of str. Got: %sr*z0content_type must be an instance of str. Got: %sz=content_transfer_encoding must be an instance of str. Got: %s)r�io�IOBaser�bytes�	bytearray�
memoryviewr�str�	TypeErrorr
r
�CONTENT_TYPEZCONTENT_TRANSFER_ENCODINGr�append)r#r,r-r)r*r+�type_options�headersrrr$�	add_field)sB
�

�

��
zFormData.add_field)rrcGs�t|�}|r�|�d�}t|tj�r:t|d�}|�||�qt|ttf�rX|�	|�
��qt|ttf�r�t|�dkr�|\}}|�||�qt
d�|���qdS)Nr�unknown�zxOnly io.IOBase, multidict and (name, file) pairs allowed, use .add_field() for passing more complex parameters, got {!r})r�poprr.r/r
r9rr�extendr r!�lenr4�format)r#rZto_addZrec�k�fprrr$r"Ws 

��zFormData.add_fieldscCsng}|jD]\}}}|�|d|f�q
|jdk	r8|jnd}|dkrJd}nd|}tjt|d|d���|d�S)Nr,zutf-8z!application/x-www-form-urlencodedz-application/x-www-form-urlencoded; charset=%sT)Zdoseq�encoding)r))rr6rr�BytesPayloadr�encode)r#�datar7�_r-rr)rrr$�_gen_form_urlencodedos�zFormData._gen_form_urlencodedcCs�|jrtd��|jD]�\}}}z<tj|krFtj||tj||jd�}ntj|||jd�}Wn:tk
r�}zt	dt
|�||f�|�W5d}~XYnX|r�|jd	d|ji|��|j
dk	s�t�|j
�tjd�|j�|�qd|_|jS)
zAEncode a list of fields using the multipart/form-data MIME formatz$Form data has been processed already)r)r8rB)r8rBz8Can not serialize value type: %r
 headers: %r
 value: %rNrrT)r)r�RuntimeErrorrr
r5rZget_payloadr�	Exceptionr4�typeZset_content_dispositionrr8�AssertionErrorZpopallZCONTENT_LENGTHrZappend_payload)r#Z
dispparamsr8r-�part�excrrr$�_gen_form_data�sJ
��
������zFormData._gen_form_datacCs|jr|��S|��SdSr&)rrNrGr'rrr$�__call__�szFormData.__call__)rTN)�__name__�
__module__�__qualname__�__doc__rr�boolrr3r%�propertyr(r9r"rrCrGrrrNrrOrrrr$rs6����.%r)r.�typingrrrrZurllib.parserZ	multidictrr�r
rrZhelpersr
r�__all__rrrrr$�<module>s

Zerion Mini Shell 1.0