HEX
Server: Apache
System: Linux srv1.prosuiteplus.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: prosuiteplus (1001)
PHP: 8.3.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/awscli/customizations/__pycache__/utils.cpython-38.pyc
U

<�^!�@s�dZddlZddlZddlmZdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zddd�Zddd�Zdd�ZdS) zC
Utility functions to make it easier to work with customizations.

�N)�ClientErrorcCs ||}|||<||_||=dS�N��name)�argument_table�
existing_name�new_name�current�r
�=/usr/lib/python3/dist-packages/awscli/customizations/utils.py�rename_argumentsrcCs$||}t�|�}||_|||<|Sr)�copyr)rZcurrent_nameZ	copy_namer	�copy_argr
r
r�_copy_arguments

rcCs6||}t|||�}d|_|jr2d|_d|_d|_dS)a{Create a hidden alias for an existing argument.

    This will copy an existing argument object in an arg table,
    and add a new entry to the arg table with a different name.
    The new argument will also be undocumented.

    This is needed if you want to check an existing argument,
    but you still need the other one to work for backwards
    compatibility reasons.

    TFN)r�
_UNDOCUMENTEDZrequiredZ_DOCUMENT_AS_REQUIRED)rr�
alias_namer	rr
r
r�make_hidden_alias&srcCs ||}|||<||_||=dSrr��
command_tablerrr	r
r
r�rename_command?srcCs||}t|||�d|_dS)aWMoves an argument to a new name, keeping the old as a hidden alias.

    :type command_table: dict
    :param command_table: The full command table for the CLI or a service.

    :type existing_name: str
    :param existing_name: The current name of the command.

    :type new_name: str
    :param new_name: The new name for the command.
    TN�rrrr
r
r�
alias_commandFsrcCst|||�}d|_dS)a�Create a hidden alias for an exiting command.

    This will copy an existing command object in a command table and add a new
    entry to the command table with a different name. The new command will
    be undocumented.

    This is needed if you want to change an existing command, but you still
    need the old name to work for backwards compatibility reasons.

    :type command_table: dict
    :param command_table: The full command table for the CLI or a service.

    :type existing_name: str
    :param existing_name: The current name of the command.

    :type alias_name: str
    :param alias_name: The new name for the command.
    TNr)rrr�newr
r
r�make_hidden_command_aliasWsrcs�fdd�}|S)Ncst|f���Sr)�validate_mutually_exclusive)�parsed_args�kwargs��groupsr
r�_handlerosz5validate_mutually_exclusive_handler.<locals>._handlerr
)rrr
rr�#validate_mutually_exclusive_handlernsr cs�t|��tdd�|D���t��fdd��D��s6dSd}�fdd��D�D]D}t||�}|dkrdqL|dkrr|}qL||ksLtd|d�|�f��qLdS)	z7Validate mututally exclusive groups in the parsed args.css|]}|D]
}|Vq
qdSrr
)�.0�group�argr
r
r�	<genexpr>wsz.validate_mutually_exclusive.<locals>.<genexpr>c3s"|]}�|dk	r|�kVqdSrr
�r!�k�Zall_args�	args_dictr
rr$xsNcsg|]}�|dk	r|�qSrr
r%)r(r
r�
<listcomp>}sz/validate_mutually_exclusive.<locals>.<listcomp>zVThe key "%s" cannot be specified when one of the following keys are also specified: %sz, )�vars�set�any�_get_group_for_key�
ValueError�join)rrZ
current_group�keyZ	key_groupr
r'rrts
�rcCs|D]}||kr|SqdSrr
)r0rr"r
r
rr-�sr-c
CsZd}z|j|d�Wn@tk
rT}z"t|jdd�}|dkrDd}W5d}~XYnX|S)NT)ZBucket�ErrorZCodei�F)Zhead_bucketr�intZresponse)Z	s3_clientZbucket_nameZ
bucket_exists�eZ
error_coder
r
r�s3_bucket_exists�sr4cCsVi}d|kr|j|d<d|kr(|j|d<d|kr:|j|d<|rH|�|�|j|f|�S)aCreates a service client, taking parsed_globals into account

    Any values specified in overrides will override the returned dict. Note
    that this override occurs after 'region' from parsed_globals has been
    translated into 'region_name' in the resulting dict.
    �regionZregion_name�endpoint_url�
verify_sslZverify)r5r6r7�updateZ
create_client)ZsessionZservice_nameZparsed_globalsZ	overridesZclient_argsr
r
r�!create_client_from_parsed_globals�s



r9cCsr|dkrtj}z|�|�WnHtk
rdt|dd�}|dkrDd}|�|d��|�}|�|�YnX|��dS)z�
    This function is used to properly write unicode to a file, usually
    stdout or stdderr.  It ensures that the proper encoding is used if the
    statement is not a string type.
    N�encoding�ascii�replace)�sys�stdout�write�UnicodeEncodeError�getattr�encode�decode�flush)Z	statementZout_fileZnew_encodingZ
new_statementr
r
r�	uni_print�s ��rEcCs,|��}|�d�rdS|�d�r$dSdSdS)z7Method to return region value as expected by policy arnzcn-zaws-cnzus-govz
aws-us-govZawsN)�lower�
startswith)r5Z
region_stringr
r
r�get_policy_arn_suffix�s

rH)N)N)�__doc__r
r=Zbotocore.exceptionsrrrrrrrr rr-r4r9rErHr
r
r
r�<module>
s"�

+