
    Ng                     z    d dl Z d dlZd dlmZ d dlmZ  G d de j        j                  Z G d de          Z	dS )    N)Iterable)cached_propertyc                       e Zd ZdZdddZd Zd Zd Zd Zd	 Z	d
 Z
d Zd ZdefdZddddedefdZed             ZdS )RepeatedzA view around a mutable sequence in protocol buffers.

    This implements the full Python MutableSequence interface, but all methods
    modify the underlying field container directly.
    N)
proto_typec                0    || _         || _        || _        dS )a  Initialize a wrapper around a protobuf repeated field.

        Args:
            sequence: A protocol buffers repeated field.
            marshal (~.MarshalRegistry): An instantiated marshal, used to
                convert values going to and from this map.
        N)_pb_marshal_proto_type)selfsequencemarshalr   s       ^/var/www/html/ai-engine/env/lib/python3.11/site-packages/proto/marshal/collections/repeated.py__init__zRepeated.__init__   s      %    c                 Z     t          |           | j        dd         | j                  S )z%Copy this object and return the copy.N)r   )typepbr
   r   s    r   __copy__zRepeated.__copy__)   s)    tDzz$'!!!*dm<<<<r   c                     | j         |= dS )zDelete the given item.Nr   r   keys     r   __delitem__zRepeated.__delitem__-   s    GCLLLr   c                     t          |d          r*t          | j                  t          |j                  k    S t          |t                    r%t          | j                  t          |          k    ndS )Nr   F)hasattrtupler   
isinstancer   r   others     r   __eq__zRepeated.__eq__1   s]    5$ 	5>>U58__441;E81L1LWuTW~~u--RWWr   c                     | j         |         S )zReturn the given item.r   r   s     r   __getitem__zRepeated.__getitem__6   s    ws|r   c                 *    t          | j                  S )z"Return the length of the sequence.)lenr   r   s    r   __len__zRepeated.__len__:   s    47||r   c                     | |k     S N r    s     r   __ne__zRepeated.__ne__>   s    5=  r   c                 $    t          g |           S r)   )reprr   s    r   __repr__zRepeated.__repr__A   s    GdG}}r   c                     || j         |<   d S r)   r   )r   r   values      r   __setitem__zRepeated.__setitem__D   s    r   indexc                 <    | j                             ||           dS z2Insert ``value`` in the sequence before ``index``.N)r   insert)r   r2   r0   s      r   r5   zRepeated.insertG   s    ue$$$$$r   Fr   reverser   r7   c                >    | j                             ||           dS )zStable sort *IN PLACE*.r6   N)r   sort)r   r   r7   s      r   r9   zRepeated.sortK   s     g.....r   c                     | j         S r)   )r	   r   s    r   r   zRepeated.pbO   s	    xr   )__name__
__module____qualname____doc__r   r   r   r"   r$   r'   r+   r.   r1   intr5   strboolr9   propertyr   r*   r   r   r   r      s          9= 
& 
& 
& 
& 
&= = =  X X X
    ! ! !    %C % % % % "&u / / /3 / / / / /   X  r   r   c                   P     e Zd ZdZed             Z fdZd Zd Zde	fdZ
 xZS )RepeatedCompositezA view around a mutable sequence of messages in protocol buffers.

    This implements the full Python MutableSequence interface, but all methods
    modify the underlying field container directly.
    c                 v   | j         | j         S t          | j                  dk    rt          | j        d                   S t	          | j        d          r+t	          | j        j        d          r| j        j        j        S t          j        | j                  	                                }t          |          S )z2Return the protocol buffer type for this sequence.Nr   _message_descriptor_concrete_class)
r   r&   r   r   r   rF   rG   copydeepcopyadd)r   canarys     r   _pb_typezRepeatedComposite._pb_type[   s    
 '## tw<<!
### 47122 	?wG'):8
 8
 	? 7.>>
 tw''++--F||r   c                     t                                          |          rdS t          |t                    r*t	          d | D                       t	          |          k    ndS )NTc                     g | ]}|S r*   r*   ).0is     r   
<listcomp>z,RepeatedComposite.__eq__.<locals>.<listcomp>|   s    ###1###r   F)superr"   r   r   r   )r   r!   	__class__s     r   r"   zRepeatedComposite.__eq__x   sc    77>>%   	4 %**E##d###$$e44	
r   c                 X    | j                             | j        | j        |                   S r)   )r
   	to_pythonrL   r   r   s     r   r$   zRepeatedComposite.__getitem__   s"    }&&t}dgclCCCr   c                 R   t          |t                    rgt          |            |cxk    rt          |           k     r0n n-|                     |           |                     ||           d S t          d          t          |t                    rr|                    t          |                     \  }}}t          |t          j	        j
                  st          d          |dk    rt          |          D ]?\  }}||z   |k     r|                     ||z              |                     ||z   |           @t          ||z
  t          |          z
            D ]'}|                     |t          |          z              (d S t          |||          }	t          |          t          |	          k    r/t          dt          |           dt          |	                     t          |	|          D ]
\  }}|| |<   d S t          dt!          |          j                   )Nz"list assignment index out of rangezcan only assign an iterable   z#attempt to assign sequence of size z to extended slice of size z-list indices must be integers or slices, not )r   r?   r&   popr5   
IndexErrorsliceindicescollectionsabcr   	TypeError	enumeraterange
ValueErrorzipr   r;   )
r   r   r0   startstopstepr2   item_r[   s
             r   r1   zRepeatedComposite.__setitem__   sQ   
 c3 /	D		zS,,,,3t99,,,,,C''''' !EFFF U## '	 #CII 6 6E4e[_%=>> ? =>>>qyy $-U#3#3 5 5KE4u}t++///KKt4444
 te|c%jj899 1 1AHHUSZZ/00001 1  tT22u::W--$*u::* *w<<* *   $'w#6#6 ' 'KE4"&DKK' ' TS		@RTT  r   r2   c                 |    | j                             | j        |          }| j                            ||           dS r4   )r
   to_protorL   r   r5   )r   r2   r0   pb_values       r   r5   zRepeatedComposite.insert   s7    =))$-??uh'''''r   )r;   r<   r=   r>   r   rL   r"   r$   r1   r?   r5   __classcell__)rS   s   @r   rD   rD   T   s            _8
 
 
 
 
D D D4 4 4l(C ( ( ( ( ( ( ( (r   rD   )
r\   rH   typingr   proto.utilsr   r]   MutableSequencer   rD   r*   r   r   <module>ro      s               ' ' ' ' ' '; ; ; ; ;{. ; ; ;|i( i( i( i( i( i( i( i( i( i(r   