From 6272d3f7ecc09203fdcd7d7a43d4cb751b501181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Eertmans?= Date: Fri, 15 Sep 2023 11:29:30 +0200 Subject: [PATCH] fix(cli/convert): ensure dest path can be written (#262) Fixes the issue that non-existing parent(s) in the dest path would raise an error. --- CHANGELOG.md | 3 +++ manim_slides/convert.py | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f35b9a9..c8125cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,9 @@ In an effort to better document changes, this CHANGELOG document is now created. [#253](https://github.com/jeertmans/manim-slides/discussions/253), caused by Python 3.11's change in how `Enum` work. [#257](https://github.com/jeertmans/manim-slides/pull/257). +- Fixed potential non-existing parent path issue in + `manim convert`'s destination path. + [#262](https://github.com/jeertmans/manim-slides/pull/262) ### Removed diff --git a/manim_slides/convert.py b/manim_slides/convert.py index cdce053..cdb968b 100644 --- a/manim_slides/convert.py +++ b/manim_slides/convert.py @@ -378,6 +378,8 @@ class RevealJS(Converter): for presentation_config in self.presentation_configs: presentation_config.copy_to(full_assets_dir) + dest.parent.mkdir(parents=True, exist_ok=True) + with open(dest, "w") as f: revealjs_template = Template(self.load_template()) @@ -434,6 +436,8 @@ class PDF(Converter): read_image_from_video_file(slide_config.file, self.frame_index) ) + dest.parent.mkdir(parents=True, exist_ok=True) + images[0].save( dest, "PDF", @@ -524,6 +528,7 @@ class PowerPoint(Converter): if self.auto_play_media: auto_play_media(movie, loop=slide_config.is_loop()) + dest.parent.mkdir(parents=True, exist_ok=True) prs.save(dest)