HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/jaraco/__pycache__/collections.cpython-310.pyc
o

�N�g�b�@s�ddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
ZGdd�dejj
�ZGdd�de�Zdd�ZGd	d
�d
e�Zdd�Zed
fdd�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Zdd�ZGdd�de�ZGdd�deejj
�ZGdd�de�ZGd d!�d!ejj
ejj�Z Gd"d#�d#ee�Z!Gd$d%�d%e�Z"Gd&d'�d'ej#�Z$Gd(d)�d)e�Z%Gd*d+�d+e�Z&d,d-�Z'Gd.d/�d/ej(�Z)Gd0d1�d1�Z*Gd2d3�d3e�Z+dS)4�N)�NonDataPropertyc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�
Projectiona@
    Project a set of keys over a mapping

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

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

    >>> sorted(list(prj.keys()))
    ['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}
    True

    Also note that Projection keeps a reference to the original dict, so
    if you modify the original dict, that could modify the Projection.

    >>> del sample['a']
    >>> dict(prj)
    {'c': 3}
    cCst|�|_||_dS�N)�tuple�_keys�_space)�self�keys�space�r�F/opt/saltstack/salt/lib/python3.10/site-packages/jaraco/collections.py�__init__2�

zProjection.__init__cC�||jvr	t|��|j|Sr)r�KeyErrorr�r�keyrrr�__getitem__6�

zProjection.__getitem__cCstt|j��|j��Sr)�iter�setr�intersectionr�rrrr�__iter__;�zProjection.__iter__cCsttt|���Sr)�lenrrrrrr�__len__>szProjection.__len__N)�__name__�
__module__�__qualname__�__doc__r
rrrrrrrr
s$rc@sjeZdZdZgdfdd�Zdd�Zee�Zedd��Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�Zdd�ZdS)�
DictFiltera�
    Takes a dict, and simulates a sub-dict based on the keys.

    >>> sample = {'a': 1, 'b': 2, 'c': 3}
    >>> filtered = DictFilter(sample, ['a', 'c'])
    >>> filtered == {'a': 1, 'c': 3}
    True
    >>> set(filtered.values()) == {1, 3}
    True
    >>> set(filtered.items()) == {('a', 1), ('c', 3)}
    True

    One can also filter by a regular expression pattern

    >>> sample['d'] = 4
    >>> sample['ef'] = 5

    Here we filter for only single-character keys

    >>> filtered = DictFilter(sample, include_pattern='.$')
    >>> filtered == {'a': 1, 'b': 2, 'c': 3, 'd': 4}
    True

    >>> filtered['e']
    Traceback (most recent call last):
    ...
    KeyError: 'e'

    Also note that DictFilter keeps a reference to the original dict, so
    if you modify the original dict, that could modify the filtered dict.

    >>> del sample['d']
    >>> del sample['a']
    >>> filtered == {'b': 2, 'c': 3}
    True
    >>> filtered != {'b': 2, 'c': 3}
    False
    NcCs4||_t|�|_|durt�|�|_dSt�|_dSr)�dictr�specified_keys�re�compile�include_pattern�pattern_keys)rr"�include_keysr&rrrr
js

zDictFilter.__init__cCst|jj|j���}t|�Sr)�filterr&�matchr"r	r)rr	rrr�get_pattern_keyssszDictFilter.get_pattern_keyscCs|j�|j�Sr)r#�unionr'rrrrr(y�zDictFilter.include_keyscCs|j�|j���Sr)r(rr"r	rrrrr	}�zDictFilter.keyscCst|jj|���Sr)�mapr"�getr	rrrr�values�r.zDictFilter.valuescCrr)r(rr")r�irrrr�rzDictFilter.__getitem__cCs |��}t|jj|�}t||�Sr)r	r/r"r0�zip)rr	r1rrr�items�s
zDictFilter.itemscCst|�|kSr�r"�r�otherrrr�__eq__��zDictFilter.__eq__cCst|�|kSrr5r6rrr�__ne__�r9zDictFilter.__ne__)rrrr r
r+rr'�propertyr(r	r1rr4r8r:rrrrr!Bs'	
r!cst�fdd�|��D��S)a1
    dict_map is much like the built-in function map.  It takes a dictionary
    and applys a function to the values of that dictionary, returning a
    new dictionary with the mapped values in the original keys.

    >>> d = dict_map(lambda x:x+1, dict(a=1, b=2))
    >>> d == dict(a=2,b=3)
    True
    c3s �|]\}}|�|�fVqdSrr)�.0r�value��functionrr�	<genexpr>�s�zdict_map.<locals>.<genexpr>)r"r4)r?Z
dictionaryrr>r�dict_map�s
rAc@sveZdZdZiejfdd�Zdd�Zddd�Zd	d
�Z	dd�Z
eed
�e
fi��ZGdd�de�Zed�Zed�ZdS)�RangeMapa.
    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. cmp [python 2 only], keys, reverse) as sort_params.

    Let's 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'

    But you'll 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'
    cCst�||�||_||_dSr)r"r
�sort_paramsr*)r�sourcerC�key_match_comparatorrrrr
�s
zRangeMap.__init__cCsbt|��fi|j��}t|tj�r|�||�}|S|�||�}t�||�}|tj	ur/t
|��|Sr)�sortedr	rC�
isinstancerB�Itemr�_find_first_match_r"�undefined_valuer)r�item�sorted_keys�resultrrrrr�s�
zRangeMap.__getitem__NcC�"z||WSty|YSw)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)rr�defaultrrrr0�s

�zRangeMap.getcCs0t�|j|�}tt||��}|r|dSt|���Nr)�	functools�partialr*�listr)r)rr	rKZis_match�matchesrrrrI�s
zRangeMap._find_first_match_cCs*t|��fi|j��}|tj|tjfSr)rFr	rCrB�
first_item�	last_item)rrLrrr�boundsszRangeMap.boundsZRangeValueUndefinedc@seZdZdZdS)z
RangeMap.Itemz
RangeMap ItemN)rrrr rrrrrH
srHr���r)rrrr �operator�ler
rr0rIrX�type�str�objectrJ�intrHrVrWrrrrrB�s?
rBcC�|Srr)�xrrr�
__identity�rbFcs�fdd�}t|��||d�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))
    cs�|d�SrQr)rK�rrr�pairkey_key%r9z!sorted_items.<locals>.pairkey_key)r�reverse)rFr4)�drrfrerrdr�sorted_itemssrhcs�eZdZdZedd��Z�fdd�Z�fdd�Z�fdd	�Z�fd
d�Z	�fdd
�Z
�fdd�Z�fdd�Z�fdd�Z
dd�Z�ZS)�KeyTransformingDictz�
    A dict subclass that transforms the keys before they're used.
    Subclasses may override the default transform_key to customize behavior.
    cCr`rrrdrrr�
transform_key1sz!KeyTransformingDict.transform_keycs8tt|���t|i|��}|��D]}|j|�qdSr)�superrir
r"r4�__setitem__)r�argsZkargsrgrK��	__class__rrr
5s
�zKeyTransformingDict.__init__cs |�|�}tt|��||�dSr)rjrkrirl)rr�valrnrrrl=s
zKeyTransformingDict.__setitem__c�|�|�}tt|��|�Sr)rjrkrirrrnrrrA�
zKeyTransformingDict.__getitem__crqr)rjrkri�__contains__rrnrrrsErrz KeyTransformingDict.__contains__crqr)rjrkri�__delitem__rrnrrrtIrrzKeyTransformingDict.__delitem__c�(|�|�}tt|�j|g|�Ri|��Sr)rjrkrir0�rrrm�kwargsrnrrr0M�
zKeyTransformingDict.getcrur)rjrkri�
setdefaultrvrnrrryQrxzKeyTransformingDict.setdefaultcrur)rjrkri�poprvrnrrrzUrxzKeyTransformingDict.popcs4zt�fdd�|��D��WStyt���w)z�
        Given a key, return the actual key stored in self that matches.
        Raise KeyError if the key isn't found.
        c3s�|]	}|�kr|VqdSrr)r<Ze_keyrdrrr@_��z7KeyTransformingDict.matching_key_for.<locals>.<genexpr>)�nextr	�
StopIterationrrrrdr�matching_key_forYs
�z$KeyTransformingDict.matching_key_for)rrrr �staticmethodrjr
rlrrsrtr0ryrzr~�
__classcell__rrrnrri+s
ric@seZdZdZedd��ZdS)�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'})).replace("u'", "'"))
    {'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'
    cCstj�|�Sr)�jaraco�textZ
FoldedCaserdrrrrj�sz!FoldedCaseKeyedDict.transform_keyN)rrrr rrjrrrrr�dsJr�c@s eZdZdZdd�Zdd�ZdS)�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
    cC�
||_dSr)r^)rZ
wrapped_obrrrr
��
zDictAdapter.__init__cCst|j|�Sr)�getattrr^)r�namerrrr�r9zDictAdapter.__getitem__N)rrrr r
rrrrrr��sr�c� eZdZdZ�fdd�Z�ZS)�ItemsAsAttributesa�
    Mix-in class to enable a mapping object to provide items as
    attributes.

    >>> C = type(str('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(
    ...     str('C'),
    ...     (dict, ItemsAsAttributes),
    ...     dict(__missing__ = missing_func),
    ... )
    >>> i = C()
    >>> i.missing
    'missing item'
    >>> i.foo
    'missing item'
    c
s�z	ttt|�|�WSty@}z+t�}dd�}||||�}||ur*|WYd}~S|j\}|�d|jjd�}|f|_�d}~ww)NcSrNrrO)ZcontrZmissing_resultrrr�
_safe_getitem�s

�z4ItemsAsAttributes.__getattr__.<locals>._safe_getitemrk�)	r�rkr��AttributeErrorr^rm�replaceror)rr�eZnovalr�rM�messagernrr�__getattr__�s��zItemsAsAttributes.__getattr__)rrrr r�r�rrrnrr��s,r�cCs2tdd�|��D��}t|�t|�kstd��|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
    css�|]	\}}||fVqdSrr)r<�k�vrrrr@r{zinvert_map.<locals>.<genexpr>z Key conflict in inverted mapping)r"r4r�
ValueError)r/�resrrr�
invert_map
sr�c@�eZdZdZdd�ZdS)�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
    cCs|Srrrrrr�__missing__0rczIdentityOverrideMap.__missing__N)rrrr r�rrrrr�#sr�c@s&eZdZdZdd�Zdd�ZejZdS)�	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
    >>> stack.push(dict(a=3))
    >>> stack['a']
    3
    >>> set(stack.keys()) == set(['a', 'b', 'c'])
    True
    >>> dict(**stack) == dict(a=3, c=2, b=2)
    True
    >>> d = stack.pop()
    >>> stack['a']
    2
    >>> d = stack.pop()
    >>> stack['a']
    1
    >>> stack.get('b', None)
    cCstttj�dd�|D����S)Ncss�|]}|��VqdSr)r	)r<�crrrr@Q��z!DictStack.keys.<locals>.<genexpr>)rTr�	itertools�chain�
from_iterablerrrrr	PszDictStack.keyscCs*t|�D]}||vr||Sqt|��r)�reversedr)rrZscoperrrrSs
�zDictStack.__getitem__N)	rrrr r	rrT�append�pushrrrrr�4s

r�csTeZdZdZ�fdd�Z�fdd�Zdd�Z�fdd	�Z�fd
d�Zdd
�Z	�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
    cs"tt|���|j|i|��dSr)rkr�r
�update�rrmrwrnrrr
�szBijectiveMap.__init__csl||krtd��||vr|||kp||vo|||k}|r"td��tt|��||�tt|��||�dS)NzKey cannot map to itselfzKey/Value pairs may not overlap)r�rkr�rl)rrKr=Zoverlaprnrrrl�s
�
�zBijectiveMap.__setitem__cCs|�|�dSr)rz)rrKrrrrt�szBijectiveMap.__delitem__cstt|���dS)N�)rkr�rrrnrrr�r.zBijectiveMap.__len__cs6||}tt|��|�tt|�j|g|�Ri|��Sr)rkr�rtrz)rrrmrwZmirrorrnrrrz�szBijectiveMap.popcOs*t|i|��}|��D]}|j|�qdSr)r"r4rl)rrmrwrgrKrrrr��s�zBijectiveMap.update)rrrr r
rlrtrrzr�r�rrrnrr�\s=r�csfeZdZdZdgZ�fdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
�ZS)�
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
    Z__datacs$tt|��|�}t|i|��|_|Sr)rkr��__new__r"�_FrozenDict__data)�clsrmrwrrnrrr��szFrozenDict.__new__cCs
||jvSr�r�rrrrrs�r�zFrozenDict.__contains__cCsttt|j�����Sr)�hashrrFr�r4rrrr�__hash__rzFrozenDict.__hash__cC�
t|j�Sr)rr�rrrrrr�zFrozenDict.__iter__cCr�r)rr�rrrrrr�zFrozenDict.__len__cCs
|j|Srr�rrrrr
r�zFrozenDict.__getitem__cOs|jj|i|��Sr)r�r0r�rrrr0r.zFrozenDict.getcCst|t�r|j}|j�|�Sr)rGr�r�r8r6rrrr8s
zFrozenDict.__eq__cCs
t�|�S)zReturn a shallow copy of self)�copyrrrrr�s
zFrozenDict.copy)rrrr �	__slots__r�rsr�rrrr0r8r�r�rrrnrr��s4r�cs:eZdZdZd	�fdd�	Zedd��Zedd��Z�ZS)
�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'
    Ncs<t|t�r	|��}|durt��}tt|��t||��dSr)	rGr]�splitr��countrkr�r
r3)r�names�codesrnrrr
=s

zEnumeration.__init__cCsdd�|D�S)Ncss�|]
}t|t�r|VqdSr)rGr])r<rrrrr@Fs�z$Enumeration.names.<locals>.<genexpr>rrrrrr�Dr-zEnumeration.namescs�fdd��jD�S)Nc3s�|]}�|VqdSrr)r<r�rrrr@Jr�z$Enumeration.codes.<locals>.<genexpr>)r�rrrrr�HszEnumeration.codesr)	rrrr r
r;r�r�r�rrrnrr�s 
r�c@r�)�
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
    cC�dS�NTrr6rrrrs\rczEverything.__contains__N)rrrr rsrrrrr�Msr�cr�)�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
    cst���||_dSr)rkr
�data)rr�rnrrr
qrzInstrumentedDict.__init__)rrrr r
r�rrrnrr�`sr�c@�(eZdZdZdd�ZeZdd�ZeZdS)�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
    cCr�r�rr6rrr�__le__�rczLeast.__le__cCr��NFrr6rrr�__ge__�rczLeast.__ge__N)rrrr r��__lt__r��__gt__rrrrr�v�r�c@r�)�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
    cCr�r�rr6rrrr��rczGreatest.__ge__cCr�r�rr6rrrr��rczGreatest.__le__N)rrrr r�r�r�r�rrrrr��r�r�cCs|dd�g}|dd�<|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)r4rMrrr�pop_all�s
r�c�(eZdZdZ�fdd�Zdd�Z�ZS)�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
    cst|dt�j�|�S)N�_frozen)r�rkr�rrnrrr��sz FreezableDefaultDict.__missing__cs�fdd��_dS)Ncs���Sr)�default_factoryrdrrr�<lambda>�sz-FreezableDefaultDict.freeze.<locals>.<lambda>)r�rrrr�freeze�r.zFreezableDefaultDict.freeze)rrrr r�r�r�rrrnrr��sr�c@seZdZddd�Zdd�ZdS)�AccumulatorrcCr�r�rp)r�initialrrrr
�r�zAccumulator.__init__cCs|j|7_|jSrr�)rrprrr�__call__�szAccumulator.__call__N)r)rrrr
r�rrrrr��s
r�cr�)�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
    cs>t|i|��}tt�|���}t�jt||���tj	d�dS)N)rE)
r"r/r�r1rkr
r3r	rZ�lt)rrmrw�rawZindexesrnrrr
	s zWeightedLookup.__init__cCs |��\}}t��|}||Sr)rX�random)r�lower�upper�selectorrrrr�szWeightedLookup.random)rrrr r
r�r�rrrnrr��s!r�),r$rZ�collections.abc�collectionsr�r�rRr�Zjaraco.classes.propertiesrZjaraco.textr��abc�Mappingrr^r!rAr"rBrbrhrir�r�r�r�r�rTr�r��Hashabler�r�r��UserDictr�r�r�r��defaultdictr�r�r�rrrr�<module>sB5R
p9PF(c]1