
    J                         d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlZddlZddlZd Z	ej                  rd Zyej                  rd	 Zyy)
z Read JSON objects from a stream.    )absolute_import)division)print_function)unicode_literalsNc              #      K   t        |       D ]/  }|st        j                  t        j                  |             1 yw)zRead the events from the skaffold event stream.

  Args:
    file_obj: A File object.

  Yields:
    Event dicts from the JSON payloads.
  N)_ReadStreamingLinesjsonloadssix
ensure_strfile_objlines     2lib/googlecloudsdk/command_lib/code/json_stream.pyReadJsonStreamr      s5      "(+d
**S^^D)
** ,s   ?Ac              #      K   t        j                  t              5  | D ]  }|  	 d d d        y # 1 sw Y   y xY ww)N)
contextlibsuppressConnectionResetErrorr   s     r   r   r   ,   s/     			1	2$
  
3	2	2s   >2	>;>c              #   \   K   	 d}	 | j                  d      }|sy|dk(  rn||z  } | (w)a*  Python 2 compatibility with py3's streaming behavior.

    If file_obj is an HTTPResponse, iterating over lines blocks until a buffer
    is full.

    Args:
      file_obj: A file-like object, including HTTPResponse.

    Yields:
      Lines, like iter(file_obj) but without buffering stalls.
           N   
)read)r   r   bytes      r   r   r   3   sK      d}}Q
5=
  j s   *,)__doc__
__future__r   r   r   r   r   r	   r   r   PY3r   PY2 r   r   <module>r!      sE    ' &  % '   
+ 77
 	WW r   