HEX
Server: LiteSpeed
System: Linux us-phx-web629.main-hosting.eu 5.14.0-503.23.2.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Feb 12 05:52:18 EST 2025 x86_64
User: u756937133 (756937133)
PHP: 8.2.27
Disabled: passthru,chgrp
Upload Files
File: //opt/gsutil/third_party/apitools/apitools/base/py/__pycache__/stream_slice.cpython-39.pyc
a

�z�g�
�@s$dZddlmZGdd�de�ZdS)z8Small helper class to provide a small slice of a stream.�)�
exceptionsc@sFeZdZdZdd�Zdd�Zdd�Zdd	�Zed
d��Z	dd
d�Z
dS)�StreamSlicez)Provides a slice-like object for streams.cCs||_||_||_dS�N��_StreamSlice__stream�_StreamSlice__remaining_bytes�_StreamSlice__max_bytes)�self�streamZ	max_bytes�r�A/opt/gsutil/third_party/apitools/apitools/base/py/stream_slice.py�__init__szStreamSlice.__init__cCsd|j|j|jfS)Nz0Slice of stream %s with %s/%s bytes not yet readr�r	rrr�__str__s�zStreamSlice.__str__cCs|jSr�rrrrr�__len__#szStreamSlice.__len__cCs
t|j�Sr)�boolrrrrr�__nonzero__&szStreamSlice.__nonzero__cCs|jSrrrrrr�length+szStreamSlice.lengthNcCsf|durt||j�}n|j}|j�|�}|dkrP|sPt�d|j|j|jf��|jt|�8_|S)aGRead at most size bytes from this slice.

        Compared to other streams, there is one case where we may
        unexpectedly raise an exception on read: if the underlying stream
        is exhausted (i.e. returns no bytes on read), and the size of this
        slice indicates we should still be able to read more bytes, we
        raise exceptions.StreamExhausted.

        Args:
          size: If provided, read no more than size bytes from the stream.

        Returns:
          The bytes read from this slice.

        Raises:
          exceptions.StreamExhausted

        Nrz;Not enough bytes in stream; expected %d, exhausted after %d)�minrr�readr�StreamExhaustedr�len)r	�sizeZ	read_size�datarrrr0s
���zStreamSlice.read)N)�__name__�
__module__�__qualname__�__doc__r
rrr�propertyrrrrrrrs
rN)r�apitools.base.pyr�objectrrrrr�<module>s