
    fv                     n    d dl Z d dlZd dlmZ  G d de j        j                  Z G d de          ZdS )    N)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/Alfredo/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          | j                  t          |          k    S )Nr   )hasattrtupler   r   others     r   __eq__zRepeated.__eq__0   sH    5$ 	5>>U58__44TW~~u--r   c                     | j         |         S )zReturn the given item.r   r   s     r   __getitem__zRepeated.__getitem__5   s    ws|r   c                 *    t          | j                  S )z"Return the length of the sequence.)lenr   r   s    r   __len__zRepeated.__len__9   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__@   s    GdG}}r   c                     || j         |<   d S r'   r   )r   r   values      r   __setitem__zRepeated.__setitem__C   s    r   indexc                 <    | j                             ||           dS z2Insert ``value`` in the sequence before ``index``.N)r   insert)r   r0   r.   s      r   r3   zRepeated.insertF   s    ue$$$$$r   Fr   reverser   r5   c                >    | j                             ||           dS )zStable sort *IN PLACE*.r4   N)r   sort)r   r   r5   s      r   r7   zRepeated.sortJ   s     g.....r   c                     | j         S r'   )r   r   s    r   r   zRepeated.pbN   s	    xr   )__name__
__module____qualname____doc__r   r   r   r    r"   r%   r)   r,   r/   intr3   strboolr7   propertyr   r(   r   r   r   r      s         9= 
& 
& 
& 
& 
&= = =  . . .
    ! ! !    %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   rD   rE   copydeepcopyadd)r   canarys     r   _pb_typezRepeatedComposite._pb_typeZ   s    
 '## tw<<!
### 47122 	?wG'):8
 8
 	? 7.>>
 tw''++--F||r   c                     t                                          |          rdS t          d | D                       t          |          k    S )NTc                     g | ]}|S r(   r(   ).0is     r   
<listcomp>z,RepeatedComposite.__eq__.<locals>.<listcomp>z   s    &&&Aa&&&r   )superr    r   )r   r   	__class__s     r   r    zRepeatedComposite.__eq__w   sH    77>>%   	4&&&&&''5<<77r   c                 X    | j                             | j        | j        |                   S r'   )r	   	to_pythonrJ   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 )
isinstancer=   r$   popr3   
IndexErrorsliceindicescollectionsabcIterable	TypeError	enumeraterange
ValueErrorzipr   r9   )
r   r   r.   startstopstepr0   item_rZ   s
             r   r/   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   r0   c                 |    | j                             | j        |          }| j                            ||           dS r2   )r	   to_protorJ   r   r3   )r   r0   r.   pb_values       r   r3   zRepeatedComposite.insert   s7    =))$-??uh'''''r   )r9   r:   r;   r<   r   rJ   r    r"   r/   r=   r3   __classcell__)rQ   s   @r   rB   rB   S   s            _88 8 8 8 8
D D D4 4 4l(C ( ( ( ( ( ( ( (r   rB   )r[   rF   proto.utilsr   r\   MutableSequencer   rB   r(   r   r   <module>rn      s         ' ' ' ' ' '; ; ; ; ;{. ; ; ;|e( e( e( e( e( e( e( e( e( e(r   