| Server IP : 198.38.94.13 / Your IP : 216.73.217.33 Web Server : Apache System : Linux d4744.dxb1.stableserver.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64 User : revivere ( 1140) PHP Version : 8.2.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /opt/saltstack/salt/lib/python3.10/site-packages/more_itertools/__pycache__/ |
Upload File : |
o
;j�� � @ sH d Z ddlZddlmZmZ ddlmZ ddlmZ ddl m
Z
ddlmZm
Z
ddlmZmZ dd lmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z" dd
l#m$Z$m%Z%m&Z&m'Z' ddl(m)Z)m*Z*m+Z,m-Z-m.Z.m/Z/ ddlm0Z0m1Z1m2Z2m3Z3 dd
l4m5Z5 g d�Z6e7� Z8z
ddlm9Z9m:Z: W n e;y� dZ<Y nw dZ<dd� Z=d�dd�Z>dd� Z?d�dd�Z@d�dd�ZAd�dd�ZBeCfdd�ZDd d!� ZEeEZFd"d#� ZGd$d%� ZHzdd&l#mIZJ W n e;y� eHZJY nw d'd(� ZKd�d)d*�ZLd+d,� Zd�d.d/�ZMd0d1� ZNd2d3� ZOd4d5� ZPd�d6d7�ZQd�d8d9�ZRd�d:d;�ZSd�d<d=�ZTd�d>d?�ZUd@dA�dBdC�ZVd�dDdE�ZWdFdG� ZXdHdI� ZYdJdK� ZZdLdM� Z[dNdO� Z\dPdQ� Z]dRdS� Z^dTdU� Z_dVdW� Z`dXdY� ZadZd[� Zbd\d]� Zcd�d^d_�Zdd`da� Zeddb�dcdd�Zfe5dek�rddflmgZh ddb�dgdh�Zgefj eg_ nefZgdidj� Ziejekffdkdl�Zldmdn� Zmdodp� Zndqdr� Zodsdt� Zpeqeedu��Zrdvdw� Zsdxdy� Ztdzd{� Zud|d}� Zvd~d� Zwg d��Zxed�d�� �Zyd�d�� Zze�{� j0Z|d�d�� Z}d�d�� Z~d�d�� Zd�d�� Z�d�d�� Z�d�d�� Z�dd��d�d��Z�d�d�� Z�dd��d�d��Z�d�d�� Z�dd��d�d��Z�d�d�� Z�dd��d�d��Z�e
ddd��G d�d�� d���Z�dd��d�d��Z�d�d�� Z�dS )�a Imported from the recipes section of the itertools documentation.
All functions taken from the recipes section of the itertools library docs
[1]_.
Some backward-compatible usability improvements have been made.
.. [1] http://docs.python.org/library/itertools.html#recipes
� N)�bisect_left�insort)�deque��suppress)� dataclass)� lru_cache�reduce)�heappush�heappushpop)�
accumulate�chain�combinations�compress�count�cycle�filterfalse�groupby�islice�pairwise�product�repeat�starmap� takewhile�tee�zip_longest)�prod�comb�isqrt�gcd)�mul�getitem�index�is_�
itemgetter�truediv)� randrange�sample�choice�shuffle)�
hexversion)8�Stats� all_equal�batched�before_and_after�consume�convolve�
dotproduct�
first_true�factor�flatten�grouper�is_prime�iter_except�
iter_index�loops�matmul�multinomial�ncycles�nth�nth_combination�padnone�pad_noner � partition�polynomial_eval�polynomial_from_roots�polynomial_derivative�powerset�prepend�quantify�reshape�#random_combination_with_replacement�random_combination�random_derangement�random_permutation�random_product�
repeatfunc�
roundrobin�running_max�running_mean�running_median�running_min�running_statistics�sieve�sliding_window� subslices�sum_of_squares�tabulate�tail�take�totient� transpose�
triplewise�unique�unique_everseen�unique_justseen)�heappush_max�heappushpop_maxFTc C � t t|| ��S )z�Return first *n* items of the *iterable* as a list.
>>> take(3, range(10))
[0, 1, 2]
If there are fewer than *n* items in the iterable, all of them are
returned.
>>> take(10, range(3))
[0, 1, 2]
)�listr )�n�iterable� rh �J/opt/saltstack/salt/lib/python3.10/site-packages/more_itertools/recipes.pyr[ q s
r[ c C s t | t|��S )a� Return an iterator over the results of ``func(start)``,
``func(start + 1)``, ``func(start + 2)``...
*func* should be a function that accepts one integer argument.
If *start* is not specified it defaults to 0. It will be incremented each
time the iterator is advanced.
>>> square = lambda x: x ** 2
>>> iterator = tabulate(square, -3)
>>> take(4, iterator)
[9, 4, 1, 0]
)�mapr )�function�startrh rh ri rY � s rY c C sF zt |�}W n ty tt|| d�� Y S w t|td|| �d�S )z�Return an iterator over the last *n* items of *iterable*.
>>> t = tail(3, 'ABCDEFG')
>>> list(t)
['E', 'F', 'G']
��maxlenr N)�len� TypeError�iterr r �max)rf rg �sizerh rh ri rZ � s �rZ c C s. |du rt | dd� dS tt| ||�d� dS )aX Advance *iterable* by *n* steps. If *n* is ``None``, consume it
entirely.
Efficiently exhausts an iterator without returning values. Defaults to
consuming the whole iterator, but an optional second argument may be
provided to limit consumption.
>>> i = (x for x in range(10))
>>> next(i)
0
>>> consume(i, 3)
>>> next(i)
4
>>> consume(i)
>>> next(i)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
StopIteration
If the iterator has fewer items remaining than the provided limit, the
whole iterator will be consumed.
>>> i = (x for x in range(3))
>>> consume(i, 5)
>>> next(i)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
StopIteration
Nr rm )r �nextr )�iteratorrf rh rh ri r/ � s r/ c C s t t| |d�|�S )z�Returns the nth item or a default value.
>>> l = range(10)
>>> nth(l, 3)
3
>>> nth(l, 20, "zebra")
'zebra'
N)rt r )rg rf �defaultrh rh ri r= � s
r= c C s, t | |�}|D ]}|D ]} dS dS dS )a�
Returns ``True`` if all the elements are equal to each other.
>>> all_equal('aaaa')
True
>>> all_equal('aaab')
False
A function that accepts a single argument and returns a transformed version
of each input item can be specified with *key*:
>>> all_equal('AaaA', key=str.casefold)
True
>>> all_equal([1, 2, 3], key=lambda x: x < 10)
True
FT)r )rg �keyru �first�secondrh rh ri r, � s
r, c C rd )zcReturn the how many times the predicate is true.
>>> quantify([True, False, True])
2
)�sumrj )rg �predrh rh ri rG � s rG c C s t | td��S )a Returns the sequence of elements and then returns ``None`` indefinitely.
>>> take(5, pad_none(range(3)))
[0, 1, 2, None, None]
Useful for emulating the behavior of the built-in :func:`map` function.
See also :func:`padded`.
N)r
r �rg rh rh ri r@ � s r@ c C s t �tt| �|��S )zvReturns the sequence elements *n* times
>>> list(ncycles(["a", "b"], 3))
['a', 'b', 'a', 'b', 'a', 'b']
)r
�
from_iterabler �tuple�rg rf rh rh ri r<