U
    N8c|                     @   s   d dl Z d dlmZ dd Zdd Zdd Zed	d
dddddgZG dd	 d	eZG dd dZG dd dZ	G dd dZ
ddddddZe dee jeZdd Zd d! ZdS )"    N)
namedtuplec                 C   s   dddddddd | | S )zGet the Python type name for a given model type.

        >>> py_type_name('list')
        'list'
        >>> py_type_name('structure')
        'dict'

    :rtype: string
    bytesstringfloatintegerdictdatetime)blob	characterdoublelongmap	structure	timestampget	type_name r   7/tmp/pip-unpacked-wheel-ozje0y8b/botocore/docs/utils.pypy_type_name   s     r   c                 C   s"   ddddddddddd	
 | d
S )zGet the Python default value for a given model type.

        >>> py_default('string')
        ''string''
        >>> py_default('list')
        '[...]'
        >>> py_default('unknown')
        '...'

    :rtype: string
    z123.0Z123z'string'zb'bytes'z
True|Falsez[...]z{...}zdatetime(2015, 1, 1))
r   r   r   r   r	   booleanlistr   r   r   z...r   r   r   r   r   
py_default&   s     r   c                 C   sn   | j d}| j dd}|dr0|dd }|drF|dd }|rj| | krj|d	| d
7 }|S )zwGenerate the official name of an AWS Service

    :param service_model: The service model representing the service
    ZserviceFullNameZserviceAbbreviation ZAmazon   NZAWS   z ())metadatar   
startswithlower)Zservice_modelZofficial_nameZ
short_namer   r   r   get_official_service_name@   s    

r!   DocumentedShapenamer   documentationr   membersrequired_membersc                       s"   e Zd ZdZd fdd	Z  ZS )r"   zBUse this class to inject new shapes into a model for documentationNc              	      s<   |d krg }|d krg }|d kr$g }t  | ||||||S N)super__new__)clsr#   r   r$   r   r%   r&   	__class__r   r   r)   `   s    	zDocumentedShape.__new__)NNN)__name__
__module____qualname____doc__r)   __classcell__r   r   r+   r   r"   ]   s
      c                   @   s   e Zd ZdddZdd ZdS )AutoPopulatedParamNc                 C   s   || _ || _|d krd| _d S )Nz{Please note that this parameter is automatically populated if it is not provided. Including this parameter is not required
)r#   param_description)selfr#   r3   r   r   r   __init__{   s
    zAutoPopulatedParam.__init__c                 K   s~   | drN| j|jkrz|| j}d|jkr6|d |d}|| j n,| drz|d}| j|jkrz|| j dS )zDocuments auto populated parameters

        It will remove any required marks for the parameter, remove the
        parameter from the example, and add a snippet about the parameter
        being autopopulated in the description.
        zdocs.request-paramszis-requiredparam-documentationzdocs.request-examplestructure-valueN)r   r#   available_sectionsget_sectiondelete_sectionwritelnr3   r4   
event_namesectionkwargsZdescription_sectionr   r   r   document_auto_populated_param   s    




z0AutoPopulatedParam.document_auto_populated_param)N)r-   r.   r/   r5   r@   r   r   r   r   r2   z   s   

r2   c                   @   s    e Zd ZdZdd Zdd ZdS )HideParamFromOperationsa>  Hides a single parameter from multiple operations.

    This method will remove a parameter from documentation and from
    examples. This method is typically used for things that are
    automatically populated because a user would be unable to provide
    a value (e.g., a checksum of a serialized XML request body).c                 C   sT   || _ t | _t | _d}d}|D ],}| j|||f  | j|||f  q"dS )a(  
        :type service_name: str
        :param service_name: Name of the service to modify.

        :type parameter_name: str
        :param parameter_name: Name of the parameter to modify.

        :type operation_names: list
        :param operation_names: Operation names to modify.
        z*docs.request-params.%s.%s.complete-sectionz+docs.request-example.%s.%s.complete-sectionN)_parameter_nameset_params_events_example_eventsadd)r4   Zservice_nameparameter_nameZoperation_namesZparam_templateZexample_templater#   r   r   r   r5      s    z HideParamFromOperations.__init__c                 K   s@   || j kr|d}n|| jkr$d S | j|jkr<|| j d S )Nr7   )rE   r9   rD   rB   r8   r:   )r4   r=   r>   r?   r   r   r   
hide_param   s    

z"HideParamFromOperations.hide_paramN)r-   r.   r/   r0   r5   rH   r   r   r   r   rA      s   rA   c                   @   s    e Zd ZdZdd Zdd ZdS )AppendParamDocumentationz-Appends documentation to a specific parameterc                 C   s   || _ || _d S r'   )rB   _doc_string)r4   rG   Z
doc_stringr   r   r   r5      s    z!AppendParamDocumentation.__init__c                 K   s2   | j |jkr.|| j }|d}|| j d S )Nr6   )rB   r8   r9   r;   rJ   r<   r   r   r   append_documentation   s    
z-AppendParamDocumentation.append_documentationN)r-   r.   r/   r0   r5   rK   r   r   r   r   rI      s   rI   z\nz\rz\tz\bz\f)
	|c                 C   s   t | d S )Nr   )	_CONTROLSgroup)matchr   r   r   <lambda>       rU   c                 C   s   t t| S r'   )_ESCAPE_CONTROLS_REsub_CONTROLS_MATCH_HANDLER)valuer   r   r   escape_controls   s    r[   )recollectionsr   r   r   r!   Z_DocumentedShaper"   r2   rA   rI   rR   compilejoinr   escaperW   rY   r[   r   r   r   r   <module>   s6   !'