U cf @sddlmZddlZddlZddlZddlmZddlmZddl m Z ddl m Z e dd Zd d Zd d ZddZdddZdS))absolute_importN)BytesIO) RequestField)six)bzutf-8cCs$ttd}tjs |d}|S)zN Our embarrassingly-simple replacement for mimetools.choose_boundary. ascii)binasciihexlifyosurandomrPY2decode)boundaryrJ/opt/hc_python/lib/python3.8/site-packages/pip/_vendor/urllib3/filepost.pychoose_boundarys rccsJt|trt|}nt|}|D]"}t|tr8|Vq"tj|Vq"dS)z Iterate over fields. Supports list of (k, v) tuples and dicts, and lists of :class:`~urllib3.fields.RequestField`. N) isinstancedictr iteritemsiterr from_tuples)fieldsifieldrrriter_field_objectss   rcCs,t|trddt|DSdd|DS)a- .. deprecated:: 1.6 Iterate over fields. The addition of :class:`~urllib3.fields.RequestField` makes this function obsolete. Instead, use :func:`iter_field_objects`, which returns :class:`~urllib3.fields.RequestField` objects. Supports list of (k, v) tuples and dicts. css|]\}}||fVqdSNr.0kvrrr :sziter_fields..css|]\}}||fVqdSrrrrrrr#<s)rrrr)rrrr iter_fields-s r$cCst}|dkrt}t|D]p}|td|t|||j}t|t r\t |}t|t j rxt||n |||dq|td|t d|}| |fS)aQ 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`). :param boundary: If not specified, then a random boundary will be generated using :func:`urllib3.filepost.choose_boundary`. Nz--%s s z--%s-- z multipart/form-data; boundary=%s)rrrwriterwriterrender_headersdatarintstrr text_typegetvalue)rrbodyrr( content_typerrrencode_multipart_formdata?s       r/)N) __future__rr codecsr iorrrpackagesrZ packages.sixrlookupr&rrr$r/rrrrs