U
    #FZh<	  ã                   @   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   úb/home/aprabhat/apps/x.techxrdev.in/venv/lib/python3.8/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   st   t || jƒr| j |¡S t |tƒrp| jspz| jf |ŽW S  tttfk
rn } z|  |¡j	 W Y ¢S d }~X Y nX |S r   )
r   r   ZpbÚdictÚis_mapr   Ú	TypeErrorÚ
ValueErrorÚAttributeErrorZ_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   1   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>   ó    