def respond(voice_data): if "football" in voice_data: speak.Speak("is it today match, odds , team or team points") if "today match" in voice_data: all_matches = sports.all_matches() football = all_matches[sports.FOOTBALL] speak.Speak(football) if "odds" in voice_data: speak.Speak("which match odds are you looking for") sports = sports.get_sport(sports.FOOTBALL) speak.Speak = (sports.ODDS, odd) if "odds" in voice_data: speak.Speak("which match points are you looking for") sports = sports.get_sport(sports.FOOTBALL) print = (sports.POINTS, points) else: if "team" in voice_data: speak.Speak("which team") voice_data = '' football = sports.get_team(sports.FOOTBALL, team) speak.Speak(football) else: if "tennis" in voice_data: speak.Speak("is it today match or player name or odds") if "today match" in voice_data: all_matches = sports.all_matches() tennis = all_matches[sports.TENNIS] speak.Speak(tennis) if "odds" in voice_data: speak.Speak("which match odds are you looking for") sports = sports.get_sport(sports.TENNIS) speak.Speak = (sports.ODDS, odd) else: if "player name" in voice_data: speak.Speak("which player") print("--------------") team = input("----") print("--------------") tennis = sports.get_team(sports.TENNIS, team) print(tennis) time.sleep(1) while 1: voice_data = record_audio() respond(voice_data)
def get_scores(sport): if sport == 1: scores = sports.get_sport(sports.FOOTBALL) elif sport == 2: scores = sports.get_sport(sports.SOCCER) elif sport == 3: scores = sports.get_sport(sports.BASKETBALL) elif sport == 4: scores = sports.get_sport(sports.BASEBALL) elif sport == 5: scores = sports.get_sport(sports.HOCKEY) elif sport == 6: scores = sports.get_sport(sports.TENNIS) elif sport == 7: scores = sports.get_sport(sports.RUGBY_L) elif sport == 8: scores = sports.get_sport(sports.VOLLEYBALL) elif sport == 9: scores = sports.get_sport(sports.CRICKET) elif sport == 10: scores = sports.get_sport(sports.HANDBALL) elif sport == 11: scores = sports.get_sport(sports.RUGBY_U) elif sport == 12: # this is for specific teams team_name = str(input("Type the name of a baseball team: ")) team_data = sports.get_team("baseball", team_name) elif sport == 13: # this is for specific teams team_name = str(input("Type the name of a football team: ")) team_data = sports.get_team("football", team_name) elif sport == 14: # this is for specific teams team_name = str(input("Type the name of a hockey team: ")) team_data = sports.get_team("hockey", team_name) elif sport == 15: # this is for specific teams team_name = str(input("Type the name of a basketball team: ")) team_data = sports.get_team("basketball", team_name) if sport < 12: # if it is just a sport for score in scores: print(score) else: print(team_data)
import sports giants = sports.get_team(sports.FOOTBALL, 'giants') jets = sports.get_team(sports.FOOTBALL, 'jets') devils = sports.get_team(sports.HOCKEY, 'devils') teams = [{ 'name': devils.name, 'link': 'https://www.nhl.com/devils/', 'record': devils.record, 'won': '3' }, { 'name': giants.name, 'link': 'https://www.giants.com/', 'record': giants.record, 'won': '8' }, { 'name': jets.name, 'link': 'https://www.newyorkjets.com/', 'record': jets.record, 'won': '1' }, { 'name': 'Red Bulls', 'link': 'https://www.newyorkredbulls.com/', 'record': '5-11-0', 'won': '5' }, { 'name': 'NJ Jackals', 'link': 'http://njjackals.pointstreaksites.com/view/njjackals', 'record': '62-27', 'won': '10'
def test_get_teams(self): self.assertIsNotNone(sports.get_team(sports.FOOTBALL, 'steelers')) self.assertIsNotNone(sports.get_team(sports.HOCKEY, 'penguins')) self.assertIsNotNone(sports.get_team(sports.BASKETBALL, '76ers')) self.assertIsNotNone(sports.get_team(sports.BASEBALL, 'pirates'))
class TestScores(unittest.TestCase): hockey_data = { 'league': 'NHL', 'home_team': 'Pittsburgh Penguins', 'away_team': 'Nashville Predators', 'home_score': '2', 'away_score': '0', 'match_date': 'Sat, 19 Aug 2017 02:12:05 GMT', 'match_time': 'Game Finished', 'match_link': 'test', } hockey_match = sports.scores.Match(sports.HOCKEY, hockey_data) steelers = sports.get_team(sports.FOOTBALL, 'steelers') def test_xml(self): try: sports.scores._request_xml(sports.BASEBALL) except sports.errors.SportError: self.fail('XML request raised SportError') self.assertRaises(sports.errors.SportError, sports.scores._request_xml, 'fake sport') def test_match(self): self.assertIsNotNone(self.hockey_match) self.assertEqual(str(self.hockey_match), 'Pittsburgh Penguins 2-0 Nashville Predators') self.assertEqual(repr(self.hockey_match), 'Pittsburgh Penguins 2-0 Nashville Predators') self.assertIsNotNone(sports.all_matches()) def test_teams(self): self.assertEqual(self.hockey_match.home_team, 'Pittsburgh Penguins') self.assertEqual(self.hockey_match.away_team, 'Nashville Predators') def test_score(self): self.assertEqual(self.hockey_match.home_score, 2) self.assertEqual(self.hockey_match.away_score, 0) def test_date(self): self.assertIsNotNone(self.hockey_match.match_date) def test_sport(self): self.assertEqual(self.hockey_match.sport, sports.HOCKEY) self.assertIsNotNone(sports.get_sport(sports.SOCCER)) def test_get_teams(self): self.assertIsNotNone(sports.get_team(sports.FOOTBALL, 'steelers')) self.assertIsNotNone(sports.get_team(sports.HOCKEY, 'penguins')) self.assertIsNotNone(sports.get_team(sports.BASKETBALL, '76ers')) self.assertIsNotNone(sports.get_team(sports.BASEBALL, 'pirates')) def test_errors(self): sport = sports.FOOTBALL teams = ['steelers', 'patriots'] self.assertEqual(str(sports.errors.MatchError(sport, teams)), 'Football match not found for steelers, patriots') self.assertEqual(str(sports.errors.SportError('fake sport')), 'Sport not found for fake sport') self.assertEqual(str(sports.errors.StatsError(sport)), 'Extra stats not yet supported for football') self.assertEqual(str(sports.errors.TeamError(sport, teams[0])), 'Team steelers not found for sport football') self.assertRaises(sports.errors.StatsError, sports.get_team, 'fake sport', 'fake team')
import sports # De onde vem os dados (biblioteca) print("Welcome to the NFL world!\n") # Apresentação team = input("Insert NFL team name and get all info: ") # Inserir dados equipe = sports.get_team(sports.FOOTBALL, team) # Onde os dados são colocados # Dados fornecidos print("Team name: ",equipe.name) print("Seasons: ",equipe.seasons) print("Record: ",equipe.record) print("Champs: ",equipe.champs) print("Super bowls winning: ",equipe.super_bowls) print("Team leaders: ",equipe.leaders)
if len(argumentList) == 2: sport = argumentList[1].lower() if sport in sports_dict.keys(): all_matches = sports.all_matches()[sport] for match in all_matches: print(match) else: print("This sport details are not supported yet") if len(argumentList) == 3: sport = argumentList[1].lower() if (sport == "baseball" or sport == "basketball" or sport == "football" or sport == "hockey"): sport = sports_dict.get(sport) team = argumentList[2].lower() team_info = sports.get_team(sport, team) print(team_info) else: print("This sport details are not supported yet") if len(argumentList) == 4: sport = argumentList[1].lower() if sport in sports_dict.keys(): sport = sports_dict.get(sport) team1 = argumentList[2].lower() team2 = argumentList[3].lower() match_info = sports.get_match(sport, team1, team2) print(match_info) else: print("This sport details are not supported yet")