From dde0aff8bd40a2492911251686dc3f079e67d9c9 Mon Sep 17 00:00:00 2001 From: Rui Dias Gomes <66125272+rmdg88@users.noreply.github.com> Date: Thu, 3 Oct 2024 13:28:25 +0100 Subject: [PATCH] update examples (#123) Signed-off-by: rmdg88 --- examples/batch_convert.py | 12 ++++++++---- examples/custom_convert.py | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/examples/batch_convert.py b/examples/batch_convert.py index eb943a7a..2f3f38b1 100644 --- a/examples/batch_convert.py +++ b/examples/batch_convert.py @@ -27,19 +27,23 @@ def export_documents( doc_filename = conv_res.input.file.stem # Export Deep Search document JSON format: - with (output_dir / f"{doc_filename}.json").open("w") as fp: + with (output_dir / f"{doc_filename}.json").open( + "w", encoding="utf-8" + ) as fp: fp.write(json.dumps(conv_res.render_as_dict())) # Export Text format: - with (output_dir / f"{doc_filename}.txt").open("w") as fp: + with (output_dir / f"{doc_filename}.txt").open("w", encoding="utf-8") as fp: fp.write(conv_res.render_as_text()) # Export Markdown format: - with (output_dir / f"{doc_filename}.md").open("w") as fp: + with (output_dir / f"{doc_filename}.md").open("w", encoding="utf-8") as fp: fp.write(conv_res.render_as_markdown()) # Export Document Tags format: - with (output_dir / f"{doc_filename}.doctags").open("w") as fp: + with (output_dir / f"{doc_filename}.doctags").open( + "w", encoding="utf-8" + ) as fp: fp.write(conv_res.render_as_doctags()) elif conv_res.status == ConversionStatus.PARTIAL_SUCCESS: diff --git a/examples/custom_convert.py b/examples/custom_convert.py index 9c84d8dd..63c8bebc 100644 --- a/examples/custom_convert.py +++ b/examples/custom_convert.py @@ -28,19 +28,23 @@ def export_documents( doc_filename = conv_res.input.file.stem # Export Deep Search document JSON format: - with (output_dir / f"{doc_filename}.json").open("w") as fp: + with (output_dir / f"{doc_filename}.json").open( + "w", encoding="utf-8" + ) as fp: fp.write(json.dumps(conv_res.render_as_dict())) # Export Text format: - with (output_dir / f"{doc_filename}.txt").open("w") as fp: + with (output_dir / f"{doc_filename}.txt").open("w", encoding="utf-8") as fp: fp.write(conv_res.render_as_text()) # Export Markdown format: - with (output_dir / f"{doc_filename}.md").open("w") as fp: + with (output_dir / f"{doc_filename}.md").open("w", encoding="utf-8") as fp: fp.write(conv_res.render_as_markdown()) # Export Document Tags format: - with (output_dir / f"{doc_filename}.doctags").open("w") as fp: + with (output_dir / f"{doc_filename}.doctags").open( + "w", encoding="utf-8" + ) as fp: fp.write(conv_res.render_as_doctags()) else: