o
    é’OjÛ  ã                   @   sR   d dl Z d dlZd dlmZ ddlmZ e  d¡Zdd„ Zddd	„Z	dd
d„Z
dS )é    N)Ú
xform_nameé   )ÚResourceLoadExceptionz	\[(.*)\]$c                 C   sB   | j jdu rt| dƒr|  ¡  n	t| jj› d�ƒ‚t || j j¡S )aE  
    Get a data member from a parent using a JMESPath search query,
    loading the parent if required. If the parent cannot be loaded
    and no data is present then an exception is raised.

    :type parent: ServiceResource
    :param parent: The resource instance to which contains data we
                   are interested in.
    :type path: string
    :param path: The JMESPath expression to query
    :raises ResourceLoadException: When no data is present and the
                                   resource cannot be loaded.
    :returns: The queried data or ``None``.
    NÚloadz has no load method!)	ÚmetaÚdataÚhasattrr   r   Ú	__class__Ú__name__ÚjmespathÚsearch)ÚparentÚpath© r   ú\/var/www/html/pharmsmart-cdr-gen/venv/lib/python3.10/site-packages/boto3/resources/params.pyÚget_data_member   s   

ÿr   c                 C   sŽ   |du ri }|j D ];}|j}|j}|dkrt| t|jƒƒ}n|dkr)t| |jƒ}n|dv r1|j}n|dkr6q	t	d|› �ƒ‚t
||||ƒ q	|S )aX  
    Handle request parameters that can be filled in from identifiers,
    resource data members or constants.

    By passing ``params``, you can invoke this method multiple times and
    build up a parameter dict over time, which is particularly useful
    for reverse JMESPath expressions that append to lists.

    :type parent: ServiceResource
    :param parent: The resource instance to which this action is attached.
    :type request_model: :py:class:`~boto3.resources.model.Request`
    :param request_model: The action request model.
    :type params: dict
    :param params: If set, then add to this existing dict. It is both
                   edited in-place and returned.
    :type index: int
    :param index: The position of an item within a list
    :rtype: dict
    :return: Pre-filled parameters to be sent to the request operation.
    NÚ
identifierr   )ÚstringÚintegerÚbooleanÚinputzUnsupported source type: )ÚparamsÚsourceÚtargetÚgetattrr   Únamer   r   ÚvalueÚNotImplementedErrorÚbuild_param_structure)r   Úrequest_modelr   ÚindexÚparamr   r   r   r   r   r   Úcreate_request_parameters3   s    
r"   c           	      C   sN  | }|  d¡}t|ƒD ]™\}}t |¡}|r‹| d¡r=| d¡dkr)|dd… }nt| d¡ƒ}|dt|› d�ƒ … }nd}|dd… }||vsPt|| tƒsTg ||< |du r^t|| ƒ}t|| ƒ|kru||  	i ¡ t|| ƒ|ksf|t|ƒd kr„||| |< q|| | }q||vr“i ||< |t|ƒd kr |||< q|| }qdS )a  
    This method provides a basic reverse JMESPath implementation that
    lets you go from a JMESPath-like string to a possibly deeply nested
    object. The ``params`` are mutated in-place, so subsequent calls
    can modify the same element by its index.

        >>> build_param_structure(params, 'test[0]', 1)
        >>> print(params)
        {'test': [1]}

        >>> build_param_structure(params, 'foo.bar[0].baz', 'hello world')
        >>> print(params)
        {'test': [1], 'foo': {'bar': [{'baz': 'hello, world'}]}}

    Ú.é   Ú*Néýÿÿÿz[]éþÿÿÿ)
ÚsplitÚ	enumerateÚINDEX_REr   ÚgroupÚintÚlenÚ
isinstanceÚlistÚappend)	r   r   r   r    ÚposÚpartsÚiÚpartÚresultr   r   r   r   d   s8   


þ

Ör   )NN)N)Úrer   Úbotocorer   Ú
exceptionsr   Úcompiler*   r   r"   r   r   r   r   r   Ú<module>   s   

1