
    h                     N    S SK JrJr  S SKJr  SS jr\\44S jr " S S5      r	g)	    )defaultdictdeque)filterfalseNc              #      #    [        5       nUR                  nUc*  [        UR                  U 5       H  nU" U5        Uv   M     gU  H  nU" U5      nXR;  d  M  U" U5        Uv   M      g7f)zHList unique elements, preserving order. Remember all elements ever seen.N)setaddr   __contains__)iterablekeyseenseen_addelementks         U/var/www/auris/envauris/lib/python3.13/site-packages/importlib_metadata/_itertools.pyunique_everseenr      sg      5DxxH
{"4#4#4h?GWM @  GGA}	  s   AA+A+c                     U c  [        S5      $ Ub  [        X5      (       a  [        U 45      $  [        U 5      $ ! [         a    [        U 45      s $ f = f)a  If *obj* is iterable, return an iterator over its items::

    >>> obj = (1, 2, 3)
    >>> list(always_iterable(obj))
    [1, 2, 3]

If *obj* is not iterable, return a one-item iterable containing *obj*::

    >>> obj = 1
    >>> list(always_iterable(obj))
    [1]

If *obj* is ``None``, return an empty iterable:

    >>> obj = None
    >>> list(always_iterable(None))
    []

By default, binary and text strings are not considered iterable::

    >>> obj = 'foo'
    >>> list(always_iterable(obj))
    ['foo']

If *base_type* is set, objects for which ``isinstance(obj, base_type)``
returns ``True`` won't be considered iterable.

    >>> obj = {'a': 1}
    >>> list(always_iterable(obj))  # Iterate over the dict's keys
    ['a']
    >>> list(always_iterable(obj, base_type=dict))  # Treat dicts as a unit
    [{'a': 1}]

Set *base_type* to ``None`` to avoid any special handling and treat objects
Python considers iterable as iterable:

    >>> obj = 'foo'
    >>> list(always_iterable(obj, base_type=None))
    ['f', 'o', 'o']
 )iter
isinstance	TypeError)obj	base_types     r   always_iterabler      sY    R {Bx:c#=#=SF|Cy SF|s   
: AAc                   :    \ rS rSrSrS
S jrS rS rS rS r	S	r
g)bucketN   ar  Wrap *iterable* and return an object that buckets the iterable into
child iterables based on a *key* function.

    >>> iterable = ['a1', 'b1', 'c1', 'a2', 'b2', 'c2', 'b3']
    >>> s = bucket(iterable, key=lambda x: x[0])  # Bucket by 1st character
    >>> sorted(list(s))  # Get the keys
    ['a', 'b', 'c']
    >>> a_iterable = s['a']
    >>> next(a_iterable)
    'a1'
    >>> next(a_iterable)
    'a2'
    >>> list(s['b'])
    ['b1', 'b2', 'b3']

The original iterable will be advanced and its items will be cached until
they are used by the child iterables. This may require significant storage.

By default, attempting to select a bucket to which no items belong  will
exhaust the iterable and cache all values.
If you specify a *validator* function, selected buckets will instead be
checked against it.

    >>> from itertools import count
    >>> it = count(1, 2)  # Infinite sequence of odd numbers
    >>> key = lambda x: x % 10  # Bucket by last digit
    >>> validator = lambda x: x in {1, 3, 5, 7, 9}  # Odd digits only
    >>> s = bucket(it, key=key, validator=validator)
    >>> 2 in s
    False
    >>> list(s[2])
    []

Nc                 z    [        U5      U l        X l        [        [        5      U l        U=(       d    S U l        g )Nc                     g)NTr   )xs    r   <lambda>!bucket.__init__.<locals>.<lambda>v   s    $    )r   _it_keyr   r   _cache
_validator)selfr
   r   	validators       r   __init__bucket.__init__r   s*    >	!%(#7r"   c                     U R                  U5      (       d  g [        X   5      nU R                  U   R                  U5        g! [         a     gf = f)NFT)r&   nextr%   
appendleftStopIteration)r'   valueitems      r   r	   bucket.__contains__x   sU    u%%	0$D KK))$/  		s   A 
AAc              #   h  #     U R                   U   (       a   U R                   U   R                  5       v   Oh  [        U R                  5      nU R                  U5      nX1:X  a  Uv   O6U R                  U5      (       a  U R                   U   R                  U5        Mg  M  ! [         a     gf = f7f)z
Helper to yield items from the parent iterator that match *value*.
Items that don't match are stored in the local cache as they
are encountered.
N)r%   popleftr,   r#   r.   r$   r&   append)r'   r/   r0   
item_values       r   _get_valuesbucket._get_values   s       {{5!kk%(0022 #DHH~ "&4J!*"
44J/66t<   ) s)   7B2B" AB2"
B/,B2.B//B2c              #     #    U R                    HJ  nU R                  U5      nU R                  U5      (       d  M,  U R                  U   R	                  U5        ML     U R                  R                  5        S h  vN   g  N7fN)r#   r$   r&   r%   r4   keys)r'   r0   r5   s      r   __iter__bucket.__iter__   s^     HHD4Jz**J'..t4 
 ;;##%%%s   5B?B:B ;Bc                 f    U R                  U5      (       d  [        S5      $ U R                  U5      $ )Nr   )r&   r   r6   )r'   r/   s     r   __getitem__bucket.__getitem__   s+    u%%8O&&r"   )r%   r#   r$   r&   r9   )__name__
__module____qualname____firstlineno____doc__r)   r	   r6   r;   r>   __static_attributes__r   r"   r   r   r   N   s!    !F8=4&'r"   r   r9   )
collectionsr   r   	itertoolsr   r   strbytesr   r   r   r"   r   <module>rJ      s+    * !& %(< 2l]' ]'r"   