コード例 #1
0
ファイル: band_test.py プロジェクト: nkolew/Softuni-Python
 def test_remove_album_working(self):
     band = Band("Death")
     album = Album("The Sound of Perseverance")
     band.add_album(album)
     message = band.remove_album("The Sound of Perseverance")
     expected = "Album The Sound of Perseverance has been removed."
     self.assertEqual(message, expected)
コード例 #2
0
ファイル: band_test.py プロジェクト: nkolew/Softuni-Python
 def test_add_album_already_added(self):
     band = Band("Death")
     album = Album("The Sound of Perseverance")
     band.add_album(album)
     message = band.add_album(album)
     expected = "Band Death already has The Sound of Perseverance in their library."
     self.assertEqual(message, expected)
コード例 #3
0
ファイル: band_test.py プロジェクト: nkolew/Softuni-Python
 def test_remove_album_published(self):
     band = Band("Death")
     album = Album("The Sound of Perseverance")
     album.publish()
     band.add_album(album)
     message = band.remove_album("The Sound of Perseverance")
     expected = "Album has been published. It cannot be removed."
     self.assertEqual(message, expected)
コード例 #4
0
ファイル: song.py プロジェクト: shehabeldeen555/Musicaly
 def get_featured(self):
     if self.ft_type == "Artist":
         artist = Artist()
         artist.load(self.ft_id)
         return artist
     elif self.ft_type == "Band":
         band = Band()
         band.load(self.ft_id)
         return band
     else:
         return "No"
コード例 #5
0
ファイル: song.py プロジェクト: shehabeldeen555/Musicaly
 def get_artist(self):
     if self.artist_type == "Artist":
         artist = Artist()
         artist.load(self.artist_id)
         return artist
     elif self.artist_type == "Band":
         band = Band()
         band.load(self.artist_id)
         return band
     else:
         return "unknown"
コード例 #6
0
ファイル: main.py プロジェクト: ociule/bandgenerator
 def get(self):
   band = Band()
   band.randomize()
   band.put()
   band.fix_encoding()
   self.generate('index.html', template_values={'page_title': 'Band Generator - Generate a band!',
                                               'band' : band,
                                               })
コード例 #7
0
    def setup(self):

        self.sax = Instrument("Saxophone")
        self.guitar = Instrument("Guitar")
        self.drums = Instrument("Drums")

        self.m1 = Musician("Evan Parker", self.sax )
        self.m2 = Musician("Derek Bailey", self.guitar )
        self.m3 = Musician("Han Bennink", self.drums )

        self.lungs_band = Band("Lungs Band", [self.m1, self.m2, self.m3])
コード例 #8
0
ファイル: main.py プロジェクト: ociule/bandgenerator
  def get(self, band_id):
    try:
      band_id = int(band_id)
    except ValueError:
      self.generate('index.html', template_values={'page_title': '404 - Band Generator - Generate a band!',
                                                  'band' : {'name': '404'},
                                                  })
      return

    band = Band.get_by_id(band_id)
    band.fix_encoding()
    band_name = band.name if band and band.name else ""
    self.generate('index.html', template_values={'page_title': band_name + 'Band Generator - Generate a band!',
                                                'band' : band,
                                                'disqus': True,
                                                })
コード例 #9
0
ファイル: python-basics.py プロジェクト: sta516/my-isc-work
for member in band:
    if member not in counts:
        counts[member] = 1
    else:
        counts[member] += 1
for member in counts:
    print(member, counts[member])

#3:
if {}: print('hi')  #Not true, so it doesn't give a value
d = {"maggie": "uk", "ronnie": "usa"}
print(dir(d))
print(d.items())
print(d.keys())
print(d.values())
#help(d.get)
print(d.get("maggie"))
print(d.get("Someone"))
print(d.get("Anybody", "Nowhere"))

#Exercise 11: Object Oriented Programming (OOP)

#2:
from band import Band
ws = Band("The White Stripes")
ws.employ("Meg", 100)
ws.employ("Jack", 100)
ws.write_annual_report()

#3:
コード例 #10
0
import discord
import asyncio
from band import Band

from discord.ext import tasks

client = discord.Client()
channel = None
discord_token = open('id.txt', 'r').read()

band = Band()

@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')
    slow_count.start()

@client.event
async def on_message(message):
    global channel
    if message.content.startswith('!start'):
        channel = message.channel
        await channel.send('Start!')

@tasks.loop(seconds=3600.0)
async def slow_count():
    if channel != None:
コード例 #11
0
ファイル: band_test.py プロジェクト: nkolew/Softuni-Python
 def test_add_album_working(self):
     band = Band("Death")
     album = Album("The Sound of Perseverance")
     message = band.add_album(album)
     expected = "Band Death has added their newest album The Sound of Perseverance."
     self.assertEqual(message, expected)
コード例 #12
0
ファイル: band_test.py プロジェクト: nkolew/Softuni-Python
 def test_init(self):
     band = Band("Death")
     message = f"{band.name} - {len(band.albums)}"
     expected = "Death - 0"
     self.assertEqual(message, expected)
コード例 #13
0
ファイル: band_test.py プロジェクト: nkolew/Softuni-Python
 def test_details1(self):
     band = Band("Death")
     message = band.details().strip()
     expected = "Band Death"
     self.assertEqual(message, expected)
コード例 #14
0
from band import Band
from singer import Singer
from song import Song
from library import Library

# Rush band and songs
rush = Band('Rush')
rush_songs = [
    Song('Tom Sawyer', rush, 'https://www.youtube.com/watch?v=auLBLk4ibAk'),
    Song('YYZ', rush, 'https://www.youtube.com/watch?v=LdpMpfp-J_I')
]
rush.songs = rush_songs

# Transatlantic band and songs
transatlantic = Band('Transatlantic')
transatlantic_songs = [
    Song('Duel With The Devil', transatlantic,
         'https://www.youtube.com/watch?v=Phl57XmsPQ8'),
]
transatlantic.songs = transatlantic_songs

# Andrea Bocelli singer and songs
bocelli = Singer('Andrea Bocelli')
bocelli_songs = [
    Song('Con Te Partirò', bocelli,
         'https://www.youtube.com/watch?v=TdWEhMOrRpQ'),
    Song('Vivo Per Lei', bocelli,
         'https://www.youtube.com/watch?v=ciawICBvQoE'),
    Song('Il Mare Calmo Della Sera', bocelli,
         'https://www.youtube.com/watch?v=Xjl156IBVGY'),
]
コード例 #15
0
print("---------- Exercise 11 script ----------")

print("Question 1:")
from band import Band

print("Question 2:")
ws = Band("The White Stripes")
ws.employ("Meg", 100)
ws.employ("Jack", 100)
ws.write_annual_report()

print("Question 3:")
hs = Band("Hearsay")
members = ["Suzanne", "Danny", "Kym", "Myleene", "Noel"]
print(f"members: {members}")
for member in members:
    hs.employ(member, 10)
hs.write_annual_report()
hs.sack("Danny")
print("Danny has not been performing...")
print(f"Members: {hs.get_members()}")
print("Trying to employ Madonna: ")
hs.employ("Madonna", 1000000)
コード例 #16
0
from band import Band, Musician, Guitarist, Bassist, Drummer
import pytest

band_one = Band('Python Band', [Bassist('Curly Noproblem')])
band_two = Band('Typescript Band', [Drummer('Stricto Mcgee')])
band_three = Band('Javasciptt Band', [Guitarist('Loosey Whatever')])
jon = Guitarist('Jon Snow')
cersei = Bassist('Cersei')
little_finger = Drummer('Little Finger')

def test_band_instance_string_attr():
    """
    A Band instance should have a name attribute which is a string
    """
    expected = 'Python Band'
    actual = band_one.name
    assert expected == actual

def test_members_attribute_from_band():
    """
    A Band instance should have a members attribute which is a list of instances that inherit from Musician base (or super) class.
    """
    # expected = ['Drummer: Stricto Mcgee']
    # actual = band_two.members
    # assert expected == actual
    pass


def test_play_solos_method():
    """
    A Band instance should have a play_solos method that asks each member musician to play a solo, in the order they were added to band.
コード例 #17
0
from band import Band

ws = Band("The White Stripes")

ws.employ("Meg", 100)
ws.employ("Jack", 100)
ws.employ("Mary", 100)
ws.write_annual_report()

ws.get_members()

ws.sack("Mary")
ws.get_members()

ws.promote("Meg", 120)
ws.write_annual_report()
コード例 #18
0
def test_create_Band_from_data():
    data = Band = Band.create_from_data(data)
 def get_band(self, band_id):
     return Band(self, band_id)
コード例 #20
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())
コード例 #21
0
ファイル: hearsay.py プロジェクト: eers1/my-isc-work
from band import Band

hs = Band("Hearsay")

new = ["Suzanne", "Danny", "Kym", "Myleene", "Noel"]

for name in new:
    hs.employ(name, 10)

print(hs.write_annual_report())

hs.sack("Danny")
hs.get_members()

#hs.employ("Madonna", 10000000)
コード例 #22
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)
コード例 #23
0
def test_play_solo():
    assert 'all for one, one for all' == Band.get_play_solo()
コード例 #24
0
phish_11_28_03 = Show(date=phirst_show)

ph_1995 = date(1995, 12, 31)
phish_12_31_95 = Show(date=ph_1995)

cornell_77 = date(1977, 5, 8)
dead_5_8_77 = Show(date=cornell_77)

sunshine_daydream = date(1972, 8, 27)
dead_venetta = Show(date=sunshine_daydream)

dead_msg = date(1979, 1, 7)
dead_1_7_79 = Show(date=dead_msg)

# Bands
phish = Band(name='Phish')
dead = Band(name="Grateful Dead")
my_hs_garage_band = Band(name="My Band From High School")

phish.shows.extend([phish_12_31_95, phish_11_28_03])
dead.shows.extend([dead_5_8_77, dead_venetta, dead_1_7_79])
person1.shows.extend([dead_5_8_77, phish_12_31_95, phish_11_28_03])
person2.shows.extend([dead_venetta, dead_5_8_77])
person3.shows.append(dead_venetta)

# Cities
uniondale = City(name="Uniondale, NY")
veneta = City(name="Veneta, OR")
nyc = City(name="New York, NY")
ithaca = City(name="Ithaca, NY")