From 7c7d5dd9c4888ce29e52191643bccbf168154b72 Mon Sep 17 00:00:00 2001 From: kwzrd Date: Sat, 28 Mar 2020 16:55:38 +0100 Subject: Deseasonify: add helper to give all available seasons --- bot/seasons.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/seasons.py b/bot/seasons.py index 83a584fd..8c3df48c 100644 --- a/bot/seasons.py +++ b/bot/seasons.py @@ -123,6 +123,11 @@ class Wildcard(SeasonBase): months = {Month.august} +def get_all_seasons() -> t.List[t.Type[SeasonBase]]: + """Give all available season classes.""" + return [SeasonBase] + SeasonBase.__subclasses__() + + def get_current_season() -> t.Type[SeasonBase]: """Give active season, based on current UTC month.""" current_month = Month(datetime.utcnow().month) @@ -150,7 +155,7 @@ def get_season(name: str) -> t.Optional[t.Type[SeasonBase]]: """ name = name.casefold() - for season in [SeasonBase] + SeasonBase.__subclasses__(): + for season in get_all_seasons(): matches = (season.__name__.casefold(), season.season_name.casefold()) if name in matches: -- cgit v1.2.3