class_docstr: Generates output from a Message object tree.
  
  This basic generator writes the message to the given file object as plain
  text.
class_docstr_tok: ["Generates","output","from","a","Message","object","tree",".","This","basic","generator","writes","the","message","to","the","given","file","object","as","plain","text","."]
code: def _handle_multipart(self, msg):
      # The trick here is to write out each part separately, merge them all
      # together, and then make sure that the boundary we've chosen isn't
      # present in the payload.
      msgtexts = []
      subparts = msg.get_payload()
      if subparts is None:
          subparts = []
      elif isinstance(subparts, basestring):
          # e.g. a non-strict parse of a message with no starting boundary.
          self._fp.write(subparts)
          return
      elif not isinstance(subparts, list):
          # Scalar payload
          subparts = [subparts]
      for part in subparts:
          s = StringIO()
          g = self.clone(s)
          g.flatten(part, unixfrom=False)
          msgtexts.append(s.getvalue())
      # BAW: What about boundaries that are wrapped in double-quotes?
      boundary = msg.get_boundary()
      if not boundary:
          # Create a boundary that doesn't appear in any of the
          # message texts.
          alltext = NL.join(msgtexts)
          boundary = _make_boundary(alltext)
          msg.set_boundary(boundary)
      # If there's a preamble, write it out, with a trailing CRLF
      if msg.preamble is not None:
          if self._mangle_from_:
              preamble = fcre.sub(">From ", msg.preamble)
          else:
              preamble = msg.preamble
          print >> self._fp, preamble
      # dash-boundary transport-padding CRLF
      print >> self._fp, "--" + boundary
      # body-part
      if msgtexts:
          self._fp.write(msgtexts.pop(0))
      # *encapsulation
      # --> delimiter transport-padding
      # --> CRLF body-part
      for body_part in msgtexts:
          # delimiter transport-padding CRLF
          print >> self._fp, "\n--" + boundary
          # body-part
          self._fp.write(body_part)
      # close-delimiter transport-padding
      self._fp.write("\n--" + boundary + "--" + NL)
      if msg.epilogue is not None:
          if self._mangle_from_:
              epilogue = fcre.sub(">From ", msg.epilogue)
          else:
              epilogue = msg.epilogue
          self._fp.write(epilogue)
  
imports: import re
  import sys
  import time
  import random
  import warnings
  from cStringIO import StringIO
  from email.header import Header
label_desc: Use image node_id 9 for calling the Generator obj's underlying member method code with example usage: obj._handle_multipart(msg) without return types