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__/flatten.cpython-38.pyc
U

<�^!%�@sFddlZddlmZe�e�ZdZGdd�de�ZGdd�de�Z	dS)�N)�CustomArgument�.cs6eZdZdZd
�fdd�	Zedd��Zdd	�Z�ZS)�FlattenedArgumenta)
    A custom argument which has been flattened from an existing structure. When
    added to the call params it is hydrated back into the structure.

    Supports both an object and a list of objects, in which case the flattened
    parameters will hydrate a list with a single object in it.
    �Nc		s8||_||_||_||_||_tt|�j|||d�dS)N)�name�	help_text�required)�type�
_container�	_property�_hydrate�_hydrate_value�superr�__init__)	�selfr�	container�proprrr	ZhydrateZ
hydrate_value��	__class__��?/usr/lib/python3/dist-packages/awscli/customizations/flatten.pyr s�zFlattenedArgument.__init__cCs|jS�N)r	)rrrr�
cli_type_name*szFlattenedArgument.cli_type_namecCs�|jjj}|jj}|j}t�d�||��|dk	r�|jdkrL|�	�dk}n&|jdkr`t
|�}n|jdkrrt|�}|jr�|�|||||�nZ||kr�|dkr�ig||<ni||<|j
r�|�
|�}|dkr�|||d|<n||||<dS)	a
        Hydrate the original structure with the value of this flattened
        argument.

        TODO: This does not hydrate nested structures (``XmlName1.XmlName2``)!
              To do this for now you must provide your own ``hydrate`` method.
        zHydrating {0}[{1}]NZbooleanZfalse)ZintegerZlong)�floatZdouble�listr)r
�argument_modelrrr�LOG�debug�formatr	�lower�intrrr
)rZ
parameters�valuerZcli_type�keyrrr�
add_to_params.s,





zFlattenedArgument.add_to_params)rNNNN)	�__name__�
__module__�__qualname__�__doc__r�propertyrr#�
__classcell__rrrrrs�

rc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�FlattenArgumentsa�	
    Flatten arguments for one or more commands for a particular service from
    a given configuration which maps service call parameters to flattened
    names. Takes in a configuration dict of the form::

        {
            "command-cli-name": {
                "argument-cli-name": {
                    "keep": False,
                    "flatten": {
                        "XmlName": {
                            "name": "flattened-cli-name",
                            "type": "Optional custom type",
                            "required": "Optional custom required",
                            "help_text": "Optional custom docs",
                            "hydrate_value": Optional function to hydrate value,
                            "hydrate": Optional function to hydrate
                        },
                        ...
                    }
                },
                ...
            },
            ...
        }

    The ``type``, ``required`` and ``help_text`` arguments are entirely
    optional and by default are pulled from the model. You should only set them
    if you wish to override the default values in the model.

    The ``keep`` argument determines whether the original command is still
    accessible vs. whether it is removed. It defaults to ``False`` if not
    present, which removes the original argument.

    The keys inside of ``flatten`` (e.g. ``XmlName`` above) can include nested
    references to structures via a colon. For example, ``XmlName1:XmlName2``
    for the following structure::

        {
            "XmlName1": {
                "XmlName2": ...
            }
        }

    The ``hydrate_value`` function takes in a value and should return a value.
    It is only called when the value is not ``None``. Example::

        "hydrate_value": lambda (value): value.upper()

    The ``hydrate`` function takes in a list of existing parameters, the name
    of the container, its type, the name of the container key and its set
    value. For the example above, the container would be
    ``'argument-cli-name'``, the key would be ``'XmlName'`` and the value
    whatever the user passed in. Example::

        def my_hydrate(params, container, cli_type, key, value):
            if container not in params:
                params[container] = {'default': 'values'}

            params[container][key] = value

    It's possible for ``cli_type`` to be ``list``, in which case you should
    ensure that a list of one or more objects is hydrated rather than a
    single object.
    cCs||_||_dSr)�configs�service_name)rr,r+rrrr�szFlattenArguments.__init__cCs,|j}|jD]}|�d�||�|j�qdS)z�
        Register with a CLI instance, listening for events that build the
        argument table for operations in the configuration dict.
        zbuilding-argument-table.{0}.{1}N)r,r+�registerr�flatten_args)rZcli�serviceZ	operationrrrr-�s

��zFlattenArguments.registerc
Ks�|j|j��D]�\}}||}d}t�d�|j|d�dd�|d��D����|d��D]b\}}	|	��}
||
d<||
d<|�|j	|�}|�
|||
�tf|
�}|||	d	<||	d	kr^d
}q^|sd|ks�|ds||=qdS)NFz$Flattening {0} argument {1} into {2}z, cSsg|]\}}|d�qS)rr)�.0�k�vrrr�
<listcomp>�sz1FlattenArguments.flatten_args.<locals>.<listcomp>ZflattenrrrTZkeep)r+r�itemsrrr�join�copy�_find_nested_argr�_merge_member_configr)
rZcommandZargument_table�kwargsr�argumentZargument_from_tableZoverwrittenZsub_argumentZ
new_config�configZ_argZnew_argrrrr.�s2��
�zFlattenArguments.flatten_argscCsft|krbt�d�|��|�t�dd�D]6}|j��D]\}}||kr8|}q*q8td�|���q*|S)z�
        Find and return a nested argument, if it exists. If no nested argument
        is requested then the original argument is returned. If the nested
        argument cannot be found, then a ValueError is raised.
        zFinding nested argument in {0}N���zInvalid piece {0})�SEPrrr�split�membersr4�
ValueError)rr:rZpiece�member_name�memberrrrr7�sz!FlattenArguments._find_nested_argcCsh|j��D]X\}}||�t�dkr
d|kr6|j|d<d|krL||jk|d<d|kr^|j|d<qdq
dS)a4
        Merges an existing config taken from the configuration dict with an
        existing member of an existing argument object. This pulls in
        attributes like ``required`` and ``help_text`` if they have not been
        overridden in the configuration dict. Modifies the config in-place.
        r<rrr	N)r?r4r>r=Z
documentationZrequired_membersZ	type_name)rr:rr;rArBrrrr8�s

z%FlattenArguments._merge_member_configN)	r$r%r&r'rr-r.r7r8rrrrr*WsA%r*)
ZloggingZawscli.argumentsrZ	getLoggerr$rr=r�objectr*rrrr�<module>s

?