HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //proc/1233/root/usr/lib/python3/dist-packages/docker/utils/__pycache__/json_stream.cpython-310.pyc
o

�2.a��@s\ddlZddlZddlmZe��Zdd�Zdd�Zdd	�Zddd�Z	dd
d�fdd�Z
dS)�N�)�StreamParseErrorccs,�|D]}t|t�s|�dd�}|VqdS)z�
    Given a stream of bytes or text, if any of the items in the stream
    are bytes convert them to text.
    This function can be removed once we return text streams
    instead of byte streams.
    zutf-8�replaceN)�
isinstance�str�decode)�stream�data�r
�:/usr/lib/python3/dist-packages/docker/utils/json_stream.py�stream_as_text
s�
�rcCsR|��}zt�|�\}}|tjj�||���d�}||fWSty(YdSw)z�Attempt to parse a json object from a buffer. If there is at least one
    object, return it and the rest of the buffer, otherwise return None.
    N)	�strip�json_decoder�
raw_decode�json�decoder�
WHITESPACE�match�end�
ValueError)�buffer�obj�index�restr
r
r�
json_splitters
�rcCst|ttj�S)z�Given a stream of text, return a stream of json objects.
    This handles streams which are inconsistently buffered (some entries may
    be newline delimited, and others are not).
    )�split_bufferrrr)rr
r
r�json_stream$sr�
cCs:|�t|��}|dkr
dS|d|d�||dd�fS)N����)�findr)r�	separatorrr
r
r�
line_splitter,s r"cCs|S)Nr
)�ar
r
r�<lambda>3sr$c
cs��|pt}d}t|�D]}||7}	||�}|durn|\}}|Vqq|r?z||�VWdSty>}zt|��d}~wwdS)aGiven a generator which yields strings and a splitter function,
    joins all input, splits on the separator and yields each chunk.
    Unlike string.split(), each chunk includes the trailing
    separator, except for the last one if none was found on the end
    of the input.
    �TN)r"r�	Exceptionr)r�splitterr�bufferedr	�buffer_split�item�er
r
rr3s*�����r)r)r�json.decoder�errorsr�JSONDecoderrrrrr"rr
r
r
r�<module>s