U
    W¨+d/  ã                   @   s4   d dl mZ d dlmZ d dlZG dd„ deƒZdS )é    )ÚConfig)ÚServiceMessageNc                       s\   e Zd Zd‡ fdd„	Zd‡ fdd„	Z‡ fdd„Zd‡ fd	d
„	Zd‡ fdd„	Zdd„ Z‡  Z	S )Ú
ServiceDefNc                    sJ   t t| ƒ |¡ || _|| _t | dd¡}|r@| d¡d | _nd | _d S )NZPyamiÚscriptsÚ.éÿÿÿÿ)	Úsuperr   Ú__init__Úaws_access_key_idÚaws_secret_access_keyr   ÚgetÚsplitÚname)ÚselfÚconfig_filer
   r   Úscript©Ú	__class__© ú</tmp/pip-unpacked-wheel-dlxw5sjy/boto/services/servicedef.pyr	      s    zServiceDef.__init__c                    s   t t| ƒ | j||¡S ©N)r   r   r   r   )r   r   Údefaultr   r   r   r   '   s    zServiceDef.getc                    s   t t| ƒ | j|¡S r   )r   r   Ú
has_optionr   )r   Úoptionr   r   r   r   *   s    zServiceDef.has_optionr   c                    s:   z t t| ƒ | j|¡}t|ƒ}W n   t|ƒ}Y nX |S r   )r   r   r   r   Úint©r   r   r   Úvalr   r   r   Úgetint-   s    zServiceDef.getintFc                    sD   z.t t| ƒ | j|¡}| ¡ dkr(d}nd}W n   |}Y nX |S )NÚtrueTF)r   r   r   r   Úlowerr   r   r   r   Úgetbool5   s    
zServiceDef.getboolc                 C   s|   |   |¡}|sdS | d¡dkr<t d|¡}|rx| t¡ n<| d¡dkrXt d|¡}n | d¡dkrtt d|¡}nd}|S )	a  
        Returns the AWS object associated with a given option.

        The heuristics used are a bit lame.  If the option name contains
        the word 'bucket' it is assumed to be an S3 bucket, if the name
        contains the word 'queue' it is assumed to be an SQS queue and
        if it contains the word 'domain' it is assumed to be a SimpleDB
        domain.  If the option name specified does not exist in the
        config file or if the AWS object cannot be retrieved this
        returns None.
        NÚqueuer   ZsqsZbucketZs3ÚdomainZsdb)r   ÚfindÚbotoÚlookupZset_message_classr   )r   r   r   Úobjr   r   r   Úget_obj@   s    
zServiceDef.get_obj)NN)N)r   )F)
Ú__name__Ú
__module__Ú__qualname__r	   r   r   r   r    r'   Ú__classcell__r   r   r   r   r      s   r   )Zboto.pyami.configr   Zboto.services.messager   r$   r   r   r   r   r   Ú<module>   s   