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__/flatten.cpython-310.pyc
o

.&�a!%�@sFddlZddlmZe�e�ZdZGdd�de�ZGdd�de�Z	dS)�N)�CustomArgument�.cs:eZdZdZ		d
�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	�hydrate�
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�||��|durw|jdkr&|�	�dk}n|jdvr0t
|�}n	|jdvr9t|�}|jrG|�|||||�dS||vrY|dkrUig||<ni||<|j
ra|�
|�}|dkro|||d|<dS||||<dSdS)	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}]N�boolean�false)�integer�long)�float�double�listr)r
�argument_modelrrr�LOG�debug�formatr	�lower�intrrr
)r�
parameters�valuer�cli_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)rr5r4rrrr�s
zFlattenArguments.__init__cCs,|j}|jD]
}|�d�||�|j�qdS)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)r5r4�registerr%�flatten_args)r�cli�service�	operationrrrr6�s

���zFlattenArguments.registerc
Ks�|j|j��D]h\}}||}d}t�d�|j|d�dd�|d��D����|d��D]3\}}	|	��}
||
d<||
d<|�|j	|�}|�
|||
�tdi|
��}|||	d	<||	d	krbd
}q/|spd|vsm|dsp||=qdS)
NFz$Flattening {0} argument {1} into {2}z, cSsg|]\}}|d�qS)rr)�.0�k�vrrr�
<listcomp>�sz1FlattenArguments.flatten_args.<locals>.<listcomp>�flattenrrrT�keepr)r4r�itemsr#r$r%�join�copy�_find_nested_argr"�_merge_member_configr)
r�command�argument_table�kwargsr�argument�argument_from_table�overwritten�sub_argument�
new_config�config�_arg�new_argrrrr7�s4������zFlattenArguments.flatten_argscCsft|vr1t�d�|��|�t�dd�D]}|j��D]\}}||kr(|}nqtd�|���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})�SEPr#r$r%�split�membersrA�
ValueError)rrIr�piece�member_name�memberrrrrD�s��z!FlattenArguments._find_nested_argcCsj|j��D]-\}}||�t�dkr2d|vr|j|d<d|vr&||jv|d<d|vr/|j|d<dSqdS)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.
        rQrrr	N)rTrArSrR�
documentation�required_members�	type_name)rrIrrNrWrXrrrrE�s

��z%FlattenArguments._merge_member_configN)	r-r.r/r0rr6r7rDrErrrrr3WsA%r3)
�logging�awscli.argumentsr�	getLoggerr-r#rRr�objectr3rrrr�<module>s

?