o
    †ÝhU+  ã                   @   s¤   d dl mZ d dlmZ d dlmZ d dlmZmZm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZmZmZmZ d d	lmZ G d
d„ deƒZG dd„ deƒZdS )é    )Ú
xform_name)Úget_official_service_name)ÚActionDocumenter)Údocument_attributeÚdocument_identifierÚdocument_reference)ÚBaseDocumenter)ÚCollectionDocumenter)ÚSubResourceDocumenter)Úadd_resource_type_overviewÚ!get_identifier_args_for_signatureÚget_identifier_descriptionÚ!get_identifier_values_for_example)ÚWaiterResourceDocumenterc                       sŒ   e Zd Z‡ fdd„Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Z‡  ZS )ÚResourceDocumenterc                    s   t ƒ  |¡ || _d S ©N)ÚsuperÚ__init__Ú_botocore_session)ÚselfÚresourceZbotocore_session©Ú	__class__© ú[/var/www/html/magazine_api/magazine_env/lib/python3.10/site-packages/boto3/docs/resource.pyr   #   s   
zResourceDocumenter.__init__c                 C   sr   |   |¡ |  |¡ | d¡}|  |¡ |  |¡ |  |¡ |  |¡ |  |¡ |  |¡ |  	|¡ |  
|¡ d S )Nzmember-overview)Ú
_add_titleÚ
_add_introÚadd_new_sectionÚ_add_identifiersÚ_add_attributesÚ_add_referencesÚ_add_actionsÚ_add_sub_resourcesÚ_add_collectionsÚ_add_waitersÚ_add_overview_of_members)r   ÚsectionZoverview_sectionr   r   r   Údocument_resource'   s   









z$ResourceDocumenter.document_resourcec                 C   s   |j  | j¡ d S r   )ÚstyleÚh2Ú_resource_name©r   r&   r   r   r   r   4   s   zResourceDocumenter._add_titlec                 C   sŽ   g }| j jr| j jD ]}| |j¡ q
t|ƒ}|jj| j› d|› dd | d¡}|  	|¡ | d¡}|  
||¡ | d¡}|  ||¡ d S )Nú(ú))Ú
class_nameÚdescriptionÚexampleÚparams)Z_resource_modelÚidentifiersÚappendÚnamer   r(   Zstart_sphinx_py_classr.   r   Ú_add_descriptionÚ_add_exampleÚ_add_params_description)r   r&   Úidentifier_namesÚ
identifierZ
class_argsZdescription_sectionZexample_sectionZparam_sectionr   r   r   r   7   s   ÿ



zResourceDocumenter._add_introc                 C   s"   t | jƒ}| d || j¡¡ d S )Nz A resource representing an {} {})r   Ú_service_modelÚwriteÚformatr*   ©r   r&   Zofficial_service_namer   r   r   r5   P   s   
ÿÿz#ResourceDocumenter._add_descriptionc                 C   sˆ   |j  ¡  |j  ¡  | d¡ |j  ¡  |j  ¡  | d | j| j¡¡ |j  ¡  t|ƒ}| d t| jƒ| j| j|¡¡ |j  	¡  d S )Núimport boto3z{} = boto3.resource('{}')z{} = {}.{}({}))
r(   Ústart_codeblockÚnew_liner;   r<   Ú_service_namer   r   r*   Úend_codeblock)r   r&   r8   Zexample_valuesr   r   r   r6   X   s*   




ÿÿ
üÿzResourceDocumenter._add_examplec                 C   sV   |D ]&}t | j|ƒ}| d|› d¡ |j ¡  | d|› d|› ¡ |j ¡  qd S )Nz:type z: stringz:param z: )r   r*   r;   r(   r@   )r   r&   r8   Zidentifier_namer/   r   r   r   r7   o   s   ÿ
ùz*ResourceDocumenter._add_params_descriptionc                 C   sx   | j D ]6}|j ¡  | d|› d¡ |j ¡  | j | D ]}|dv r.|j d|› d¡ q|j d|› d¡ qqd S )Nz#These are the resource's available ú:)Ú
attributesÚcollectionsr2   Ú
referencesz
:py:attr:`ú`z
:py:meth:`z()`)Ú
member_mapr(   r@   r;   Zli)r   r&   Zresource_member_typeÚmemberr   r   r   r%   y   s   


ÿ
÷úz+ResourceDocumenter._add_overview_of_membersc                 C   sn   | j jjj}| d¡}g }|r|| jd< t|dddd |D ]}| |j¡}| |j¡ t	|| j
|d qd S )Nr2   ZIdentifierszYIdentifiers are properties of a resource that are set upon instantiation of the resource.Úidentifiers_attributes_intro©r&   Zresource_typer/   Z
intro_link)r&   Úresource_nameZidentifier_model)Ú	_resourceÚmetaÚresource_modelr2   r   rH   r   r4   r3   r   r*   )r   r&   r2   Zmember_listr9   Zidentifier_sectionr   r   r   r   ‹   s(   

ù	ýýz#ResourceDocumenter._add_identifiersc           
   	   C   sÀ   | j jjjj}i }| j jjjr | | j jjj¡}| j jj |¡}| d¡}g }|r6t	|dddd || j
d< t|ƒD ]#}|| \}}| |¡}	| |¡ t|	| j| j|| j jjjj|d q:d S )NrD   Z
Attributesz”Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the :py:meth:`load` method.rJ   rK   )r&   Úservice_namerL   Ú	attr_nameZevent_emitterZ
attr_model)rM   rN   ÚclientÚservice_modelrO   ÚshapeZ	shape_forZget_attributesr   r   rH   Úsortedr3   r   rA   r*   Úevents)
r   r&   rS   rD   rT   Zattribute_listrQ   Ú_Z
attr_shapeZattribute_sectionr   r   r   r   £   s@   
ÿ
ÿ
÷


úüz"ResourceDocumenter._add_attributesc                 C   sj   |  d¡}| jjjj}g }|rt|dddd || jd< |D ]}|  |j¡}| |j¡ t	||d qd S )NrF   Z
ReferenceszNReferences are related resource instances that have a belongs-to relationship.Zreferences_introrK   )r&   Zreference_model)
r   rM   rN   rO   rF   r   rH   r4   r3   r   )r   r&   rF   Zreference_listÚ	referenceZreference_sectionr   r   r   r    É   s$   
ù
	ÿýz"ResourceDocumenter._add_referencesc                 C   ó>   |  d¡}| jjjj}|rt| jƒ}| j|_| |¡ d S d S )NÚactions)r   rM   rN   rO   rZ   r   rH   Zdocument_actions)r   r&   rZ   Ú
documenterr   r   r   r!   ß   ó   

ýzResourceDocumenter._add_actionsc                 C   rY   )Nzsub-resources)r   rM   rN   rO   Zsubresourcesr
   rH   Zdocument_sub_resources)r   r&   Zsub_resourcesr[   r   r   r   r"   ç   r\   z%ResourceDocumenter._add_sub_resourcesc                 C   rY   )NrE   )r   rM   rN   rO   rE   r	   rH   Zdocument_collections)r   r&   rE   r[   r   r   r   r#   ï   r\   z#ResourceDocumenter._add_collectionsc                 C   sN   |  d¡}| jjjj}|r%| j | j¡}t| j|ƒ}| j	|_	| 
|¡ d S d S )NÚwaiters)r   rM   rN   rO   r]   r   Zget_waiter_modelrA   r   rH   Zdocument_resource_waiters)r   r&   r]   Zservice_waiter_modelr[   r   r   r   r$   ÷   s   
ÿÿøzResourceDocumenter._add_waiters)Ú__name__Ú
__module__Ú__qualname__r   r'   r   r   r5   r6   r7   r%   r   r   r    r!   r"   r#   r$   Ú__classcell__r   r   r   r   r   "   s     
&r   c                   @   s0   e Zd Zedd„ ƒZdd„ Zdd„ Zdd„ Zd	S )
ÚServiceResourceDocumenterc                 C   s   | j › dS )Nz.ServiceResource)Z_service_docs_name)r   r   r   r   r.     s   z$ServiceResourceDocumenter.class_namec                 C   s   |j  d¡ d S )NzService Resource)r(   r)   r+   r   r   r   r   
  s   z$ServiceResourceDocumenter._add_titlec                 C   s   t | jƒ}| d|› ¡ d S )NzA resource representing )r   r:   r;   r=   r   r   r   r5     s   
z*ServiceResourceDocumenter._add_descriptionc                 C   sZ   |j  ¡  |j  ¡  | d¡ |j  ¡  |j  ¡  | | j› d| j› d¡ |j  ¡  d S )Nr>   z = boto3.resource('z'))r(   r?   r@   r;   rA   rB   )r   r&   r8   r   r   r   r6     s   




ÿz&ServiceResourceDocumenter._add_exampleN)r^   r_   r`   Úpropertyr.   r   r5   r6   r   r   r   r   rb     s    
rb   N)Zbotocorer   Zbotocore.docs.utilsr   Zboto3.docs.actionr   Zboto3.docs.attrr   r   r   Zboto3.docs.baser   Zboto3.docs.collectionr	   Zboto3.docs.subresourcer
   Zboto3.docs.utilsr   r   r   r   Zboto3.docs.waiterr   r   rb   r   r   r   r   Ú<module>   s    d