
    xnh                         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	y)    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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       c/var/www/html/profi_bot/bot/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        |t              r!t        | j                        t        |      k(  S dS )Nr   F)hasattrtupler   
isinstancer   r   others     r   __eq__zRepeated.__eq__1   sM    5$>U588_441;E81LuTWW~u-WRWWr   c                      | j                   |   S )zReturn the given item.r   r   s     r   __getitem__zRepeated.__getitem__6   s    wws|r   c                 ,    t        | j                        S )z"Return the length of the sequence.)lenr   r   s    r   __len__zRepeated.__len__:   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__A   s    GdG}r   c                 "    || j                   |<   y r)   r   )r   r   values      r   __setitem__zRepeated.__setitem__D   s    r   indexc                 <    | j                   j                  ||       y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                   j                  ||       y)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    xxr   )__name__
__module____qualname____doc__r   r   r   r"   r$   r'   r+   r.   r1   intr5   strboolr9   propertyr   r*   r   r   r   r      st     9= 
&=X
!%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   rF   rG   copydeepcopyadd)r   canarys     r   _pb_typezRepeatedComposite._pb_type[   s    
 '### tww<!
## 47712wGG''):8
 77..>>>
 tww'++-F|r   c                     t         |   |      ryt        |t              r%t	        | D cg c]  }| c}      t	        |      k(  S dS c c}w )NTF)superr"   r   r   r   )r   r!   i	__class__s      r   r"   zRepeatedComposite.__eq__x   sR    7>%  %* d#d1d#$e4	
 	
#s   	A	c                 h    | j                   j                  | j                  | j                  |         S r)   )r
   	to_pythonrL   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 )r   r?   r&   popr5   
IndexErrorsliceindicescollectionsabcr   	TypeError	enumeraterange
ValueErrorzipr   r;   )
r   r   r0   startstopstepr2   item_rX   s
             r   r1   zRepeatedComposite.__setitem__   s   
 c3D	zS,3t9, !!EFF C' !EFF U# #CI 6E4e[__%=%=> =>>qy $-U#3KE4u}t+/KKt4 $4 te|c%j89AHHUSZ/0 :  tT2u:W-$=u:,&Aw<.*  $'w#6KE4"&DK $7 ?S	@R@R?ST r   r2   c                     | j                   j                  | j                  |      }| j                  j	                  ||       yr4   )r
   to_protorL   r   r5   )r   r2   r0   pb_values       r   r5   zRepeatedComposite.insert   s.    ==))$--?uh'r   )r;   r<   r=   r>   r   rL   r"   r$   r1   r?   r5   __classcell__)rP   s   @r   rD   rD   T   s9      8
D4l(C (r   rD   )
rY   rH   typingr   proto.utilsr   rZ   MutableSequencer   rD   r*   r   r   <module>rl      s8       ';{.. ;|i( i(r   