def document_iters_to_http_response_body(ranges_iter, boundary, multipart, logger):
 if multipart:
  return document_iters_to_multipart_byteranges(ranges_iter, boundary)
 else:
  try:
   response_body_iter = next(ranges_iter)['part_iter']
  except StopIteration:
   return ''
  def string_along(useful_iter, useless_iter_iter, logger):
   with closing_if_possible(useful_iter):
    for x in useful_iter:
     (yield x)
   try:
    next(useless_iter_iter)
   except StopIteration:
    pass
   else:
    logger.warning(_('More than one part in a single-part response?'))
  return string_along(response_body_iter, ranges_iter, logger)

def document_iters_to_http_response_body ( ranges_iter , boundary , multipart , logger ) : if multipart : return document_iters_to_multipart_byteranges ( ranges_iter , boundary ) else : try : response_body_iter = next ( ranges_iter ) [ 'part_iter' ] except StopIteration : return '' def string_along ( useful_iter , useless_iter_iter , logger ) : with closing_if_possible ( useful_iter ) : for x in useful_iter : ( yield x ) try : next ( useless_iter_iter ) except StopIteration : pass else : logger . warning ( _ ( 'More than one part in a single-part response?' ) ) return string_along ( response_body_iter , ranges_iter , logger )
takes an iterator of range iters and turns it into an appropriate http response body .