Skip to content

Commit

Permalink
Merge pull request #6 from IPLSplatoon/1.2.3-not-bracket-data
Browse files Browse the repository at this point in the history
Various fixes 1.2.3
  • Loading branch information
vlee489 authored Oct 8, 2024
2 parents 7fe1d4c + f245f2f commit 0b98e9b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "sendou-py"
version = "1.2.2"
version = "1.2.3"
description = "An async Python library for Sendou.ink"
authors = [ "Vincent Lee <[email protected]>",]
license = "MIT"
Expand Down
7 changes: 5 additions & 2 deletions sendou/models/tournament/bracket/Standing.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,15 @@ class BracketStanding:
"""
tournament_team_id: int
placement: int
stats: StandingStats
stats: Optional[StandingStats]

def __init__(self, data: dict):
self.tournament_team_id = data.get("tournamentTeamId", 0)
self.placement = data.get("placement", 0)
self.stats = StandingStats.from_dict(data.get("stats", {}))
if stats := data.get("stats", {}):
self.stats = StandingStats.from_dict(stats)
else:
self.stats = None

@staticmethod
def api_route(**kwargs) -> str:
Expand Down
6 changes: 6 additions & 0 deletions sendou/models/tournament/bracket/bracket.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,19 @@ def __init__(self, data: dict, request_client: RequestsClient):
self.opponent1 = BracketMatchOpponent(data.get("opponent1", {}))
if data.get("opponent2", {}):
self.opponent2 = BracketMatchOpponent(data.get("opponent2", {}))
else:
self.opponent2 = None
self.round_id = data.get("round_id", 0)
self.stage_id = data.get("stage_id", 0)
self.status = data.get("status", 0)
if data.get("lastGameFinishedAt", None):
self.lastGameFinishedAt = datetime.fromtimestamp(data.get("lastGameFinishedAt", 0), tz=timezone.utc)
else:
self.lastGameFinishedAt = None
if data.get("createdAt", None):
self.createdAt = datetime.fromtimestamp(data.get("createdAt", 0), tz=timezone.utc)
else:
self.createdAt = None

async def get_match(self) -> Optional[Match]:
"""
Expand Down
10 changes: 7 additions & 3 deletions sendou/models/tournament/tournament.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,19 @@ def __init__(self, data: dict, index: int, tournament_id: int, request_client: R
self._index = index
self.__tournament_id = tournament_id

async def get_bracket_data(self) -> Bracket:
async def get_bracket_data(self) -> Optional[Bracket]:
"""
Get the detailed bracket data
Get the detailed bracket data, if bracket has details.
*Here are cases where Brackets haven't been played so no data exists*
Returns:
(Bracket): Bracket Data
(Optional[Bracket]): Bracket Data
"""
path = Bracket.api_route(tournament_id=self.__tournament_id, bracket_index=self._index)
data = await self._request_client.get_response(path)
if not data.get("match", []):
return
return Bracket(data, self._request_client)

async def get_standings(self) -> List[BracketStanding]:
Expand Down

0 comments on commit 0b98e9b

Please sign in to comment.