def option_1(): name_list = m.import_name() t.print_table("names", name_list) add_name_option = str( input( "\nPlease select an option:\n[1] Add name\n[2] Remove name\n[3] Return to menu\n" )) if add_name_option == "1": x = name_input() if x.isnumeric == True: print("You can't add that to the database.\n") option_1() elif x in name_list: print( "That entry already exists.\nPlease enter a unique name into the database.\n" ) option_1() else: name_to_add = c.Names(x) name_to_add.insert_name_entry() option_1() elif add_name_option == "2": y = name_input() name_to_del = c.Names(y) if y in name_list: name_to_del.remove_name_entry() option_1() else: print("That name does not exist") option_1() elif add_name_option == "3": ultimate_menu() else: print("That's not a valid option.") option_1()
def name_selector(): name_list = m.import_name() t.print_table("names", name_list) person_select = str(input("Please type a name from the list:\n")).title() if person_select in name_list: return person_select else: print("\nNot a valid option.\n")
def aux_manager(): name_list = m.import_name() x = str(input("Who's in charge of the aux cable?\n")).title() if x in name_list: return x else: print("Not a valid name.\n") aux_manager()
def assign_a_song(): x = m.import_name() t.print_table("names", x) name_input = input("Choose a name from the list: ").title() if name_input in x: y = m.import_songID() t.print_table("songs", y) song_input = str(input("Choose a song number from the list: ")) for item in y: while song_input == item[0]: continue m.update_entry("Names", f"fav_songID={song_input}", f"first_name='{name_input}'") option_3() else: print("That name doesn't exist.") assign_a_song()
def add_preference(): names_list = m.import_name() t.print_table("names", names_list) choice = str(input("\nSelect a name from the list\n")).title() choice2 = str( input( "Would you like to:\n[1] Assign a whole album\n[2] Individual songs?\n[3] Exit?\n" )) if choice2 == "1": album_list = m.import_album() album_stuff = [] for key, value in album_list.items(): album_stuff.append(f"{key} {value[0]}, {value[1]}") t.print_table("albums", album_stuff) choice3 = str(input("Choose an album no. from the list.\n")) if choice3 in album_list.keys(): album_choice = m.import_song_choice( "s.song_title, a.album_name", "Songs as s, Albums as a", f"s.albumID={choice3} AND a.albumID={choice3}") try: for item in album_choice: m.insert_entry( "Favourites (name, song_title, album_name)", f"\'{choice}\', \'{item[0]}\', \'{item[1]}\'") print("Your preferences have been saved.") except: print("There was an issue in saving your preferences.") else: print("Not a valid option") assign_an_album() elif choice2 == "2": song_data = m.import_song() song_list = [] for key, value in song_data.items(): song_list.append(f"{key} {value[0]}, {value[2]} - {value[3]}") t.print_table("songs", song_list) choice4 = str(input("Choose a song no. from the list.\n")) if choice4 in song_data.keys(): try: song_choice = song_data[choice4] m.insert_entry( "Favourites (name, song_title, album_name)", f"\'{choice}\', \'{song_choice[0]}\', \'{song_choice[2]}\'" ) print("Your preferences have been saved.\n") except: print("There was an issue in saving your preferences.\n") choice5 = str( input( "Would you like to save another preference?:\n[1] Yes\n[2] No\n" )) if choice5 == "1": add_preference() elif choice5 == "2": ultimate_menu() else: print("Not a valid option") del_preference() else: print("Not a valid option.") add_preference() elif choice2 == "3": ultimate_menu() else: print("Not a valid option") add_preference()