Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added progress bar #32

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
colorama==0.4.6
pandas==2.0.1
tqdm==4.66.5
84 changes: 77 additions & 7 deletions tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import http.server
import socketserver
import threading
from tqdm import tqdm

init()

Expand All @@ -29,10 +30,24 @@
class NoLogRequestHandler(http.server.SimpleHTTPRequestHandler):
def log_request(self, code='-', size='-'):
pass
def display_progress_bar(task_description, steps_completed, total=100, duration=3):
"""
function which Displays a progress bar.
"""
with tqdm(total=total, desc=task_description, ncols=100, colour='green') as pbar:
for _ in range(steps_completed):
time.sleep(duration / steps_completed) # Control smoothness of progress
pbar.update(1) # Increment the bar by 1 step


def pre_setup():
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)
Expand Down Expand Up @@ -65,6 +80,11 @@ def show_about_section():
def josaa_rounds_year():
os.system("cls" if os.name == "nt" else "clear")
print(Fore.GREEN + ascii_art)
# progress bar of step 1
total=100
steps_completed= int(total*0.1)
display_progress_bar("STEP 1/10 ",steps_completed=steps_completed,total=total, duration=0.3)

print(Fore.YELLOW + "Select JOSAA round year")
print(Fore.GREEN + "1." + Fore.BLUE + "2022")
print(Fore.GREEN + "2." + Fore.BLUE + "2023" + Fore.RESET)
Expand All @@ -80,6 +100,10 @@ def josaa_rounds_year():
def josaa_rounds(josaa_round_year):
os.system("cls" if os.name == "nt" else "clear")
print(Fore.GREEN + ascii_art)
#progress bar for step-2
total=100
steps_completed= int(total*0.2)
display_progress_bar("STEP 2/10 ",steps_completed=steps_completed,total=total,duration=0.3)
print("{Fore.YELLOW}Select JOSAA round {{josaa_round_year}}")

menu_options = [
Expand All @@ -103,6 +127,11 @@ def josaa_rounds(josaa_round_year):
def csab_rounds_year():
os.system("cls" if os.name == "nt" else "clear")
print(Fore.GREEN + ascii_art)
#progress bar for step-1
total=100
steps_completed= int(total*0.1)
display_progress_bar("STEP 1/10 ",steps_completed=steps_completed,total=total, duration=0.3)

print(Fore.YELLOW + "Select CSAB round year")
print(Fore.GREEN + "1." + Fore.BLUE + "2021")
print(Fore.GREEN + "2." + Fore.BLUE + "2022")
Expand All @@ -121,6 +150,11 @@ def csab_rounds_year():
def csab_rounds(csab_round_year):
os.system("cls" if os.name == "nt" else "clear")
print(Fore.GREEN + ascii_art)
#progress bar for step-2
total=100
steps_completed= int(total*0.2)
display_progress_bar("STEP 2/10 ",steps_completed=steps_completed,total=total, duration=0.3)

print(f"{Fore.YELLOW}Select CSAB round ({csab_round_year})" )
print(Fore.GREEN + "1." + Fore.BLUE + "Round 1")
print(Fore.GREEN + "2." + Fore.BLUE + "Round 2")
Expand Down Expand Up @@ -164,7 +198,10 @@ def csab_institue_types(df):
# clear the screen
os.system("cls" if os.name == "nt" else "clear")
print(Fore.GREEN + ascii_art)

#progress bar for step-3
total=100
steps_completed= int(total*0.3)
display_progress_bar("STEP 3/10 ",steps_completed=steps_completed,total=total, duration=0.3)
# ask for user input for institute type
print(Fore.YELLOW + "Select Institute type:")
print(Fore.GREEN + "1." + Fore.BLUE + "ALL")
Expand Down Expand Up @@ -198,7 +235,10 @@ def josaa_institue_types(CSV_FILES):
# clear the screen
os.system("cls" if os.name == "nt" else "clear")
print(Fore.GREEN + ascii_art)

#progress bar for step-3
total=100
steps_completed= int(total*0.3)
display_progress_bar("STEP 3/10 ",steps_completed=steps_completed,total=total, duration=0.3)
# ask for user input for institute type
print(Fore.YELLOW + "Select Institute type:")
print(Fore.GREEN + "1." + Fore.BLUE + "ALL (No IITs Included)")
Expand Down Expand Up @@ -243,7 +283,13 @@ def josaa_institue_types(CSV_FILES):


def filter_programs(institute_df):
os.system("cls" if os.name == "nt" else "clear")
print(Fore.GREEN + ascii_art)
#progress bar for step-4
total=100
steps_completed= int(total*0.4)
display_progress_bar("STEP 4/10 ",steps_completed=steps_completed,total=total, duration=0.3)

print("Note: Programs marked with '*' will display all the programs similar to them.")
print("Select Program:")
print(Fore.GREEN + "1." + Fore.BLUE + "All")
Expand Down Expand Up @@ -441,6 +487,11 @@ def display_df_web(df, heading, subheading):
# Save the HTML content to the file
with open(filename, "w") as file:
file.write(html_content)
#progress bar for step-10
total=100
steps_completed= int(total*1.0)
display_progress_bar("STEP 10/10 ",steps_completed=steps_completed,total=total, duration=0.3)


print(filename)
# open the file in the default web browser
Expand Down Expand Up @@ -484,17 +535,27 @@ def main(df):
os.system("cls" if os.name == "nt" else "clear")
filtered_df = filter_programs(institute_df)

def filter_by_choices(choices, column_name):
def filter_by_choices(choices, column_name, steps):
unique_choices = institute_df[column_name].unique()

os.system("cls" if os.name == "nt" else "clear")
print(Fore.GREEN + ascii_art)

total=100
steps_completed=int(total*steps)
steps_count = int(steps*10)
str_steps=f"STEP {steps_count}/10"
display_progress_bar(str_steps,steps_completed=steps_completed,total=total, duration=0.3)


print(f"{Fore.YELLOW}Select {column_name}:")

print(Fore.GREEN + "1." + Fore.BLUE +" All")
for i, choice in enumerate(unique_choices, start=2):
print(f"{Fore.GREEN}{i}. {Fore.BLUE}{choice}{Fore.RESET}")



print(f"{Fore.YELLOW}")
print(f"You are Selecting {column_name}")
choices_input = input("Choose Options ((space-separated, e.g., 2 3 4) & 1 for all choices) : ")
Expand All @@ -507,19 +568,28 @@ def filter_by_choices(choices, column_name):
filtered_choices = [unique_choices[i] for i in selected_choices]
return filtered_df[filtered_df[column_name].isin(filtered_choices)]

filtered_df = filter_by_choices(institute_df["Institute"], "Institute")
filtered_df = filter_by_choices(institute_df["Quota"], "Quota")
filtered_df = filter_by_choices(institute_df["Seat Type"], "Seat Type")
filtered_df = filter_by_choices(institute_df["Gender"], "Gender")
filtered_df = filter_by_choices(institute_df["Institute"], "Institute",0.5)

filtered_df = filter_by_choices(institute_df["Quota"], "Quota",0.6)

filtered_df = filter_by_choices(institute_df["Seat Type"], "Seat Type",0.7)


filtered_df = filter_by_choices(institute_df["Gender"], "Gender",0.8)



os.system("cls" if os.name == "nt" else "clear")
print(Fore.GREEN + ascii_art)
display_progress_bar("STEP 9/10 ",steps_completed=90,total=100, duration=0.3)
rank = int(input(Fore.YELLOW + "Enter your rank: " + Fore.RESET))
filtered_df["Closing Rank"] = filtered_df["Closing Rank"].astype(
str).str.extract(r"(\d+)").astype(int)
filtered_df = filtered_df[filtered_df["Closing Rank"] > rank].sort_values(
by=["Closing Rank"], ascending=True)

os.system("cls" if os.name == "nt" else "clear")
print(Fore.GREEN + ascii_art)
display_df_web(filtered_df, "JEE Counsellor", "-By Ksauraj")
print(
Fore.GREEN +
Expand Down