>ac@skddlZddlZddlmZddlmZddlmZdefdYZ dZ dS(iN(tparse_timestamp(tescape_controls(tsixtSharedExampleDocumentercBseZdZdZdZdZedZdZdZ dZ dZ d Z d Z d Zd ZRS( cCsc|jj|j|jd|jj|j||||j|j|||jdS(s8Documents 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 t descriptionN( tstylet new_paragraphtwritetgettnew_linetdocument_inputt input_shapetdocument_outputt output_shape(tselftexampletprefixtsectiontoperation_model((s</usr/lib/fence-agents/bundled/botocore/docs/sharedexample.pytdocument_shared_examples   c Cs|jd}|jj|dk r8|j|n|jdi}|jd}|rq|jd}n|jd}|j|||g||jd} | jj| jj| jd| jjdS(Ntinputtcommentst parameterss input-closesprint(response)( tadd_new_sectionRtstart_codeblocktNoneRRt_document_paramsR t end_codeblock( RRRRtshapet input_sectiontparamsRt param_sectiontclosing_section((s</usr/lib/fence-agents/bundled/botocore/docs/sharedexample.pyR (s     cCs|jd}|jj|jd|jj|jj|jdi}idd6|d<|jd}|r|jd}n|j|||g|t|jd}|jjdS(NtoutputsExpected Output:s...tResponseMetadataRs output-close( RRR RRRt_document_dicttTrueR(RRRRtoutput_sectionRRR ((s</usr/lib/fence-agents/bundled/botocore/docs/sharedexample.pyR 9s    cCst|tr+|j|||||nt|trV|j|||||nft|tjr~|j|||n>|r|jdkr|j |||n|j |||dS(s :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. t timestampN( t isinstancetdictR#tlistt_document_listtnumberstNumbert_document_numbert type_namet_document_datetimet _document_str(RRtvalueRtpathR((s</usr/lib/fence-agents/bundled/botocore/docs/sharedexample.pyt _documentJscCsY|jd}|j|dx|jD]\}} |jd||j|} | jj|j||} | r| j| | jjn| jd|d} |r|j dkr|j j |} q|j dkr|j } qn|j | | ||| |jq,W|jd} |j| d|sU| jd ndS( Ns dict-valuet{s.%ss'%s': t structuretmaps ending-bracet}t,(Rt_start_nested_valuetitemstappendRR t _get_commentRRR.tmembersRR1R3tpopt_end_nested_value(RRR1RR2Rt top_levelt dict_sectiontkeytvalt item_sectiont item_commentt item_shapetdict_section_end((s</usr/lib/fence-agents/bundled/botocore/docs/sharedexample.pyR#cs.  c Cs|jd}|j|dx|jD]\}}|jd||j|} | jj|j||} | r| j| | jjn| j|dd} |r|j j |} n|j | |||| |j q,W|jd} |j | ddS(Ns param-valuest(s.%st=sending-parenthesist)(RR9R:R;RR R<RRR=RR3R>R?( RRR1RR2RRRBRCRDRERFtparam_section_end((s</usr/lib/fence-agents/bundled/botocore/docs/sharedexample.pyRs$  c Cs|jd}|j|d|j}xt|D]\}} |j|} | jj|jd||j||} | r| j| | jjn|j | | ||||j q5W|jd} |j | ddS(Ns list-sectiont[s[%s]sending-brackets],( RR9tmembert enumerateRR R;R<RR3R>R?( RRR1RR2Rt list_sectionRFtindexRCRDREtlist_section_end((s</usr/lib/fence-agents/bundled/botocore/docs/sharedexample.pyR*s   cCs*t|}|jdtj|dS(Nu'%s',(RRRt text_type(RRR1R2t safe_value((s</usr/lib/fence-agents/bundled/botocore/docs/sharedexample.pyR0s cCs|jdt|dS(Ns%s,(Rtstr(RRR1R2((s</usr/lib/fence-agents/bundled/botocore/docs/sharedexample.pyR-scCsot|j}t|d}x5tdt|D]}|dt||7}q8W|jd|dS(Niis, s datetime(%s),(Rt timetupleRTtrangetlenR(RRR1R2tdatetime_tuplet datetime_strti((s</usr/lib/fence-agents/bundled/botocore/docs/sharedexample.pyR/s cCsDtjdddj|}|r<||kr<d||SdSdS(Ns^\.ts# (tretsubtjoin(RR2RRB((s</usr/lib/fence-agents/bundled/botocore/docs/sharedexample.pyR<s cCs+|j||jj|jjdS(N(RRtindent(RRtstart((s</usr/lib/fence-agents/bundled/botocore/docs/sharedexample.pyR9s  cCs8|jj|jj|jj|j|dS(N(RtdedentR R(RRtend((s</usr/lib/fence-agents/bundled/botocore/docs/sharedexample.pyR?s   (t__name__t __module__RR R R3tFalseR#RR*R0R-R/R<R9R?(((s</usr/lib/fence-agents/bundled/botocore/docs/sharedexample.pyRs            c Csy|jd}|jj|jjdt}x=|D]5}|jd|d|j|dd|d|q<WdS( sDocuments 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. sshared-examplestExamplesRRtidRRN(RRRtboldRR(RRtexample_prefixtshared_examplestcontainer_sectiont documenterR((s</usr/lib/fence-agents/bundled/botocore/docs/sharedexample.pytdocument_shared_exampless     ( R\R+tbotocore.utilsRtbotocore.docs.utilsRtbotocore.compatRtobjectRRm(((s</usr/lib/fence-agents/bundled/botocore/docs/sharedexample.pyt s