From 609a97874866c11971c2c508331edfa81215c55d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Renaud=20Gue=CC=81rin?= Date: Sun, 20 Aug 2023 15:19:33 +0100 Subject: [PATCH] Create any missing directories in output path --- src/greaseweazle/image/image.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/greaseweazle/image/image.py b/src/greaseweazle/image/image.py index 31be5e16..62da19f0 100644 --- a/src/greaseweazle/image/image.py +++ b/src/greaseweazle/image/image.py @@ -23,6 +23,7 @@ class Image: ## Context manager for image objects created using .to_file() def __enter__(self): + os.makedirs(os.path.dirname(self.filename), exist_ok=True) self.file = open(self.filename, ('wb','xb')[self.noclobber]) return self