HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/libcloud/utils/__pycache__/files.cpython-310.pyc
o

;j��	@svddlZddlZddlmZddlmZmZdZgd�Zddd�Z	d	e
d
edee
de
ffdd
�Zdd�Z
dd�ZdS)�N)�	Generator)�b�nexti�)�read_in_chunks�exhaust_iterator�guess_file_mime_typeFc	cs�|pt}z|j}|f}Wntyt}|f}Ynwtd�}d}|r*t|�dkr�|sMzt||��}t|�dkr>||7}nd}WntyLd}Ynwt|�dkr^|r\|r\td�VdS|ryt||d�EdH}|rx|d|�V||d�}n|Vtd�}|r*t|�dks*dSdS)a:
    Return a generator which yields data in chunks.

    :param iterator: An object which implements an iterator interface
                     or a File like object with read method.
    :type iterator: :class:`object` which implements iterator interface.

    :param chunk_size: Optional chunk size (defaults to CHUNK_SIZE)
    :type chunk_size: ``int``

    :param fill_size: If True, make sure chunks are exactly chunk_size in
                      length (except for last chunk).
    :type fill_size: ``bool``

    :param yield_empty: If true and iterator returned no data, only yield empty
                        bytes object
    :type yield_empty: ``bool``

    TODO: At some point in the future we could use byte arrays here if version
    >= Python 3. This should speed things up a bit and reduce memory usage.
    �FrTN)�data�
chunk_size)�
CHUNK_SIZE�read�AttributeErrorrr�len�
StopIteration�_optimized_chunked_generator)	�iteratorr
Z	fill_sizeZyield_empty�get_data�argsr	�empty�chunk�r�H/opt/saltstack/salt/lib/python3.10/site-packages/libcloud/utils/files.pyrsF�

�
��
��rr	r
�returnccsP�d}||t|�kr ||||�V||7}||t|�ks||d�}|S)Nr)r)r	r
Zchunk_startrrrrYs��rcCs�td�}ztt|��}Wn
tytd�}Ynwt|�dkr@||7}ztt|��}Wn
ty9td�}Ynwt|�dks |S)aM
    Exhaust an iterator and return all data returned by it.

    :type iterator: :class:`object` which implements iterator interface.
    :param iterator: An object which implements an iterator interface
                     or a File like object with read method.

    :rtype ``str``
    :return Data returned by the iterator.
    rr)rrrr)rr	rrrrres���rcCs"tj�|�}t�|�\}}||fS)N)�os�path�basename�	mimetypesZ
guess_type)Z	file_path�filenameZmimetype�encodingrrrr�sr)NFF)rr�typingrZlibcloud.utils.py3rrr�__all__r�bytes�intrrrrrrr�<module>s
 >