File: //usr/lib/python3/dist-packages/sphinx/ext/napoleon/__pycache__/iterators.cpython-310.pyc
o
�$�a� � @ sB d Z ddlZddlmZmZmZ G dd� d�ZG dd� de�ZdS )z�
sphinx.ext.napoleon.iterators
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A collection of helpful iterators.
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
� N)�Any�Iterable�Optionalc @ s� e Zd ZdZdeddfdd�Zddd�Zdd edefd
d�Zd e e ddfdd
�Z
defdd�Zdd edefdd�Z
dd e e defdd�ZdS )� peek_iteral An iterator object that supports peeking ahead.
Parameters
----------
o : iterable or callable
`o` is interpreted very differently depending on the presence of
`sentinel`.
If `sentinel` is not given, then `o` must be a collection object
which supports either the iteration protocol or the sequence protocol.
If `sentinel` is given, then `o` must be a callable object.
sentinel : any value, optional
If given, the iterator will call `o` with no arguments for each
call to its `next` method; if the value returned is equal to
`sentinel`, :exc:`StopIteration` will be raised, otherwise the
value will be returned.
See Also
--------
`peek_iter` can operate as a drop in replacement for the built-in
`iter <https://docs.python.org/3/library/functions.html#iter>`_ function.
Attributes
----------
sentinel
The value used to indicate the iterator is exhausted. If `sentinel`
was not given when the `peek_iter` was instantiated, then it will
be set to a new object instance: ``object()``.
�args�returnNc G s: t |� | _t�� | _t|�dkr|d | _dS t� | _dS )z__init__(o, sentinel=None)� � N)�iter� _iterable�collections�deque�_cache�len�sentinel�object)�selfr � r �?/usr/lib/python3/dist-packages/sphinx/ext/napoleon/iterators.py�__init__2 s
zpeek_iter.__init__c C � | S �Nr �r r r r �__iter__; s zpeek_iter.__iter__�nc C s
| � |�S r )�next�r r r r r �__next__>