Merge pull request #81 from yousefissa/yi-write-to-file

Fix: create file dir if it doesnt exist during write_to_file
This commit is contained in:
Toran Bruce Richards
2023-04-04 11:27:37 +12:00
committed by GitHub

View File

@@ -31,6 +31,9 @@ def read_file(filename):
def write_to_file(filename, text):
try:
filepath = safe_join(working_directory, filename)
directory = os.path.dirname(filepath)
if not os.path.exists(directory):
os.makedirs(directory)
with open(filepath, "w") as f:
f.write(text)
return "File written to successfully."