-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdivision.py
59 lines (53 loc) · 1.64 KB
/
division.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from dataclasses import dataclass
from typing import Optional, Union
from mlbstatsapi.models.leagues import League
# from mlbstatsapi.models.sports import Sport
@dataclass(repr=False)
class Division:
"""
A class to represent a division.
Attributes
----------
id : int
id number of the divison
name : str
name of the division
link : str
link of the division
season : str
Current season for the division
nameshort : str
Short name for the division
abbreviation : str
Abbreviation of the divison name
league : League
League this division is in
sport : Sport
Sport this divison is in
haswildcard : bool
If this league has a wildcard
sortorder : int
Sort order
numplayoffteams : int
Number of playoff teams in division
active : bool
Current status of this division
"""
id: int
link: str
name: Optional[str] = None
season: Optional[str] = None
nameShort: Optional[str] = None
abbreviation: Optional[str] = None
league: dict = None
sport: dict = None
hasWildcard: Optional[bool] = None
sortOrder: Optional[int] = None
numPlayoffTeams: Optional[int] = None
active: Optional[bool] = None
def __post_init__(self):
self.league = League(**self.league) if self.league else self.league
# self.sport = Sport(**self.sport) if self.sport else self.sport
def __repr__(self) -> str:
kws = [f'{key}={value}' for key, value in self.__dict__.items() if value is not None and value]
return "{}({})".format(type(self).__name__, ", ".join(kws))