o
    Mf1  ã                   @   s   G d d„ dƒZ dS )c                   @   sJ   e Zd ZdZdedefdd„Zddœdef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/analyze/labelStudio/lib/python3.10/site-packages/proto/marshal/rules/message.pyÚ__init__   s   
zMessageRule.__init__N)Úabsentr   c                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ƒr6| js6z	| jdi |¤ŽW S  ty5 } z|  |¡jW  Y d }~S d }~ww |S )Nr   )r   r   ÚpbÚdictÚis_mapr   Ú	TypeErrorÚ_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   Ú
DESCRIPTORÚhas_optionsÚ
GetOptionsÚ	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>   s   