File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/setuptools/_vendor/more_itertools/__pycache__/recipes.cpython-310.pyc
Back
o ;jS� � @ sN d Z ddlZddlmZmZ ddlmZ ddlmZ ddl m Z mZmZ ddl mZmZ ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZ dd lm Z m!Z!m"Z"m#Z# dd l$m%Z%m&Z&m'Z'm(Z(m)Z) ddlm*Z*m+Z+m,Z, ddl-m.Z. g d �Z/e0� Z1ze2dd� W n e3y� e2Z4Y nw ee2dd�Z4zddlm5Z6 W n e7y� dd� Z6Y nw z ddl m8Z8m9Z9 W n e7y� dZ:Y nw dZ:dd� Z;d�dd�Z<dd� Z=d�dd�Z>d�dd�Z?d�dd �Z@eAfd!d"�ZBd#d$� ZCeCZDd%d&� ZEd'd(� ZFd)d*� ZGd�d+d,�ZHd-d.� ZIzdd/lmJZK W n e7�y eIZJY n w d0d1� ZJeIj eJ_ G d2d3� d3eL�ZMd4d5� ZNd6d7� ZOd�d9d:�ZPd;d<� ZQd=d>� ZRd?d@� ZSd�dAdB�ZTd�dCdD�ZUd�dEdF�ZVd�dGdH�ZWd�dIdJ�ZXdKdL�dMdN�ZYd�dOdP�ZZdQdR� Z[dSdT� Z\dUdV� Z]dWdX� Z^dYdZ� Z_d[d\� Z`d]d^� Zad_d`� Zbdadb� Zcdcdd� Zddedf� Zedgdh� Zfd�didj�Zgdkdl� Zhdd�dmdn�Zie.dok�r�ddplmjZk dd�dqdr�Zjeij ej_ neiZjdsdt� Zlemenffdudv�Zodwdx� Zpdydz� Zqd{d|� Zrd}d~� Zsetehd��Zud�d�� Zvd�d�� Zwd�d�� Zxd�d�� Zyd�d�� Zzg d��Z{e d�d�� �Z|d�d�� Z}e�~� j*Zd�d�� Z�d�d�� Z�d�d�� Z�d�d�� Z�d�d�� Z�d�d�� Z�dd��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)� lru_cache�partial�reduce)�heappush�heappushpop)� accumulate�chain�combinations�compress�count�cycle�groupby�islice�product�repeat�starmap� takewhile�tee�zip_longest)�prod�comb�isqrt�gcd)�mul�not_� itemgetter�getitem�index)� randrange�sample�choice)� hexversion)2� 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_none�pairwise� partition�polynomial_eval�polynomial_from_roots�polynomial_derivative�powerset�prepend�quantify�reshape�#random_combination_with_replacement�random_combination�random_permutation�random_product� repeatfunc� roundrobin�running_median�sieve�sliding_window� subslices�sum_of_squares�tabulate�tail�take�totient� transpose� triplewise�unique�unique_everseen�unique_justseenT��strict)�sumprodc C s t | |�S �N)r, )�x�y� r_ �]/opt/saltstack/salt/lib/python3.10/site-packages/setuptools/_vendor/more_itertools/recipes.py�<lambda>l s ra )�heappush_max�heappushpop_maxFc 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�iterabler_ r_ r` rR x s rR 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�startr_ r_ r` rP � s rP 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 �sizer_ r_ r` rQ � s �rQ 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 rk )r �nextr )�iteratorrf r_ r_ r` 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)rr r )rg rf �defaultr_ r_ r` r8 � s r8 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 �keyrs �first�secondr_ r_ r` r'