o
    uZh                     @   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   C/var/www/html/lang_env/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   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   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"   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   |