aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar kwzrd <[email protected]>2020-03-28 16:55:38 +0100
committerGravatar kwzrd <[email protected]>2020-03-28 16:55:38 +0100
commit7c7d5dd9c4888ce29e52191643bccbf168154b72 (patch)
tree55646cf39438cc6368439dbe3d821af4896d7122
parentDeseasonify: log in `add_cog` rather than in each `setup` (diff)
Deseasonify: add helper to give all available seasons
-rw-r--r--bot/seasons.py7
1 files changed, 6 insertions, 1 deletions
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: