mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-19 06:54:22 +01:00
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:
@@ -31,6 +31,9 @@ def read_file(filename):
|
|||||||
def write_to_file(filename, text):
|
def write_to_file(filename, text):
|
||||||
try:
|
try:
|
||||||
filepath = safe_join(working_directory, filename)
|
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:
|
with open(filepath, "w") as f:
|
||||||
f.write(text)
|
f.write(text)
|
||||||
return "File written to successfully."
|
return "File written to successfully."
|
||||||
|
|||||||
Reference in New Issue
Block a user