docs: def to_file(epub, file):
          """Export to ``file``, which is a *file* or *file-like object*."""
          directory = tempfile.mkdtemp('-epub')
          # Write out the contents to the filesystem.
          package_filenames = []
          for package in epub:
              opf_filepath = Package.to_file(package, directory)
              opf_filename = os.path.basename(opf_filepath)
              package_filenames.append(opf_filename)
  
          # Create the container.xml
          container_xml_filepath = os.path.join(directory,
                                                EPUB_CONTAINER_XML_RELATIVE_PATH)
          template = jinja2.Template(CONTAINER_XML_TEMPLATE,
                                     trim_blocks=True, lstrip_blocks=True)
          os.makedirs(os.path.dirname(container_xml_filepath))  # FIXME PY3
          with open(container_xml_filepath, 'w') as fb:
              xml = template.render(package_filenames=package_filenames)
              fb.write(xml)
          # Write the mimetype file.
          with open(os.path.join(directory, 'mimetype'), 'w') as fb:
              fb.write("application/epub+zip")
  
          # Pack everything up
          pack_epub(directory, file=file)