impl: Create folders if they don't exist

This commit is contained in:
Dendy 2024-02-24 13:41:59 +01:00
parent 903f648b58
commit b4066c1552
1 changed files with 2 additions and 1 deletions

View File

@ -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)