Skip to content

Commit

Permalink
tool: remove page indexing system
Browse files Browse the repository at this point in the history
* tool: remove page indexing system

currently, we are temporarily disabling this feature due to numerous bugs.

* tool: correct formatting in prompt and add colourful styling
  • Loading branch information
ksauraj authored Oct 28, 2023
1 parent 7b03914 commit 20b6257
Showing 1 changed file with 32 additions and 46 deletions.
78 changes: 32 additions & 46 deletions tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def pre_setup():

def josaa_rounds_year():
os.system("cls" if os.name == "nt" else "clear")
print("Select JOSAA round year")
print(Fore.GREEN + ascii_art)
print(Fore.YELLOW + "Select JOSAA round year")
print(Fore.GREEN + "1." + Fore.BLUE + "2022")
print(Fore.GREEN + "2." + Fore.BLUE + "2023" + Fore.RESET)
josaa_round_year_sel = input("Select Option (1 to 2): ")
Expand All @@ -50,7 +51,8 @@ def josaa_rounds_year():

def josaa_rounds(josaa_round_year):
os.system("cls" if os.name == "nt" else "clear")
print(Fore.YELLOW + "Select JOSAA round")
print(Fore.GREEN + ascii_art)
print("{Fore.YELLOW}Select JOSAA round {{josaa_round_year}}")

menu_options = [
"Round 1",
Expand All @@ -72,7 +74,8 @@ def josaa_rounds(josaa_round_year):

def csab_rounds_year():
os.system("cls" if os.name == "nt" else "clear")
print("Select CSAB round year")
print(Fore.GREEN + ascii_art)
print(Fore.YELLOW + "Select CSAB round year")
print(Fore.GREEN + "1." + Fore.BLUE + "2021")
print(Fore.GREEN + "2." + Fore.BLUE + "2022")
print(Fore.GREEN + "3." + Fore.BLUE + "2023" + Fore.RESET)
Expand All @@ -89,7 +92,8 @@ def csab_rounds_year():

def csab_rounds(csab_round_year):
os.system("cls" if os.name == "nt" else "clear")
print("Select CSAB round (2022)")
print(Fore.GREEN + ascii_art)
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")
csab_round = input(Fore.RESET + "Select Option (1 to 2) : ")
Expand Down Expand Up @@ -131,9 +135,10 @@ def csv_files(type, round, year):
def csab_institue_types(df):
# clear the screen
os.system("cls" if os.name == "nt" else "clear")
print(Fore.GREEN + ascii_art)

# ask for user input for institute type
print("Select Institute type:")
print(Fore.YELLOW + "Select Institute type:")
print(Fore.GREEN + "1." + Fore.BLUE + "ALL")
print(Fore.GREEN + "2." + Fore.BLUE + "IIITs")
print(Fore.GREEN + "3." + Fore.BLUE + "NITs")
Expand Down Expand Up @@ -164,9 +169,10 @@ def csab_institue_types(df):
def josaa_institue_types(CSV_FILES):
# clear the screen
os.system("cls" if os.name == "nt" else "clear")
print(Fore.GREEN + ascii_art)

# ask for user input for institute type
print("Select Institute type:")
print(Fore.YELLOW + "Select Institute type:")
print(Fore.GREEN + "1." + Fore.BLUE + "ALL (No IITs Included)")
print(Fore.GREEN + "2." + Fore.BLUE + "IIITs")
print(Fore.GREEN + "3." + Fore.BLUE + "NITs")
Expand Down Expand Up @@ -209,6 +215,7 @@ def josaa_institue_types(CSV_FILES):


def filter_programs(institute_df):
print(Fore.GREEN + ascii_art)
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 @@ -422,48 +429,27 @@ def main(df):

def filter_by_choices(choices, column_name):
unique_choices = institute_df[column_name].unique()
num_choices = len(unique_choices)
start_index = 0
batch_size = 15
selected_choices = []

while start_index < num_choices:
os.system("cls" if os.name == "nt" else "clear")
print(f"Select {column_name} :")
print(Fore.GREEN + "1." + Fore.BLUE + " All")
end_index = start_index + batch_size
current_choices = unique_choices[start_index:end_index]

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

if end_index < num_choices:
print(f"{Fore.GREEN}{end_index+2}. Next {batch_size}")

if start_index > 0:
print(f"{Fore.GREEN}{end_index+3}. Return to Last Page")

choices_input = input("Choose Options (space-separated, e.g., 1 2 3) : ")
if choices_input:
selected_choices.extend(map(int, choices_input.split()))

if end_index < num_choices:
print(f"{Fore.GREEN}{end_index+4}. Done")

if start_index > 0:
print(f"{Fore.GREEN}{end_index+5}. Return to Last Page")

if 1 in selected_choices:
return filtered_df
else:
selected_choices = [choice - 2 for choice in selected_choices]
filtered_choices = [unique_choices[i] for i in selected_choices]
return filtered_df[filtered_df[column_name].isin(filtered_choices)]


os.system("cls" if os.name == "nt" else "clear")
print(Fore.GREEN + ascii_art)
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) : ")
selected_choices = list(map(int, choices_input.split()))

if 1 in selected_choices:
return filtered_df
else:
selected_choices = [choice - 2 for choice in selected_choices]
filtered_choices = [unique_choices[i] for i in selected_choices]
return filtered_df[filtered_df[column_name].isin(filtered_choices)]

# Example usage
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")
Expand Down

0 comments on commit 20b6257

Please sign in to comment.