def export_iter(self, pages): basename = encode_filename(pages.name) dir = get_tmpdir().subdir('mhtml_export_tmp_dir') dir.remove_children() file = dir.file(basename + '.html') layout = SingleFileLayout(file, pages.prefix) exporter = SingleFileExporter(layout, self.template, 'html', document_root_url=self.document_root_url) for p in exporter.export_iter(pages): yield p encoder = MHTMLEncoder() linker = ExportLinker(pages.notebook, layout, output=file, usebase=True) self.file.write(encoder(layout, linker))
def build_single_file_exporter(file, format, template, namespace=None, **opts): '''Returns an L{Exporter} that is suitable for exporting a set of pages to a single file ''' from zim.export.layouts import SingleFileLayout from zim.export.exporters.files import SingleFileExporter template = get_template(format, template) layout = SingleFileLayout(file) return SingleFileExporter(layout, template, format, **opts)