o
    =jý  ã                   @   sf   d dl mZ d dlmZ d dlmZ d dlmZ G dd„ dƒZG dd„ deƒZ	G d	d
„ d
eƒZ
dZdS )é    )ÚEnumMeta)Údescriptor_pb2)ÚEnumTypeWrapper)Ú	ProtoTypec                	   @   sx   e Zd ZdZdZddddddœdedededefd	d
„Ze	dd„ ƒZ
e	defdd„ƒZe	defdd„ƒZe	dd„ ƒZdS )ÚFieldz8A representation of a type of field in protocol buffers.FN)ÚmessageÚenumÚoneofÚ	json_nameÚoptionalÚnumberr	   r
   r   c                C   sn   d | _ d | _t|tƒst|ttfƒr|}tj}n|}tj}|| _	|| _
|| _|| _|| _|| _|| _d | _d S )N)Ú	mcls_dataÚparentÚ
isinstanceÚintr   r   r   ZENUMZMESSAGEr   Ú
proto_typer   r   r
   r   r	   Ú_descriptor)Úselfr   r   r   r   r	   r
   r   © r   úVC:\Users\psant\Downloads\Anu Raj Backend\school\venv\Lib\site-packages\proto/fields.pyÚ__init__   s    

zField.__init__c              	   C   sø   | j syd}t| jtƒr | j | j¡sdj| j| jd�| _| j}nB| jr4t| jdƒr.| jjj	n| jj
j	}n.t| jtƒrO| j | j¡sKdj| j| jd�| _| j}n| jrbt| jdƒr]| jjj	n| jj
j	}tj| j| j| jrmdnd| j|| j| jd�| _ | j S )z$Return the descriptor for the field.Nz{package}.{name})ÚpackageÚnameÚ
DESCRIPTORé   é   )r   r   ÚlabelÚtypeÚ	type_namer
   Zproto3_optional)r   r   r   ÚstrÚ
startswithr   ÚformatÚhasattrr   Z	full_nameÚ_metar   r   ZFieldDescriptorProtor   r   Úrepeatedr   r
   r   )r   r   r   r   r   Ú
descriptorH   sH   þ
ÿýþ
ÿýùzField.descriptorÚreturnc                 C   ó
   | j d S )zReturn the name of the field.r   N©r   ©r   r   r   r   r   w   ó   
z
Field.namec                 C   r'   )z Return the package of the field.r   Nr(   r)   r   r   r   r   |   r*   zField.packagec                 C   s4   | j r| j S | js| jS t| jdƒr| j ¡ S | jS )zMReturn the composite type of the field, or the primitive type if a primitive.r#   N)r   r   r   r"   Zpbr)   r   r   r   Úpb_type�   s   
zField.pb_type)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r$   r   r   Úboolr   Úpropertyr%   r   r   r+   r   r   r   r   r      s2    ÷üùø	
÷*
.r   c                   @   s   e Zd ZdZdZdS )ÚRepeatedFieldz9A representation of a repeated field in protocol buffers.TN)r,   r-   r.   r/   r$   r   r   r   r   r2   “   s    r2   c                       s.   e Zd ZdZdddœdef‡ fdd„Z‡  ZS )ÚMapFieldz4A representation of a map field in protocol buffers.N)r   r   r   c                   s   t ƒ j||||d� || _d S )N)r   r   r   )Úsuperr   Zmap_key_type)r   Zkey_typeZ
value_typer   r   r   ©Ú	__class__r   r   r   œ   s   
zMapField.__init__)r,   r-   r.   r/   r   r   Ú__classcell__r   r   r5   r   r3   ™   s    "r3   )r   r3   r2   N)r   r   Zgoogle.protobufr   Z*google.protobuf.internal.enum_type_wrapperr   Zproto.primitivesr   r   r2   r3   Ú__all__r   r   r   r   Ú<module>   s   |