관리-도구
편집 파일: more.cpython-37.pyc
B ��Re�� � S @ sj d dl Z d dlmZmZmZmZ d dlmZ d dlm Z d dl mZmZm Z d dlmZmZmZmZ d dlmZmZmZmZmZmZmZmZmZmZmZmZ d dl m!Z!m"Z"m#Z#m$Z$ d d l%m&Z&m'Z' d d l(m(Z(m)Z)m*Z* d dl+m,Z,m-Z-m.Z.m/Z/m0Z0 d dl1m2Z2m3Z3 d d l4m5Z5 ddl6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z< ddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbgSZ=e>� Z?d�ddd�Z@e?fded&�ZAe?fdfd0�ZBe?fdgd6�ZCG dhd?� d?�ZDdid� ZEdjd� ZFdkd(� ZGdld-� ZHdmdY� ZId�dnd:�ZJd�dod!�ZKd�dpd+�ZLdqdV� ZMd�drdX�ZNdsdS� ZOd�dtdT�ZPG dud� d�ZQd�dvdP�ZRdwd*� ZSdxd)� ZTd�dyd�ZUd�dzdH�ZVd�d{dI�ZWd�d}dK�ZXd�d~dM�ZYd�ddL�ZZd�d�dN�Z[d�dO� Z\d�d�d<�Z]d�d�d@�Z^d�d"� Z_d�d�dQ�Z`G d�dZ� dZea�Zbd�d�� Zcd�d[� Zddcdd��d�d\�Zed�d�dJ�Zfd�dW� Zgd�d#� Zheiejffd�d�Zkd�d�d�Zld�d�d'�ZmG d�d9� d9ejejn�Zod�d�d�Zpd�d� Zqerdfd�d1�Zsd�d2� Ztd�dC� Zud�dR� ZvG d�d,� d,�Zwd�d�� Zxd�d� Zyd�d�� fd�d�Zze.fdd��d�d�Z{G d�dG� dGe�Z|G d�dF� dF�Z}G d�dD� dD�Z~erfd�d$�Zd�d� Z�d�d�d3�Z�d�d�d5�Z�erdfd�dB�Z�d�d�dA�Z�d�d=� Z�d�d�d>�Z�G d�dU� dU�Z�d�d�d;�Z�d�d.� Z�d�d � Z�d�d%� Z�d�d4� Z�d�d�� Z�d�d�� Z�d�d�dE�Z�d�d�d/�Z�G d�d� de��Z�G d�d� d�Z�d�d]� Z�d�d�d^�Z�d�d8� Z�d�d7� Z�d�d_� Z�d�d`� Z�d�da� Z�d�db� Z�G d�d� d�Z�dS )�� N)�Counter�defaultdict�deque�abc)�Sequence)�ThreadPoolExecutor)�partial�reduce�wraps)�merge�heapify�heapreplace�heappop)�chain�compress�count�cycle� dropwhile�groupby�islice�repeat�starmap� takewhile�tee�zip_longest)�exp� factorial�floor�log)�Empty�Queue)�random� randrange�uniform)� itemgetter�mul�sub�gt�lt)� hexversion�maxsize)� monotonic� )�consume�flatten�pairwise�powerset�take�unique_everseen�AbortThread�adjacent�always_iterable�always_reversible�bucket� callback_iter�chunked�circular_shifts�collapse�collate�consecutive_groups�consumer� countable�count_cycle� mark_ends� difference�distinct_combinations�distinct_permutations� distribute�divide� exactly_n� filter_except�first�groupby_transform�ilen�interleave_longest� interleave�intersperse�islice_extended�iterate�ichunked� is_sorted�last�locate�lstrip�make_decorator� map_except� map_reduce�nth_or_last�nth_permutation�nth_product� numeric_range�one�only�padded� partitions�set_partitions�peekable�repeat_last�replace�rlocate�rstrip� run_length�sample�seekable�SequenceView�side_effect�sliced� sort_together�split_at�split_after�split_before� split_when� split_into�spy�stagger�strip� substrings�substrings_indexes�time_limited�unique_to_each�unzip�windowed� with_iter�UnequalIterablesError� zip_equal� zip_offset�windowed_complete� all_unique�value_chain� product_index�combination_index�permutation_indexFc s: t tt�t | ��g �� |r2� �fdd�}t |� �S � S dS )aJ Break *iterable* into lists of length *n*: >>> list(chunked([1, 2, 3, 4, 5, 6], 3)) [[1, 2, 3], [4, 5, 6]] By the default, the last yielded list will have fewer than *n* elements if the length of *iterable* is not divisible by *n*: >>> list(chunked([1, 2, 3, 4, 5, 6, 7, 8], 3)) [[1, 2, 3], [4, 5, 6], [7, 8]] To use a fill-in value instead, see the :func:`grouper` recipe. If the length of *iterable* is not divisible by *n* and *strict* is ``True``, then ``ValueError`` will be raised before the last list is yielded. c 3 s, x&� D ]} t | ��krtd��| V qW d S )Nziterable is not divisible by n.)�len� ValueError)�chunk)�iterator�n� ��/builddir/build/BUILDROOT/alt-python37-setuptools-58.3.0-4.el8.x86_64/opt/alt/python37/lib/python3.7/site-packages/setuptools/_vendor/more_itertools/more.py�ret� s zchunked.<locals>.retN)�iterr r1 )�iterabler� �strictr� r� )r� r� r� r9 s c C sF yt t| ��S tk r@ } z|tkr0td�|�|S d}~X Y nX dS )a� Return the first item of *iterable*, or *default* if *iterable* is empty. >>> first([0, 1, 2, 3]) 0 >>> first([], 'some default') 'some default' If *default* is not provided and there are no items in the iterable, raise ``ValueError``. :func:`first` is useful when you have a generator of expensive-to-retrieve values and want any arbitrary one. It is marginally shorter than ``next(iter(iterable), default)``. zKfirst() was called on an empty iterable, and no default value was provided.N)�nextr� � StopIteration�_markerr� )r� �default�er� r� r� rI � s c C st yDt | t�r| d S t| d�r2tdkr2tt| ��S t| dd�d S W n* ttt fk rn |t krjtd��|S X dS )a Return the last item of *iterable*, or *default* if *iterable* is empty. >>> last([0, 1, 2, 3]) 3 >>> last([], 'some default') 'some default' If *default* is not provided and there are no items in the iterable, raise ``ValueError``. ����__reversed__i� r, )�maxlenzDlast() was called on an empty iterable, and no default was provided.N)� isinstancer �hasattrr) r� �reversedr � IndexError� TypeErrorr� r� r� )r� r� r� r� r� rS � s c C s t t| |d �|d�S )ag Return the nth or the last item of *iterable*, or *default* if *iterable* is empty. >>> nth_or_last([0, 1, 2, 3], 2) 2 >>> nth_or_last([0, 1], 2) 1 >>> nth_or_last([], 0, 'some default') 'some default' If *default* is not provided and there are no items in the iterable, raise ``ValueError``. r, )r� )rS r )r� r� r� r� r� r� rY � s c @ sT e Zd ZdZdd� Zdd� Zdd� Zefdd �Zd d� Z dd � Z dd� Zdd� ZdS )rb a Wrap an iterator to allow lookahead and prepending elements. Call :meth:`peek` on the result to get the value that will be returned by :func:`next`. This won't advance the iterator: >>> p = peekable(['a', 'b']) >>> p.peek() 'a' >>> next(p) 'a' Pass :meth:`peek` a default value to return that instead of raising ``StopIteration`` when the iterator is exhausted. >>> p = peekable([]) >>> p.peek('hi') 'hi' peekables also offer a :meth:`prepend` method, which "inserts" items at the head of the iterable: >>> p = peekable([1, 2, 3]) >>> p.prepend(10, 11, 12) >>> next(p) 10 >>> p.peek() 11 >>> list(p) [11, 12, 1, 2, 3] peekables can be indexed. Index 0 is the item that will be returned by :func:`next`, index 1 is the item after that, and so on: The values up to the given index will be cached. >>> p = peekable(['a', 'b', 'c', 'd']) >>> p[0] 'a' >>> p[1] 'b' >>> next(p) 'a' Negative indexes are supported, but be aware that they will cache the remaining items in the source iterator, which may require significant storage. To check whether a peekable is exhausted, check its truth value: >>> p = peekable(['a', 'b']) >>> if p: # peekable has items ... list(p) ['a', 'b'] >>> if not p: # peekable is exhausted ... list(p) [] c C s t |�| _t� | _d S )N)r� �_itr �_cache)�selfr� r� r� r� �__init__% s zpeekable.__init__c C s | S )Nr� )r� r� r� r� �__iter__) s zpeekable.__iter__c C s&