From be87550ff2b066bd7bdf947363a3f22e1674e1cf Mon Sep 17 00:00:00 2001 From: adldotori Date: Fri, 7 Apr 2023 22:25:50 +0900 Subject: [PATCH] feat: make directory --- core/tools/editor/write.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/tools/editor/write.py b/core/tools/editor/write.py index 54337b3..2eb0919 100644 --- a/core/tools/editor/write.py +++ b/core/tools/editor/write.py @@ -4,6 +4,8 @@ write protocol: """ +import os + from .verify import verify @@ -21,6 +23,9 @@ class WriteCommand: @verify def execute(self) -> str: + dir_path = os.path.dirname(self.filepath) + if dir_path: + os.makedirs(dir_path, exist_ok=True) with open(self.filepath, self.mode) as f: f.write(self.content) return self.content