
    nbi#                    ~    d dl mZ d dlZd dlZd dlZej        rddlmZm	Z	 	 dddZ
ddZddZ G d d          ZdS )    )annotationsN   )_TYPE_FIELD_VALUE_TYPE_FIELD_VALUE_TUPLEapplication/octet-streamfilename
str | Nonedefaultstrreturnc                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)r   r
   s     e/var/www/html/mdtn/previsions/meteo_cartes/venv/lib/python3.11/site-packages/urllib3_future/fields.pyguess_content_typer      s,      <#H--a0;G;N    namevaluer   c                N   t          t                    r                    d          t          fddD                       s7|  d d}	 |                    d           |S # t
          t          f$ r Y nw xY wt          j        	                    d          |  d S )a  
    Helper function to format and quote a single header parameter using the
    strategy defined in RFC 2231.

    Particularly useful for header parameters which might contain
    non-ASCII values, like file names. This follows
    `RFC 2388 Section 4.4 <https://tools.ietf.org/html/rfc2388#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 ``bytes`` or `str``.
    :returns:
        An RFC-2231-formatted unicode string.

    .. deprecated:: 2.0.0
        Will be removed in urllib3 v2.1.0. This is not valid for
        ``multipart/form-data`` header parameters.
    utf-8c              3      K   | ]}|v V  	d S N ).0chr   s     r   	<genexpr>z.format_header_param_rfc2231.<locals>.<genexpr>2   s'      //rrU{//////r   z"\
=""asciiz*=)

isinstancebytesdecodeanyencodeUnicodeEncodeErrorUnicodeDecodeErroremailutilsencode_rfc2231)r   r   results    ` r   format_header_param_rfc2231r+      s    ( % &W%%////Y///// $$E$$$	MM'""" M #$67 	 	 	D	
 K&&ug66EuELs   A' 'A;:A;c                    t          |t                    r|                    d          }|                    dddd          }|  d| dS )a  
    Format and quote a single multipart header parameter.

    This follows the `WHATWG HTML Standard`_ as of 2021/06/10, matching
    the behavior of current browser and curl versions. Values are
    assumed to be UTF-8. The ``\n``, ``\r``, and ``"`` characters are
    percent encoded.

    .. _WHATWG HTML Standard:
        https://html.spec.whatwg.org/multipage/
        form-control-infrastructure.html#multipart-form-data

    :param name:
        The name of the parameter, an ASCII-only ``str``.
    :param value:
        The value of the parameter, a ``str`` or UTF-8 encoded
        ``bytes``.
    :returns:
        A string ``name="value"`` with the escaped value.

    .. versionchanged:: 2.0.0
        Matches the WHATWG HTML Standard as of 2021/06/10. Control
        characters are no longer percent encoded.

    .. versionchanged:: 2.0.0
        Renamed from ``format_header_param_html5`` and
        ``format_header_param``. The old names will be removed in
        urllib3 v2.1.0.
    r   z%0Az%0Dz%22)
      "   r   r   )r    r!   r"   	translate)r   r   s     r   format_multipart_header_paramr1   A   s[    < % &W%% OOEu==>>Eer   c                  f    e Zd ZdZ	 	 	 dddZe	 dd d            Zd!dZd"dZd#dZ		 	 	 dd$dZ
dS )%RequestFielda  
    A data container for request body parameters.

    :param name:
        The name of this request field. Must be unicode.
    :param data:
        The data/value body.
    :param filename:
        An optional filename of the request field. Must be unicode.
    :param headers:
        An optional dict-like object of headers to initially use for the field.

    .. versionchanged:: 2.0.0
        The ``header_formatter`` parameter is deprecated and will
        be removed in urllib3 v2.1.0.
    Nr   r   datar   r   r	   headerstyping.Mapping[str, str] | Noneheader_formatter5typing.Callable[[str, _TYPE_FIELD_VALUE], str] | Nonec                    || _         || _        || _        i | _        |rt	          |          | _        |	|| _        d S t          | _        d S r   )_name	_filenamer4   r5   dictr7   r1   )selfr   r4   r   r5   r7   s         r   __init__zRequestField.__init__y   sW     
!	.0 	)==DL'$4D!!!$AD!!!r   	fieldnamer   r   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   r7   )content_type)r    tuplelenr   make_multipart)clsr?   r   r7   r   r4   rB   request_params           r   from_tupleszRequestField.from_tuples   s    6 eU## 		5zzQ/4,$!&$1(;;HLDthAQ
 
 
 	$$,$???r   c                .    |                      ||          S )a  
        Override this method to change how each multipart header
        parameter is formatted. By default, this calls
        :func:`format_multipart_header_param`.

        :param name:
            The name of the parameter, an ASCII-only ``str``.
        :param value:
            The value of the parameter, a ``str`` or UTF-8 encoded
            ``bytes``.

        :meta public:
        )r7   )r=   r   r   s      r   _render_partzRequestField._render_part   s     $$T5111r   header_parts[dict[str, _TYPE_FIELD_VALUE | None] | typing.Sequence[tuple[str, _TYPE_FIELD_VALUE | None]]c                    g }t          |t                    r|                                }n|}|D ]0\  }}|)|                    |                     ||                     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) tuples or a :class:`dict` of (k, v) to format
            as `k1="v1"; k2="v2"; ...`.
        N; )r    r<   itemsappendrJ   join)r=   rK   partsiterabler   r   s         r   _render_partszRequestField._render_parts   s    & lD)) 	$#))++HH#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
)r5   getrP   rO   rQ   )r=   lines	sort_keyssort_keyheader_nameheader_values         r   render_headerszRequestField.render_headers   s     OOO	! 	F 	FH|%00 FDDDL,BDDEEE)-););)=)= 	C 	C%K)++ CLLK!A!A<!A!ABBBV{{5!!!r   content_dispositionrB   content_locationNonec           	         |pdd                     d|                     d| j        fd| j        ff          g          z   }|| j        d<   || 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_disposition:
            The 'Content-Disposition' of the request body. Defaults to 'form-data'
        :param content_type:
            The 'Content-Type' of the request body.
        :param content_location:
            The 'Content-Location' of the request body.

        z	form-datarN    r   r   rV   rW   rX   N)rQ   rT   r:   r;   r5   )r=   r`   rB   ra   s       r   rE   zRequestField.make_multipart   s    (  3AkTYY""dj)J+GH F
 F
 
 /B*+'3^$+;'(((r   )NNN)
r   r   r4   r   r   r	   r5   r6   r7   r8   r   )r?   r   r   r   r7   r8   r   r3   r   r   r   r   r   r   )rK   rL   r   r   )r   r   )r`   r	   rB   r	   ra   r	   r   rb   )__name__
__module____qualname____doc__r>   classmethodrH   rJ   rT   r_   rE   r   r   r   r3   r3   g   s         *  $37RVB B B B B( 
 SW	* * * * [*X2 2 2 2        >" " " "* +/#''+	< < < < < < <r   r3   )r   )r   r	   r
   r   r   r   re   )
__future__r   email.utilsr'   r   typingTYPE_CHECKING_typingr   r   r   r+   r1   r3   r   r   r   <module>rp      s    " " " " " "         	 DCCCCCCCC *D     # # # #L# # # #Lt< t< t< t< t< t< t< t< t< t<r   