def _get_season_string(self, season_int=None):
"""Season string generator.
Generates this month's season name, or the season name from a given season int.
A season int is defined by anilist as "First 2 numbers are the year (16 is 2016).
Last number is the season starting at 1 (3 is Summer)."
Keyword Args:
season_int (int): An optional season int from anilist for a season.
Returns:
The season (winter, spring, summer, or fall) as a string.
"""
monthsToSeasons = {(1,2,3):'winter', (4,5,6):'spring', (7,8,9):'summer', (10,11,12):'fall'}
seasonIntToSeasons = {1:'winter', 2:'spring', 3:'summer', 4:'fall'}
if season_int:
season = seasonIntToSeasons[int(str(season_int)[2:])]
else:
targetDate = date.today()
season = next(val for key, val in monthsToSeasons.items() if targetDate.month in key)
return season
评论列表
文章目录