
    Ohh                       d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dl	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mZ d dlZerd dlmZ d dlmZ d dlmZ  ede	      Zn ed      Z ed
      Z ed      Zeee
ee	j@                  f   Z!d9dZ" G d dejF                  j                        Z$ G d de$      Z%d Z& G d deeef         Z'd Z(e(dfdZ) G d de*      Z+ G d de+      Z, G d d      Z- G d d      Z.d Z/ G d  d!e*      Z0 G d" d#e1ejF                  jd                        Z3 G d$ d%e*      Z4 G d& d'ejF                  j                  ejF                  jj                        Z6 G d( d)e.e4      Z7 G d* d+      Z8 G d, d-ejr                        Z: G d. d/      Z; G d0 d1      Z<d2 Z= G d3 d4ej|                        Z? G d5 d6      Z@ G d7 d8e'      ZAy):    )annotationsN)	ContainerIterableMapping)TYPE_CHECKINGAnyCallableDictTypeVarUnionoverload)_SupportsComparison)SupportsKeysAndGetItem)Self_RangeMapKT)bound_T_VTc                    t        | t        j                        r| j                  S t        | t              s't        | t
              st        |       } | j                  } | S N)
isinstancerePattern	fullmatchr	   r   set__contains__)objs    /mnt/c/Users/Administrator/Desktop/help_/test_env/lib/python3.12/site-packages/setuptools/_vendor/jaraco/collections/__init__.py	_dispatchr   !   sI     #rzz"}}c8$#y)c(CJ    c                  0    e Zd ZdZddZd Zd Zd Zd Zy)	
ProjectionaT  
    Project a set of keys over a mapping

    >>> sample = {'a': 1, 'b': 2, 'c': 3}
    >>> prj = Projection(['a', 'c', 'd'], sample)
    >>> dict(prj)
    {'a': 1, 'c': 3}

    Projection also accepts an iterable or callable or pattern.

    >>> iter_prj = Projection(iter('acd'), sample)
    >>> call_prj = Projection(lambda k: ord(k) in (97, 99, 100), sample)
    >>> pat_prj = Projection(re.compile(r'[acd]'), sample)
    >>> prj == iter_prj == call_prj == pat_prj
    True

    Keys should only appear if they were specified and exist in the space.
    Order is retained.

    >>> list(prj)
    ['a', 'c']

    Attempting to access a key not in the projection
    results in a KeyError.

    >>> prj['b']
    Traceback (most recent call last):
    ...
    KeyError: 'b'

    Use the projection to update another dict.

    >>> target = {'a': 2, 'b': 2}
    >>> target.update(prj)
    >>> target
    {'a': 1, 'b': 2, 'c': 3}

    Projection keeps a reference to the original dict, so
    modifying the original dict may modify the Projection.

    >>> del sample['a']
    >>> dict(prj)
    {'c': 3}
    c                2    t        |      | _        || _        y r   )r   _match_space)selfkeysspaces      r   __init__zProjection.__init__]   s    or    c                X    | j                  |      st        |      | j                  |   S r   )r$   KeyErrorr%   r&   keys     r   __getitem__zProjection.__getitem__a   s'    {{33-{{3r    c                B    t        | j                  | j                        S r   )filterr$   r%   r&   s    r   _keys_resolvedzProjection._keys_resolvedf   s    dkk4;;//r    c                "    | j                         S r   )r2   r1   s    r   __iter__zProjection.__iter__i   s    ""$$r    c                F    t        t        | j                                     S r   )lentupler2   r1   s    r   __len__zProjection.__len__l   s    5,,./00r    N)r'   
_Matchabler(   r   )	__name__
__module____qualname____doc__r)   r.   r2   r4   r8    r    r   r"   r"   /   s!    +Z 
0%1r    r"   c                  "     e Zd ZdZ fdZ xZS )Maskz
    The inverse of a :class:`Projection`, masking out keys.

    >>> sample = {'a': 1, 'b': 2, 'c': 3}
    >>> msk = Mask(['a', 'c', 'd'], sample)
    >>> dict(msk)
    {'b': 2}
    c                L    t        |   |i | | j                  fd| _        y )Nc                     ||        S r   r>   )r-   origs     r   <lambda>zMask.__init__.<locals>.<lambda>}   s    S	M r    )superr)   r$   r&   argskwargs	__class__s      r   r)   zMask.__init__z   s#    $)&)'+{{Ar    r:   r;   r<   r=   r)   __classcell__rI   s   @r   r@   r@   p   s    B Br    r@   c                H     t         fd|j                         D              S )z
    Return a new dict with function applied to values of dictionary.

    >>> dict_map(lambda x: x+1, dict(a=1, b=2))
    {'a': 2, 'b': 3}
    c              3  8   K   | ]  \  }}| |      f  y wr   r>   ).0r-   valuefunctions      r   	<genexpr>zdict_map.<locals>.<genexpr>   s     L:3huo&Ls   )dictitems)rQ   
dictionarys   ` r   dict_maprV      s     L9I9I9KLLLr    c                      e Zd ZdZi ej
                  f	 	 	 	 	 ddZe	 	 	 	 dd       ZddZ	e
dd       Ze
ddd       ZdddZ	 	 	 	 	 	 dd	Zdd
Z  eddi              Z G d de      Z ed      Z ed      Zy)RangeMapaP  
    A dictionary-like object that uses the keys as bounds for a range.
    Inclusion of the value for that range is determined by the
    key_match_comparator, which defaults to less-than-or-equal.
    A value is returned for a key if it is the first key that matches in
    the sorted list of keys.

    One may supply keyword parameters to be passed to the sort function used
    to sort keys (i.e. key, reverse) as sort_params.

    Create a map that maps 1-3 -> 'a', 4-6 -> 'b'

    >>> r = RangeMap({3: 'a', 6: 'b'})  # boy, that was easy
    >>> r[1], r[2], r[3], r[4], r[5], r[6]
    ('a', 'a', 'a', 'b', 'b', 'b')

    Even float values should work so long as the comparison operator
    supports it.

    >>> r[4.5]
    'b'

    Notice that the way rangemap is defined, it must be open-ended
    on one side.

    >>> r[0]
    'a'
    >>> r[-1]
    'a'

    One can close the open-end of the RangeMap by using undefined_value

    >>> r = RangeMap({0: RangeMap.undefined_value, 3: 'a', 6: 'b'})
    >>> r[0]
    Traceback (most recent call last):
    ...
    KeyError: 0

    One can get the first or last elements in the range by using RangeMap.Item

    >>> last_item = RangeMap.Item(-1)
    >>> r[last_item]
    'b'

    .last_item is a shortcut for Item(-1)

    >>> r[RangeMap.last_item]
    'b'

    Sometimes it's useful to find the bounds for a RangeMap

    >>> r.bounds()
    (0, 6)

    RangeMap supports .get(key, default)

    >>> r.get(0, 'not found')
    'not found'

    >>> r.get(7, 'not found')
    'not found'

    One often wishes to define the ranges by their left-most values,
    which requires use of sort params and a key_match_comparator.

    >>> r = RangeMap({1: 'a', 4: 'b'},
    ...     sort_params=dict(reverse=True),
    ...     key_match_comparator=operator.ge)
    >>> r[1], r[2], r[3], r[4], r[5], r[6]
    ('a', 'a', 'a', 'b', 'b', 'b')

    That wasn't nearly as easy as before, so an alternate constructor
    is provided:

    >>> r = RangeMap.left({1: 'a', 4: 'b', 7: RangeMap.undefined_value})
    >>> r[1], r[2], r[3], r[4], r[5], r[6]
    ('a', 'a', 'a', 'b', 'b', 'b')

    c                L    t         j                  | |       || _        || _        y r   )rS   r)   sort_paramsmatch)r&   sourcerZ   key_match_comparators       r   r)   zRangeMap.__init__   s!     	dF#&)
r    c                H     | |t        d      t        j                        S )NT)reverse)rZ   r]   )rS   operatorge)clsr\   s     r   leftzRangeMap.left   s!     T 2
 	
r    c                8   t        | j                         fi | j                  }t        |t        j
                        r| j                  ||         }|S | j                  ||      }t        j                  | |      }|t        j                  u rt        |      |S r   )sortedr'   rZ   r   rX   Itemr.   _find_first_match_rS   undefined_valuer+   )r&   itemsorted_keysresultr-   s        r   r.   zRangeMap.__getitem__   s    TYY[=D,<,<=dHMM*%%k$&78F 	 ))+t<C%%dC0F111sm#r    c                     y r   r>   r&   r-   defaults      r   getzRangeMap.get   s    >Ar    Nc                     y r   r>   rm   s      r   ro   zRangeMap.get   s    ILr    c                0    	 | |   S # t         $ r |cY S w xY w)z
        Return the value for key if key is in the dictionary, else default.
        If default is not given, it defaults to None, so that this method
        never raises a KeyError.
        r+   rm   s      r   ro   zRangeMap.get  s%    	9 	N	    c                    t        j                  | j                  |      }t        ||      }	 t	        |      S # t
        $ r t        |      d w xY wr   )	functoolspartialr[   r0   nextStopIterationr+   )r&   r'   ri   is_matchmatchess        r   rg   zRangeMap._find_first_match_  sP     $$TZZ64(	+=  	+4.d*	+s	   
9 Ac                    t        | j                         fi | j                  }|t        j                     |t        j
                     fS r   )re   r'   rZ   rX   
first_item	last_item)r&   rj   s     r   boundszRangeMap.bounds  s>    TYY[=D,<,<=H//0+h>P>P2QRRr    RangeValueUndefinedr>   c                      e Zd ZdZy)RangeMap.ItemzRangeMap ItemN)r:   r;   r<   r=   r>   r    r   rf   r     s    r    rf   r   )r\   LSupportsKeysAndGetItem[_RangeMapKT, _VT] | Iterable[tuple[_RangeMapKT, _VT]]rZ   zMapping[str, Any]r]   z*Callable[[_RangeMapKT, _RangeMapKT], bool])r\   r   returnr   )ri   r   r   r   )r-   r   rn   r   r   z_VT | _Tr   )r-   r   rn   Noner   z
_VT | None)r-   r   rn   z	_T | Noner   z_VT | _T | None)r'   zIterable[_RangeMapKT]ri   r   r   r   )r   ztuple[_RangeMapKT, _RangeMapKT])r:   r;   r<   r=   r`   ler)   classmethodrc   r.   r   ro   rg   r~   typerh   intrf   r|   r}   r>   r    r   rX   rX      s    Nj *,KS;;
* Y
*
 '
* I
* 
 Y

 

 
	 A AL L	+)+1<+	+S
 :d0"b9;Os  aJRIr    rX   c                    | S r   r>   )xs    r   
__identityr   $  s    Hr    Fc                F    fd}t        | j                         ||      S )a  
    Return the items of the dictionary sorted by the keys.

    >>> sample = dict(foo=20, bar=42, baz=10)
    >>> tuple(sorted_items(sample))
    (('bar', 42), ('baz', 10), ('foo', 20))

    >>> reverse_string = lambda s: ''.join(reversed(s))
    >>> tuple(sorted_items(sample, key=reverse_string))
    (('foo', 20), ('bar', 42), ('baz', 10))

    >>> tuple(sorted_items(sample, reverse=True))
    (('foo', 20), ('baz', 10), ('bar', 42))
    c                     | d         S )Nr   r>   )ri   r-   s    r   pairkey_keyz!sorted_items.<locals>.pairkey_key9  s    47|r    )r-   r_   )re   rT   )dr-   r_   r   s    `  r   sorted_itemsr   (  s    " !'')g>>r    c                  ~     e Zd ZdZed        Z fdZ fdZ fdZ fdZ	 fdZ
 fdZ fd	Z fd
Zd Z xZS )KeyTransformingDictz
    A dict subclass that transforms the keys before they're used.
    Subclasses may override the default transform_key to customize behavior.
    c                    | S r   r>   r-   s    r   transform_keyz!KeyTransformingDict.transform_keyE  s    
r    c                    t         |           t        |i |}|j                         D ]  } | j                  |   y r   )rE   r)   rS   rT   __setitem__)r&   rG   kargsr   ri   rI   s        r   r)   zKeyTransformingDict.__init__I  sB    $ % GGI 	$DDd#	$r    c                H    | j                  |      }t        | 	  ||       y r   )r   rE   r   )r&   r-   valrI   s      r   r   zKeyTransformingDict.__setitem__Q  s"      %C%r    c                D    | j                  |      }t        | 	  |      S r   )r   rE   r.   r&   r-   rI   s     r   r.   zKeyTransformingDict.__getitem__U  #      %w"3''r    c                D    | j                  |      }t        | 	  |      S r   )r   rE   r   r   s     r   r   z KeyTransformingDict.__contains__Y  s#      %w#C((r    c                D    | j                  |      }t        | 	  |      S r   )r   rE   __delitem__r   s     r   r   zKeyTransformingDict.__delitem__]  r   r    c                L    | j                  |      }t        |   |g|i |S r   )r   rE   ro   r&   r-   rG   rH   rI   s       r   ro   zKeyTransformingDict.geta  ,      %w{30000r    c                L    | j                  |      }t        |   |g|i |S r   )r   rE   
setdefaultr   s       r   r   zKeyTransformingDict.setdefaulte  s-      %w!#7777r    c                L    | j                  |      }t        |   |g|i |S r   )r   rE   popr   s       r   r   zKeyTransformingDict.popi  r   r    c                    	 t        fd| j                         D              S # t        $ r}t              |d}~ww xY w)z
        Given a key, return the actual key stored in self that matches.
        Raise KeyError if the key isn't found.
        c              3  .   K   | ]  }|k(  s	|  y wr   r>   )rO   e_keyr-   s     r   rR   z7KeyTransformingDict.matching_key_for.<locals>.<genexpr>s  s     G%%3,Gs   
N)rw   r'   rx   r+   )r&   r-   errs    ` r   matching_key_forz$KeyTransformingDict.matching_key_form  s;    
	)G499;GGG 	)3-S(	)s   !% 	?:?)r:   r;   r<   r=   staticmethodr   r)   r   r.   r   r   ro   r   r   r   rK   rL   s   @r   r   r   ?  sI    
  $&()(181)r    r   c                       e Zd ZdZed        Zy)FoldedCaseKeyedDicta  
    A case-insensitive dictionary (keys are compared as insensitive
    if they are strings).

    >>> d = FoldedCaseKeyedDict()
    >>> d['heLlo'] = 'world'
    >>> list(d.keys()) == ['heLlo']
    True
    >>> list(d.values()) == ['world']
    True
    >>> d['hello'] == 'world'
    True
    >>> 'hello' in d
    True
    >>> 'HELLO' in d
    True
    >>> print(repr(FoldedCaseKeyedDict({'heLlo': 'world'})))
    {'heLlo': 'world'}
    >>> d = FoldedCaseKeyedDict({'heLlo': 'world'})
    >>> print(d['hello'])
    world
    >>> print(d['Hello'])
    world
    >>> list(d.keys())
    ['heLlo']
    >>> d = FoldedCaseKeyedDict({'heLlo': 'world', 'Hello': 'world'})
    >>> list(d.values())
    ['world']
    >>> key, = d.keys()
    >>> key in ['heLlo', 'Hello']
    True
    >>> del d['HELLO']
    >>> d
    {}

    get should work

    >>> d['Sumthin'] = 'else'
    >>> d.get('SUMTHIN')
    'else'
    >>> d.get('OTHER', 'thing')
    'thing'
    >>> del d['sumthin']

    setdefault should also work

    >>> d['This'] = 'that'
    >>> print(d.setdefault('this', 'other'))
    that
    >>> len(d)
    1
    >>> print(d['this'])
    that
    >>> print(d.setdefault('That', 'other'))
    other
    >>> print(d['THAT'])
    other

    Make it pop!

    >>> print(d.pop('THAT'))
    other

    To retrieve the key in its originally-supplied form, use matching_key_for

    >>> print(d.matching_key_for('this'))
    This

    >>> d.matching_key_for('missing')
    Traceback (most recent call last):
    ...
    KeyError: 'missing'
    c                @    t         j                  j                  |       S r   )jaracotext
FoldedCaser   s    r   r   z!FoldedCaseKeyedDict.transform_key  s    {{%%c**r    N)r:   r;   r<   r=   r   r   r>   r    r   r   r   x  s    HT + +r    r   c                      e Zd ZdZd Zd Zy)DictAdapteraD  
    Provide a getitem interface for attributes of an object.

    Let's say you want to get at the string.lowercase property in a formatted
    string. It's easy with DictAdapter.

    >>> import string
    >>> print("lowercase is %(ascii_lowercase)s" % DictAdapter(string))
    lowercase is abcdefghijklmnopqrstuvwxyz
    c                    || _         y r   )object)r&   
wrapped_obs     r   r)   zDictAdapter.__init__  s	     r    c                .    t        | j                  |      S r   )getattrr   )r&   names     r   r.   zDictAdapter.__getitem__  s    t{{D))r    N)r:   r;   r<   r=   r)   r.   r>   r    r   r   r     s    	!*r    r   c                  "     e Zd ZdZ fdZ xZS )ItemsAsAttributesa  
    Mix-in class to enable a mapping object to provide items as
    attributes.

    >>> C = type('C', (dict, ItemsAsAttributes), dict())
    >>> i = C()
    >>> i['foo'] = 'bar'
    >>> i.foo
    'bar'

    Natural attribute access takes precedence

    >>> i.foo = 'henry'
    >>> i.foo
    'henry'

    But as you might expect, the mapping functionality is preserved.

    >>> i['foo']
    'bar'

    A normal attribute error should be raised if an attribute is
    requested that doesn't exist.

    >>> i.missing
    Traceback (most recent call last):
    ...
    AttributeError: 'C' object has no attribute 'missing'

    It also works on dicts that customize __getitem__

    >>> missing_func = lambda self, key: 'missing item'
    >>> C = type(
    ...     'C',
    ...     (dict, ItemsAsAttributes),
    ...     dict(__missing__ = missing_func),
    ... )
    >>> i = C()
    >>> i.missing
    'missing item'
    >>> i.foo
    'missing item'
    c                   	 t        t               |      S # t        $ re}t               }d } || ||      }||ur|cY d }~S |j                  \  }|j                  d| j                  j                  d      }|f|_         d }~ww xY w)Nc                0    	 | |   S # t         $ r |cY S w xY wr   rr   )contr-   missing_results      r   _safe_getitemz4ItemsAsAttributes.__getattr__.<locals>._safe_getitem  s&    *9$ *))*rs   rE      )r   rE   AttributeErrorr   rG   replacerI   r:   )r&   r-   enovalr   rk   messagerI   s          r   __getattr__zItemsAsAttributes.__getattr__  s    	57C(( 	 HE* #4e4FU" JWoogt~~/F/FJGZAF'	s    	BB B>B  B)r:   r;   r<   r=   r   rK   rL   s   @r   r   r     s    *X r    r   c                    t        d | j                         D              }t        |      t        |       k(  st        d      |S )a  
    Given a dictionary, return another dictionary with keys and values
    switched. If any of the values resolve to the same key, raises
    a ValueError.

    >>> numbers = dict(a=1, b=2, c=3)
    >>> letters = invert_map(numbers)
    >>> letters[1]
    'a'
    >>> numbers['d'] = 3
    >>> invert_map(numbers)
    Traceback (most recent call last):
    ...
    ValueError: Key conflict in inverted mapping
    c              3  *   K   | ]  \  }}||f  y wr   r>   )rO   kvs      r   rR   zinvert_map.<locals>.<genexpr>1  s     .$!Q1v.s   z Key conflict in inverted mapping)rS   rT   r6   
ValueError)mapress     r   
invert_mapr   !  s;      .#))+.
.Cs8s3x;<<Jr    c                      e Zd ZdZd Zy)IdentityOverrideMapz
    A dictionary that by default maps each key to itself, but otherwise
    acts like a normal dictionary.

    >>> d = IdentityOverrideMap()
    >>> d[42]
    42
    >>> d['speed'] = 'speedo'
    >>> print(d['speed'])
    speedo
    c                    |S r   r>   r,   s     r   __missing__zIdentityOverrideMap.__missing__D  s    
r    N)r:   r;   r<   r=   r   r>   r    r   r   r   7  s    
r    r   c                  R    e Zd ZdZd Zd Zej                  Zd Z	d Z
d Zd Zd Zy	)
	DictStacka  
    A stack of dictionaries that behaves as a view on those dictionaries,
    giving preference to the last.

    >>> stack = DictStack([dict(a=1, c=2), dict(b=2, a=2)])
    >>> stack['a']
    2
    >>> stack['b']
    2
    >>> stack['c']
    2
    >>> len(stack)
    3
    >>> stack.push(dict(a=3))
    >>> stack['a']
    3
    >>> stack['a'] = 4
    >>> set(stack.keys()) == set(['a', 'b', 'c'])
    True
    >>> set(stack.items()) == set([('a', 4), ('b', 2), ('c', 2)])
    True
    >>> dict(**stack) == dict(stack) == dict(a=4, c=2, b=2)
    True
    >>> d = stack.pop()
    >>> stack['a']
    2
    >>> d = stack.pop()
    >>> stack['a']
    1
    >>> stack.get('b', None)
    >>> 'c' in stack
    True
    >>> del stack['c']
    >>> dict(stack)
    {'a': 1}
    c                    t         j                  |       }t        t        t        j
                  j                  d |D                          S )Nc              3  <   K   | ]  }|j                           y wr   )r'   )rO   cs     r   rR   z%DictStack.__iter__.<locals>.<genexpr>p  s     5N1affh5Ns   )listr4   iterr   	itertoolschainfrom_iterable)r&   dictss     r   r4   zDictStack.__iter__n  s5    d#C	555N5NNOPPr    c                    t        t        t        j                  |                   D ]  }||v s||   c S  t	        |      r   )reversedr7   r   r4   r+   )r&   r-   scopes      r   r.   zDictStack.__getitem__r  sA    eDMM$$789 	"Ee|Sz!	" smr    c                V    t         j                  j                  j                  | |      S r   )collectionsabcr   r   r&   others     r   r   zDictStack.__contains__z  s    &&33D%@@r    c                <    t        t        t        |                   S r   )r6   r   r   r1   s    r   r8   zDictStack.__len__}  s    4T
#$$r    c                R    t         j                  | d      }|j                  ||      S Nr   )r   r.   r   )r&   r-   ri   lasts       r   r   zDictStack.__setitem__  s'    b)T**r    c                P    t         j                  | d      }|j                  |      S r   )r   r.   r   )r&   r-   r   s      r   r   zDictStack.__delitem__  s%    b)$$r    c                4    t        j                  | g|i |S r   )r   r   r&   rG   rH   s      r   r   zDictStack.pop  s    xx.t.v..r    N)r:   r;   r<   r=   r4   r.   r   appendpushr   r8   r   r   r   r>   r    r   r   r   H  s8    #JQ ;;DA%+%
/r    r   c                  L     e Zd ZdZ fdZ fdZd Z fdZ fdZd Z	 xZ
S )BijectiveMapa  
    A Bijective Map (two-way mapping).

    Implemented as a simple dictionary of 2x the size, mapping values back
    to keys.

    Note, this implementation may be incomplete. If there's not a test for
    your use case below, it's likely to fail, so please test and send pull
    requests or patches for additional functionality needed.


    >>> m = BijectiveMap()
    >>> m['a'] = 'b'
    >>> m == {'a': 'b', 'b': 'a'}
    True
    >>> print(m['b'])
    a

    >>> m['c'] = 'd'
    >>> len(m)
    2

    Some weird things happen if you map an item to itself or overwrite a
    single key of a pair, so it's disallowed.

    >>> m['e'] = 'e'
    Traceback (most recent call last):
    ValueError: Key cannot map to itself

    >>> m['d'] = 'e'
    Traceback (most recent call last):
    ValueError: Key/Value pairs may not overlap

    >>> m['e'] = 'd'
    Traceback (most recent call last):
    ValueError: Key/Value pairs may not overlap

    >>> print(m.pop('d'))
    c

    >>> 'c' in m
    False

    >>> m = BijectiveMap(dict(a='b'))
    >>> len(m)
    1
    >>> print(m['b'])
    a

    >>> m = BijectiveMap()
    >>> m.update(a='b')
    >>> m['b']
    'a'

    >>> del m['b']
    >>> len(m)
    0
    >>> 'a' in m
    False
    c                F    t         |            | j                  |i | y r   )rE   r)   updaterF   s      r   r)   zBijectiveMap.__init__  s!    T$V$r    c                    ||k(  rt        d      || v xr | |   |k7  xs || v xr | |   |k7  }|rt        d      t        | 	  ||       t        | 	  ||       y )NzKey cannot map to itselfzKey/Value pairs may not overlap)r   rE   r   )r&   ri   rP   overlaprI   s       r   r   zBijectiveMap.__setitem__  s    5=788DL $T
e#$} $Ut#	 	 >??D%(E4(r    c                &    | j                  |       y r   )r   )r&   ri   s     r   r   zBijectiveMap.__delitem__  s    r    c                &    t         |          dz  S )N   )rE   r8   )r&   rI   s    r   r8   zBijectiveMap.__len__  s    w A%%r    c                R    | |   }t         |   |       t        |   |g|i |S r   )rE   r   r   )r&   r-   rG   rH   mirrorrI   s        r   r   zBijectiveMap.pop  s2    cF#w{30000r    c                b    t        |i |}|j                         D ]  } | j                  |   y r   )rS   rT   r   )r&   rG   rH   r   ri   s        r   r   zBijectiveMap.update  s6    $!&!GGI 	$DDd#	$r    )r:   r;   r<   r=   r)   r   r   r8   r   r   rK   rL   s   @r   r   r     s'    ;z%)&1
$r    r   c                  X     e Zd ZdZdgZ fdZd Zd Zd Zd Z	d Z
d	 Zd
 Zd Z xZS )
FrozenDicta  
    An immutable mapping.

    >>> a = FrozenDict(a=1, b=2)
    >>> b = FrozenDict(a=1, b=2)
    >>> a == b
    True

    >>> a == dict(a=1, b=2)
    True
    >>> dict(a=1, b=2) == a
    True
    >>> 'a' in a
    True
    >>> type(hash(a)) is type(0)
    True
    >>> set(iter(a)) == {'a', 'b'}
    True
    >>> len(a)
    2
    >>> a['a'] == a.get('a') == 1
    True

    >>> a['c'] = 3
    Traceback (most recent call last):
    ...
    TypeError: 'FrozenDict' object does not support item assignment

    >>> a.update(y=3)
    Traceback (most recent call last):
    ...
    AttributeError: 'FrozenDict' object has no attribute 'update'

    Copies should compare equal

    >>> copy.copy(a) == a
    True

    Copies should be the same type

    >>> isinstance(copy.copy(a), FrozenDict)
    True

    FrozenDict supplies .copy(), even though
    collections.abc.Mapping doesn't demand it.

    >>> a.copy() == a
    True
    >>> a.copy() is not a
    True
    __datac                F    t         |   |       }t        |i ||_        |S r   )rE   __new__rS   _FrozenDict__data)rb   rG   rH   r&   rI   s       r   r  zFrozenDict.__new__'  s'    ws#D+F+r    c                    || j                   v S r   r  r,   s     r   r   zFrozenDict.__contains__-  s    dkk!!r    c                l    t        t        t        | j                  j	                                           S r   )hashr7   re   r  rT   r1   s    r   __hash__zFrozenDict.__hash__1  s$    E&!2!2!45677r    c                ,    t        | j                        S r   )r   r  r1   s    r   r4   zFrozenDict.__iter__5  s    DKK  r    c                ,    t        | j                        S r   )r6   r  r1   s    r   r8   zFrozenDict.__len__8  s    4;;r    c                     | j                   |   S r   r  r,   s     r   r.   zFrozenDict.__getitem__;  s    {{3r    c                :     | j                   j                  |i |S r   )r  ro   r   s      r   ro   zFrozenDict.get?  s    t{{///r    c                p    t        |t              r|j                  }| j                  j                  |      S r   )r   r   r  __eq__r   s     r   r  zFrozenDict.__eq__C  s*    eZ(LLE{{!!%((r    c                ,    t        j                   |       S )zReturn a shallow copy of self)copyr1   s    r   r  zFrozenDict.copyH  s    yyr    )r:   r;   r<   r=   	__slots__r  r   r	  r4   r8   r.   ro   r  r  rK   rL   s   @r   r   r     s?    2h 
I"8!  0)
r    r   c                  D     e Zd ZdZd fd	Zed        Zed        Z xZS )Enumerationa  
    A convenient way to provide enumerated values

    >>> e = Enumeration('a b c')
    >>> e['a']
    0

    >>> e.a
    0

    >>> e[1]
    'b'

    >>> set(e.names) == set('abc')
    True

    >>> set(e.codes) == set(range(3))
    True

    >>> e.get('d') is None
    True

    Codes need not start with 0

    >>> e = Enumeration('a b c', range(1, 4))
    >>> e['a']
    1

    >>> e[3]
    'c'
    c                    t        |t              r|j                         }|t        j                         }t
        |   t        ||             y r   )r   strsplitr   countrE   r)   zip)r&   namescodesrI   s      r   r)   zEnumeration.__init__n  s=    eS!KKME=OO%EUE*+r    c                    d | D        S )Nc              3  B   K   | ]  }t        |t              s|  y wr   )r   r  )rO   r-   s     r   rR   z$Enumeration.names.<locals>.<genexpr>w  s     <z#s';<s   r>   r1   s    r   r  zEnumeration.namesu  s    <t<<r    c                .      fd j                   D        S )Nc              3  (   K   | ]	  }|     y wr   r>   )rO   r   r&   s     r   rR   z$Enumeration.codes.<locals>.<genexpr>{  s     2tT
2s   )r  r1   s   `r   r  zEnumeration.codesy  s    2tzz22r    r   )	r:   r;   r<   r=   r)   propertyr  r  rK   rL   s   @r   r  r  M  s6    @, = = 3 3r    r  c                      e Zd ZdZd Zy)
Everythinga  
    A collection "containing" every possible thing.

    >>> 'foo' in Everything()
    True

    >>> import random
    >>> random.randint(1, 999) in Everything()
    True

    >>> random.choice([None, 'foo', 42, ('a', 'b', 'c')]) in Everything()
    True
    c                     yNTr>   r   s     r   r   zEverything.__contains__      r    N)r:   r;   r<   r=   r   r>   r    r   r"  r"  ~  s    r    r"  c                  "     e Zd ZdZ fdZ xZS )InstrumentedDictaD  
    Instrument an existing dictionary with additional
    functionality, but always reference and mutate
    the original dictionary.

    >>> orig = {'a': 1, 'b': 2}
    >>> inst = InstrumentedDict(orig)
    >>> inst['a']
    1
    >>> inst['c'] = 3
    >>> orig['c']
    3
    >>> inst.keys() == orig.keys()
    True
    c                0    t         |           || _        y r   )rE   r)   data)r&   r)  rI   s     r   r)   zInstrumentedDict.__init__  s    	r    rJ   rL   s   @r   r'  r'    s      r    r'  c                  $    e Zd ZdZd ZeZd ZeZy)Leasta  
    A value that is always lesser than any other

    >>> least = Least()
    >>> 3 < least
    False
    >>> 3 > least
    True
    >>> least < 3
    True
    >>> least <= 3
    True
    >>> least > 3
    False
    >>> 'x' > least
    True
    >>> None > least
    True
    c                     yr$  r>   r   s     r   __le__zLeast.__le__  r%  r    c                     yNFr>   r   s     r   __ge__zLeast.__ge__      r    N)r:   r;   r<   r=   r-  __lt__r0  __gt__r>   r    r   r+  r+        ( F Fr    r+  c                  $    e Zd ZdZd ZeZd ZeZy)Greatesta2  
    A value that is always greater than any other

    >>> greatest = Greatest()
    >>> 3 < greatest
    True
    >>> 3 > greatest
    False
    >>> greatest < 3
    False
    >>> greatest > 3
    True
    >>> greatest >= 3
    True
    >>> 'x' > greatest
    False
    >>> None > greatest
    False
    c                     yr$  r>   r   s     r   r0  zGreatest.__ge__  r%  r    c                     yr/  r>   r   s     r   r-  zGreatest.__le__  r1  r    N)r:   r;   r<   r=   r0  r3  r-  r2  r>   r    r   r6  r6    r4  r    r6  c                    | dd g c}| dd |S )z
    Clear items in place and return a copy of items.

    >>> items = [1, 2, 3]
    >>> popped = pop_all(items)
    >>> popped is items
    False
    >>> popped
    [1, 2, 3]
    >>> items
    []
    Nr>   )rT   rk   s     r   pop_allr:    s     QxFE!HMr    c                  (     e Zd ZdZ fdZd Z xZS )FreezableDefaultDicta!  
    Often it is desirable to prevent the mutation of
    a default dict after its initial construction, such
    as to prevent mutation during iteration.

    >>> dd = FreezableDefaultDict(list)
    >>> dd[0].append('1')
    >>> dd.freeze()
    >>> dd[1]
    []
    >>> len(dd)
    1
    c                :     t        | dt        |         |      S )N_frozen)r   rE   r   r   s     r   r   z FreezableDefaultDict.__missing__  s    <wtY(;<SAAr    c                      fd _         y )Nc                $    j                         S r   )default_factory)r-   r&   s    r   rD   z-FreezableDefaultDict.freeze.<locals>.<lambda>  s    4#7#7#9 r    )r>  r1   s   `r   freezezFreezableDefaultDict.freeze
  s
    9r    )r:   r;   r<   r=   r   rB  rK   rL   s   @r   r<  r<    s    B:r    r<  c                      e Zd ZddZd Zy)Accumulatorc                    || _         y r   r   )r&   initials     r   r)   zAccumulator.__init__  s	    r    c                D    | xj                   |z  c_         | j                   S r   rF  )r&   r   s     r   __call__zAccumulator.__call__  s    Cxxr    N)r   )r:   r;   r<   r)   rI  r>   r    r   rD  rD    s    r    rD  c                  (     e Zd ZdZ fdZd Z xZS )WeightedLookupa  
    Given parameters suitable for a dict representing keys
    and a weighted proportion, return a RangeMap representing
    spans of values proportial to the weights:

    >>> even = WeightedLookup(a=1, b=1)

    [0, 1) -> a
    [1, 2) -> b

    >>> lk = WeightedLookup(a=1, b=2)

    [0, 1) -> a
    [1, 3) -> b

    >>> lk[.5]
    'a'
    >>> lk[1.5]
    'b'

    Adds ``.random()`` to select a random weighted value:

    >>> lk.random() in ['a', 'b']
    True

    >>> choices = [lk.random() for x in range(1000)]

    Statistically speaking, choices should be .5 a:b
    >>> ratio = choices.count('a') / choices.count('b')
    >>> .4 < ratio < .6
    True
    c                    t        |i |}t        t               |j                               }t        |   t        ||j                               t        j                         y )N)r]   )
rS   r   rD  valuesrE   r)   r  r'   r`   lt)r&   rG   rH   rawindexesrI   s        r   r)   zWeightedLookup.__init__9  sK    D#F# kmSZZ\2Wchhj1Tr    c                `    | j                         \  }}t        j                         |z  }| |   S r   )r~   random)r&   lowerupperselectors       r   rR  zWeightedLookup.random@  s+    {{}u==?U*H~r    )r:   r;   r<   r=   r)   rR  rK   rL   s   @r   rK  rK    s    BUr    rK  )r   r9   r   r	   )B
__future__r   collections.abcr   r  ru   r   r`   rR  r   r   r   r   typingr   r   r	   r
   r   r   r   jaraco.textr   	_operatorr   	_typeshedr   typing_extensionsr   r   r   r   r   r9   r   r   r"   r@   rV   rX   r   r   rS   r   r   r   r   r   r   r   MutableMappingr   r   Hashabler   r  r"  UserDictr'  r+  r6  r:  defaultdictr<  rD  rK  r>   r    r   <module>ra     s   "       	 8 8 O O O -0&-/BCK -(KT]en8Y"**<=
>1(( >1BB: B MWtK$% Wt #E ?.6)$ 6)rM+- M+`* *&C CL,$ "B/koo44 B/J`$4 `$FZ((+//*B*B Zz.3#\ .3b &{++ , @ @":;22 :, ,X ,r    