
    g(                         d dl Z d dlmZ  G d d      Z G d de      Z G d de      Z G d	 d
e      Z	 G d de      Z
 G d de      Zy)    N)Mappingc                   N    e Zd ZdZddZd Zd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zy)
OrderedSetz?
    A set which keeps the ordering of the inserted items.
    Nc                 @    t         j                  |xs d      | _         y )N )dictfromkeys)selfiterables     s/var/www/python.vincentserveurtest.ovh/public_html/venv/lib/python3.12/site-packages/django/utils/datastructures.py__init__zOrderedSet.__init__
   s    MM(.b1	    c                 "    d | j                   |<   y Nr   r
   items     r   addzOrderedSet.add   s    		$r   c                     | j                   |= y r   r   r   s     r   removezOrderedSet.remove   s    IIdOr   c                 F    	 | j                  |       y # t        $ r Y y w xY wr   )r   KeyErrorr   s     r   discardzOrderedSet.discard   s%    	KK 		s    	  c                 ,    t        | j                        S r   )iterr   r
   s    r   __iter__zOrderedSet.__iter__       DIIr   c                 ,    t        | j                        S r   )reversedr   r   s    r   __reversed__zOrderedSet.__reversed__   s    		""r   c                     || j                   v S r   r   r   s     r   __contains__zOrderedSet.__contains__   s    tyy  r   c                 ,    t        | j                        S r   )boolr   r   s    r   __bool__zOrderedSet.__bool__"   r   r   c                 ,    t        | j                        S r   )lenr   r   s    r   __len__zOrderedSet.__len__%   s    499~r   c                     | j                   rt        t        | j                               nd}| j                  j                   d| dS )N ())r   reprlist	__class____qualname__)r
   datas     r   __repr__zOrderedSet.__repr__(   s:    (,		tDO$r..--.avQ77r   r   )__name__
__module__r1   __doc__r   r   r   r   r   r!   r#   r&   r)   r3   r   r   r   r   r      s9    2#!8r   r   c                       e Zd Zy)MultiValueDictKeyErrorN)r4   r5   r1   r   r   r   r8   r8   -   s    r   r8   c                        e Zd ZdZd fd	Z fdZ fdZ fdZd Zd Z	d Z
d	 Zdd
Zd fd	ZddZ fdZddZddZd Zd Z fdZd Zd Zd Zd Z xZS )MultiValueDicta  
    A subclass of dictionary customized to handle multiple values for the
    same key.

    >>> d = MultiValueDict({'name': ['Adrian', 'Simon'], 'position': ['Developer']})
    >>> d['name']
    'Simon'
    >>> d.getlist('name')
    ['Adrian', 'Simon']
    >>> d.getlist('doesnotexist')
    []
    >>> d.getlist('doesnotexist', ['Adrian', 'Simon'])
    ['Adrian', 'Simon']
    >>> d.get('lastname', 'nonexistent')
    'nonexistent'
    >>> d.setlist('lastname', ['Holovaty', 'Willison'])

    This class exists to solve the irritating problem raised by cgi.parse_qs,
    which returns a list for every key, even though most web forms submit
    single name-value pairs.
    c                 $    t         |   |       y r   )superr   )r
   key_to_list_mappingr0   s     r   r   zMultiValueDict.__init__H   s    ,-r   c                 V    d| j                   j                  dt        |          dS )N<z: >)r0   r4   r<   r3   r
   r0   s    r   r3   zMultiValueDict.__repr__K   s     !^^44eg6F6HIIr   c                     	 t         |   |      }	 |d   S # t        $ r t        |      w xY w# t        $ r g cY S w xY w)z|
        Return the last data value for this key, or [] if it's an empty list;
        raise KeyError if not found.
        )r<   __getitem__r   r8   
IndexErrorr
   keylist_r0   s      r   rD   zMultiValueDict.__getitem__N   sW    
	.G',E	9  	.(--	.  	I	s    0 ->>c                 (    t         |   ||g       y r   r<   __setitem__)r
   rG   valuer0   s      r   rK   zMultiValueDict.__setitem__\   s    C%)r   c           
      |    | j                  | j                         D cg c]  \  }}||d d  f c}}      S c c}}w r   )r0   lists)r
   kvs      r   __copy__zMultiValueDict.__copy___   s5    ~~TZZ\B\TQ1Q4y\BCCBs   8
c           	          | j                         }||t        |       <   t        j                  |       D ]D  \  }}t        j	                  |t        j                  ||      t        j                  ||             F |S r   )r0   idr   itemsrK   copydeepcopy)r
   memoresultrG   rL   s        r   __deepcopy__zMultiValueDict.__deepcopy__b   sd    !RX**T*JCc40$--t2L + r   c           	      l    i | j                   d| D ci c]  }|| j                  |       c}iS c c}w N_data)__dict___getlist)r
   rO   s     r   __getstate__zMultiValueDict.__getstate__k   s8    N$--N*M11dmmA.>+>*MNN*Ms   1c                     |j                  di       }|j                         D ]  \  }}| j                  ||        | j                  j	                  |       y r[   )poprT   setlistr]   update)r
   obj_dictr2   rO   rP   s        r   __setstate__zMultiValueDict.__setstate__n   sF    ||GR(JJLDAqLLA !X&r   c                 B    	 | |   }|g k(  r|S |S # t         $ r |cY S w xY w)z
        Return the last data value for the passed key. If key doesn't exist
        or value is an empty list, return `default`.
        )r   )r
   rG   defaultvals       r   getzMultiValueDict.gett   s9    
	s)C "9N
	  	N	s    c                 x    	 t         |   |      }|r|t        |      nd}|S # t        $ r |g cY S |cY S w xY w)z
        Return a list of values for the key.

        Used internally to manipulate values list. If force_list is True,
        return a new copy of values.
        N)r<   rD   r/   r   )r
   rG   rg   
force_listvaluesr0   s        r   r^   zMultiValueDict._getlist   sQ    		W(-F )/);fM  		N	s   % 999c                 *    | j                  ||d      S )zn
        Return the list of values for the key. If key doesn't exist, return a
        default value.
        T)rk   )r^   r
   rG   rg   s      r   getlistzMultiValueDict.getlist   s    
 }}S'd};;r   c                 &    t         |   ||       y r   rJ   rF   s      r   rb   zMultiValueDict.setlist   s    C'r   c                     || vr|| |<   | |   S r   r   rn   s      r   
setdefaultzMultiValueDict.setdefault   s    d?DI Cyr   c                 X    || vr|g }| j                  ||       | j                  |      S r   )rb   r^   )r
   rG   default_lists      r   setlistdefaultzMultiValueDict.setlistdefault   s3    d?#!LLl+ }}S!!r   c                 D    | j                  |      j                  |       y)z8Append an item to the internal list associated with key.N)ru   appendr
   rG   rL   s      r   
appendlistzMultiValueDict.appendlist   s    C ''.r   c              #   ,   K   | D ]  }|| |   f  yw)zu
        Yield (key, value) pairs, where value is the last item in the list
        associated with the key.
        Nr   r
   rG   s     r   rT   zMultiValueDict.items   s      
 CtCy.  s   c                 2    t        t        | 	               S )zYield (key, list) pairs.)r   r<   rT   rA   s    r   rN   zMultiValueDict.lists   s    EGMO$$r   c              #   (   K   | D ]	  }| |     yw)z'Yield the last value on every key list.Nr   r{   s     r   rl   zMultiValueDict.values   s     Cs)O s   c                 ,    t        j                   |       S )z%Return a shallow copy of this object.)rU   r   s    r   rU   zMultiValueDict.copy   s    yyr   c                    t        |      dkD  rt        dt        |      z        |r|d   }t        |t              r9|j	                         D ]%  \  }}| j                  |      j                  |       ' nJt        |t              r|j                         }|D ]%  \  }}| j                  |      j                  |       ' |j                         D ]%  \  }}| j                  |      j                  |       ' y)z.Extend rather than replace existing key lists.   z*update expected at most 1 argument, got %dr   N)
r(   	TypeError
isinstancer:   rN   ru   extendr   rT   rw   )r
   argskwargsargrG   
value_listrL   s          r   rc   zMultiValueDict.update   s    t9q=H3t9TUUq'C#~.'*yy{OC'',33J? (3 c7+))+C"%JC'',33E: #& ,,.JC$++E2 )r   c                 4    | D ci c]  }|| |   
 c}S c c}w )z5Return current object as a dict with singular values.r   r{   s     r   r   zMultiValueDict.dict   s"    *./$3T#Y$///s   )r   r   )NF)r4   r5   r1   r6   r   r3   rD   rK   rQ   rY   r_   re   ri   r^   ro   rb   rr   ru   ry   rT   rN   rl   rU   rc   r   __classcell__r0   s   @r   r:   r:   1   st    ,.J*DO'$<("/!%
3"0r   r:   c                   V    e Zd ZdZdddZd ZeZeZeZeZ	eZ
eZeZeZeZeZeZeZeZy)ImmutableLista0  
    A tuple-like object that raises useful errors when it is asked to mutate.

    Example::

        >>> a = ImmutableList(range(5), warning="You cannot mutate this.")
        >>> a[3] = '4'
        Traceback (most recent call last):
            ...
        AttributeError: You cannot mutate this.
    z"ImmutableList object is immutable.)warningc                F    t        j                  | g|i |}||_        |S r   )tuple__new__r   )clsr   r   r   r
   s        r   r   zImmutableList.__new__   s&    }}S24262r   c                 ,    t        | j                        r   )AttributeErrorr   )r
   r   r   s      r   complainzImmutableList.complain   s    T\\**r   N)r4   r5   r1   r6   r   r   __delitem____delslice____iadd____imul__rK   __setslice__rw   r   insertra   r   sortreverser   r   r   r   r      sZ    
 %I 
+ KLHHKLFFF
CFDGr   r   c                   ,     e Zd ZdZ fdZ fdZ xZS )DictWrapperaG  
    Wrap accesses to a dictionary so that certain values (those starting with
    the specified prefix) are passed through a function before being returned.
    The prefix is removed before looking up the real value.

    Used by the SQL construction code to ensure that values are correctly
    quoted before being used.
    c                 @    t         |   |       || _        || _        y r   )r<   r   funcprefix)r
   r2   r   r   r0   s       r   r   zDictWrapper.__init__  s    	r   c                     |j                  | j                        }|j                  | j                        }t        |   |      }|r| j                  |      S |S )z
        Retrieve the real value after stripping the prefix string (if
        present). If the prefix is present, pass the value through self.func
        before returning, otherwise return the raw value.
        )
startswithr   removeprefixr<   rD   r   )r
   rG   use_funcrL   r0   s       r   rD   zDictWrapper.__getitem__  sQ     >>$++.t{{+#C(99U##r   )r4   r5   r1   r6   r   rD   r   r   s   @r   r   r     s    
 r   r   c                   J    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
ed	        Zy
)CaseInsensitiveMappinga  
    Mapping allowing case-insensitive key lookups. Original case of keys is
    preserved for iteration and string representation.

    Example::

        >>> ci_map = CaseInsensitiveMapping({'name': 'Jane'})
        >>> ci_map['Name']
        Jane
        >>> ci_map['NAME']
        Jane
        >>> ci_map['name']
        Jane
        >>> ci_map  # original case preserved
        {'name': 'Jane'}
    c                     | j                  |      D ci c]  \  }}|j                         ||f c}}| _        y c c}}w r   )_unpack_itemslower_store)r
   r2   rO   rP   s       r   r   zCaseInsensitiveMapping.__init__0  s;    595G5G5MN5MTQqwwy1a&(5MNNs   <c                 B    | j                   |j                            d   S )Nr   )r   r   r{   s     r   rD   z"CaseInsensitiveMapping.__getitem__3  s    {{399;'**r   c                 ,    t        | j                        S r   )r(   r   r   s    r   r)   zCaseInsensitiveMapping.__len__6  s    4;;r   c                    t        |t              xre | j                         D ci c]  \  }}|j                         | c}}|j                         D ci c]  \  }}|j                         | c}}k(  S c c}}w c c}}w r   )r   r   rT   r   )r
   otherrO   rP   s       r   __eq__zCaseInsensitiveMapping.__eq__9  st    %) 6%)ZZ\/
%1TQAGGIqL\/
',{{}5}tq!aggil}5/6 	6 /
5s   A8A>c                 D    d | j                   j                         D        S )Nc              3   &   K   | ]	  \  }}|  y wr   r   ).0original_keyrL   s      r   	<genexpr>z2CaseInsensitiveMapping.__iter__.<locals>.<genexpr>?  s     M8L!4u8Ls   )r   rl   r   s    r   r   zCaseInsensitiveMapping.__iter__>  s    M8J8J8LMMr   c                 |    t        | j                  j                         D ci c]  \  }}||
 c}}      S c c}}w r   )r.   r   rl   rx   s      r   r3   zCaseInsensitiveMapping.__repr__A  s6    $++2D2D2FG2FJCS%Z2FGHHGs   8
c                     | S r   r   r   s    r   rU   zCaseInsensitiveMapping.copyD  s    r   c           	   #   H  K   t        | t        t        f      r| j                         E d {    y t	        |       D ]_  \  }}t        |      dk7  r$t        dj                  |t        |                  t        |d   t              st        d|d   z        | a y 7 sw)N   zDdictionary update sequence element #{} has length {}; 2 is required.r   z0Element key %r invalid, only strings are allowed)	r   r   r   rT   	enumerater(   
ValueErrorformatstr)r2   ielems      r   r   z$CaseInsensitiveMapping._unpack_itemsG  s     
 dT7O,zz|## GAt4yA~ %%+VAs4y%9  d1gs+ FaP  J ' $s   *B"B A4B"N)r4   r5   r1   r6   r   rD   r)   r   r   r3   rU   staticmethodr   r   r   r   r   r     sA    "O+ 6
NI  r   r   )rU   collections.abcr   r   r   r8   r   r:   r   r   r   r   r   r   r   <module>r      sV     #%8 %8P	X 	h0T h0V"E "J$ :;W ;r   