From 88a02836e26c80768df481225f88869520c0158c Mon Sep 17 00:00:00 2001 From: Per Unneberg Date: Tue, 14 Nov 2023 12:40:33 +0100 Subject: [PATCH] Make directory for post rendered files --- scripts/post-render.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/post-render.py b/scripts/post-render.py index 05693edc..6e7cbd97 100755 --- a/scripts/post-render.py +++ b/scripts/post-render.py @@ -5,6 +5,16 @@ import shutil +def safe_mkdir(dirname): + logging.debug(f"Making directory {dirname}") + if not os.path.exists(dirname): + try: + os.mkdir(dirname) + except FileNotFoundError as e: + print(e) + raise + + def safe_copy(src, dst): logging.debug(f"Copy {dst} -> {src}") if not os.path.exists(src): @@ -38,4 +48,6 @@ def safe_copy(src, dst): for fn in files: src = os.path.join(qpd, fn) dst = os.path.join(SITE_DIR, fn) + dirname = os.path.dirname(dst) + safe_mkdir(dirname) safe_copy(src, dst)