def _handle_stream_line(line):
 line = json.loads(line)
 if ('error' in line):
  content = ('ERROR: ' + line['error'])
 else:
  content = line.get('stream', '')
 for streamline in content.split('\n'):
  if streamline:
   (yield streamline)

def _handle_stream_line ( line ) : line = json . loads ( line ) if ( 'error' in line ) : content = ( 'ERROR: ' + line [ 'error' ] ) else : content = line . get ( 'stream' , '' ) for streamline in content . split ( '\n' ) : if streamline : ( yield streamline )
input is the json representation of: {stream: "content content"} output is a generator yield "content" .