code: def convert_frame(frame, body_encoding=None):
      
      lines = []
  
      body = None
      if frame.body:
          if body_encoding:
              body = encode(frame.body, body_encoding)
          else:
              body = encode(frame.body)
  
          if HDR_CONTENT_LENGTH in frame.headers:
              frame.headers[HDR_CONTENT_LENGTH] = len(body)
  
      if frame.cmd:
          lines.append(encode(frame.cmd))
          lines.append(ENC_NEWLINE)
      for key, vals in sorted(frame.headers.items()):
          if vals is None:
              continue
          if type(vals) != tuple:
              vals = (vals,)
          for val in vals:
              lines.append(encode("%s:%s\n" % (key, val)))
      lines.append(ENC_NEWLINE)
      if body:
          lines.append(body)
  
      if frame.cmd:
          lines.append(ENC_NULL)
      return lines
docs: Convert a frame to a list of lines separated by newlines.
  
      :param Frame frame: the Frame object to convert
  
      :rtype: list(str)