Skip to content
Snippets Groups Projects

Develop

Closed Huihui, Jonathan requested to merge develop into main
1 file
+ 10
1
Compare changes
  • Side-by-side
  • Inline
@@ -49,7 +49,13 @@ def delete_directory(dirc=None):
if dirc is not None:
try:
if path_exists(dirc):
Path(dirc).rmdir()
directory_to_delete = Path(dirc)
for item in directory_to_delete.iterdir():
if item.is_file(): item.unlink()
if item.is_dir(): item.rmdir()
directory_to_delete.rmdir()
return f"{dirc} deleted successfully."
else:
return f"{dirc} does not exist."
@@ -125,6 +131,9 @@ def write_file(file_name, file_data=""):
"""
try:
if Path(file_name).suffix == ".json":
if not Path(file_name).exists():
with open(f"{file_name}", 'w') as json_file:
json_file.write(json.dumps({}))
with open(f"{file_name}", "r+") as file:
file_contents = json.load(file)
file_contents.update(file_data)
Loading