o
    'hT	                     @  s   d dl mZ d dlZd dlZd dlZd dlZd dlmZ ddlm	Z	m
Z
 edd Zejejeee	f e
f  Zejeejee	f f Zdd
dZdddZ	ddddZdS )    )annotationsN)BytesIO   )_TYPE_FIELD_VALUE_TUPLERequestFieldzutf-8   returnstrc                   C  s   t td S )zN
    Our embarrassingly-simple replacement for mimetools.choose_boundary.
       )binasciihexlifyosurandomdecode r   r   L/var/www/html/olx_land/venv/lib/python3.10/site-packages/urllib3/filepost.pychoose_boundary   s   r   fields_TYPE_FIELDStyping.Iterable[RequestField]c                 c  sH    t | tjr|  }n| }|D ]}t |tr|V  qtj| V  qdS )z
    Iterate over fields.

    Supports list of (k, v) tuples and dicts, and lists of
    :class:`~urllib3.fields.RequestField`.

    N)
isinstancetypingMappingitemsr   from_tuples)r   iterablefieldr   r   r   iter_field_objects   s   


r   boundary
str | Nonetuple[bytes, str]c                 C  s   t  }|du r
t }t| D ]:}|d| dd t||  |j}t|t	r1t
|}t|t
r>t|| n|| |d q|d| dd d| }| |fS )a  
    Encode a dictionary of ``fields`` using the multipart/form-data MIME format.

    :param fields:
        Dictionary of fields or list of (key, :class:`~urllib3.fields.RequestField`).
        Values are processed by :func:`urllib3.fields.RequestField.from_tuples`.

    :param boundary:
        If not specified, then a random boundary will be generated using
        :func:`urllib3.filepost.choose_boundary`.
    Nz--z
zlatin-1s   
z--
zmultipart/form-data; boundary=)r   r   r   writeencodewriterrender_headersdatar   intr	   getvalue)r   r   bodyr   r%   content_typer   r   r   encode_multipart_formdata3   s    



r*   )r   r	   )r   r   r   r   )N)r   r   r   r   r   r    )
__future__r   r   codecsr   r   ior   r   r   r   lookupr#   SequenceUniontupler	   _TYPE_FIELDS_SEQUENCEr   r   r   r   r*   r   r   r   r   <module>   s(    

