aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar kwzrd <[email protected]>2020-03-20 22:48:32 +0100
committerGravatar kwzrd <[email protected]>2020-03-21 14:27:35 +0100
commit1435a916bc760de40b2f000f97b1a7f11a9a9a12 (patch)
treece1cd73e322abd87b544ab4de167ec993e27e619
parentDeseasonify: improve branding embed (diff)
Deseasonify: define all seasons in one place
Defining seasons in seasonal packages' __init__.py files made more sense when extensions were strictly tied to seasons. It introduces an annoying circular dependency where a seasonal package must be imported in order for the __init__.py file to run and register the season, but it also imports SeasonBase from the parent directory so that it can inherit from it. I have made the decision to scrap the seasonal __init__.py files, and instead define all seasons directly under SeasonBase. The classes are no longer scattered around, we remove the above mentioned import problem, and everything is more transparent and easier to digest.
-rw-r--r--bot/seasons/__init__.py152
-rw-r--r--bot/seasons/christmas/__init__.py19
-rw-r--r--bot/seasons/easter/__init__.py19
-rw-r--r--bot/seasons/halloween/__init__.py16
-rw-r--r--bot/seasons/pride/__init__.py22
-rw-r--r--bot/seasons/valentines/__init__.py16
-rw-r--r--bot/seasons/wildcard/__init__.py14
7 files changed, 129 insertions, 129 deletions
diff --git a/bot/seasons/__init__.py b/bot/seasons/__init__.py
index 13fec76b..f9c89279 100644
--- a/bot/seasons/__init__.py
+++ b/bot/seasons/__init__.py
@@ -6,11 +6,139 @@ from typing import List, Optional, Set, Type
from bot.constants import Colours, Month
-__all__ = ("SeasonBase", "get_seasons", "get_extensions", "get_current_season", "get_season")
+__all__ = (
+ "SeasonBase",
+ "Christmas",
+ "Easter",
+ "Halloween",
+ "Pride",
+ "Valentines",
+ "Wildcard",
+ "get_seasons",
+ "get_extensions",
+ "get_current_season",
+ "get_season",
+)
log = logging.getLogger(__name__)
+class SeasonBase:
+ """
+ Base for Seasonal classes.
+
+ This serves as the off-season fallback for when no specific
+ seasons are active.
+
+ Seasons are 'registered' simply by inheriting from `SeasonBase`.
+ We discover them by calling `__subclasses__`.
+ """
+
+ season_name: str = "Evergreen"
+ bot_name: str = "SeasonalBot"
+
+ colour: str = Colours.soft_green
+ description: str = "The default season!"
+
+ branding_path: str = "seasonal/evergreen"
+
+ months: Set[Month] = set(Month)
+
+
+class Christmas(SeasonBase):
+ """Branding for december."""
+
+ season_name = "Festive season"
+ bot_name = "Merrybot"
+
+ colour = Colours.soft_red
+ description = (
+ "The time is here to get into the festive spirit! No matter who you are, where you are, "
+ "or what beliefs you may follow, we hope every one of you enjoy this festive season!"
+ )
+
+ branding_path = "seasonal/christmas"
+
+ months = {Month.december}
+
+
+class Easter(SeasonBase):
+ """Branding for april."""
+
+ season_name = "Easter"
+ bot_name = "BunnyBot"
+
+ colour = Colours.bright_green
+ description = (
+ "Bunny here, bunny there, bunny everywhere! Here at Python Discord, we celebrate "
+ "our version of Easter during the entire month of April."
+ )
+
+ branding_path = "seasonal/easter"
+
+ months = {Month.april}
+
+
+class Halloween(SeasonBase):
+ """Branding for october."""
+
+ season_name = "Halloween"
+ bot_name = "NeonBot"
+
+ colour = Colours.orange
+ description = "Trick or treat?!"
+
+ branding_path = "seasonal/halloween"
+
+ months = {Month.october}
+
+
+class Pride(SeasonBase):
+ """Branding for june."""
+
+ season_name = "Pride"
+ bot_name = "ProudBot"
+
+ colour = Colours.pink
+ description = (
+ "The month of June is a special month for us at Python Discord. It is very important to us "
+ "that everyone feels welcome here, no matter their origin, identity or sexuality. During the "
+ "month of June, while some of you are participating in Pride festivals across the world, "
+ "we will be celebrating individuality and commemorating the history and challenges "
+ "of the LGBTQ+ community with a Pride event of our own!"
+ )
+
+ branding_path = "seasonal/pride"
+
+ months = {Month.june}
+
+
+class Valentines(SeasonBase):
+ """Branding for february."""
+
+ season_name = "Valentines"
+ bot_name = "TenderBot"
+
+ colour = Colours.pink
+ description = "Love is in the air!"
+
+ branding_path = "seasonal/valentines"
+
+ months = {Month.february}
+
+
+class Wildcard(SeasonBase):
+ """Branding for august."""
+
+ season_name = "Wildcard"
+ bot_name = "RetroBot"
+
+ colour = Colours.purple
+ description = "A season full of surprises!"
+
+ months = {Month.august}
+
+
def get_seasons() -> List[str]:
"""Returns all the Season objects located in /bot/seasons/."""
seasons = []
@@ -44,28 +172,6 @@ def get_extensions() -> List[str]:
return extensions
-class SeasonBase:
- """
- Base for Seasonal classes.
-
- This serves as the off-season fallback for when no specific
- seasons are active.
-
- Seasons are 'registered' simply by inheriting from `SeasonBase`.
- We discover them by calling `__subclasses__`.
- """
-
- season_name: str = "Evergreen"
- bot_name: str = "SeasonalBot"
-
- colour: str = Colours.soft_green
- description: str = "The default season!"
-
- branding_path: str = "seasonal/evergreen"
-
- months: Set[Month] = set(Month)
-
-
def get_current_season() -> Type[SeasonBase]:
"""Give active season, based on current UTC month."""
current_month = Month(datetime.utcnow().month)
diff --git a/bot/seasons/christmas/__init__.py b/bot/seasons/christmas/__init__.py
index 0b524f44..e69de29b 100644
--- a/bot/seasons/christmas/__init__.py
+++ b/bot/seasons/christmas/__init__.py
@@ -1,19 +0,0 @@
-from bot.constants import Colours, Month
-from bot.seasons import SeasonBase
-
-
-class Christmas(SeasonBase):
- """Branding for december."""
-
- season_name = "Festive season"
- bot_name = "Merrybot"
-
- colour = Colours.soft_red
- description = (
- "The time is here to get into the festive spirit! No matter who you are, where you are, "
- "or what beliefs you may follow, we hope every one of you enjoy this festive season!"
- )
-
- branding_path = "seasonal/christmas"
-
- months = {Month.december}
diff --git a/bot/seasons/easter/__init__.py b/bot/seasons/easter/__init__.py
index 15992941..e69de29b 100644
--- a/bot/seasons/easter/__init__.py
+++ b/bot/seasons/easter/__init__.py
@@ -1,19 +0,0 @@
-from bot.constants import Colours, Month
-from bot.seasons import SeasonBase
-
-
-class Easter(SeasonBase):
- """Branding for april."""
-
- season_name = "Easter"
- bot_name = "BunnyBot"
-
- colour = Colours.bright_green
- description = (
- "Bunny here, bunny there, bunny everywhere! Here at Python Discord, we celebrate "
- "our version of Easter during the entire month of April."
- )
-
- branding_path = "seasonal/easter"
-
- months = {Month.april}
diff --git a/bot/seasons/halloween/__init__.py b/bot/seasons/halloween/__init__.py
index ec546578..e69de29b 100644
--- a/bot/seasons/halloween/__init__.py
+++ b/bot/seasons/halloween/__init__.py
@@ -1,16 +0,0 @@
-from bot.constants import Colours, Month
-from bot.seasons import SeasonBase
-
-
-class Halloween(SeasonBase):
- """Branding for october."""
-
- season_name = "Halloween"
- bot_name = "NeonBot"
-
- colour = Colours.orange
- description = "Trick or treat?!"
-
- branding_path = "seasonal/halloween"
-
- months = {Month.october}
diff --git a/bot/seasons/pride/__init__.py b/bot/seasons/pride/__init__.py
index 90e2fde9..e69de29b 100644
--- a/bot/seasons/pride/__init__.py
+++ b/bot/seasons/pride/__init__.py
@@ -1,22 +0,0 @@
-from bot.constants import Colours, Month
-from bot.seasons import SeasonBase
-
-
-class Pride(SeasonBase):
- """Branding for june."""
-
- season_name = "Pride"
- bot_name = "ProudBot"
-
- colour = Colours.pink
- description = (
- "The month of June is a special month for us at Python Discord. It is very important to us "
- "that everyone feels welcome here, no matter their origin, identity or sexuality. During the "
- "month of June, while some of you are participating in Pride festivals across the world, "
- "we will be celebrating individuality and commemorating the history and challenges "
- "of the LGBTQ+ community with a Pride event of our own!"
- )
-
- branding_path = "seasonal/pride"
-
- months = {Month.june}
diff --git a/bot/seasons/valentines/__init__.py b/bot/seasons/valentines/__init__.py
index 02cf11ff..e69de29b 100644
--- a/bot/seasons/valentines/__init__.py
+++ b/bot/seasons/valentines/__init__.py
@@ -1,16 +0,0 @@
-from bot.constants import Colours, Month
-from bot.seasons import SeasonBase
-
-
-class Valentines(SeasonBase):
- """Branding for february."""
-
- season_name = "Valentines"
- bot_name = "TenderBot"
-
- colour = Colours.pink
- description = "Love is in the air!"
-
- branding_path = "seasonal/valentines"
-
- months = {Month.february}
diff --git a/bot/seasons/wildcard/__init__.py b/bot/seasons/wildcard/__init__.py
deleted file mode 100644
index bcc79e3a..00000000
--- a/bot/seasons/wildcard/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from bot.constants import Colours, Month
-from bot.seasons import SeasonBase
-
-
-class Wildcard(SeasonBase):
- """Branding for august."""
-
- season_name = "Wildcard"
- bot_name = "RetroBot"
-
- colour = Colours.purple
- description = "A season full of surprises!"
-
- months = {Month.august}