示例#1
0
def song_option():
    song_data = m.import_song()
    song_list = []
    for item in song_data.values():
        song_list.append(f"{item[0]}, {item[2]} - {item[3]}")
    t.print_table("songs", song_list)
    wait()
示例#2
0
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()
示例#3
0
def del_preference():
    fav_songs = m.import_fav_songs()
    fav_song_list = []
    for key, value in fav_songs.items():
        fav_song_list.append(f"{key} {value[0]} - {value[1]}, {value[2]}")
    t.print_table("favourites", fav_song_list)
    choice = str(input("\nChoose an record no. from the list.\n"))
    if choice in fav_songs.keys():
        try:
            m.remove_entry("Favourites", f"favID={choice}")
            print("Your preference was removed successfully.\n")
        except:
            print("There was an issue with deleting your preference.\n")
        choice2 = str(
            input(
                "Would you like to delete another record?\n[1] Yes\n[2] No\n"))
        if choice2 == "1":
            del_preference()
        elif choice2 == "2":
            ultimate_menu()
        else:
            print("Not a valid option")
            del_preference()
    else:
        print("Not a valid option.")
        del_preference()
示例#4
0
def print_favourites_table(favourites: dict, people: List[Person],
                           drinks: List[Drink]):
    people_dict = {person.id: person for person in people}
    drink_dict = {drink.id: drink for drink in drinks}
    print_table('Favourites', [
        f'{people_dict[person_id].get_full_name()}: {drink_dict[drink_id].name}'
        for person_id, drink_id in favourites.items()
    ])
示例#5
0
def option_3():
    assigned_song = make_a_combo()
    if assigned_song not in fav_songs_list:
        fav_songs_list.append(assigned_song)
        t.print_table("fav songs", fav_songs_list)
    else:
        print("That combination has already been done.")
        option_3()
示例#6
0
def option_5():
    t.print_table("fav songs", fav_songs_list)
    del_assigned_song = make_a_combo()
    if del_assigned_song in fav_songs_list:
        delete_item(fav_songs_list, del_assigned_song)
    else:
        print("That combination does not exist.")
        option_5()
示例#7
0
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")
示例#8
0
def song_selector():
    t.print_table("songs", song_list)
    song_select = str(
        input("Please assign a song from the database:\n")).title()
    if song_select in song_list:
        return song_select
    else:
        print("\nOne of your options is not in the database.\n")
        song_selector()
示例#9
0
def name_selector():
    t.print_table("names", name_list)
    person_select = str(
        input("Please type a name from the database:\n")).title()
    if person_select in name_list:
        return person_select
    else:
        print("\nOne of your options is not in the database.\n")
        name_selector()
示例#10
0
def option_4():
    t.print_table("fav songs", fav_songs_list)
    del_assigned_song = make_a_combo()
    if del_assigned_drink in fav_songs_list:
        delete_item(fav_songs_list, del_assigned_song)
        l.save_stuff("favsongs.csv", fav_songs_list)
    else:
        print("That combination does not exist.")
        option_4()
示例#11
0
def song_selector():
    song_data = m.import_song()
    song_list = []
    for key, value in song_data.items():
        song_list.append(f"{key} {value[0]}, {value[2]}")
    t.print_table("songs", song_list)
    song_select = str(input("Please assign a song no. from the list:\n"))
    if song_select.isnumeric() == True:
        for key in song_data.keys():
            if song_select == key:
                x = song_data[song_select]
                return f"{x[0]}, {x[2]}"
示例#12
0
def song_selector():
    song_list = m.import_songID()
    t.print_table("songs", song_list)
    song_select = str(input("Please assign a song no. from the list:\n"))
    if song_select.isnumeric() == True:
        for item in song_list:
            if song_select == item[0]:                
                return item[2:]
            
    else:
        print("\nNot a valid option.\n")
        song_selector()             
示例#13
0
def option_3():
    fav_songs = m.return_fav_songs()
    t.print_table("fav songs", fav_songs)
    choice = input("\nWould you like to update this list?\ny or n?\n").lower()
    if choice == "y":
        assign_a_song()
        option()
    elif choice == "n":
        ultimate_menu()
    else:
        print("Not a valid option.")
        option()
示例#14
0
def song_selector():
    song_data = m.import_song()
    song_list = []
    for key, value in song_data.items():
        song_list.append(f"{key} {value[0]}, {value[2]}")
    t.print_table("songs", song_list)
    song_select = str(input("Please assign a song no. from the list:\n"))
    if song_select in song_data.keys():
        for key in song_data.keys():
            x = song_data[song_select]
            return f"{x[0]}, {x[2]}"
    else:
        print("Not a valid option.")
示例#15
0
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()
示例#16
0
def album_option():
    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)
    choice = input("\nSelect an album to view or enter x to return to menu.\n")
    for key in album_list.keys():
        if choice == "x":
            ultimate_menu()
        elif choice == key:
            song_list = m.import_song_title(f"WHERE albumID={choice}")
            x = album_list[choice]
            t.print_table(f"{x[0]}", song_list)
            wait()
            album_option()
        elif choice not in album_list.keys():
            print("\nNot a valid option.\n")
            album_option()
示例#17
0
def option_1():
    t.print_table("names", name_list)
    add_name_option = str(
        input(
            "\nWould you like to edit this database?\n[1] Add name\n[2] Remove name\n[3] Return to menu\n"
        ))
    if add_name_option == "1":
        x = name_input()
        name_to_add = c.Names(x)
        name_to_add.name_add(name_list)
        option_1()
    elif add_name_option == "2":
        y = name_input()
        name_to_del = c.Names(y)
        name_to_del.del_name(name_list)
        option_1()
    elif add_name_option == "3":
        wait()
    else:
        print("That's not a valid option.")
        option_1()
示例#18
0
def option_2():
    t.print_table("songs", song_list)
    add_drink_option = str(
        input(
            "\nWould you like to edit this database?\n[1] Add song\n[2] Remove song\n[3] Return to menu\n"
        ))
    if add_drink_option == "1":
        x = song_input()
        drink_to_add = c.Song(x)
        drink_to_add.song_add(song_list)
        option_2()
    elif add_drink_option == "2":
        y = songx = song_input()
        drink_to_del = c.Song(y)
        drink_to_del.del_song(song_list)
        option_2()
    elif add_drink_option == "3":
        wait()
    else:
        print("That's not a valid option.")
        option_2()
示例#19
0
 def print_order(self):
     items = []
     for name, drink in self.orders.items():
         items.append(f'{name} ordered {drink}')
     print_table(f"{self.name}'s Round", items)
示例#20
0
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()
示例#21
0
 def print_order(self):
     content = [
         f'{name} ordered {drink}' for name, drink in self.order.items()
     ]
     print_table(f"{self.brewer.name}'s round", content)
示例#22
0
def option_6():
    t.print_table("fav songs", fav_songs_list)
    wait()
示例#23
0
def view_fav_songs():
    fav_album = m.import_fav_songs()
    fav_song_list = []
    for value in fav_album.values():
        fav_song_list.append(f"{value[0]} - {value[1]}, {value[2]}")
    t.print_table(f"Favourites", fav_song_list)
示例#24
0
def print_people_table(people: List[Person]):
    data = [person.get_full_name() for person in people]
    print_table('people', data)
示例#25
0
def print_drinks_table(drinks: List[Drink]):
    data = [drink.name for drink in drinks]
    print_table('drinks', data)
示例#26
0
def handle_get_drinks():
    print_table('drinks', drinks)
示例#27
0
def handle_view_favourites():
    # Using list comprehension to loop through favourites dictionary (dict.items())
    # Using tuple unpacking to dict (key, value) pairs into separate name, drink variables
    # Creating a list where each item is the result of f'{name}: {drink}'
    print_table('Favourites', [
                f'{name}: {drink}' for name, drink in favourite_drinks.items()])
示例#28
0
def print_preferences(data):
    items = []
    for name, drink in data.items():
        items.append(f"{name}: {drink}")
    print_table('PREFERENCE', items)
示例#29
0
def print_all_drinks():
    drinks = b.read_drink_database()
    print_table('DRINKS', drinks)
    wait()
示例#30
0
def print_all_people():
    people = a.read_people_database()
    print_table('PEOPLE'.center(24), people)
    wait()