o |nhT @sddlmZddlZddlZddlZddlZddlmZddlm Z m Z e ddZ ej ejeee fe fZejeejee ffZdd d ZdddZ ddddZdS)) annotationsN)BytesIO)_TYPE_FIELD_VALUE_TUPLE RequestFieldzutf-8returnstrcCsttdS)zN Our embarrassingly-simple replacement for mimetools.choose_boundary. )binasciihexlifyosurandomdecoderrH/usr/local/bin/dhwp/env/lib/python3.10/site-packages/urllib3/filepost.pychoose_boundarysrfields _TYPE_FIELDStyping.Iterable[RequestField]ccsHt|tjr |}n|}|D]}t|tr|Vqtj|VqdS)z Iterate over fields. Supports list of (k, v) tuples and dicts, and lists of :class:`~urllib3.fields.RequestField`. N) isinstancetypingMappingitemsr from_tuples)riterablefieldrrriter_field_objectss  rboundary str | Nonetuple[bytes, str]cCst}|dur t}t|D]:}|d|ddt|||j}t|t r1t |}t|t r>t||n|||dq|d|ddd|}| |fS)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 zlatin-1s z-- zmultipart/form-data; boundary=) rrrwriteencodewriterrender_headersdatarintr getvalue)rrbodyrr% content_typerrrencode_multipart_formdata3s        r*)rr )rrrr)N)rrrrrr ) __future__rr codecsr riorrrrlookupr#SequenceUniontupler _TYPE_FIELDS_SEQUENCErrrrr*rrrrs(