Skip to content

Commit

Permalink
feat: add option to clear output dir
Browse files Browse the repository at this point in the history
  • Loading branch information
lakshita10341 authored Oct 20, 2024
1 parent 29cbe3e commit 8af1cb2
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import socketserver
import threading
from tqdm import tqdm
import shutil

init()

Expand Down Expand Up @@ -40,29 +41,55 @@ def display_progress_bar(task_description, steps_completed, total=100, duration=
pbar.update(1) # Increment the bar by 1 step



def delete_output_directory():
"""Offers an option to delete the output directory if the user selects the appropriate menu option."""
output_dir = 'output'
if os.path.exists(output_dir):
print(f"{Fore.MAGENTA}Warning: This will delete all contents in the 'output' directory.")
user_input = input(f"{Fore.YELLOW}Press 1 to confirm deletion, or any other key to cancel: {Fore.RESET}")

if user_input == '1':
shutil.rmtree(output_dir) # Delete the directory and all its contents
print(f"{Fore.GREEN}Output directory deleted successfully.{Fore.RESET}")
else:
print(f"{Fore.YELLOW}Output directory was not deleted.{Fore.RESET}")

else:
print(f"{Fore.YELLOW}Output directory does not exist.{Fore.RESET}")
time.sleep(1)
pre_setup()


def pre_setup():
#progress bar for loading tool...
os.system("cls" if os.name == "nt" else "clear")
print(Fore.GREEN + ascii_art)
#progress bar for loading tool...
total=100
steps_completed= int(total*1.0)
display_progress_bar("Loadiing Tool...",steps_completed=steps_completed,total=total, duration=0.3)


print(Fore.YELLOW + "Select Counseling type:")
print(Fore.GREEN + "1." + Fore.BLUE + "JOSAA")
print(Fore.GREEN + "2." + Fore.BLUE + "CSAB" + Fore.RESET)
print(Fore.GREEN + "3." + Fore.BLUE + "About" + Fore.RESET)
print(Fore.GREEN + "4." + Fore.BLUE + "Exit" + Fore.RESET) #adding exit function in main menu
option = input("Select Option (1 to 4) : ") #increasing last choice value
print(Fore.GREEN + "4." + Fore.BLUE + "Clean Output Directory" + Fore.RESET) # Added option to clean the output directory
print(Fore.GREEN + "5." + Fore.BLUE + "Exit" + Fore.RESET) #adding exit function in main menu

option = input("Select Option (1 to 5) : ") #increasing last choice value
if option == '1':
josaa_rounds_year()
elif option == '2':
csab_rounds_year()
elif option == '3':
show_about_section()
elif option == '4': #adding exit condition
elif option=='4':
delete_output_directory()
elif option == '5': #adding exit condition
print("Exiting...") #printing exiting
exit(0) #calling exit function

else:
pre_setup()

Expand Down

0 comments on commit 8af1cb2

Please sign in to comment.