o
    Ü!d  ã                   @   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                       sd   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	d‡ 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)ÚnameZ	help_textÚactionZcli_type_nameZpositional_argNc                    s<   t t| ƒ |¡ |d u rtj}|d u rtj}|| _|| _d S )N)Úsuperr   Ú__init__ÚsysÚstdoutÚstderrÚ_streamÚ_error_stream)ÚselfZsessionÚstreamZerror_stream©Ú	__class__© úGusr/lib/python3.10/site-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	   Ú_sessionZget_scoped_configr   Ú_get_dotted_config_valueÚLOGÚdebugÚ
isinstancer   Zstring_typesr   ÚwriteÚdictr   )r   ÚargsZ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   ZprofilesZprofileé   é   Údefaultéÿÿÿÿ)	ÚsplitÚcountr   r   Úfull_configr   Zget_config_variableÚlenÚAttributeError)
r   r	   ÚpartsZnum_dotsr.   ÚsectionZconfig_namer&   Zprofile_nameÚ	remainingr   r   r   r   J   sR   

ÿÿÿÿþþz,ConfigureGetCommand._get_dotted_config_value)NN)Ú__name__Ú
__module__Ú__qualname__ÚNAMEr   Z	FROM_FILEZDESCRIPTIONZSYNOPSISZEXAMPLESZ	ARG_TABLEr   r'   r   Ú__classcell__r   r   r   r   r      s     ÿýÿ	r   )r   ÚloggingZawscli.customizations.commandsr   Zawscli.compatr   Ú r   Ú	getLoggerr4   r   r   r   r   r   r   Ú<module>   s   
