
    &g                     j    d Z ddlmZmZ ddlmZmZ ddlmZ ej	        dd            Z
d Zd	 Zd
 ZdS )z
oauthlib.parameters
~~~~~~~~~~~~~~~~~~~

This module contains methods related to `section 3.5`_ of the OAuth 1.0a spec.

.. _`section 3.5`: https://tools.ietf.org/html/rfc5849#section-3.5
    )urlparse
urlunparse)extract_params	urlencode   )utilsNc                 H   |pi }g }| D ]X\  }}t          j        |          }t          j        |          }d                    ||          }|                    |           Yd                    |          }	|rd|z  |	z   }	d|	z  }
i }|                    |           |
|d<   |S )a  **Prepare the Authorization header.**
    Per `section 3.5.1`_ of the spec.

    Protocol parameters can be transmitted using the HTTP "Authorization"
    header field as defined by `RFC2617`_ with the auth-scheme name set to
    "OAuth" (case insensitive).

    For example::

        Authorization: OAuth realm="Example",
            oauth_consumer_key="0685bd9184jfhq22",
            oauth_token="ad180jjd733klru7",
            oauth_signature_method="HMAC-SHA1",
            oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D",
            oauth_timestamp="137131200",
            oauth_nonce="4572616e48616d6d65724c61686176",
            oauth_version="1.0"


    .. _`section 3.5.1`: https://tools.ietf.org/html/rfc5849#section-3.5.1
    .. _`RFC2617`: https://tools.ietf.org/html/rfc2617
    z{}="{}"z, zrealm="%s", zOAuth %sAuthorization)r   escapeformatappendjoinupdate)oauth_paramsheadersrealm%authorization_header_parameters_partsoauth_parameter_namevalueescaped_nameescaped_valuepartauthorization_header_parametersauthorization_headerfull_headerss               T/var/www/api/venv/lib/python3.11/site-packages/oauthlib/oauth1/rfc5849/parameters.pyprepare_headersr      s    0 mG -/)'3 ; ;#e
 |$899U++
 m<<-44T:::: '+ii-'/ '/#  L+9E+A+J,K' &(GG L   $8L!    c                 |    t          |          }|                    |            |                    d            |S )a>  Append OAuth params to an existing set of parameters.

    Both params and oauth_params is must be lists of 2-tuples.

    Per `section 3.5.2`_ and `3.5.3`_ of the spec.

    .. _`section 3.5.2`: https://tools.ietf.org/html/rfc5849#section-3.5.2
    .. _`3.5.3`: https://tools.ietf.org/html/rfc5849#section-3.5.3

    c                 8    | d                              d          S )Nr   oauth_)
startswith)is    r   <lambda>z _append_params.<locals>.<lambda>i   s    adooh77 r   )key)listextendsort)r   paramsmergeds      r   _append_paramsr+   X   s@     &\\F
MM,
 KK77K888Mr   c                 "    t          | |          S )zPrepare the Form-Encoded Body.

    Per `section 3.5.2`_ of the spec.

    .. _`section 3.5.2`: https://tools.ietf.org/html/rfc5849#section-3.5.2

    )r+   )r   bodys     r   prepare_form_encoded_bodyr.   m   s     ,---r   c                     t          |          \  }}}}}}t          t          | t          |          pg                     }t	          ||||||f          S )zPrepare the Request URI Query.

    Per `section 3.5.3`_ of the spec.

    .. _`section 3.5.3`: https://tools.ietf.org/html/rfc5849#section-3.5.3

    )r   r   r+   r   r   )r   urischnetpathparqueryfras           r   prepare_request_uri_queryr7   y   sb     '/smm#CdC|^E%:%:%@bAAC CEsCsE37888r   )NN)__doc__urllib.parser   r   oauthlib.commonr   r    r   filter_paramsr   r+   r.   r7    r   r   <module>r>      s     . - - - - - - - 5 5 5 5 5 5 5 5      
 B B B BJ  *	. 	. 	.9 9 9 9 9r   