
    G	                         S r SSKJrJr  SSKrSSKrSSKJrJr   SSK	J
r
   SSKJ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! \ a	    SSKJr   N6f = f)zooauthlib.utils ~~~~~~~~~~~~~~

This module contains utility methods used by various parts of the OAuth 2 spec.
    )absolute_importunicode_literalsN)unicode_type	urldecode)quote)urlparsec                     [        U [        5      (       d  U c  U $ [        U [        [        [        45      (       a+  SR                  U  Vs/ s H  n[        U5      PM     sn5      $ [        SU -  5      es  snf )z5Convert a list of scopes to a space separated string. z8Invalid scope (%s), must be string, tuple, set, or list.)
isinstancer   settuplelistjoin
ValueErrorscopess     0lib/third_party/oauthlib/oauth2/rfc6749/utils.pylist_to_scoper      sj    |$$L%#ud+,,88e4e\!_e455
BUJL L 5s   
A4c                     [        U [        [        [        45      (       a  U  Vs/ s H  n[	        U5      PM     sn$ U c  gU R                  5       R                  S5      $ s  snf )z5Convert a space separated string to a list of scopes.Nr
   )r   r   r   r   r   stripsplitr   s     r   scope_to_listr   "   sS    tS)**%*+ULOU++};;=s##	 ,s   A c                     [        [        [        U 5      R                  5      5      nSU;   a  [	        US   5      US'   U$ )Nr   )dictr   r   queryr   )uriparamss     r   params_from_urir   ,   s:    	(3---./&#F7O4F7O	-    c                     SSS.n[        U 5      u  p#pEpgSU;   a  UR                  SS5      u  p8X84$ UR                  UR                  5       5      nX84$ )zmExtract hostname and port from URI.

Will use default port for HTTP and HTTPS if none is present in the URI.
80443)HTTPHTTPS:   )r   r   getupper)	r   default_portsschnetlocpathparr   fraports	            r   host_from_urir1   3   sf     -
 (0}$#t%F]<<Q'LF 
 SYY[)D	r    c                 t    [        U [        5      (       d  [        S5      e[        U R	                  S5      SS9$ )zlEscape a string in an OAuth-compatible fashion.

TODO: verify whether this can in fact be used for OAuth 2

z#Only unicode objects are escapable.zutf-8   ~)safe)r   r   r   r   encode)us    r   escaper7   F   s3     
A|	$	$
:
;;	qxx t	,,r    c                     [         R                   R                  5       U -
  nUR                  UR                  UR                  S-  S-  -   S-  -   S-  n[        U5      $ )z9Generate a age parameter for MAC authentication draft 00.   i  i@B )datetimenowmicrosecondssecondsdaysr   )
issue_timetdages      r   generate_agerB   Q   sT    +"	BJJ2)<<E	EN#	c	r    c                     [         R                  R                  S5      (       a  gU R                  5       R	                  S5      $ )zCheck if the uri is over ssl.OAUTHLIB_INSECURE_TRANSPORTTzhttps://)osenvironr(   lower
startswith)r   s    r   is_secure_transportrI   X   s0    ZZ^^122			
	++r    )__doc__
__future__r   r   r:   rE   oauthlib.commonr   r   urllibr   ImportErrorurllib.parser   r   r   r   r1   r7   rB   rI    r    r   <module>rQ      st    9  	 3!$
L$&-,S  ! !  $#$s    ? A AAA A 