
    Thv                     t    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y)    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y)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                .    || _         || _        || _        y)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       b/opt/server/standalone/crm/venv/lib/python3.12/site-packages/proto/marshal/collections/repeated.py__init__zRepeated.__init__   s     %    c                 V     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!    tDz$''!*dmm<<r   c                     | j                   |= y)zDelete the given item.Nr   r   keys     r   __delitem__zRepeated.__delitem__,   s    GGCLr   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   s>    5$>U588_44TWW~u--r   c                      | j                   |   S )zReturn the given item.r   r   s     r   __getitem__zRepeated.__getitem__5   s    wws|r   c                 ,    t        | j                        S )z"Return the length of the sequence.)lenr   r   s    r   __len__zRepeated.__len__9   s    477|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                   |<   y r'   r   )r   r   values      r   __setitem__zRepeated.__setitem__C   s    r   indexc                 <    | j                   j                  ||       y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                   j                  ||       y)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    xxr   )__name__
__module____qualname____doc__r   r   r   r    r"   r%   r)   r,   r/   intr3   strboolr7   propertyr   r(   r   r   r   r      ss     9= 
&=.
!%C % "&u /3 / /  r   r   c                   J     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                    | j                   | j                   S t        | j                        dkD  rt        | j                  d         S t	        | j                  d      r@t	        | j                  j
                  d      r | j                  j
                  j                  S t        j                  | j                        j                         }t        |      S )z2Return the protocol buffer type for this sequence.r   _message_descriptor_concrete_class)
r
   r$   r   r   r   rD   rE   copydeepcopyadd)r   canarys     r   _pb_typezRepeatedComposite._pb_typeZ   s    
 '### tww<!
## 47712wGG''):8
 77..>>>
 tww'++-F|r   c                 x    t         |   |      ryt        | D cg c]  }| c}      t        |      k(  S c c}w )NT)superr    r   )r   r   i	__class__s      r   r    zRepeatedComposite.__eq__w   s4    7>% &Aa&'5<77&s   	7c                 h    | j                   j                  | j                  | j                  |         S r'   )r	   	to_pythonrJ   r   r   s     r   r"   zRepeatedComposite.__getitem__|   s%    }}&&t}}dggclCCr   c                    t        |t              rZt        |        |cxk  rt        |       k  r1n t        d      | j                  |       | j	                  ||       y t        d      t        |t              r4|j                  t        |             \  }}}t        |t        j                  j                        st        d      |dk(  rt        |      D ]6  \  }}||z   |k  r| j                  ||z          | j	                  ||z   |       8 t        ||z
  t        |      z
        D ]  }| j                  |t        |      z          ! y t        |||      }	t        |      t        |	      k7  r#t        dt        |       dt        |	             t        |	|      D ]
  \  }}|| |<    y 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_rW   s
             r   r/   zRepeatedComposite.__setitem__   s   
 c3D	zS,3t9, !!EFF C' !EFF U# #CI 6E4e[__%=%=> =>>qy $-U#3 5KE4u}t+/KKt45 te|c%j89 1AHHUSZ/01  tT2u:W-$=u:,&Aw<.*  $'w#6 'KE4"&DK' ?S	@R@R?ST r   r0   c                     | j                   j                  | j                  |      }| j                  j	                  ||       yr2   )r	   to_protorJ   r   r3   )r   r0   r.   pb_values       r   r3   zRepeatedComposite.insert   s.    ==))$--?uh'r   )r9   r:   r;   r<   r   rJ   r    r"   r/   r=   r3   __classcell__)rN   s   @r   rB   rB   S   s9      88
D4l(C (r   rB   )rX   rF   proto.utilsr   rY   MutableSequencer   rB   r(   r   r   <module>rk      s5      ';{.. ;|e( e(r   