
    g
                         S r SSKJrJr  SSKJrJrJr   SSKrSrS rS rS rS	 rS
 rS rS rg! \	 a	    SSK
Jr   N&f = f)zmoauthlib.utils ~~~~~~~~~~~~~~

This module contains utility methods used by various parts of the OAuth
spec.
    )absolute_importunicode_literals)quoteunicode_typeunquoteN>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789c                 6   ^  U 4S jnT R                   Ul         U$ )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   > [        U 5      n T" U /UQ70 UD6$ )N)filter_oauth_params)paramsargskwargstargets      0lib/third_party/oauthlib/oauth1/rfc5849/utils.pywrapperfilter_params.<locals>.wrapper   s"     (F&*4*6**    )__doc__)r   r   s   ` r   filter_paramsr      s    + NN'/	.r   c           	          S n[        U [        5      (       a,  [        [        U[        U R	                  5       5      5      5      $ [        [        X5      5      $ )zARemoves all non oauth parameters from a dict or a list of params.c                 *    U S   R                  S5      $ )Nr   oauth_)
startswith)kvs    r   <lambda>%filter_oauth_params.<locals>.<lambda>&   s    1((2r   )
isinstancedictlistfilteritems)r   is_oauths     r   r   r   $   sA    2(xflln!5677x())r   c           	          [        U [        5      (       d   [        SSU < S[        U 5      < S3-   5      e[	        U SS9$ )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 z	 of type .   ~)safe)r   r   
ValueErrortyper   us    r   escaper+   -   sA     
A|	$	$
;-.Q89 : : 
qt	r   c                 X    [        U [        5      (       d  [        S5      e[        U 5      $ )Nz%Only unicode objects are unescapable.)r   r   r'   r   r)   s    r   unescaper-   =   s%    	A|	$	$
<
==	r   c                 .    [         R                  " U 5      $ )z1A unicode-safe version of urllib2.parse_keqv_list)urllib2parse_keqv_list)ls    r   r0   r0   C        
	 	 	##r   c                 .    [         R                  " U 5      $ )z1A unicode-safe version of urllib2.parse_http_list)r/   parse_http_listr)   s    r   r4   r4   I   r2   r   c                 8   SR                  5       nU S[        U5       R                  5       R                  U5      (       a:  [        U [        U5      S 5      n [	        [        U5      R                  5       5      $ [        S5      e! [        [        4 a     Nf = f)z;Parse an OAuth authorization header into a list of 2-tupleszOAuth NzMalformed authorization header)	lowerlenr   r4   r   r0   r!   
IndexErrorr'   )authorization_headerauth_schemer!   s      r   parse_authorization_headerr;   O   s     ++3{+,224??LL0[1A1BCDE/%(..011 	344 
# 
s   !B BB)r   
__future__r   r   oauthlib.commonr   r   r   r/   ImportErrorurllib.requestrequestUNICODE_ASCII_CHARACTER_SETr   r   r+   r-   r0   r4   r;    r   r   <module>rC      s]   
 9 8 8# , 
* $$	5E  #"#s   2 A A