@contextlib.contextmanager
def _convert_to_fd_or_read_function(fd):
 if six.callable(fd):
  (yield fd)
  return
 with data.get_readable_fileobj(fd, encoding=u'binary') as new_fd:
  if sys.platform.startswith(u'win'):
   (yield new_fd.read)
  elif six.PY2:
   if isinstance(new_fd, file):
    (yield new_fd)
   else:
    (yield new_fd.read)
  elif isinstance(new_fd, io.FileIO):
   (yield new_fd)
  else:
   (yield new_fd.read)

@ contextlib . contextmanager def _convert_to_fd_or_read_function ( fd ) : if six . callable ( fd ) : ( yield fd ) return with data . get_readable_fileobj ( fd , encoding = u'binary' ) as new_fd : if sys . platform . startswith ( u'win' ) : ( yield new_fd . read ) elif six . PY2 : if isinstance ( new_fd , file ) : ( yield new_fd ) else : ( yield new_fd . read ) elif isinstance ( new_fd , io . FileIO ) : ( yield new_fd ) else : ( yield new_fd . read )
returns a function suitable for streaming input .