o
    .&ßaŸ  ã                   @   sR   d dl Z d dlZd dlmZ d dlmZ ddlmZ e e	¡Z
G dd„ deƒZdS )é    N)ÚBasicCommand)Úsixé   )ÚPREDEFINED_SECTION_NAMESc                       sl   e Zd ZdZe ddd¡ZdZe ddd¡Zdddd	d
dœgZ	e
je
jf‡ fdd„	Zdd„ Zdd„ Z‡  ZS )ÚConfigureGetCommandÚgetÚ	configurez_description.rstz2aws configure get varname [--profile profile-name]z_examples.rstÚvarnamez)The name of the config value to retrieve.ÚstoreÚstringT)ÚnameÚ	help_textÚactionÚcli_type_nameÚpositional_argc                    s    t t| ƒ |¡ || _|| _d S )N)Úsuperr   Ú__init__Ú_streamÚ_error_stream)ÚselfÚsessionÚstreamÚerror_stream©Ú	__class__© úE/usr/lib/python3/dist-packages/awscli/customizations/configure/get.pyr   %   s   
zConfigureGetCommand.__init__c                 C   s†   |j }d|vr| j ¡ }| |¡}n|  |¡}t d| ¡ t|tj	ƒr2| j
 |¡ | j
 d¡ dS t|tƒrA| j d| ¡ dS dS )NÚ.zConfig value retrieved: %sÚ
r   zBvarname (%s) must reference a value, not a section or sub-section.r   )r	   Ú_sessionÚget_scoped_configr   Ú_get_dotted_config_valueÚLOGÚdebugÚ
isinstancer   Ústring_typesr   ÚwriteÚdictr   )r   ÚargsÚparsed_globalsr	   ÚconfigÚvaluer   r   r   Ú	_run_main*   s$   


ÿÿzConfigureGetCommand._run_mainc           
      C   s^  |  d¡}| d¡}|dkr9|d tv r9| jj}|  d¡\}}| |i ¡ |¡}|d u r7|d  |i ¡ |¡}|S |d dkrN|d }|d }|dd … }	n5|d dks^|d | jjd v rm|d }|d }|dd … }	n| j d¡}|d u ryd}|d }|dd … }	| jjd  |i ¡ |¡}t|	ƒdkr­z
| |	d	 ¡}W |S  ty¬   d }Y |S w |S )
Nr   r   r   ÚprofilesÚprofileé   é   Údefaultéÿÿÿÿ)	ÚsplitÚcountr   r   Úfull_configr   Úget_config_variableÚlenÚAttributeError)
r   r	   ÚpartsÚnum_dotsr5   ÚsectionÚconfig_namer+   Úprofile_nameÚ	remainingr   r   r   r!   F   sR   

ÿÿÿÿþþz,ConfigureGetCommand._get_dotted_config_value)Ú__name__Ú
__module__Ú__qualname__ÚNAMEr   Ú	FROM_FILEÚDESCRIPTIONÚSYNOPSISÚEXAMPLESÚ	ARG_TABLEÚsysÚstdoutÚstderrr   r,   r!   Ú__classcell__r   r   r   r   r      s     ÿýÿr   )rH   ÚloggingÚawscli.customizations.commandsr   Úawscli.compatr   Ú r   Ú	getLoggerr?   r"   r   r   r   r   r   Ú<module>   s   
