U
    ڲg                     @   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                   @   sr   e Zd ZdZdZddddddeeeedddZe	dd	 Z
e	ed
ddZe	ed
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r0|}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   0/tmp/pip-unpacked-wheel-zasgy6sz/proto/fields.py__init__   s     
zField.__init__c              	   C   s   | j sd}t| jtr@| j| js8dj| j| jd| _| j}n| jrht| jdr\| jjj	n| jj
j	}n\t| jtr| j| jsdj| j| jd| _| j}n&| jrt| jdr| jjj	n| jj
j	}tj| j| j| jrd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   s
   | j d S )zReturn the name of the field.r   r   r   r   r   r   r   w   s    z
Field.namec                 C   s
   | j d S )z Return the package of the field.r   r'   r(   r   r   r   r   |   s    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      s*   *
.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   r0      s   r0   c                       s.   e Zd ZdZddded 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   r3   r   r1      s   r1   )r   r1   r0   N)r   r   Zgoogle.protobufr   Z*google.protobuf.internal.enum_type_wrapperr   Zproto.primitivesr   r   r0   r1   __all__r   r   r   r   <module>   s   |