HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/awscli/customizations/__pycache__/utils.cpython-310.pyc
o

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

�N)�ClientErrorcC� ||}|||<||_||=dS�N��name)�argument_table�
existing_name�new_name�current�r�=/usr/lib/python3/dist-packages/awscli/customizations/utils.py�rename_argument�
r
cCs$||}t�|�}||_|||<|Sr)�copyr)r�current_name�	copy_namer
�copy_argrrr�_copy_arguments

rcCs:||}t|||�}d|_|jrd|_d|_d|_dSdS)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�
_UNDOCUMENTED�required�_DOCUMENT_AS_REQUIRED)rr�
alias_namer
rrrr�make_hidden_alias&s
�rcCrrr��
command_tablerr	r
rrr�rename_command?rrcCs||}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�rrrrrr�
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�newrrr�make_hidden_command_aliasWs
rcs�fdd�}|S)Ncst|g��R�Sr)�validate_mutually_exclusive)�parsed_args�kwargs��groupsrr�_handlerosz5validate_mutually_exclusive_handler.<locals>._handlerr)r$r%rr#r�#validate_mutually_exclusive_handlernsr&cs�t|��tdd�|D���t��fdd��D��sdSd}�fdd��D�D]"}t||�}|dur2q&|dur9|}q&||ksHtd|d�|�f��q&dS)	z7Validate mututally exclusive groups in the parsed args.css�|]
}|D]}|VqqdSrr)�.0�group�argrrr�	<genexpr>ws�z.validate_mutually_exclusive.<locals>.<genexpr>c3s$�|]
}�|dur|�vVqdSrr�r'�k��all_args�	args_dictrrr*xs�"Ncsg|]
}�|dur|�qSrrr+)r/rr�
<listcomp>}sz/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)r!r$�
current_group�key�	key_grouprr-rr ts"
���r cCs|D]
}||vr|SqdSrr)r8r$r(rrrr4�s
��r4c
Csjd}z	|j|d�W|Sty4}zt|jdd�}|dkr)d}WYd}~|SWYd}~|Sd}~ww)NT)�Bucket�Error�Codei�F)�head_bucketr�int�response)�	s3_client�bucket_name�
bucket_exists�e�
error_coderrr�s3_bucket_exists�s�
���rEcCsZi}d|vr|j|d<d|vr|j|d<d|vr|j|d<|r$|�|�|j|fi|��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.
    �region�region_name�endpoint_url�
verify_ssl�verify)rFrHrI�update�
create_client)�session�service_name�parsed_globals�	overrides�client_argsrrr�!create_client_from_parsed_globals�s



rRcCsp|durtj}z|�|�Wn#ty1t|dd�}|dur!d}|�|d��|�}|�|�Ynw|��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)�	statement�out_file�new_encoding�
new_statementrrr�	uni_print�s ���rbcCs(|��}|�d�rdS|�d�rdSdS)z7Method to return region value as expected by policy arnzcn-zaws-cnzus-govz
aws-us-gov�aws)�lower�
startswith)rF�
region_stringrrr�get_policy_arn_suffix�s

rgr)�__doc__rrV�botocore.exceptionsrr
rrrrrr&r r4rErRrbrgrrrr�<module>s$
�
+