a
    ù!f1  ã                   @   s   G d d„ dƒZ dS )c                   @   sH   e Zd ZdZeedœdd„Zddœedœdd„Zd	d
„ Ze	dd„ ƒZ
dS )ÚMessageRulez@A marshal for converting between a descriptor and proto.Message.)Ú
descriptorÚwrapperc                 C   s   || _ || _d S ©N)Ú_descriptorÚ_wrapper)Úselfr   r   © r   ú\/var/www/html/python-backend/venv/lib/python3.9/site-packages/proto/marshal/rules/message.pyÚ__init__   s    zMessageRule.__init__N)Úabsentc                C   s   t || jƒr| j |¡S |S r   )Ú
isinstancer   r   Úwrap)r   Úvaluer   r   r   r	   Ú	to_python   s    zMessageRule.to_pythonc              
   C   sp   t || jƒr| j |¡S t |tƒrl| jslz| jf i |¤ŽW S  tyj } z|  |¡jW  Y d }~S d }~0 0 |S r   )r   r   ZpbÚdictÚis_mapr   Ú	TypeErrorZ_pb)r   r   Úexr   r   r	   Úto_proto   s    "zMessageRule.to_protoc                 C   s   | j j}|jo| ¡ jS )z>Return True if the descriptor is a map entry, False otherwise.)r   Z
DESCRIPTORZhas_optionsZ
GetOptionsZ	map_entry)r   Údescr   r   r	   r   ,   s    zMessageRule.is_map)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Útyper
   Úboolr   r   Úpropertyr   r   r   r   r	   r      s   r   N)r   r   r   r   r	   Ú<module>   ó    