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: //proc/self/root/lib/python3.6/site-packages/botocore/docs/__pycache__/sharedexample.cpython-36.pyc
3

�T_n$�@sPddlZddlZddlmZddlmZddlmZGdd�de�Z	dd�Z
dS)	�N)�parse_timestamp)�escape_controls)�sixc@sveZdZdd�Zdd�Zdd�Zdd�Zdd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�SharedExampleDocumentercCsJ|jj�|j|jd��|jj�|j||||j�|j|||j�dS)a8Documents a single shared example based on its definition.

        :param example: The model of the example

        :param prefix: The prefix to use in the method example.

        :param section: The section to write to.

        :param operation_model: The model of the operation used in the example
        �descriptionN)	�style�
new_paragraph�write�get�new_line�document_inputZinput_shape�document_outputZoutput_shape)�self�example�prefix�section�operation_model�r�#/usr/lib/python3.6/sharedexample.py�document_shared_examples


z/SharedExampleDocumenter.document_shared_examplec
Cs�|jd�}|jj�|dk	r&|j|�|jdi�}|jd�}|rJ|jd�}|jd�}|j|||g|�|jd�}	|	jj�|	jj�|	jd�|	jj�dS)N�input�commentsZ
parameterszinput-closezprint(response))�add_new_sectionr�start_codeblockr	r
�_document_paramsr�
end_codeblock)
rrrr�shapeZ
input_section�paramsr�
param_section�closing_sectionrrrr(s









z&SharedExampleDocumenter.document_inputcCs�|jd�}|jj�|jd�|jj�|jj�|jdi�}ddi|d<|jd�}|rb|jd�}|j|||g|d�|jd�}|jj�dS)N�outputzExpected Output:z...ZResponseMetadatarTzoutput-close)rrrr	rr
�_document_dictr)rrrrZoutput_sectionrrrrrrr
9s







z'SharedExampleDocumenter.document_outputcCs�t|t�r|j|||||�nft|t�r<|j|||||�nHt|tj�rX|j|||�n,|rv|jdkrv|j	|||�n|j
|||�dS)a
        :param section: The section to add the docs to.

        :param value: The input / output values representing the parameters that
                      are included in the example.

        :param comments: The dictionary containing all the comments to be
                         applied to the example.

        :param path: A list describing where the documenter is in traversing the
                     parameters. This is used to find the equivalent location
                     in the comments dictionary.
        Z	timestampN)�
isinstance�dictr!�list�_document_list�numbers�Number�_document_number�	type_name�_document_datetime�
_document_str)rr�valuer�pathrrrr�	_documentJs

z!SharedExampleDocumenter._documentFcCs�|jd�}|j|d�x�|j�D]�\}}	|jd|�|j|�}
|
jj�|j||�}|rn|
j|�|
jj�|
jd|�d}|r�|jdkr�|j	j
|�}n|jdkr�|j}|j|
|	|||�|j
�q W|jd�}
|j|
d�|s�|
jd	�dS)
Nz
dict-value�{z.%sz'%s': Z	structure�mapzending-brace�}�,)r�_start_nested_value�items�appendrr�_get_commentr	r)�membersr
r,r.�pop�_end_nested_value)rrr,rr-rZ	top_levelZdict_section�key�val�item_section�item_comment�
item_shapeZdict_section_endrrrr!cs.







z&SharedExampleDocumenter._document_dictc
Cs�|jd�}|j|d�x�|j�D]�\}}|jd|�|j|�}	|	jj�|j||�}
|
rn|	j|
�|	jj�|	j|d�d}|r�|jj	|�}|j
|	||||�|j�q W|jd�}|j|d�dS)Nzparam-values�(z.%s�=zending-parenthesis�))
rr3r4r5rrr6r	r7r
r.r8r9)
rrr,rr-rrr:r;r<r=r>Zparam_section_endrrrrs$





z(SharedExampleDocumenter._document_paramsc
Cs�|jd�}|j|d�|j}xtt|�D]h\}}	|j|�}
|
jj�|jd|�|j||�}|rt|
j|�|
jj�|j	|
|	|||�|j
�q&W|jd�}|j|d�dS)Nzlist-section�[z[%s]zending-bracketz],)rr3�member�	enumeraterrr5r6r	r.r8r9)
rrr,rr-rZlist_sectionr>�indexr;r<r=Zlist_section_endrrrr%�s





z&SharedExampleDocumenter._document_listcCs t|�}|jdtj|��dS)Nz'%s',)rr	rZ	text_type)rrr,r-Z
safe_valuerrrr+�sz%SharedExampleDocumenter._document_strcCs|jdt|��dS)Nz%s,)r	�str)rrr,r-rrrr(�sz(SharedExampleDocumenter._document_numbercCsVt|�j�}t|d�}x*tdt|��D]}|dt||�7}q(W|jd|�dS)Nr�z, z
datetime(%s),)rZ	timetuplerF�range�lenr	)rrr,r-Zdatetime_tupleZdatetime_str�irrrr*�s
z*SharedExampleDocumenter._document_datetimecCs4tjdddj|��}|r,||kr,d||SdSdS)Nz^\.�z# )�re�sub�join)rr-rr:rrrr6�sz$SharedExampleDocumenter._get_commentcCs"|j|�|jj�|jj�dS)N)r	r�indent)rr�startrrrr3�s

z+SharedExampleDocumenter._start_nested_valuecCs,|jj�|jj�|jj�|j|�dS)N)r�dedentrr	)rr�endrrrr9�s


z)SharedExampleDocumenter._end_nested_valueN)F)�__name__�
__module__�__qualname__rrr
r.r!rr%r+r(r*r6r3r9rrrrrs
rcCsT|jd�}|jj�|jjd�t�}x(|D] }|j||j|d�||d�q,WdS)aDocuments the shared examples

    :param section: The section to write to.

    :param operation_model: The model of the operation.

    :param example_prefix: The prefix to use in the method example.

    :param shared_examples: The shared JSON examples from the model.
    zshared-examplesZExamples�id)rrrrN)rrrZboldrr)rrZexample_prefixZshared_examplesZcontainer_sectionZ
documenterrrrr�document_shared_examples�s


rW)rLr&Zbotocore.utilsrZbotocore.docs.utilsrZbotocore.compatr�objectrrWrrrr�<module>
s6