Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes 1.2.3 #6

Merged
merged 5 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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