From 3ab8ca1b143a8868ea55531d738006d8c442b0b0 Mon Sep 17 00:00:00 2001 From: iaacornus Date: Wed, 17 Aug 2022 09:55:50 +0800 Subject: [PATCH] do the formatting under try except block --- src/utils/tex/sections/body.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/utils/tex/sections/body.py b/src/utils/tex/sections/body.py index b80d9b7..e4e6709 100644 --- a/src/utils/tex/sections/body.py +++ b/src/utils/tex/sections/body.py @@ -191,11 +191,7 @@ def format_body( ref: TextIO with open(out_file, "r", encoding="utf-8") as ref: ref_tex: list[str] = ref.readlines() - except (FileNotFoundError, OSError, PermissionError, IOError) as Err: - log.logger( - "E", f"{Err}. Cannot format the document, aborting ..." - ) - else: + log.logger("I", "Formatting the document ...") ignore: int = -1 @@ -224,7 +220,9 @@ def format_body( break continue - file.write(f"\t{line}") - file.write("\\end{document}") + except (FileNotFoundError, OSError, PermissionError, IOError) as Err: + log.logger( + "E", f"{Err}. Cannot format the document, aborting ..." + )