コード例 #1
0
 def test_to_and_from_str_multiple_tracks(self):
     album = Album('album title', 2020)
     album.add(Song('first song title'))
     album.add(Song('second song title'))
     de = Album.from_string(str(album))
     assert Album.from_string(str(album)) == album
コード例 #2
0
laulud = []

first_albumid = []
first_lauljad = []

for row in tabel:
    laul = Laul(row[3], row[0])
    laulud.append(laul)

    if row[0] not in first_lauljad:
        laulja = Laulja(row[0])
        lauljad.append(laulja)
        first_lauljad.append(laulja.nimi)

    if row[1] not in first_albumid:
        album = Album(row[1], row[2], row[0])
        laulja.lisa_album(album)
        albumid.append(album)
        first_albumid.append(row[1])

    album.lisa_laul(laul)

kas_jatkata = True
while kas_jatkata:
    print("Tee valik:")
    print("1: väljasta albumid ja laulud")
    print("2: otsing albumi pealkirja või aasta järgi")
    print("3: otsing laulu järgi")
    print("4: otsing laulja järgi")

    valik = input("Valik [1, 2, 3, 4]: ")
コード例 #3
0
ファイル: band_test.py プロジェクト: nkolew/Softuni-Python
 def test_album_init(self):
     album = Album("The Sound of Perseverance")
     message = album.details().strip()
     expected = "Album The Sound of Perseverance"
     self.assertEqual(message, expected)
コード例 #4
0
ファイル: main.py プロジェクト: budgielang/budgie
    print_strings("all pets", pets)
    indexLastFew = pets[1:3]
    print_strings("last few pets", pets)

    # Ranges by length
    lengthAll = pets[0:3]
    print_strings("all pets", pets)
    lengthLastFew = pets[1:4]
    print_strings("last few pets", pets)

    # Sorting strings
    flavors = ["plain", "chocolate", "vanilla", "strawberry"]
    flavors.sort()
    print_strings("flavor", flavors)

    # Sorting ints
    ints = [1, 10, 2, -3, 8, 4, 5]
    ints.sort()
    print_ints("int", ints)

    # Sorting members
    albums = [
        Album("Thriller", 1982),
        Album("Back in Black", 1980),
        Album("The Dark Side of the Moon", 1973)
    ]
    albums.sort(key=lambda album: album.name)
    print_list_fancy("album by name", albums, lambda album: album.name)
    albums.sort(key=lambda album: album.year)
    print_list_fancy("album by year", albums, lambda album: album.get_label())
コード例 #5
0
from laul import Laul
from album import Album

laul1 = Laul("Mutionu pidu", "Onu Remus")
print(laul1.pealkiri, laul1.laulja)

album1 = Album("Aerosmith", "Toys In The Attic", 1975)
print(album1.pealkiri, album1.laulja, album1.aasta)
コード例 #6
0
from album import Album
from laulja import Laulja
tabel = []
albumid = []
lauljad = []
albumid_olemas = []
lauljad_olemas = []
#tekitan 2 listi kuhu panna muutujaid ja 2 listi, millega jälgida olemasolevaid muutujaid.
fail = open("albumid.txt", encoding="UTF-8")
for rida in fail:
    tabel.append(rida.strip().split(
        "\t"))  #lisan albumid.txt sisu tabelisse lihtsamaks kasutamiseks
fail.close()
for i in tabel:
    if i[1] not in albumid_olemas:  #kontrollin kas see album on juba objektina tekitatud
        temp = Album(i[1], i[2], i[0])  #teen albumist objekti
        albumid.append(temp)
        albumid_olemas.append(
            i[1])  #lisan objekti päris ja kontrollimise listi
    if i[0] not in lauljad_olemas:  #sama asi mis albumitega nüüd lauljatega.
        temp = Laulja(i[0])
        lauljad.append(temp)
        lauljad_olemas.append(i[0])
    teemp = Laul(i[3], i[0], i[1])  #siin muudan laulu objektiks
    for i in albumid:
        if i.pealkiri == teemp.album:  #kontrollin kas laulu album ja albumi pealkiri on samad
            i.lisa_laul(teemp)  #kui on siis lisan laulu albumisse
for i in albumid:
    for j in lauljad:
        if i.laulja == j.nimi:  #kontrollin kõikide albumitega läbi kõik lauljad ja lisan sobivuse korral albumi listi
            j.lisa_album(i)
コード例 #7
0
from album import Album
from laul import Laul
# testime laulu objekti loomist
from laulja import Laulja

laul_1 = Laul("Für Oksana", "Nublu")
#print(laul_1.laulja, laul_1.pealkiri)
laul_2 = Laul("12", "Nublu")
#print(laul_2.laulja, laul_2.pealkiri)
laul_3 = Laul("Crousandid", "Nublu")
#print(laul_1.laulja, laul_1.pealkiri)
laul_4 = Laul("Öölaps", "Nublu")
#print(laul_2.laulja, laul_2.pealkiri)
# testime albumi loomist
album_1 = Album("Uus album 1", 2019, "Numblu")
# lisame laulud albumisse
album_1.lisa_laul(laul_1)
album_1.lisa_laul(laul_2)
# testime albumi loomist
album_2 = Album("Uus album 2", 2019, "Numblu")
# lisame laulud albumisse
album_2.lisa_laul(laul_3)
album_2.lisa_laul(laul_4)
# vaatame loodud albumi sisu
#print(album_2.pealkiri)
#for laul in album_2.laulud:
#    print(laul.laulja, laul.pealkiri)
# testime Laulja loomist
laulja = Laulja("Nublu")
laulja.lisa_album(album_1)
laulja.lisa_album(album_2)
コード例 #8
0
 def test_init_with_invalid_name(self):
     with pytest.raises(ValueError):
         Album('---;;;', 2020)
コード例 #9
0
 def test_title_property(self):
     album = Album('title', 2020)
     assert album.title == 'title'
コード例 #10
0
 def test_equality_for_artist_with_albums(self):
     artist = Artist('artist name', 'country')
     artist.add_album(Album('album title', 2020))
     assert artist != Artist('artist name', 'country')
コード例 #11
0
 def test_to_and_from_str_with_albums_without_songs(self):
     artist = Artist('artist name', 'country')
     artist.add_album(Album('first album name', 2020))
     artist.add_album(Album('second album name', 2020))
     assert Artist.from_string(str(artist)) == artist
コード例 #12
0
 def test_artist_with_one_song(self):
     artist = Artist('artist name', 'country')
     album = Album('album title', 2020)
     album.add(Song('song title'))
     artist.add_album(album)
     assert list(artist.get_songs()) == [Song('song title')]
コード例 #13
0
 def test_artist_with_albums_but_no_songs(self):
     artist = Artist('artist name', 'country')
     artist.add_album(Album('album title', 2020))
     assert list(artist.get_songs()) == []
コード例 #14
0
 def test_artist_with_single_album(self):
     artist = Artist('artist name', 'country')
     artist.add_album(Album('album title', 2020))
     assert list(artist.get_albums()) == [Album('album title', 2020)]
コード例 #15
0
    def init_songs():
        from song import Song
        from album import Album
        from discography import Discography
        album_taylorswift = Album("Taylor Swift", [])
        album_fearless = Album("Fearless", [])
        album_speaknow = Album("Speak Now", [])
        album_red = Album("Red", [])
        album_1989 = Album("1989", [])
        album_reputation = Album("reputation", [])
        album_lover = Album("Lover", [])
        album_folklore = Album("folklore", [])
        # debut songs
        tim_mcgraw = Song("Tim McGraw", album_taylorswift, 1, "discography/taylorswift/tim_mcgraw_lyrics.txt")
        picture_to_burn = Song("Picture to Burn", album_taylorswift, 2, "discography/taylorswift/picture_to_burn_lyrics.txt")
        teardrops_on_my_guitar = Song("Teardrops on my Guitar", album_taylorswift, 3, "discography/taylorswift/teardrops_on_my_guitar_lyrics.txt")
        a_place_in_this_world = Song("A Place in this World", album_taylorswift, 4, "discography/taylorswift/a_place_in_this_world_lyrics.txt")
        cold_as_you = Song("Cold as You", album_taylorswift, 5, "discography/taylorswift/cold_as_you_lyrics.txt")
        the_outside = Song("The Outside", album_taylorswift, 6, "discography/taylorswift/the_outside_lyrics.txt")
        tied_together_with_a_smile = Song("Tied Together with a Smile", album_taylorswift, 7, "discography/taylorswift/tied_together_with_a_smile_lyrics.txt")
        stay_beautiful = Song("Stay Beautiful", album_taylorswift, 8, "discography/taylorswift/stay_beautiful_lyrics.txt")
        shouldve_said_no = Song("Should've Said No", album_taylorswift, 9, "discography/taylorswift/shouldve_said_no_lyrics.txt")
        marys_song = Song("Mary's Song (Oh My My My)", album_taylorswift, 10, "discography/taylorswift/marys_song_lyrics.txt")
        our_song = Song("Our Song", album_taylorswift, 11, "discography/taylorswift/our_song_lyrics.txt")
        im_only_me_when_im_with_you = Song("I'm Only Me When I'm With You", album_taylorswift, 12, "discography/taylorswift/im_only_me_when_im_with_you_lyrics.txt")
        invisible = Song("Invisible", album_taylorswift, 13, "discography/taylorswift/invisible_lyrics.txt")
        a_perfectly_good_heart = Song("A Perfectly Good Heart", album_taylorswift, 14, "discography/taylorswift/a_perfectly_good_heart_lyrics.txt")

        #fearless songs
        fearless = Song("Fearless", album_fearless, 1, "discography/fearless/fearless_lyrics.txt")
        fifteen = Song("Fifteen", album_fearless, 2, "discography/fearless/fifteen_lyrics.txt")
        love_story = Song("Love Story", album_fearless, 3, "discography/fearless/love_story_lyrics.txt")
        hey_stephen = Song("Hey Stephen", album_fearless, 4, "discography/fearless/hey_stephen_lyrics.txt")
        white_horse = Song("White Horse", album_fearless, 5, "discography/fearless/white_horse_lyrics.txt")
        you_belong_with_me = Song("You Belong With Me", album_fearless, 6, "discography/fearless/you_belong_with_me_lyrics.txt")
        breathe = Song("Breathe", album_fearless, 7, "discography/fearless/breathe_lyrics.txt")
        tell_me_why = Song("Tell Me Why", album_fearless, 8, "discography/fearless/tell_me_why_lyrics.txt")
        youre_not_sorry = Song("You're Not Sorry", album_fearless, 9, "discography/fearless/youre_not_sorry_lyrics.txt")
        the_way_i_loved_you = Song("The Way I Loved You", album_fearless, 10, "discography/fearless/the_way_i_loved_you_lyrics.txt")
        forever_and_always = Song("Forever & Always", album_fearless,11, "discography/fearless/forever_and_always_lyrics.txt")
        the_best_day = Song("The Best Day", album_fearless, 12, "discography/fearless/the_best_day_lyrics.txt")
        change = Song("Change", album_fearless, 13, "discography/fearless/change_lyrics.txt")
        jump_then_fall = Song("Jump Then Fall", album_fearless, 14, "discography/fearless/jump_then_fall_lyrics.txt")
        untouchable = Song("Untouchable", album_fearless, 15, "discography/fearless/untouchable_lyrics.txt")
        forever_and_always_piano = Song("Forever And Always (Piano Version)", album_fearless, 16, "discography/fearless/forever_and_always_lyrics.txt")
        come_in_with_the_rain = Song("Come In With The Rain", album_fearless, 17, "discography/fearless/come_in_with_the_rain_lyrics.txt")
        superstar = Song("Superstar", album_fearless, 18, "discography/fearless/superstar_lyrics.txt")
        the_other_side_of_the_door = Song("The Other Side of the Door", album_fearless, 19, "discography/fearless/the_other_side_of_the_door_lyrics.txt")
        today_was_a_fairytale = Song("Today Was a Fairytale", album_fearless, 20, "discography/fearless/today_was_a_fairytale_lyrics.txt")
        you_all_over_me = Song("You All Over Me", album_fearless, 21, "discography/fearless/you_all_over_me_lyrics.txt")
        mr_perfectly_fine = Song("Mr.Perfectly Fine", album_fearless, 22, "discography/fearless/mr_perfectly_fine_lyrics.txt")
        we_were_happy = Song("We Were Happy", album_fearless, 23, "discography/fearless/we_were_happy_lyrics.txt")
        thats_when = Song("That's When", album_fearless, 24, "discography/fearless/thats_when_lyrics.txt")
        dont_you = Song("Don't You", album_fearless, 25, "discography/fearless/dont_you_lyrics.txt")
        bye_bye_baby = Song("Bye Bye Baby", album_fearless, 26, "discography/fearless/bye_bye_baby_lyrics.txt")

        # speak now songs
        mine = Song("Mine", album_speaknow, 1, "discography/speaknow/mine_lyrics.txt")
        sparks_fly = Song("Sparks Fly", album_speaknow, 2, "discography/speaknow/sparks_fly_lyrics.txt")
        back_to_december = Song("Back to December", album_speaknow, 3, "discography/speaknow/back_to_december_lyrics.txt")
        speak_now = Song("Speak Now", album_speaknow, 4, "discography/speaknow/speak_now_lyrics.txt")
        dear_john = Song("Dear John", album_speaknow, 5, "discography/speaknow/dear_john_lyrics.txt")
        mean = Song("Mean", album_speaknow,6, "discography/speaknow/mean_lyrics.txt")
        the_story_of_us = Song("The Story of Us", album_speaknow, 7, "discography/speaknow/the_story_of_us_lyrics.txt")
        never_grow_up = Song("Never Grow Up", album_speaknow, 8, "discography/speaknow/never_grow_up_lyrics.txt")
        enchanted = Song("Enchanted", album_speaknow, 9, "discography/speaknow/enchanted_lyrics.txt")
        better_than_revenge = Song("Better Than Revenge", album_speaknow, 10, "discography/speaknow/better_than_revenge_lyrics.txt")
        innocent = Song("Innocent", album_speaknow, 11, "discography/speaknow/innocent_lyrics.txt")
        haunted = Song("Haunted", album_speaknow,12, "discography/speaknow/haunted_lyrics.txt")
        last_kiss = Song("Last Kiss", album_speaknow, 13, "discography/speaknow/last_kiss_lyrics.txt")
        long_live = Song("Long Live", album_speaknow, 14, "discography/speaknow/long_live_lyrics.txt")

        # red songs
        state_of_grace = Song("State of Grace", album_red, 1, "discography/red/state_of_grace_lyrics.txt")
        red = Song("Red", album_red, 2, "discography/red/red_lyrics.txt")
        treacherous = Song("Treacherous", album_red, 3, "discography/red/treacherous_lyrics.txt")
        i_knew_you_were_trouble = Song("I Knew You Were Trouble", album_red, 4, "discography/red/i_knew_you_were_trouble_lyrics.txt")
        all_too_well = Song("All Too Well", album_red, 5, "discography/red/all_too_well_lyrics.txt")
        _22 = Song("22", album_red, 6, "discography/red/22_lyrics.txt")
        i_almost_do = Song("I Almost Do", album_red, 7, "discography/red/i_almost_do_lyrics.txt")
        we_are_never_ever_getting_back_together = Song("We Are Never Ever Getting Back Together", album_red, 8,
        "discography/red/we_are_never_ever_getting_back_together_lyrics.txt")
        stay_stay_stay = Song("Stay Stay Stay", album_red, 9, "discography/red/stay_stay_stay_lyrics.txt")
        the_last_time = Song("The Last Time", album_red, 10, "discography/red/the_last_time_lyrics.txt")
        holy_ground = Song("Holy Ground", album_red, 11, "discography/red/holy_ground_lyrics.txt")
        sad_beautiful_tragic = Song("Sad Beautiful Tragic", album_red, 12, "discography/red/sad_beautiful_tragic_lyrics.txt")
        the_lucky_one = Song("The Lucky One", album_red, 13, "discography/red/the_lucky_one_lyrics.txt")
        everything_has_changed = Song("Everything Has Changed", album_red, 14, "discography/red/everything_has_changed_lyrics.txt")
        starlight = Song("Starlight", album_red, 15, "discography/red/starlight_lyrics.txt")
        begin_again = Song("Begin Again", album_red, 16, "discography/red/begin_again_lyrics.txt")
        the_moment_i_knew = Song("The Moment I Knew", album_red, 17, "discography/red/the_moment_i_knew_lyrics.txt")
        come_back_be_here = Song("Come Back...Be Here", album_red, 18, "discography/red/come_back_be_here_lyrics.txt")
        girl_at_home = Song("Girl At Home", album_red, 19, "discography/red/girl_at_home_lyrics.txt")

        # 1989 songs
        welcome_to_new_york = Song("Welcome to New York", album_1989, 1, "discography/1989/welcome_to_new_york_lyrics.txt")
        blank_space = Song("Blank Space", album_1989, 2, "discography/1989/blank_space_lyrics.txt")
        style = Song("Style", album_1989, 3, "discography/1989/style_lyrics.txt")
        out_of_the_woods = Song("Out of the Woods", album_1989, 4, "discography/1989/out_of_the_woods_lyrics.txt")
        all_you_had_to_do_was_stay = Song("All You Had To Do Was Stay", album_1989, 5, "discography/1989/all_you_had_to_do_was_stay_lyrics.txt")
        shake_it_off = Song("Shake It Off", album_1989, 6, "discography/1989/shake_it_off_lyrics.txt")
        i_wish_you_would = Song("I Wish You Would", album_1989, 7, "discography/1989/i_wish_you_would_lyrics.txt")
        bad_blood = Song("Bad Blood", album_1989, 8, "discography/1989/bad_blood_lyrics.txt")
        wildest_dreams = Song("Wildest Dreams", album_1989, 9, "discography/1989/wildest_dreams_lyrics.txt")
        how_you_get_the_girl = Song("How You Get The Girl", album_1989, 10, "discography/1989/how_you_get_the_girl_lyrics.txt")
        this_love = Song("This Love", album_1989, 11, "discography/1989/this_love_lyrics.txt")
        i_know_places = Song("I Know Places", album_1989, 12, "discography/1989/i_know_places_lyrics.txt")
        clean = Song("Clean", album_1989, 13, "discography/1989/clean_lyrics.txt")
        wonderland = Song("Wonderland", album_1989, 14, "discography/1989/wonderland_lyrics.txt")
        you_are_in_love = Song("You Are In Love", album_1989, 15, "discography/1989/you_are_in_love_lyrics.txt")
        new_romantics = Song("New Romantics", album_1989, 16, "discography/1989/new_romantics_lyrics.txt")

        # reputation songs
        ready_for_it = Song("...Ready For It?", album_reputation, 1, "discography/reputation/ready_for_it_lyrics.txt")
        end_game = Song("End Game", album_reputation, 2, "discography/reputation/end_game_lyrics.txt")
        i_did_something_bad = Song("I Did Something Bad", album_reputation, 3, "discography/reputation/i_did_something_bad_lyrics.txt")
        dont_blame_me = Song("Don't Blame Me", album_reputation, 4, "discography/reputation/dont_blame_me_lyrics.txt")
        delicate = Song("Delicate", album_reputation, 5, "discography/reputation/delicate_lyrics.txt")
        look_what_you_made_me_do = Song("Look What You Made Me Do", album_reputation, 6,
        "discography/reputation/look_what_you_made_me_do_lyrics.txt")
        so_it_goes = Song("So It Goes...", album_reputation, 7, "discography/reputation/so_it_goes_lyrics.txt")
        gorgeous = Song("Gorgeous", album_reputation, 8, "discography/reputation/gorgeous_lyrics.txt")
        getaway_car = Song("Getaway Car", album_reputation, 9, "discography/reputation/getaway_car_lyrics.txt")
        king_of_my_heart = Song("King of my Heart", album_reputation, 10, "discography/reputation/king_of_my_heart_lyrics.txt")
        dancing_with_our_hands_tied = Song("Dancing With Our Hands Tied", album_reputation, 11,
        "discography/reputation/dancing_with_our_hands_tied_lyrics.txt")
        dress = Song("Dress", album_reputation, 12, "discography/reputation/dress_lyrics.txt")
        this_is_why_we_cant_have_nice_things = Song("This Is Why We Can't Have Nice Things", album_reputation, 13,
         "discography/reputation/this_is_why_we_cant_have_nice_things_lyrics.txt")
        call_it_what_you_want = Song("Call It What You Want", album_reputation, 14, "discography/reputation/call_it_what_you_want_lyrics.txt")
        new_years_day = Song("New Year's Day", album_reputation, 15, "discography/reputation/new_years_day_lyrics.txt")

        # lover songs
        i_forgot_that_you_existed = Song("I Forgot That You Existed", album_lover, 1, "discography/lover/i_forgot_that_you_existed_lyrics.txt")
        cruel_summer = Song("Cruel Summer", album_lover, 2, "discography/lover/cruel_summer_lyrics.txt")
        lover = Song("Lover", album_lover, 3, "discography/lover/lover_lyrics.txt")
        the_man = Song("The Man", album_lover, 4, "discography/lover/the_man_lyrics.txt")
        the_archer = Song("The Archer", album_lover, 5, "discography/lover/the_archer_lyrics.txt")
        i_think_he_knows = Song("I Think He Knows", album_lover, 6, "discography/lover/i_think_he_knows_lyrics.txt")
        miss_americana_and_the_heartbreak_prince = Song("Miss Americana & The Heartbreak Prince", album_lover,
        7, "discography/lover/miss_americana_and_the_heartbreak_prince_lyrics.txt")
        paper_rings = Song("Paper Rings", album_lover, 8, "discography/lover/paper_rings_lyrics.txt")
        cornelia_street = Song("Cornelia Street", album_lover, 9, "discography/lover/cornelia_street_lyrics.txt")
        death_by_a_thousand_cuts = Song("Death by a Thousand Cuts", album_lover, 10,
        "discography/lover/death_by_a_thousand_cuts_lyrics.txt")
        london_boy = Song("London Boy", album_lover, 11, "discography/lover/london_boy_lyrics.txt")
        soon_youll_get_better = Song("Soon You'll Get Better", album_lover, 12,
        "discography/lover/soon_youll_get_better_lyrics.txt")
        false_god = Song("False God", album_lover, 13, "discography/lover/false_god_lyrics.txt")
        you_need_to_calm_down = Song("You Need To Calm Down", album_lover, 14,
        "discography/lover/you_need_to_calm_down_lyrics.txt")
        afterglow = Song("Afterglow", album_lover, 15, "discography/lover/afterglow_lyrics.txt")
        me = Song("ME!", album_lover, 16, "discography/lover/me_lyrics.txt")
        its_nice_to_have_a_frend = Song("It's Nice To Have A Friend", album_lover,
        17, "discography/lover/its_nice_to_have_a_friend_lyrics.txt")
        daylight = Song("Daylight", album_lover, 18, "discography/lover/daylight_lyrics.txt")


        # folklore songs
        the_1 = Song("The 1", album_folklore, 1, "discography/folklore/the_1_lyrics.txt")
        cardigan = Song("cardigan", album_folklore, 2, "discography/folklore/cardigan_lyrics.txt")
        the_last_great_american_dynasty = Song("the last great american dynasty", album_folklore, 3,
        "discography/folklore/the_last_great_american_dynasty_lyrics.txt")
        exile = Song("exile", album_folklore, 4, "discography/folklore/exile_lyrics.txt")
        my_tears_ricochet = Song("my tears ricochet", album_folklore, 5, "discography/folklore/my_tears_ricochet_lyrics.txt")
        mirrorball = Song("mirrorball", album_folklore, 6, "discography/folklore/mirrorball_lyrics.txt")
        seven = Song("seven", album_folklore, 7, "discography/folklore/seven_lyrics.txt")
        august = Song("august", album_folklore, 8, "discography/folklore/august_lyrics.txt")
        this_is_me_trying = Song("this is my trying", album_folklore, 9, "discography/folklore/this_is_me_trying_lyrics.txt")
        illicit_affairs = Song("illicit affairs", album_folklore,  10, "discography/folklore/illicit_affairs_lyrics.txt")
        invisible_string = Song("invisible string", album_folklore, 11, "discography/folklore/invisible_string_lyrics.txt")
        mad_woman = Song("mad woman", album_folklore, 12, "discography/folklore/mad_woman_lyrics.txt")
        epiphany = Song("epiphany", album_folklore, 13, "discography/folklore/epiphany_lyrics.txt")
        betty = Song("betty", album_folklore, 14, "discography/folklore/betty_lyrics.txt")
        peace = Song("peace", album_folklore, 15, "discography/folklore/peace_lyrics.txt")
        hoax = Song("hoax", album_folklore, 16, "discography/folklore/hoax_lyrics.txt")
        the_lakes = Song("the lakes", album_folklore, 17, "discography/folklore/the_lakes_lyrics.txt")

        listofsongs = [tim_mcgraw, picture_to_burn, teardrops_on_my_guitar,
        a_place_in_this_world, cold_as_you, the_outside, tied_together_with_a_smile, stay_beautiful, shouldve_said_no,
        marys_song, our_song, im_only_me_when_im_with_you, invisible, a_perfectly_good_heart, mine, sparks_fly, back_to_december,
        speak_now, dear_john, mean, the_story_of_us, never_grow_up, enchanted, better_than_revenge, innocent,
        haunted, last_kiss, long_live, fearless, fifteen, love_story, hey_stephen, white_horse, you_belong_with_me, breathe,
        tell_me_why, youre_not_sorry, the_way_i_loved_you, forever_and_always, the_best_day, change, come_in_with_the_rain, jump_then_fall, superstar,
                       the_other_side_of_the_door, today_was_a_fairytale, untouchable, mr_perfectly_fine, dont_you, bye_bye_baby, thats_when, we_were_happy, you_all_over_me,
                       forever_and_always_piano,
        state_of_grace, red, treacherous, i_knew_you_were_trouble, all_too_well, _22, i_almost_do,
        we_are_never_ever_getting_back_together, stay_stay_stay, the_last_time, holy_ground, sad_beautiful_tragic,
        the_lucky_one, everything_has_changed, starlight, begin_again, the_moment_i_knew, come_back_be_here,
        girl_at_home,
        welcome_to_new_york, blank_space,style, out_of_the_woods, all_you_had_to_do_was_stay, shake_it_off,
        i_wish_you_would, bad_blood, how_you_get_the_girl, this_love, i_know_places,clean,you_are_in_love,
        wonderland, wildest_dreams, new_romantics,
        ready_for_it, end_game, i_did_something_bad, dont_blame_me, delicate, look_what_you_made_me_do,
        so_it_goes, gorgeous, getaway_car, king_of_my_heart, dancing_with_our_hands_tied, dress, this_is_why_we_cant_have_nice_things,
        call_it_what_you_want, new_years_day,
        i_forgot_that_you_existed, cruel_summer, lover, the_man, the_archer, i_think_he_knows, miss_americana_and_the_heartbreak_prince,
        paper_rings, cornelia_street, death_by_a_thousand_cuts, london_boy, soon_youll_get_better, false_god, you_need_to_calm_down,
        afterglow, me, its_nice_to_have_a_frend, daylight,
        the_1, cardigan, the_last_great_american_dynasty, exile, my_tears_ricochet, mirrorball, seven, august, this_is_me_trying,
        illicit_affairs, invisible_string, mad_woman, epiphany, betty, peace, hoax, the_lakes]

        listofalbums = [album_taylorswift, album_fearless, album_speaknow, album_red, album_1989, album_reputation,
        album_lover, album_folklore]
        for s in listofsongs:
            for a in listofalbums:
                if s.getAlbum() == a:
                    a.addSongToAlbum(s)

        disc = Discography([])
        for a in listofalbums:
            disc.addAlbum(a)
        return disc
コード例 #16
0
 def test_empty_album(self):
     album = Album('title', 2020)
     assert list(album.songs()) == []
コード例 #17
0
ファイル: test_album.py プロジェクト: MayerMax/AudioAlbum
 def setting_up_album(self, path=''):
     return Album(album_path=path)
コード例 #18
0
 def test_one_song_album(self):
     album = Album('album title', 2020)
     song = Song('song title')
     album.add(song)
     assert list(album.songs()) == [song]
コード例 #19
0
 def add_item(self):
     collection = self.choose_collection()
     if not collection:
         pass
     else:
         item_type = input(
             f"What you want to add to collection {collection.f__name}?\n"
             f"(book - press b; movie - press m; album - press a):")
         while item_type != 'b' and item_type != 'm' and item_type != 'a':
             item_type = input(
                 f"What you want to add to collection {collection.f__name}?\n"
                 f"(book - press b; movie - press m; album - press a):")
         print()
         if item_type == 'b':
             if len(collection.f__book_collection
                    ) < self.__user.f__max_collections():
                 new_book = Book()
                 new_book.write_data()
                 collection.f__book_collection.append(new_book)
                 print(
                     f"\nItem successfully added to your collection {collection.f__name}.\n"
                     f"At the moment in this collection you have: "
                     f"{len(collection.f__book_collection)} books, "
                     f"{len(collection.f__movie_collection)} movies and "
                     f"{len(collection.f__album_collection)} albums.\n")
             else:
                 print(
                     "You can't add new book. You have maximum amount of books in that collection.\n"
                     "If you want you can modify or delete existing books.\n"
                 )
         elif item_type == 'm':
             if len(collection.f__movie_collection
                    ) < self.__user.f__max_collections():
                 new_movie = Movie()
                 new_movie.write_data()
                 collection.f__movie_collection.append(new_movie)
                 print(
                     f"\nItem successfully added to your collection {collection.f__name}\n"
                     f"At the moment in this collection you have: "
                     f"{len(collection.f__book_collection)} books, "
                     f"{len(collection.f__movie_collection)} movies and "
                     f"{len(collection.f__album_collection)} albums.")
             else:
                 print(
                     "You can't add new movie. You have maximum amount of movies in that collection.\n"
                     "If you want you can modify or delete existing movies.\n"
                 )
         elif item_type == 'a':
             if len(collection.f__album_collection
                    ) < self.__user.f__max_collections():
                 new_album = Album()
                 new_album.write_data()
                 collection.f__album_collection.append(new_album)
                 print(
                     f"Item successfully added to your collection {collection.f__name}\n"
                     f"At the moment in this collection you have: "
                     f"{len(collection.f__book_collection)} books, "
                     f"{len(collection.f__movie_collection)} movies and "
                     f"{len(collection.f__album_collection)} albums.")
             else:
                 print(
                     "You can't add new album. You have maximum amount of albums in that collection.\n"
                     "If you want you can modify or delete existing albums.\n"
                 )
         self.exit_to_menu()
コード例 #20
0
 def test_equality_for_same_empty_albums(self):
     first_album = Album('album title', 2020)
     second_album = Album('album title', 2020)
     assert first_album == second_album
コード例 #21
0
from album import Album
from artist import Artist
from song import Song
from datetime import timedelta, date

# create an artist
rhcp = Artist('Red Hot Chili Peppers', ['Rock'],
              ['Flea', 'Anthony Kiedis', 'Chad Smith', 'Josh Klinghoffer'])
print('Artist:', rhcp.name)

# create an album and add it to rhcp
rhcp.albums.append(Album('Stadium Arcadium', date(2006, 5, 9)))
print('Album:', rhcp.albums)

# add songs to the album
t1 = Song('Dani California', timedelta(minutes=4, seconds=42),
          date(2006, 5, 9))
t2 = Song('Snow (Hey Oh)', timedelta(minutes=5, seconds=34), date(2006, 5, 9))
t3 = Song('Charlie', timedelta(minutes=4, seconds=37), date(2006, 5, 9))

# this is messy imo, but necessary if data is stored in lists
# and you want to access a specific element
for a in rhcp.albums:
    if a.title == 'Stadium Arcadium':
        a.songs += [t1, t2, t3]

# print the number of songs and total duration for each album
for a in rhcp.albums:
    print('Album: "{}", # of Songs: {}, Total Duration: {}'.format(
        a.title, a.count_songs(), a.totalDuration()))
コード例 #22
0
 def test_equality_for_different_empty_albums(self):
     first_album = Album('album title', 2020)
     second_album = Album('other album title', 2020)
     newer_album = Album('album title', 2021)
     assert first_album != second_album
     assert first_album != newer_album
コード例 #23
0
ファイル: song.py プロジェクト: PetkoAndreev/Python-OOP
from album import Album
from band import Band


class Song:
    def __init__(self, name, length, single):
        self.name = name
        self.length = length
        self.single = single

    def get_info(self):
        return f'{self.name} - {self.length}'


song = Song("Running in the 90s", 3.45, False)
print(song.get_info())
album = Album("Initial D", song)
second_song = Song("Around the World", 2.34, False)
print(album.add_song(second_song))
print(album.details())
print(album.publish())
band = Band("Manuel")
print(band.add_album(album))
print(band.remove_album("Initial D"))
print(band.details())
コード例 #24
0
 def test_equality_for_same_albums_with_songs(self):
     first_album = Album('album title', 2020)
     second_album = Album('album title', 2020)
     first_album.add(Song('same song'))
     second_album.add(Song('same song'))
     assert first_album == second_album
コード例 #25
0
ファイル: menu.py プロジェクト: SanderPaasalu/ITA19_kordamine
laulud = []
lauljad = []
albumid = []

artist = []
album = []
l1 = []
# võtab välja tabelist laulud, lauljad ja albumid
for line in tabel:
    laulja = Laulja(line[0])
    if line[0] not in artist:
        lauljad.append(laulja)
        artist.append(line[0])
        laulja.albumid.append(line[1])
for line in tabel:
    albumi = Album(line[1], line[0], line[2])
    if line[1] not in album:
        albumid.append(albumi)
        album.append(line[1])
for line in tabel:
    laul = Laul(line[3], line[1], line[0], line[2])
    if line[3] not in l1:
        laulud.append(laul)
        l1.append(line[3])
# mida otsid uuritakse
program = True

# Funktioon, mis  aitab otsida seda mida kasutaja soovib


def otsing1(otsing):
コード例 #26
0
 def test_to_and_from_str_empty(self):
     album = Album('album title', 2020)
     assert Album.from_string(str(album)) == album
コード例 #27
0
ファイル: band_test.py プロジェクト: nkolew/Softuni-Python
 def test_remove_album_not_found(self):
     band = Band("Death")
     album = Album("The Sound of Perseverance")
     message = band.remove_album("The Sound of Perseverance")
     expected = "Album The Sound of Perseverance is not found."
     self.assertEqual(message, expected)
コード例 #28
0
 def test_to_and_from_str_single_track(self):
     album = Album('album title', 2020)
     album.add(Song('song title'))
     assert Album.from_string(str(album)) == album
コード例 #29
0
ファイル: band_test.py プロジェクト: nkolew/Softuni-Python
 def test_add_song_working(self):
     album = Album("The Sound of Perseverance")
     song = Song("Scavenger of Human Sorrow", 6.56, False)
     message = album.add_song(song)
     expected = "Song Scavenger of Human Sorrow has been added to the album The Sound of Perseverance."
     self.assertEqual(message, expected)
コード例 #30
0
 def setUp(self):
     self.movie = Movie()
     self.book = Book()
     self.album = Album()
     self.collection = Collection("Collection", [self.movie], [self.book],
                                  [self.album])