Skip to content

Commit

Permalink
Merge pull request #7 from IPLSplatoon/1.2.6-old-data-fix
Browse files Browse the repository at this point in the history
1.2.7 A number of fixes
  • Loading branch information
vlee489 authored Oct 9, 2024
2 parents 004b730 + 3dfb8e4 commit 5136627
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 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.6"
version = "1.2.7"
description = "An async Python library for Sendou.ink"
authors = [ "Vincent Lee <[email protected]>",]
license = "MIT"
Expand Down
6 changes: 3 additions & 3 deletions sendou/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,18 @@ async def run():
data = await self.__client.get_response(path)
return User(data, self.__client)

async def get_calendar(self, year: str, month: str) -> List[CalendarEntry]:
async def get_calendar(self, year: int, week: int) -> List[CalendarEntry]:
"""
Get Sendou.ink calendar
Attributes:
year: Year
month: Month
week: Week of year
Returns:
(List[CalendarEntry]): Calendar Entries
"""
path = CalendarEntry.api_route(year=year, month=month)
path = CalendarEntry.api_route(year=year, week=week)
data = await self.__client.get_response(path)
return [CalendarEntry(entry, self.__client) for entry in data]

Expand Down
6 changes: 3 additions & 3 deletions sendou/models/calendarEntry.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ def api_route(**kwargs) -> str:
"""
API Route
Args:
year (str): Year
month (str): Month
year (int): Year
week (int): week
Returns:
str: API Route
"""
return f"api/calendar/{kwargs.get('year')}/{kwargs.get('month')}"
return f"api/calendar/{kwargs.get('year')}/{kwargs.get('week')}"

async def get_tournament(self) -> Optional[Tournament]:
"""
Expand Down
8 changes: 4 additions & 4 deletions sendou/models/tournament/bracket/Standing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ class StandingStats:
Attributes:
set_wins (int): Set Wins
set_loses (int): Set Loses
set_losses (int): Set Loses
map_wins (int): Map Wins
map_loses (int): Map Loses
map_losses (int): Map Loses
points (int): Points
wins_against_tied (int): Wins Against Tied
buchholz_sets (Optional[int]): Buchholz Sets
buchholz_maps (Optional[int]): Buchholz Maps
"""
set_wins: int
set_loses: int
set_losses: int
map_wins: int
map_loses: int
map_losses: int
points: int
wins_against_tied: int
buchholz_sets: Optional[int]
Expand Down
14 changes: 9 additions & 5 deletions sendou/models/tournament/bracket/bracket.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ class BracketStage:
settings (Any): Bracket Stage Settings
tournament_id (int): Tournament ID
type (BracketType): Bracket Type
created_at (datetime): Created At
created_at (Optional[datetime]): Created At
"""
id: int
name: str
number: int
settings: BracketSettings
tournament_id: int
type: BracketType
created_at: datetime # Provided as unix timestamp
created_at: Optional[datetime] # Provided as unix timestamp

def __init__(self, data: dict):
self.id = data.get("id", 0)
Expand All @@ -88,7 +88,8 @@ def __init__(self, data: dict):
self.settings = BracketSettings(data.get("settings", {}))
self.tournament_id = data.get("tournament_id", 0)
self.type = BracketType(data.get("type", ""))
self.created_at = datetime.fromtimestamp(data.get("createdAt", 0), tz=timezone.utc)
if created_at := data.get("createdAt", 0):
self.created_at = datetime.fromtimestamp(created_at, tz=timezone.utc)


class BracketGroup:
Expand Down Expand Up @@ -199,7 +200,7 @@ class BracketMatch(BaseModel):
id: int
group_id: int
number: int
opponent1: BracketMatchOpponent
opponent1: Optional[BracketMatchOpponent]
opponent2: Optional[BracketMatchOpponent]
round_id: int
stage_id: int
Expand All @@ -212,7 +213,10 @@ def __init__(self, data: dict, request_client: RequestsClient):
self.id = data.get("id", 0)
self.group_id = data.get("group_id", 0)
self.number = data.get("number", 0)
self.opponent1 = BracketMatchOpponent(data.get("opponent1", {}))
if data.get("opponent1", {}):
self.opponent1 = BracketMatchOpponent(data.get("opponent1", {}))
else:
self.opponent1 = None
if data.get("opponent2", {}):
self.opponent2 = BracketMatchOpponent(data.get("opponent2", {}))
else:
Expand Down

0 comments on commit 5136627

Please sign in to comment.