
    2Bf                         d Z ddlZddlmZ ddlmZ ddlmZm	Z	m
Z
 ddlmZmZmZmZmZmZ  G d d	eeef   eeef         Zy)
zProvide :class:`MutableBidict`.    N   )MutableBidirectionalMapping)
BidictBase)OnDupON_DUP_RAISEON_DUP_DROP_OLD)_NONEKTVTVDT	IterItemsMapOrIterItemsc            	          e Zd ZdZdZej                  r	ed"d       Zde	ddfdZ
de	deddfd	Zefde	ded
eddfdZde	deddfdZd#dZej$                  de	defd       Zej$                  d$de	dedefd       Zefde	dedefdZdej,                  e	ef   fdZej$                  dej0                  e	ef   deddfd       Zej$                  dee	ef   deddfd       Zej$                  deddfd       Zdee	ef   deddfdZej$                  dej0                  e	ef   deddfd       Zej$                  dee	ef   deddfd       Zej$                  deddfd       Zdee	ef   deddfdZej$                  dej0                  e	ef   d
eddfd       Zej$                  efdee	ef   d
eddfd        Zefdee	ef   d
eddfd!Zy)%MutableBidictz.Base class for mutable bidirectional mappings. returnc                      y Nr   selfs    K/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/bidict/_mut.pyinversezMutableBidict.inverse-   s    69    keyNc                 &    | j                  |       y)u#   *x.__delitem__(y)　⟺　del x[y]*N)_popr   r   s     r   __delitem__zMutableBidict.__delitem__0   s    		#r   valc                 >    | j                  ||| j                         y)a*  Set the value for *key* to *val*.

        If *key* is already associated with *val*, this is a no-op.

        If *key* is already associated with a different value,
        the old value will be replaced with *val*,
        as with dict's :meth:`__setitem__`.

        If *val* is already associated with a different key,
        an exception is raised
        to protect against accidental removal of the key
        that's currently associated with *val*.

        Use :meth:`put` instead if you want to specify different behavior in
        the case that the provided key or value duplicates an existing one.
        Or use :meth:`forceput` to unconditionally associate *key* with *val*,
        replacing any existing items as necessary to preserve uniqueness.

        :raises bidict.ValueDuplicationError: if *val* duplicates that of an
            existing item.

        :raises bidict.KeyAndValueDuplicationError: if *key* duplicates the key of an
            existing item and *val* duplicates the value of a different
            existing item.
        N)_puton_dupr   r   r   s      r   __setitem__zMutableBidict.__setitem__4   s    4 			#sDKK(r   r"   c                 *    | j                  |||       y)aL  Associate *key* with *val*, honoring the :class:`OnDup` given in *on_dup*.

        For example, if *on_dup* is :attr:`~bidict.ON_DUP_RAISE`,
        then *key* will be associated with *val* if and only if
        *key* is not already associated with an existing value and
        *val* is not already associated with an existing key,
        otherwise an exception will be raised.

        If *key* is already associated with *val*, this is a no-op.

        :raises bidict.KeyDuplicationError: if attempting to insert an item
            whose key only duplicates an existing item's, and *on_dup.key* is
            :attr:`~bidict.RAISE`.

        :raises bidict.ValueDuplicationError: if attempting to insert an item
            whose value only duplicates an existing item's, and *on_dup.val* is
            :attr:`~bidict.RAISE`.

        :raises bidict.KeyAndValueDuplicationError: if attempting to insert an
            item whose key duplicates one existing item's, and whose value
            duplicates another existing item's, and *on_dup.kv* is
            :attr:`~bidict.RAISE`.
        N)r!   )r   r   r   r"   s       r   putzMutableBidict.putP   s    0 			#sF#r   c                 2    | j                  ||t               y)zAssociate *key* with *val* unconditionally.

        Replace any existing mappings containing key *key* or value *val*
        as necessary to preserve uniqueness.
        N)r!   r   r#   s      r   forceputzMutableBidict.forceputj   s     			#sO,r   c                 l    | j                   j                          | j                  j                          y)zRemove all items.N)_fwdmclear_invmr   s    r   r+   zMutableBidict.clearr   s"    



r   c                      y r   r   r   s     r   popzMutableBidict.popw   s    "%r   defaultc                      y r   r   r   r   r/   s      r   r.   zMutableBidict.popy   s    7:r   c                 Z    	 | j                  |      S # t        $ r |t        u r |cY S w xY w)u   *x.pop(k[, d]) → v*

        Remove specified key and return the corresponding value.

        :raises KeyError: if *key* is not found and no *default* is provided.
        )r   KeyErrorr	   r1   s      r   r.   zMutableBidict.pop{   s4    	99S>! 	%N	s    **c                 x    | st        d      | j                  j                         \  }}| j                  |= ||fS )u   *x.popitem() → (k, v)*

        Remove and return some item as a (key, value) pair.

        :raises KeyError: if *x* is empty.
        zmapping is empty)r3   r*   popitemr,   r#   s      r   r5   zMutableBidict.popitem   s=     -..::%%'SJJsOCxr   _MutableBidict__argkwc                      y r   r   r   r6   r7   s      r   updatezMutableBidict.update   s    CFr   c                      y r   r   r9   s      r   r:   zMutableBidict.update   s    BEr   c                      y r   r   r   r7   s     r   r:   zMutableBidict.update   s    (+r   argsc                 P    |s|r" | j                   d| j                  g|i | yy)zCLike calling :meth:`putall` with *self.on_dup* passed for *on_dup*.FN)_updater"   r   r>   r7   s      r   r:   zMutableBidict.update   s*    2DLL9d9b9 r   c                      y r   r   r9   s      r   forceupdatezMutableBidict.forceupdate       HKr   c                      y r   r   r9   s      r   rC   zMutableBidict.forceupdate   s    GJr   c                      y r   r   r=   s     r   rC   zMutableBidict.forceupdate   s    -0r   c                 :     | j                   dt        g|i | y)zLike a bulk :meth:`forceput`.FN)r@   r   rA   s      r   rC   zMutableBidict.forceupdate   s    UO9d9b9r   itemsc                      y r   r   r   rH   r"   s      r   putallzMutableBidict.putall   rD   r   c                      y r   r   rJ   s      r   rK   zMutableBidict.putall   s    VYr   c                 0    |r| j                  d||       yy)zLike a bulk :meth:`put`.

        If one of the given items causes an exception to be raised,
        none of the items is inserted.
        FN)r@   rJ   s      r   rK   zMutableBidict.putall   s     LL. r   )r   zMutableBidict[VT, KT])r   N).)__name__
__module____qualname____doc__	__slots___tTYPE_CHECKINGpropertyr   r
   r   r   r$   r   r   r&   r(   r+   overloadr.   r   r	   Tupler5   Mappingr:   r   r   rC   rK   r   r   r   r   r   '   s   8I		9 
9r d )r ) )t )8 5A $r $ $E $T $4-B -R -D -
 [[%r%b% %[[:r:C:#: :*/ r C C "b&)  [[FBJJr2v.FbFTF F[[EIb"f-EREDE E[[+2+$+ +:N2r62 :" : :
 [[KBF!3K2K$K K[[J2r6!2J"JJ J[[00t0 0:B!7 :r :d : [[KBJJr2v.KK$K K[[?KYIb"f-YuYPTY YDP /N2r62 /E /UY /r   r   )rQ   typingrS   _abcr   _baser   _dupr   r   r   _typingr	   r
   r   r   r   r   r   r   r   r   <module>r^      sB   : &  -  6 6 B BO/Jr2v&(CBF(K O/r   