From 8d50a73e44edfac6cb9be2decf4f5a93cc801569 Mon Sep 17 00:00:00 2001 From: Kifah Meeran Date: Tue, 6 Jun 2023 16:12:33 +0400 Subject: [PATCH] Fix IsADirectoryError in main_no_modal.py Fixes #26 --- main_no_modal.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main_no_modal.py b/main_no_modal.py index b3edba516..389dc6946 100644 --- a/main_no_modal.py +++ b/main_no_modal.py @@ -193,8 +193,14 @@ def write_file(filename, filecode, directory): print("\033[94m" + filename + "\033[0m") print(filecode) - file_path = directory + "/" + filename + file_path = os.path.join(directory, filename) dir = os.path.dirname(file_path) + + # Check if the filename is actually a directory + if os.path.isdir(file_path): + print(f"Error: {filename} is a directory, not a file.") + return + os.makedirs(dir, exist_ok=True) # Open the file in write mode