
    ?g5
                     R    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y)zn
oauthlib.utils
~~~~~~~~~~~~~~

This module contains utility methods used by various parts of the OAuth
spec.
    N)quoteunquote>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789c                 4      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                 2    t        |       }  | g|i |S )N)filter_oauth_params)paramsargskwargstargets      R/var/www/openai/venv/lib/python3.12/site-packages/oauthlib/oauth1/rfc5849/utils.pywrapperzfilter_params.<locals>.wrapper   s"    $V,f.t.v..    )__doc__)r   r   s   ` r   filter_paramsr      s    / nnGONr   c           	          d }t        | t              r,t        t        |t        | j	                                           S t        t        ||             S )zARemoves all non oauth parameters from a dict or a list of params.c                 *    | d   j                  d      S )Nr   oauth_)
startswith)kvs    r   <lambda>z%filter_oauth_params.<locals>.<lambda>!   s    "Q%**84r   )
isinstancedictlistfilteritems)r	   is_oauths     r   r   r      s@    4H&$F8T&,,.%9:;;F8V,--r   c           	          t        | t              s't        ddj                  | 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'   (   sI     a?/66q$q'BC D 	D r   c                 N    t        | t              st        d      t        |       S )Nz%Only unicode objects are unescapable.)r   r!   r"   r   r%   s    r   unescaper)   8   s"    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j                         }| dt        |       j                         j                  |      r:t        | t        |      d       }	 t	        t        |      j                               S t        d      # t        t        f$ r Y t        d      w xY w)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AA+N 4S5E5F GH	.44677 5
66 J' 	
5
66	s   !B BB)r   urllib.requestrequestr+   oauthlib.commonr   r   UNICODE_ASCII_CHARACTER_SETr   r   r'   r)   r,   r0   r7    r   r   <module>r=      s=    ! * , 
. &&	7r   