ó
è?F[c           @  s¤   d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l m	 Z	 d e j
 j f d „  ƒ  YZ d e j j f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   print_functionN(   t   awsqueryrequestt   NoCredentialsErrorc           B  s   e  Z d  „  Z RS(   c         C  s    d } t  t |  ƒ j | ƒ d  S(   Ns   Unable to find credentials(   t   superR   t   __init__(   t   selft   s(    (    s:   lib/python2.7/site-packages/boto/roboto/awsqueryservice.pyR      s    (   t   __name__t
   __module__R   (    (    (    s:   lib/python2.7/site-packages/boto/roboto/awsqueryservice.pyR   
   s   t   AWSQueryServicec           B  sb   e  Z d  Z d  Z d  Z d Z d Z d Z d Z d Z	 g  Z
 d „  Z d „  Z d „  Z d	 „  Z RS(
   t    s   sign-v2t   /i»  t   awst   AWS_URLc         K  s$  | |  _  |  j ƒ  |  j ƒ  d |  j  k r“ |  j r“ |  j  j d |  j d d ƒ } x8 |  j D]* } | d | k r_ | d |  j  d <q_ q_ Wq“ n  d |  j  k rµ |  j |  j  d <n  d |  j  k r× |  j |  j  d <n  y& t t |  ƒ j	 |  j    d  |  _ Wn  t j j k
 rt ƒ  ‚ n Xd  S(   Nt   hostt   region_namei    t   namet   endpointt   patht   port(   t   argst   check_for_credential_filet   check_for_env_urlt   Regionst   gett   Patht   PortR   R	   R   t   Nonet   aws_responset   botot	   exceptiont   NoAuthHandlerFoundR   (   R   R   R   t   region(    (    s:   lib/python2.7/site-packages/boto/roboto/awsqueryservice.pyR      s&    	

	c         C  sS  d t  j k rOt  j d } t  j j | ƒ } t  j j | ƒ } t  j j | ƒ rBt | ƒ } | j ƒ  } | j ƒ  xÕ | D]À } | d d k r{ d | k r;| j	 d d ƒ \ } } | j
 ƒ  d k rõ d |  j k r5| j
 ƒ  } | |  j d <q5q8| j
 ƒ  d k r8d	 |  j k r5| j
 ƒ  } | |  j d	 <q5q8q;q{ q{ WqOt d
 ƒ n  d S(   sq  
        Checks for the existence of an AWS credential file.
        If the environment variable AWS_CREDENTIAL_FILE is
        set and points to a file, that file will be read and
        will be searched credentials.
        Note that if credentials have been explicitelypassed
        into the class constructor, those values always take
        precedence.
        t   AWS_CREDENTIAL_FILEi    t   #t   =i   t   AWSAccessKeyIdt   aws_access_key_idt   AWSSecretKeyt   aws_secret_access_keys+   Warning: unable to read AWS_CREDENTIAL_FILEN(   t   ost   environR   t
   expandusert
   expandvarst   isfilet   opent	   readlinest   closet   splitt   stripR   t   print(   R   R   t   fpt   linest   lineR   t   value(    (    s:   lib/python2.7/site-packages/boto/roboto/awsqueryservice.pyR   2   s*    

 c         C  sj  |  j  j d d
 ƒ } | r( |  j  d =n  | rT |  j t j k rT t j |  j } n  | rft j | ƒ } d |  j  k r§ | j d k r— t |  j  d <q§ t	 |  j  d <n  | j
 } d
 } | j d ƒ } t | ƒ d k rô | d } t | d ƒ } n  d |  j  k r| |  j  d <n  | r8d |  j  k r8| |  j  d <n  | j rfd	 |  j  k rf| j |  j  d	 <qfn  d
 S(   s¡  
        First checks to see if a url argument was explicitly passed
        in.  If so, that will be used.  If not, it checks for the
        existence of the environment variable specified in ENV_URL.
        If this is set, it should contain a fully qualified URL to the
        service you want to use.
        Note that any values passed explicitly to the class constructor
        will take precedence.
        t   urlt	   is_securet   httpst   :i   i    R   R   R   N(   R   R   R   t   EnvURLR(   R)   t   urlparset   schemet   Truet   Falset   netlocR0   t   lent   intR   (   R   R7   t   rsltR   R   t   l(    (    s:   lib/python2.7/site-packages/boto/roboto/awsqueryservice.pyR   S   s.    
	
c         C  s
   |  j  g S(   N(   t   Authentication(   R   (    (    s:   lib/python2.7/site-packages/boto/roboto/awsqueryservice.pyt   _required_auth_capabilityx   s    (   R   R   t   Namet   Descriptiont
   APIVersionRE   R   R   t   ProviderR;   R   R   R   R   RF   (    (    (    s:   lib/python2.7/site-packages/boto/roboto/awsqueryservice.pyR	      s   		!	%(   t
   __future__R    R(   R<   R   t   boto.connectiont   boto.jsonresponset   boto.exceptiont   boto.robotoR   R   t   BotoClientErrorR   t
   connectiont   AWSQueryConnectionR	   (    (    (    s:   lib/python2.7/site-packages/boto/roboto/awsqueryservice.pyt   <module>   s   