Skip to content

Commit

Permalink
refactor: adding cleanup script
Browse files Browse the repository at this point in the history
  • Loading branch information
arunavabasucom committed Feb 6, 2024
1 parent 9d3c06f commit 55f2e9d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
6 changes: 5 additions & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ to start redis server
`rm -rf radis.json .radisdb`

info about the file
`ls -lh CO.hdf5`
`ls -lh CO.hdf5`

# getting the coverage information

coverage run --source=src -m pytest -v __tests__/ && coverage report -m && coverage html && coverage xml
28 changes: 28 additions & 0 deletions backend/cleanup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os
import shutil

def delete_folders(folder_path, folders_to_delete):
"""
Deletes specified folders within a directory.
:param folder_path: Path to the directory where folders are to be deleted.
:param folders_to_delete: List of folder names to delete.
"""
for root, dirs, files in os.walk(folder_path, topdown=True):
for folder in dirs:
if folder in folders_to_delete:
folder_to_delete = os.path.join(root, folder)
print(f"Deleting folder: {folder_to_delete}")
try:
shutil.rmtree(folder_to_delete)
print(f"Folder '{folder}' deleted successfully.")
except OSError as e:
print(f"Error: {e.strerror}")

# List of folders to delete
folders_to_delete = ['__pycache__', '.pytest_cache','DOWNLOADED_SPECFILES','DOWNLOADED_TXT']

# Path to the directory containing the folders to delete
directory_path = '.'
# Call the function to delete folders
delete_folders(directory_path, folders_to_delete)

0 comments on commit 55f2e9d

Please sign in to comment.