o
    7 h                     @   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   ENUMMESSAGEr   
proto_typer   r   r
   r   r	   _descriptor)selfr   r   r   r   r	   r
   r    r   T/var/www/html/figdemos/bartoux_crm/venv/lib/python3.10/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   	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   r   r   r   r   r   r   w      
z
Field.namec                 C   r*   )z Return the package of the field.r   r+   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&   )r   r   r   r$   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)r0   r1   r2   r3   r'   r   r   r   r   r6      s    r6   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_type
value_typer   r   r   	__class__r   r   r      s   
zMapField.__init__)r0   r1   r2   r3   r   r   __classcell__r   r   r:   r   r7      s    "r7   )r   r7   r6   N)r   r   google.protobufr   Z*google.protobuf.internal.enum_type_wrapperr   proto.primitivesr   r   r6   r7   __all__r   r   r   r   <module>   s   |