a
    ݌xd"                     @   sL   d dl mZ d dlmZ G dd deZG dd deZG dd deZd	S )
    )ShapeDocumenter)
py_defaultc                   @   st   e Zd ZdddZdd ZdddZddd	Zdd
dZdddZdddZ	dd Z
dddZdddZdd ZdS ) BaseExampleDocumenterNc                 C   sV   g }|j   |j   |dur*|| | j|||||d |d}|j   dS )a]  Generates an example based on a shape

        :param section: The section to write the documentation to.

        :param shape: The shape of the operation.

        :param prefix: Anything to be included before the example

        :type include: Dictionary where keys are parameter names and
            values are the shapes of the parameter names.
        :param include: The parameter shapes to include in the documentation.

        :type exclude: List of the names of the parameters to exclude.
        :param exclude: The names of the parameters to exclude from
            documentation.
        N)sectionshapehistoryincludeexcludezfinal-blank-line)stylenew_lineZstart_codeblockwritetraverse_and_document_shapeadd_new_section)selfr   r   prefixr   r	   r   Zfinal_blank_line_section r   M/var/www/html/Ranjet/env/lib/python3.9/site-packages/botocore/docs/example.pydocument_example   s    



z&BaseExampleDocumenter.document_examplec                 K   s   | d d S )Nz{'... recursive ...'})r   )r   r   r   kwargsr   r   r   document_recursive_shape4   s    z.BaseExampleDocumenter.document_recursive_shapec                 K   s>   |  |}|d u rt|j}| jd|kr0d}|| d S )NZstreaming_shapezStreamingBody())Z_get_special_py_defaultr   	type_name_contextgetr   )r   r   r   r   r   r	   r   Zpy_typer   r   r   document_shape_default7   s    

z,BaseExampleDocumenter.document_shape_defaultc           	      K   sd   d|j v rRt|j d D ]6\}}|d|  |t|j d d k r|d qn| ||| d S )Nenum'%s'   |)metadata	enumerater   lenr   )	r   r   r   r   r   r	   r   ir   r   r   r   document_shape_type_stringB   s    
z0BaseExampleDocumenter.document_shape_type_stringc                 K   sn   |j }|d}| |d |jdd|jid}	| j|	||d |d}
|
d |d	}| |d
 d S )Nz
list-value[memberr   contextr   r   r   ending-comma,ending-bracket])r$   r   _start_nested_paramnamer   r   _end_nested_param)r   r   r   r   r   r	   r   param_shapeZlist_sectionparam_sectionending_comma_sectionZending_bracket_sectionr   r   r   document_shape_type_listM   s    




z.BaseExampleDocumenter.document_shape_type_listc                 K   s   |j s|d d S |d}| |d | |j |}t|D ]\}}	|rV|	|v rVq@||	}
|
d|	  ||	 }|
jdd|jid}| j||||	d |t|d	 k r@|
d
}|d |j	
  q@| |dd d S )Nz{}structure-value{z'%s': member-valuer   r%   r   r   r   r-   r   r(   r)   })membersr   r   r,   _add_members_to_shaper   r-   r   r    r
   r   _end_structure)r   r   r   r   r   r	   r   input_membersr!   paramr0   r/   param_value_sectionr1   r   r   r   document_shape_type_structure^   s8    




z3BaseExampleDocumenter.document_shape_type_structurec                 K   sz   | d}| |d |j}|j dd|jjid}	|	d |j dd|jid}
| j|
||d | d	}| |d
 d S )Nz	map-valuer4   keyr   r%   z
'string': valuer'   r*   r7   )r   r,   r@   r?   r-   r   r   r.   )r   r   r   r   r   r	   r   Zmap_sectionZvalue_shapeZkey_sectionZvalue_sectionend_bracket_sectionr   r   r   document_shape_type_map   s    



z-BaseExampleDocumenter.document_shape_type_mapc                 C   s$   |r |  }|D ]}|||j< q|S N)copyr-   )r   r8   r   r<   r   r   r   r9      s
    z+BaseExampleDocumenter._add_members_to_shapec                 C   s4   |d ur| | |j  |j  |j  d S rC   )r   r
   indentr   )r   r   startr   r   r   r,      s
    


z)BaseExampleDocumenter._start_nested_paramc                 C   s4   |j   |j   |j   |d ur0|| d S rC   )r
   dedentr   r   )r   r   endr   r   r   r.      s
    


z'BaseExampleDocumenter._end_nested_paramc                 C   sB   |j s(|  |||  | | n|d}| || d S )Nr*   )Zavailable_sectionsZ
clear_textr   r.   r   )r   r   rF   rH   rA   r   r   r   r:      s    
z$BaseExampleDocumenter._end_structure)NNN)NN)NN)NN)NN)NN)N)N)__name__
__module____qualname__r   r   r   r"   r2   r>   rB   r9   r,   r.   r:   r   r   r   r   r      s"    
" 
 
 
 
$ 


r   c                   @   s   e Zd ZdZdd ZdS )ResponseExampleDocumenterzresponse-examplec                 K   s8   | d | j|||fi | |d}| d d S )NzEventStream(zevent-stream-end))r   r>   r   )r   r   r   r   r   end_sectionr   r   r    document_shape_type_event_stream   s    

z:ResponseExampleDocumenter.document_shape_type_event_streamN)rI   rJ   rK   
EVENT_NAMErO   r   r   r   r   rL      s   rL   c                   @   s   e Zd ZdZdddZdS )RequestExampleDocumenterzrequest-exampleNc                 K   s   d}d}d}	d}
t |dkr,d}d}	d}
d	}|d
}| ||	 | |j|}t|D ]\}}|rn||v rnqX||}|||  || || }|jdd|jid}| j||||d |t |d k rX|d}|d |j	
  qX| ||	|
 d S )Nr   z: r4   r7   r   =(rM   z%sr3   r5   r   r%   r6   r(   r)   )r    r   r,   r9   r8   r   r   r-   r   r
   r   r:   )r   r   r   r   r   r	   r   Zparam_formatoperatorrF   rH   r;   r!   r<   r0   r/   r=   r1   r   r   r   r>      sF    




z6RequestExampleDocumenter.document_shape_type_structure)NN)rI   rJ   rK   rP   r>   r   r   r   r   rQ      s    rQ   N)Zbotocore.docs.shaper   Zbotocore.docs.utilsr   r   rL   rQ   r   r   r   r   <module>   s
    &