a
    o=ic5
                     @   s`   d Z ddlmZ ddlmZmZ dZdd Zdd Z	d	d
 Z
dd Zdd Zdd Zdd ZdS )zn
oauthlib.utils
~~~~~~~~~~~~~~

This module contains utility methods used by various parts of the OAuth
spec.
    N)quoteunquoteZ>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789c                    s    fd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                    s   t | }  | g|R i |S )N)filter_oauth_params)paramsargskwargstarget n/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/oauthlib/oauth1/rfc5849/utils.pywrapper   s    zfilter_params.<locals>.wrapper)__doc__)r	   r   r
   r   r   filter_params   s    r   c                 C   s:   dd }t | tr(tt|t|  S tt|| S dS )zARemoves all non oauth parameters from a dict or a list of params.c                 S   s   | d  dS )Nr   Zoauth_)
startswith)kvr
   r
   r   <lambda>!       z%filter_oauth_params.<locals>.<lambda>N)
isinstancedictlistfilteritems)r   Zis_oauthr
   r
   r   r      s    
r   c                 C   s.   t | ts"tdd| t|  t| d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   ur
   r
   r   escape(   s
    
r    c                 C   s   t | tstdt| S )Nz%Only unicode objects are unescapable.)r   r   r   r   r   r
   r
   r   unescape8   s    
r!   c                 C   s
   t | S )z1A unicode-safe version of urllib2.parse_keqv_list)urllib2parse_keqv_list)lr
   r
   r   r#   >   s    r#   c                 C   s
   t | S )z1A unicode-safe version of urllib2.parse_http_list)r"   parse_http_listr   r
   r
   r   r%   D   s    r%   c              	   C   sl   d  }| dt|   |r`t| t|d }ztt| W S  ttfy^   Y n0 tddS )z;Parse an OAuth authorization header into a list of 2-tupleszOAuth NzMalformed authorization header)	lowerlenr   r%   r   r#   r   
IndexErrorr   )Zauthorization_headerZauth_schemer   r
   r
   r   parse_authorization_headerJ   s    r)   )r   Zurllib.requestrequestr"   Zoauthlib.commonr   r   ZUNICODE_ASCII_CHARACTER_SETr   r   r    r!   r#   r%   r)   r
   r
   r
   r   <module>   s   	