From 2f51e102186cb8ea62a384d79fcac828ba74ca37 Mon Sep 17 00:00:00 2001 From: Surferlul Date: Fri, 13 Oct 2023 19:30:11 +0200 Subject: [PATCH] added more verbose error --- main.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index 567a48f..eb95d6b 100644 --- a/main.py +++ b/main.py @@ -54,13 +54,13 @@ def main() -> None: home_md_file = None pages, draws = get_draws(vault_path) - missing_any_svgs = False + missing_svgs = [] replace_dict = {} for draw, svg in iter_svgs(vault_path, draws): if svg is None: replace_dict[f"[[{draw}]]"] = "

MISSING IMAGE

" - missing_any_svgs = True + missing_svgs.append(draw) else: replace_dict[f"[[{draw}]]"] = f"![{draw}](../{svg})" @@ -74,11 +74,10 @@ def main() -> None: with open(page, "w") as f: f.write(content) - if missing_any_svgs: + if missing_svgs: if home_md_file is not None: eprint(f"::notice::Writing error message to {home_md_file}") - with open(home_md_file, "a") as f: - f.write("\n" + """ + file_error = "\n" + f""" -

Some drawings were not loaded

\t- ## How to fix as a Contributor \t\t- drawings are located in /draws @@ -92,8 +91,11 @@ def main() -> None: \t\t\t- Enable "Background" and check if you need Dark or Light theme \t\t\t- Click "SVG" and copy to /assets/excalidraw_svgs \t\t\t- Rename the file so the base names match -""" - ) +\t- ## The svgs for following drawing are missing""" + for draw in missing_svgs: + file_error += "\n\t\t- `{draw}`" + with open(home_md_file, "a") as f: + f.write(file_error) else: eprint("::warning::home-md-file not set for logseq-publish-excalidraw-to-svg, won't write error message to " "website")