HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/awscli/customizations/__pycache__/flatten.cpython-36.pyc
3

�T_!%�@sFddlZddlmZeje�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.6/flatten.pyr szFlattenedArgument.__init__cCs|jS)N)r	)rrrr�
cli_type_name*szFlattenedArgument.cli_type_namecCs�|jjj}|jj}|j}tjdj||��|dk	r�|jdkrL|j	�dk}n&|jdkr`t
|�}n|jdkrrt|�}|jr�|j|||||�nZ||kr�|d	kr�ig||<ni||<|j
r�|j
|�}|d	kr�|||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�integer�long�float�double�listr)rr)rr)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__rr)rrrs
	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||_||_dS)N)�configs�service_name)rr-r,rrrr�szFlattenArguments.__init__cCs0|j}x$|jD]}|jdj||�|j�qWdS)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)rZcliZserviceZ	operationrrrr.�s

zFlattenArguments.registerc
	Ks�x�|j|jj�D]�\}}||}d}tjdj|j|djdd�|dj�D����xr|dj�D]b\}}	|	j�}
||
d<||
d<|j|j	|�}|j
|||
�tf|
�}|||	d	<||	d	krbd
}qbW|rd|ks�|dr||=qWdS)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/�s( 


zFlattenArguments.flatten_argscCslt|krhtjdj|��xN|jt�dd�D]8}x2|jj�D]\}}||kr<|}Pq<Wtdj|���q,W|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_argcCsjxd|jj�D]V\}}||jt�dkrd|kr8|j|d<d|krN||jk|d<d|kr`|j|d<PqWdS)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	Nr=)r@r4r?r>Z
documentationZrequired_membersZ	type_name)rr:rr;rBrCrrrr8�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

?