
    c                     |    d dl mZ d dlZd dlZ G d de          Z e            Zd
dZd Z	 G d d	e          Z
dS )    )absolute_importNc                   8    e Zd ZddlZej        d         dk    ZdS )Sixr   N   )__name__
__module____qualname__sysversion_infoPY3     Elib/python3.11/site-packages/anaconda_project/internal/test/fields.pyr   r      s)        JJJ

1

!CCCr   r   application/octet-streamc                 B    | rt          j        |           d         p|S |S )z
    Guess the "Content-Type" of a file.

    :param filename:
        The filename to guess the "Content-Type" of using :mod:`mimetypes`.
    :param default:
        If no "Content-Type" can be guessed, default to `default`.
    r   )	mimetypes
guess_type)filenamedefaults     r   guess_content_typer   '   s,      <#H--a0;G;Nr   c                 .   t          fddD                       s0| dd}	 |                    d           |S # t          $ r Y nw xY wt          j        s                    d          t
          j                            d          | dS )a  
    Helper function to format and quote a single header parameter.

    Particularly useful for header parameters which might contain
    non-ASCII values, like file names. This follows RFC 2231, as
    suggested by RFC 2388 Section 4.4.

    :param name:
        The name of the parameter, a string expected to be ASCII only.
    :param value:
        The value of the parameter, provided as a unicode string.
    c              3       K   | ]}|v V  	d S Nr   ).0chvalues     r   	<genexpr>z&format_header_param.<locals>.<genexpr>B   s'      //rrU{//////r   z"\
z=""asciizutf-8z*=)anyencodeUnicodeEncodeErrorsixr   emailutilsencode_rfc2231)namer   results    ` r   format_header_paramr)   5   s     ////Y///// "ddEEE*	MM'""" M " 	 	 	D	 7 &W%%K&&ug66Eee$ELs   = 
A
	A
c                   J    e Zd ZdZd	dZed             Zd Zd Zd Z	d
dZ
dS )RequestFieldaK  
    A data container for request body parameters.

    :param name:
        The name of this request field.
    :param data:
        The data/value body.
    :param filename:
        An optional filename of the request field.
    :param headers:
        An optional dict-like object of headers to initially use for the field.
    Nc                 n    || _         || _        || _        i | _        |rt	          |          | _        d S d S r   )_name	_filenamedataheadersdict)selfr'   r/   r   r0   s        r   __init__zRequestField.__init__^   sA    
!	 	)==DLLL	) 	)r   c                     t          |t                    r/t          |          dk    r|\  }}}n|\  }}t          |          }nd}d}|} | |||          }|                    |           |S )a  
        A :class:`~urllib3.fields.RequestField` factory from old-style tuple parameters.

        Supports constructing :class:`~urllib3.fields.RequestField` from
        parameter of key/value strings AND key/filetuple. A filetuple is a
        (filename, data, MIME type) tuple where the MIME type is optional.
        For example::

            'foo': 'bar',
            'fakefile': ('foofile.txt', 'contents of foofile'),
            'realfile': ('barfile.txt', open('realfile').read()),
            'typedfile': ('bazfile.bin', open('bazfile').read(), 'image/jpeg'),
            'nonamefile': 'contents of nonamefile field',

        Field names and filenames must be unicode.
           N)r   )content_type)
isinstancetuplelenr   make_multipart)cls	fieldnamer   r   r/   r6   request_params          r   from_tupleszRequestField.from_tuplesf   s    $ eU## 		5zzQ </4,$!&$1(;;HLDIth???$$,$???r   c                 "    t          ||          S )a  
        Overridable helper function to format a single header parameter.

        :param name:
            The name of the parameter, a string expected to be ASCII only.
        :param value:
            The value of the parameter, provided as a unicode string.
        )r)   )r2   r'   r   s      r   _render_partzRequestField._render_part   s     #4///r   c                     g }|}t          |t                    r|                                }|D ]0\  }}|r)|                    |                     ||                     1d                    |          S )aO  
        Helper function to format and quote a single header.

        Useful for single headers that are composed of multiple items. E.g.,
        'Content-Disposition' fields.

        :param header_parts:
            A sequence of (k, v) typles or a :class:`dict` of (k, v) to format
            as `k1="v1"; k2="v2"; ...`.
        ; )r7   r1   itemsappendr@   join)r2   header_partspartsiterabler'   r   s         r   _render_partszRequestField._render_parts   s     lD)) 	,#))++H# 	= 	=KD% =T..tU;;<<<yyr   c                 j   g }g d}|D ]B}| j                             |d          r%|                    |d| j         |                    C| j                                         D ]%\  }}||vr|r|                    |d|           &|                    d           d                    |          S )z=
        Renders the headers for this request field.
        )Content-DispositionContent-TypeContent-LocationFz: z
)r0   getrD   rC   rE   )r2   lines	sort_keyssort_keyheader_nameheader_values         r   render_headerszRequestField.render_headers   s     OOO	! 	L 	LH|%00 L4<3I3IJKKK)-););)=)= 	I 	I%K)+ I ILL[[[,,!GHHHV{{5!!!r   c                     |pd| j         d<   | j         dxx         d                    d|                     d| j        fd| j        ff          g          z  cc<   || j         d<   || j         d<   d	S )
a|  
        Makes this request field into a multipart request field.

        This method overrides "Content-Disposition", "Content-Type" and
        "Content-Location" headers to the request parameter.

        :param content_type:
            The 'Content-Type' of the request body.
        :param content_location:
            The 'Content-Location' of the request body.

        z	form-datarK   rB    r'   r   rL   rM   N)r0   rE   rI   r-   r.   )r2   content_dispositionr6   content_locations       r   r:   zRequestField.make_multipart   s     /B.P[*+*+++tyy##fdj%9J;W$XYYZ0\ 0\ 	\+++'3^$+;'(((r   )NN)NNN)r   r   r	   __doc__r3   classmethodr>   r@   rI   rT   r:   r   r   r   r+   r+   Q   s         ) ) ) )   [B	0 	0 	0     ," " "&< < < < < <r   r+   )r   )
__future__r   email.utilsr$   r   objectr   r#   r   r)   r+   r   r   r   <module>r^      s   2 ' & & & & &        " " " " "& " " "
 
cee     8|< |< |< |< |<6 |< |< |< |< |<r   