CURRENT PATH:
/
opt
/
gsutil
/
gslib
/
__pycache__
/
[ ⬅ KEMBALI ]
|
[ HOME ]
Upload File:
Upload Ke Sini
Dir Baru
File Baru
Editing:
plurality_checkable_iterator.cpython-39.pyc
a +(Wg� � @ sZ d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlZddlZG dd� dej�Z dS ) zHIterator wrapper for checking wrapped iterator's emptiness or plurality.� )�absolute_import)�print_function)�division)�unicode_literalsNc @ sJ e Zd ZdZdd� Zddd�Zdd� Zd d � Zdd� Zd d� Z dd� Z dS )�PluralityCheckableIteratora� Iterator wrapper class. Allows you to check whether the wrapped iterator is empty and whether it has more than 1 element. This iterator accepts three types of values from the iterator it wraps: 1. A yielded element (this is the normal case). 2. A raised exception, which will be buffered and re-raised when it is reached in this iterator. 3. A yielded tuple of (exception, stack trace), which will be buffered and raised with it is reached in this iterator. c C s || _ d | _g | _d| _d S )NF)� orig_iterator� base_iterator�head�underlying_iter_empty)�self�it� r �1/opt/gsutil/gslib/plurality_checkable_iterator.py�__init__0 s z#PluralityCheckableIterator.__init__� c C s� | j s�t| j�|k r�zj| js(t| j�| _t| j�}d| _ t|t�rlt|d t �rl| j� d|d |d f� n| j� d|f� W q ty� d| _ Y q t y� } z&| j� d|t� � d f� W Y d}~q d}~0 0 q t| j�S ) a Populates self.head from the underlying iterator. Args: num_elements: Populate until self.head contains this many elements (or until the underlying iterator runs out). Returns: Number of elements at self.head after execution complete. Fr � exceptionr �elementT� N)r �lenr r �iterr �next� isinstance�tuple� Exception�append� StopIteration�sys�exc_info)r �num_elements�er r r � _PopulateHead8 s 2z(PluralityCheckableIterator._PopulateHeadc C s | S �Nr �r r r r �__iter__W s z#PluralityCheckableIterator.__iter__c C sN | � � rD| j�d�}|d dkr(|d S t�|d j|d |d ��t� �d S )Nr r r r )r r �pop�six�reraise� __class__r )r Z item_tupler r r �__next__Z s z#PluralityCheckableIterator.__next__c C s | � � S r! �r r"