From 213e431f60d9dfab187ca0b868cc5c3222519f51 Mon Sep 17 00:00:00 2001 From: Ryan Day Date: Thu, 1 Feb 2024 04:13:44 +0000 Subject: [PATCH 1/3] Update MyFantasyLeague for playoff weeks --- leeger/league_loader/MyFantasyLeagueLeagueLoader.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/leeger/league_loader/MyFantasyLeagueLeagueLoader.py b/leeger/league_loader/MyFantasyLeagueLeagueLoader.py index 817bb0cd..1fb4baea 100644 --- a/leeger/league_loader/MyFantasyLeagueLeagueLoader.py +++ b/leeger/league_loader/MyFantasyLeagueLeagueLoader.py @@ -151,7 +151,14 @@ def __buildWeeks(self, mflLeague: dict) -> list[Week]: playoffsStarted = True # get each teams matchup for that week matchups = list() - for matchup in week["matchup"]: + # skip weeks with no matchup. get() is a safe method that doesn't throw an error if the element is missing. + local_matchups = week.get("matchup", {}) + if not local_matchups: + break + # Make sure that localMatchups is a list (some weeks just have a json element) + if not (isinstance(local_matchups, list)): + local_matchups = [local_matchups] + for matchup in local_matchups: teamAMFLFranchiseId = matchup["franchise"][0]["id"] teamAId = self.__mflFranchiseIdToTeamMap[teamAMFLFranchiseId].id teamAScore = float(matchup["franchise"][0]["score"]) From ac685e62110b3bbf133c0326570a173f01da3ac1 Mon Sep 17 00:00:00 2001 From: Ryan Day Date: Sun, 4 Feb 2024 22:33:29 +0000 Subject: [PATCH 2/3] Ran black formatter on mfl loader --- leeger/league_loader/MyFantasyLeagueLeagueLoader.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/leeger/league_loader/MyFantasyLeagueLeagueLoader.py b/leeger/league_loader/MyFantasyLeagueLeagueLoader.py index 1fb4baea..d450b142 100644 --- a/leeger/league_loader/MyFantasyLeagueLeagueLoader.py +++ b/leeger/league_loader/MyFantasyLeagueLeagueLoader.py @@ -43,9 +43,9 @@ def __init__( self.__mflLeagueIdToYearMap: dict[str, int] = dict() self.__mflFranchiseIdToOwnerMap: dict[str, Owner] = dict() self.__mflFranchiseIdToTeamMap: dict[int, Team] = dict() - self.__mflDivisionIdToDivisionMap: dict[ - str, Division - ] = dict() # holds the division info for ONLY the current year + self.__mflDivisionIdToDivisionMap: dict[str, Division] = ( + dict() + ) # holds the division info for ONLY the current year def __getAllLeagues(self) -> list[dict]: mflLeagues: list[dict] = list() @@ -157,7 +157,7 @@ def __buildWeeks(self, mflLeague: dict) -> list[Week]: break # Make sure that localMatchups is a list (some weeks just have a json element) if not (isinstance(local_matchups, list)): - local_matchups = [local_matchups] + local_matchups = [local_matchups] for matchup in local_matchups: teamAMFLFranchiseId = matchup["franchise"][0]["id"] teamAId = self.__mflFranchiseIdToTeamMap[teamAMFLFranchiseId].id From b6f5c7edce605c3fcad93fec50b58c954edcf387 Mon Sep 17 00:00:00 2001 From: Ryan Day Date: Sun, 4 Feb 2024 22:34:47 +0000 Subject: [PATCH 3/3] Ran make fmt --- leeger/league_loader/MyFantasyLeagueLeagueLoader.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/leeger/league_loader/MyFantasyLeagueLeagueLoader.py b/leeger/league_loader/MyFantasyLeagueLeagueLoader.py index d450b142..1b37994a 100644 --- a/leeger/league_loader/MyFantasyLeagueLeagueLoader.py +++ b/leeger/league_loader/MyFantasyLeagueLeagueLoader.py @@ -43,9 +43,9 @@ def __init__( self.__mflLeagueIdToYearMap: dict[str, int] = dict() self.__mflFranchiseIdToOwnerMap: dict[str, Owner] = dict() self.__mflFranchiseIdToTeamMap: dict[int, Team] = dict() - self.__mflDivisionIdToDivisionMap: dict[str, Division] = ( - dict() - ) # holds the division info for ONLY the current year + self.__mflDivisionIdToDivisionMap: dict[ + str, Division + ] = dict() # holds the division info for ONLY the current year def __getAllLeagues(self) -> list[dict]: mflLeagues: list[dict] = list()