Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1"""LICENSE 

2Copyright 2020 Hermann Krumrey <hermann@krumreyh.com> 

3 

4This file is part of betbot. 

5 

6betbot is free software: you can redistribute it and/or modify 

7it under the terms of the GNU General Public License as published by 

8the Free Software Foundation, either version 3 of the License, or 

9(at your option) any later version. 

10 

11betbot is distributed in the hope that it will be useful, 

12but WITHOUT ANY WARRANTY; without even the implied warranty of 

13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

14GNU General Public License for more details. 

15 

16You should have received a copy of the GNU General Public License 

17along with betbot. If not, see <http://www.gnu.org/licenses/>. 

18LICENSE""" 

19 

20from typing import Dict, Any 

21 

22 

23class Match: 

24 """ 

25 Class that encapsulates information about a Match 

26 """ 

27 

28 def __init__( 

29 self, 

30 league: str, 

31 season: str, 

32 matchday: int, 

33 home_team: str, 

34 away_team: str, 

35 finished: bool 

36 ): 

37 """ 

38 Initializes the Match 

39 :param _id: The ID of the match 

40 :param matchday: The matchday of the match 

41 :param home_team: The name of the home team 

42 :param away_team: The name of the away team 

43 :param finished: Whether the match is already finished or not 

44 """ 

45 self.league = league 

46 self.season = season 

47 self.matchday = matchday 

48 self.home_team = home_team 

49 self.away_team = away_team 

50 self.finished = finished 

51 

52 @classmethod 

53 def from_json( 

54 cls, 

55 json_data: Dict[str, Any] 

56 ): 

57 """ 

58 Generates a Match object from JSON data 

59 :param json_data: The JSON data 

60 :return: The generated Match 

61 """ 

62 return cls( 

63 json_data["league"], 

64 json_data["season"], 

65 json_data["matchday"], 

66 json_data["home_team_abbreviation"], 

67 json_data["away_team_abbreviation"], 

68 json_data["finished"] 

69 )