
    &g5
                     T    d Z ddlmZ ddlmZmZ dZd Zd Z	d Z
d Zd	 Zd
 Zd ZdS )zn
oauthlib.utils
~~~~~~~~~~~~~~

This module contains utility methods used by various parts of the OAuth
spec.
    N)quoteunquote>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789c                 *      fd} j         |_         |S )zDecorator which filters params to remove non-oauth_* parameters

    Assumes the decorated method takes a params dict or list of tuples as its
    first argument.
    c                 :    t          |           }  | g|R i |S )N)filter_oauth_params)paramsargskwargstargets      O/var/www/api/venv/lib/python3.11/site-packages/oauthlib/oauth1/rfc5849/utils.pywrapperzfilter_params.<locals>.wrapper   s0    $V,,vf.t...v...    )__doc__)r   r   s   ` r   filter_paramsr      s,    / / / / / nGONr   c           	          d }t          | t                    r<t          t          |t          |                                                               S t          t          ||                     S )zARemoves all non oauth parameters from a dict or a list of params.c                 8    | d                              d          S )Nr   oauth_)
startswith)kvs    r   <lambda>z%filter_oauth_params.<locals>.<lambda>!   s    "Q%**844 r   )
isinstancedictlistfilteritems)r	   is_oauths     r   r   r      s\    44H&$ .F8T&,,..%9%9::;;;F8V,,---r   c           	          t          | t                    s3t          dd                    | t	          |                     z             t          | d          S )zEscape a unicode string in an OAuth-compatible fashion.

    Per `section 3.6`_ of the spec.

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

    z$Only unicode objects are escapable. zGot {!r} of type {}.   ~)safe)r   str
ValueErrorformattyper   us    r   escaper'   (   sc     a D?/66q$q''BBC D D 	D r   c                 h    t          | t                    st          d          t          |           S )Nz%Only unicode objects are unescapable.)r   r!   r"   r   r%   s    r   unescaper)   8   s0    a B@AAA1::r   c                 *    t          j        |           S )z1A unicode-safe version of urllib2.parse_keqv_list)urllib2parse_keqv_list)ls    r   r,   r,   >        "1%%%r   c                 *    t          j        |           S )z1A unicode-safe version of urllib2.parse_http_list)r+   parse_http_listr%   s    r   r0   r0   D   r.   r   c                    d                                 }| dt          |                                                                        |          rjt          | t          |          d                   }	 t	          t          |                                                    S # t          t          f$ r Y nw xY wt          d          )z;Parse an OAuth authorization header into a list of 2-tupleszOAuth NzMalformed authorization header)	lowerlenr   r0   r   r,   r   
IndexErrorr"   )authorization_headerauth_schemer   s      r   parse_authorization_headerr7   J   s    ..""K-S---.4466AA+NN  4S5E5E5F5F GHH	..4466777J' 	 	 	D	
5
6
66s   6-B$ $B87B8)r   urllib.requestrequestr+   oauthlib.commonr   r   UNICODE_ASCII_CHARACTER_SETr   r   r'   r)   r,   r0   r7    r   r   <module>r=      s     !           * * * * * * * * , 
  . . .     & & && & &	7 	7 	7 	7 	7r   