def output(f, format, thread, posts): if format == "json": thread.json_dump(f, subset=posts, indent=4) elif format == "html": f.write(archivelib.render_html(thread, posts)) elif format == "plaintext": f.write(archivelib.render_plaintext(thread, posts))
def write_html_dir(src, dest, thread, posts): image_src_dir = os.path.join(src, "images") image_dest_dir = os.path.join(dest, "images") html_dest = os.path.join(dest, "thread.html") if os.path.exists(dest): shutil.rmtree(dest) os.makedirs(dest, exist_ok=True) shutil.copytree(image_src_dir, image_dest_dir) with open(html_dest, "w") as f: f.write(archivelib.render_html(thread, posts))