o
    {j6hT                     @   s   d Z ddlZddlZddlZddlmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZ edZedZedZG dd dee Zejje G d	d
 d
ee ee ZG dd dee ee ZG dd de
eef ZG dd de
eef ZG dd dZG dd dZG dd dZdS )a  Contains container classes to represent different protocol buffer types.

This file defines container classes which represent categories of protocol
buffer field types which need extra maintenance. Currently these categories
are:

-   Repeated scalar fields - These are all repeated fields which aren't
    composite (e.g. they are of simple types like int32, string, etc).
-   Repeated composite fields - Repeated fields which are composite. This
    includes groups and nested messages.
    N)AnyIterableIteratorListMutableMappingMutableSequenceNoReturnOptionalSequenceTypeVarUnionoverload_T_K_Vc                   @   s   e Zd ZdZddgZdeddfddZed	ede	fd
dZ
ed	edee	 fddZ
dd Z
defddZdedefddZdZdefddZdddZdddZdS )BaseContainerzBase container class._message_listener_valuesmessage_listenerreturnNc                 C   s   || _ g | _dS )z
    Args:
      message_listener: A MessageListener implementation.
        The RepeatedScalarFieldContainer will call this object's
        Modified() method when it is modified.
    N)r   r   )selfr    r   r/var/www/html/chefvision.cloud.itp360.com/venv/lib/python3.10/site-packages/google/protobuf/internal/containers.py__init__2   s   
zBaseContainer.__init__keyc                 C      d S Nr   r   r   r   r   r   __getitem__<      zBaseContainer.__getitem__c                 C   r   r   r   r   r   r   r   r   @   r   c                 C   
   | j | S )z$Retrieves item by the specified key.r   r   r   r   r   r   D      
c                 C   
   t | jS )z0Returns the number of elements in the container.lenr   r   r   r   r   __len__H   r"   zBaseContainer.__len__otherc                 C   s
   | |k S )z3Checks if another instance isn't equal to this one.r   r   r(   r   r   r   __ne__L   s   
zBaseContainer.__ne__c                 C   r#   r   reprr   r&   r   r   r   __repr__S      
zBaseContainer.__repr__c                 O   s,   d|v r| d|d< | jj|i | d S )Nsort_functioncmp)popr   sort)r   argskwargsr   r   r   r2   V   s   zBaseContainer.sortc                 C   s   | j   d S r   )r   reverser&   r   r   r   r5   ^   s   zBaseContainer.reverser   N)__name__
__module____qualname____doc__	__slots__r   r   r   intr   r   slicer   r'   boolr*   __hash__strr-   r2   r5   r   r   r   r   r   ,   s    

r   c                       sH  e Zd ZdZdgZdededdf fddZd	eddfd
dZde	d	eddfddZ
dee ddfddZdedee f ddfddZdefddZd)dee	 defddZede	d	eddfddZeded	ee ddfddZd*ddZdee	ef ddfd d!Zdedefd"d#Z	d+d$eddfd%d&Zdefd'd(Z  ZS ),RepeatedScalarFieldContainerzGSimple, type-checked, list-like container for holding repeated scalars._type_checkerr   type_checkerr   Nc                       t  | || _dS )a"  Args:

      message_listener: A MessageListener implementation. The
      RepeatedScalarFieldContainer will call this object's Modified() method
      when it is modified.
      type_checker: A type_checkers.ValueChecker instance to run on elements
      inserted into this container.
    N)superr   rB   )r   r   rC   	__class__r   r   r   m   s   
z%RepeatedScalarFieldContainer.__init__valuec                 C   s.   | j | j| | jjs| j  dS dS )z6Appends an item to the list. Similar to list.append().N)r   appendrB   
CheckValuer   dirtyModifiedr   rH   r   r   r   rI   }   s   z#RepeatedScalarFieldContainer.appendr   c                 C   s0   | j || j| | jjs| j  dS dS )zEInserts the item at the specified position. Similar to list.insert().N)r   insertrB   rJ   r   rK   rL   r   r   rH   r   r   r   rN      s   z#RepeatedScalarFieldContainer.insertelem_seqc                    s8   t |} fdd|D }|r j|  j  dS )zBExtends by appending the given iterable. Similar to list.extend().c                    s   g | ]} j |qS r   )rB   rJ   ).0elemr&   r   r   
<listcomp>   s    z7RepeatedScalarFieldContainer.extend.<locals>.<listcomp>N)iterr   extendr   rL   )r   rP   elem_seq_iter
new_valuesr   r&   r   rU      s
   z#RepeatedScalarFieldContainer.extendr(   z RepeatedScalarFieldContainer[_T]c                 C      | j | | j  dS )zAppends the contents of another repeated field of the same type to this
    one. We do not check the types of the individual fields.
    N)r   rU   r   rL   r)   r   r   r   	MergeFrom   s   z&RepeatedScalarFieldContainer.MergeFromrR   c                 C   rX   z8Removes an item from the list. Similar to list.remove().Nr   remover   rL   r   rR   r   r   r   r\         z#RepeatedScalarFieldContainer.removec                 C      | j | }| | |S zDRemoves and returns an item at a given index. Similar to list.pop().r   __delitem__rO   r   r   r   r1         

z RepeatedScalarFieldContainer.popc                 C   r   r   r   rO   r   r   r   __setitem__   r   z(RepeatedScalarFieldContainer.__setitem__c                 C   r   r   r   rO   r   r   r   re      r   c                 C   s^   t |tr|jdurtdt| jj|| j|< | j	  dS | j|| j|< | j	  dS )z(Sets the item on the specified position.NzExtended slices not supported)

isinstancer=   step
ValueErrormaprB   rJ   r   r   rL   rO   r   r   r   re      s   

c                 C      | j |= | j  dS z+Deletes the item at the specified position.Nr   r   rL   r   r   r   r   rc         z(RepeatedScalarFieldContainer.__delitem__c                 C   s.   | |u rdS t || jr|j| jkS || jkS )/Compares the current instance with another one.T)rf   rG   r   r)   r   r   r   __eq__   s
   
z#RepeatedScalarFieldContainer.__eq__unused_memoc                 C   s"   t t| j| j}||  |S r   )rA   copydeepcopyr   rB   rY   )r   rp   cloner   r   r   __deepcopy__   s
   
z)RepeatedScalarFieldContainer.__deepcopy__c                 K   s
   t d)Nz:Can't pickle repeated scalar fields, convert to list first)picklePickleError)r   r4   r   r   r   
__reduce__   s   z'RepeatedScalarFieldContainer.__reduce__r_   r6   r   )r7   r8   r9   r:   r;   r   r   r   rI   r<   rN   r   rU   r   rY   r\   r	   r1   r   re   r=   rc   r>   ro   rt   r   rw   __classcell__r   r   rF   r   rA   g   sD    



	rA   c                       s8  e Zd ZdZdgZdededdf fddZd	edefd
dZdeddfddZ	de
deddfddZdee ddfddZdedee f ddfddZdeddfddZd'dee
 defddZede
deddfdd Zededee ddfd!d Zd"d  Zdee
ef ddfd#d$Zdedefd%d&Z  ZS )(RepeatedCompositeFieldContainerzBSimple, list-like container for holding repeated composite fields._message_descriptorr   message_descriptorr   Nc                    rD   )a  
    Note that we pass in a descriptor instead of the generated directly,
    since at the time we construct a _RepeatedCompositeFieldContainer we
    haven't yet necessarily initialized the type that will be contained in the
    container.

    Args:
      message_listener: A MessageListener implementation.
        The RepeatedCompositeFieldContainer will call this object's
        Modified() method when it is modified.
      message_descriptor: A Descriptor instance describing the protocol type
        that should be present in this container.  We'll use the
        _concrete_class field of this descriptor when the client calls add().
    N)rE   r   r{   )r   r   r|   rF   r   r   r      s   
z(RepeatedCompositeFieldContainer.__init__r4   c                 K   s@   | j jdi |}|| j | j| | jjs| j  |S )z{Adds a new element at the end of the list and returns it. Keyword
    arguments may be used to initialize the element.
    Nr   )r{   _concrete_class_SetListenerr   r   rI   rK   rL   )r   r4   new_elementr   r   r   add   s   
z#RepeatedCompositeFieldContainer.addrH   c                 C   sF   | j  }|| j || | j| | jjs!| j  dS dS )z+Appends one element by copying the message.N)	r{   r}   r~   r   CopyFromr   rI   rK   rL   )r   rH   r   r   r   r   rI      s   

z&RepeatedCompositeFieldContainer.appendr   c                 C   sH   | j  }|| j || | j|| | jjs"| j  dS dS )z6Inserts the item at the specified position by copying.N)	r{   r}   r~   r   r   r   rN   rK   rL   )r   r   rH   r   r   r   r   rN     s   

z&RepeatedCompositeFieldContainer.insertrP   c                 C   sN   | j j}| j}| j}|D ]}| }|| || || q|  dS )z|Extends by appending the given sequence of elements of the same type

    as this one, copying each individual message.
    N)r{   r}   r   r   r~   rY   rI   rL   )r   rP   message_classlistenervaluesmessager   r   r   r   rU     s   

z&RepeatedCompositeFieldContainer.extendr(   z#RepeatedCompositeFieldContainer[_T]c                 C   s   |  | dS )zvAppends the contents of another repeated field of the same type to this
    one, copying each individual message.
    N)rU   r)   r   r   r   rY     s   z)RepeatedCompositeFieldContainer.MergeFromrR   c                 C   rX   rZ   r[   r]   r   r   r   r\   $  r^   z&RepeatedCompositeFieldContainer.remover_   c                 C   r`   ra   rb   rO   r   r   r   r1   )  rd   z#RepeatedCompositeFieldContainer.popc                 C   r   r   r   rO   r   r   r   re   /  r   z+RepeatedCompositeFieldContainer.__setitem__c                 C   r   r   r   rO   r   r   r   re   3  r   c                 C   s   t | jj d)Nz( object does not support item assignment)	TypeErrorrG   r7   rO   r   r   r   re   7  s   c                 C   rj   rk   rl   r   r   r   r   rc   >  rm   z+RepeatedCompositeFieldContainer.__delitem__c                 C   s,   | |u rdS t || jstd| j|jkS )rn   TzSCan only compare repeated composite fields against other repeated composite fields.)rf   rG   r   r   r)   r   r   r   ro   C  s
   z&RepeatedCompositeFieldContainer.__eq__rx   )r7   r8   r9   r:   r;   r   r   r   r   rI   r<   rN   r   rU   r   rY   r\   r	   r1   r   re   r=   rc   r>   ro   ry   r   r   rF   r   rz      s,    		
	rz   c                
   @   s"  e Zd ZdZg dZdededededdf
d	d
ZdedefddZ	dede
fddZededee fddZedededeeef fddZd+ddZdededefddZdeddfddZdefddZdee fddZdefdd Zd,d#d$Zd-d%d&Zd-d'd(Zdefd)d*ZdS ).	ScalarMapzGSimple, type-checked, dict-like container for holding repeated scalars.)_key_checker_value_checkerr   r   _entry_descriptorr   key_checkervalue_checkerentry_descriptorr   Nc                 C   "   || _ || _|| _|| _i | _dS a  
    Args:
      message_listener: A MessageListener implementation.
        The ScalarMap will call this object's Modified() method when it
        is modified.
      key_checker: A type_checkers.ValueChecker instance to run on keys
        inserted into this container.
      value_checker: A type_checkers.ValueChecker instance to run on values
        inserted into this container.
      entry_descriptor: The MessageDescriptor of a map entry: key and value.
    N)r   r   r   r   r   )r   r   r   r   r   r   r   r   r   T  
   
zScalarMap.__init__r   c                 C   sD   z| j | W S  ty!   | j|}| j }|| j |< | Y S w r   )r   KeyErrorr   rJ   r   DefaultValue)r   r   valr   r   r   r   l  s   

zScalarMap.__getitem__itemc                 C   s   | j | || jv S r   r   rJ   r   r   r   r   r   r   __contains__u  s   
zScalarMap.__contains__c                 C   r   r   r   r   r   r   r   get{  r   zScalarMap.getdefaultc                 C   r   r   r   r   r   r   r   r   r   r     r   c                 C      || v r| | S |S r   r   r   r   r   r   r        rH   c                 C   s0   | j |}| j|}|| j|< | j  d S r   )r   rJ   r   r   r   rL   )r   r   rH   checked_keychecked_valuer   r   r   re     s   
zScalarMap.__setitem__c                 C   s   | j |= | j  d S r   rl   r   r   r   r   rc     s   zScalarMap.__delitem__c                 C   r#   r   r$   r&   r   r   r   r'     r.   zScalarMap.__len__c                 C   r#   r   rT   r   r&   r   r   r   __iter__  r.   zScalarMap.__iter__c                 C   r#   r   r+   r&   r   r   r   r-     r.   zScalarMap.__repr__r(   ScalarMap[_K, _V]c                 C   s   | j |j  | j  d S r   )r   updater   rL   r)   r   r   r   rY     s   zScalarMap.MergeFromc                 C      | j }| | _ d |d < d S r   r   rq   r   originalr   r   r   InvalidateIterators     
zScalarMap.InvalidateIteratorsc                 C      | j   | j  d S r   r   clearr   rL   r&   r   r   r   r        
zScalarMap.clearc                 C      | j jS r   r   r}   r&   r   r   r   GetEntryClass     zScalarMap.GetEntryClassr   )r(   r   r   Nr6   )r7   r8   r9   r:   r;   r   r   r   r   r   r>   r   r   r	   r   r   r   re   rc   r<   r'   r   r   r@   r-   rY   r   r   r   r   r   r   r   r   M  s<    
	 



r   c                
   @   s4  e Zd ZdZg dZdededededdf
d	d
ZdedefddZ	dedefddZ
ededee fddZedededeeef fddZd-ddZdedefddZdededefddZdeddfddZdefddZdee fdd Zdefd!d"Zd.d%d&Zd/d'd(Zd/d)d*Zdefd+d,ZdS )0
MessageMapzESimple, type-checked, dict-like container for with submessage values.)r   r   r   r{   r   r   r|   r   r   r   Nc                 C   r   r   )r   r{   r   r   r   )r   r   r|   r   r   r   r   r   r     r   zMessageMap.__init__r   c                 C   sZ   | j |}z| j| W S  ty,   | j }|| j || j|< | j  | Y S w r   )	r   rJ   r   r   r{   r}   r~   r   rL   )r   r   r   r   r   r   r     s   


zMessageMap.__getitem__c                 C   s   | | S )aa  get_or_create() is an alias for getitem (ie. map[key]).

    Args:
      key: The key to get or create in the map.

    This is useful in cases where you want to be explicit that the call is
    mutating the map.  This can avoid lint errors for statements like this
    that otherwise would appear to be pointless statements:

      msg.my_map[key]
    r   r   r   r   r   get_or_create  s   zMessageMap.get_or_createc                 C   r   r   r   r   r   r   r   r     r   zMessageMap.getr   c                 C   r   r   r   r   r   r   r   r     r   c                 C   r   r   r   r   r   r   r   r     r   r   c                 C   s   | j |}|| jv S r   r   r   r   r   r   r     s   
zMessageMap.__contains__rH   c                 C   s   t d)Nz5May not set values directly, call my_map[key].foo = 5)rh   rO   r   r   r   re      r   zMessageMap.__setitem__c                 C   s"   | j |}| j|= | j  d S r   )r   rJ   r   r   rL   r   r   r   r   rc     s   zMessageMap.__delitem__c                 C   r#   r   r$   r&   r   r   r   r'     r.   zMessageMap.__len__c                 C   r#   r   r   r&   r   r   r   r     r.   zMessageMap.__iter__c                 C   r#   r   r+   r&   r   r   r   r-     r.   zMessageMap.__repr__r(   MessageMap[_K, _V]c                 C   s0   |j D ]}|| v r| |= | | ||  qd S r   )r   r   )r   r(   r   r   r   r   rY     s
   
zMessageMap.MergeFromc                 C   r   r   r   r   r   r   r   r     r   zMessageMap.InvalidateIteratorsc                 C   r   r   r   r&   r   r   r   r   $  r   zMessageMap.clearc                 C   r   r   r   r&   r   r   r   r   (  r   zMessageMap.GetEntryClassr   )r(   r   r   Nr6   )r7   r8   r9   r:   r;   r   r   r   r   r   r   r   r	   r   r   r   r>   r   r   re   rc   r<   r'   r   r   r@   r-   rY   r   r   r   r   r   r   r   r     s>    
 



r   c                   @   s0   e Zd ZdZg dZdd Zdd Zdd Zd	S )
_UnknownFieldzA parsed unknown field._field_number
_wire_type_datac                 C   s   || _ || _|| _d S r   r   )r   field_number	wire_typedatar   r   r   r   2  s   z_UnknownField.__init__c                 C   s   | j |j k S r   )r   r)   r   r   r   __lt__8  s   z_UnknownField.__lt__c                 C   s0   | |u rdS | j |j ko| j|jko| j|jkS NTr   r)   r   r   r   ro   <  s   

z_UnknownField.__eq__N)r7   r8   r9   r:   r;   r   r   ro   r   r   r   r   r   ,  s    r   c                   @   s@   e Zd Zdd Zdd Zedd Zedd Zed	d
 ZdS )UnknownFieldRefc                 C   s   || _ || _d S r   )_parent_index)r   parentindexr   r   r   r   G  s   
zUnknownFieldRef.__init__c                 C   s*   | j std| jt| j krtdd S )NzAUnknownField does not exist. The parent message might be cleared.)r   rh   r   r%   r&   r   r   r   _check_validK  s
   zUnknownFieldRef._check_validc                 C      |    | j| jjS r   )r   r   _internal_getr   r   r&   r   r   r   r   S     zUnknownFieldRef.field_numberc                 C   r   r   )r   r   r   r   r   r&   r   r   r   r   Y  r   zUnknownFieldRef.wire_typec                 C   r   r   )r   r   r   r   r   r&   r   r   r   r   _  r   zUnknownFieldRef.dataN)	r7   r8   r9   r   r   propertyr   r   r   r   r   r   r   r   E  s    

r   c                   @   s^   e Zd ZdZdgZdd Zdd Zdd Zd	d
 Zdd Z	dd Z
dd Zdd Zdd ZdS )UnknownFieldSetzUnknownField containerr   c                 C   s
   g | _ d S r   r!   r&   r   r   r   r   l  r.   zUnknownFieldSet.__init__c                 C   sP   | j d u r	tdt| j }|dk r||7 }|dk s||kr#tdjt| |S )NBUnknownFields does not exist. The parent message might be cleared.r   zindex %d out of range)r   rh   r%   
IndexErrorr   r   )r   r   sizer   r   r   r   o  s   



zUnknownFieldSet.__getitem__c                 C   r    r   r!   )r   r   r   r   r   r   {  r.   zUnknownFieldSet._internal_getc                 C   s   | j d u r	tdt| j S )Nr   )r   rh   r%   r&   r   r   r   r'   ~  s   

zUnknownFieldSet.__len__c                 C   s   t |||}| j| |S r   )r   r   rI   )r   r   r   r   unknown_fieldr   r   r   _add  s   zUnknownFieldSet._addc                 c   s$    t t| D ]}t| |V  qd S r   )ranger%   r   )r   ir   r   r   r     s   zUnknownFieldSet.__iter__c                 C   s   |d u rd S | j |j  d S r   )r   rU   r)   r   r   r   _extend  s   zUnknownFieldSet._extendc                 C   s>   | |u rdS t | j}|d u r| S |  t|j}||kS r   )listr   r2   sorted)r   r(   r   other_valuesr   r   r   ro     s   

zUnknownFieldSet.__eq__c                 C   s,   | j D ]}t|jtr|j  qd | _ d S r   )r   rf   r   r   _clearrM   r   r   r   r     s
   


zUnknownFieldSet._clearN)r7   r8   r9   r:   r;   r   r   r   r'   r   r   r   ro   r   r   r   r   r   r   f  s    r   )r:   collections.abccollectionsrq   ru   typingr   r   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   abcregisterrA   rz   r   r   r   r   r   r   r   r   r   <module>   s"   88pvfy!