File: //opt/saltstack/salt/lib/python3.10/site-packages/cherrypy/lib/__pycache__/__init__.cpython-310.pyc
o
�N�g�
� @ s: d Z dd� Zdd� ZG dd� de�Zd
dd �Zd
d� ZdS )zCherryPy Library.c C s4 ddl m} t| |�r
dS t| d�sdS t| �| u S )z�Detect if the object provided implements the iterator protocol.
(i.e. like a generator).
This will return False for objects which are iterable,
but not iterators themselves.
� )�
GeneratorTypeT�__iter__F)�typesr �
isinstance�hasattr�iter)�objr � r �I/opt/saltstack/salt/lib/python3.10/site-packages/cherrypy/lib/__init__.py�is_iterator s
r c C sb t | �sdS ddl}|�| �rdS t| d�rt| j�sdS z |�| j� W dS ty0 Y dS w )z9Detect if the given object is both closable and iterator.Fr NT�close)r �inspectZisgeneratorr �callabler Zgetcallargs� TypeError)r r
r r r
�is_closable_iterator s
��r c @ s6 e Zd ZdZddd�Zdd� Zdd� ZeZd d
� ZdS )
�file_generatorzOYield the given input (a file object) in chunks (default 64k).
(Core)
� c C s || _ || _dS )zAInitialize file_generator with file ``input`` for chunked access.N)�input� chunkSize)�selfr r r r r
�__init__5 s
zfile_generator.__init__c C s | S )zReturn iterator.r �r r r r
r : s zfile_generator.__iter__c C s2 | j �| j�}|r|S t| j d�r| j �� t� �)zReturn next chunk of file.r )r �readr r r �
StopIteration)r �chunkr r r
�__next__>