From b4066c155228b4fd178e9bc00275e098aa024a81 Mon Sep 17 00:00:00 2001 From: Dendy Faist Date: Sat, 24 Feb 2024 13:41:59 +0100 Subject: [PATCH] impl: Create folders if they don't exist --- src/files.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/files.py b/src/files.py index 59b4639..83971e8 100644 --- a/src/files.py +++ b/src/files.py @@ -97,7 +97,8 @@ class DocumentTree(): def document_write(self, path: str, text: str) -> None: internal_path = os.path.join(self.base, *path.split('/')) + '.md' - # TODO: Check if the directory exists before writing + # TODO: Probably add some sort of confirmation beforehand? + os.makedirs(os.path.dirname(internal_path)) with open(internal_path, 'w') as file: file.write(text)