aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/seasons/__init__.py15
-rw-r--r--bot/utils/persist.py4
2 files changed, 10 insertions, 9 deletions
diff --git a/bot/seasons/__init__.py b/bot/seasons/__init__.py
index f9c89279..8cefd156 100644
--- a/bot/seasons/__init__.py
+++ b/bot/seasons/__init__.py
@@ -14,7 +14,7 @@ __all__ = (
"Pride",
"Valentines",
"Wildcard",
- "get_seasons",
+ "get_season_names",
"get_extensions",
"get_current_season",
"get_season",
@@ -139,13 +139,14 @@ class Wildcard(SeasonBase):
months = {Month.august}
-def get_seasons() -> List[str]:
- """Returns all the Season objects located in /bot/seasons/."""
- seasons = []
+def get_season_names() -> List[str]:
+ """Return names of all packages located in /bot/seasons/."""
+ seasons = [
+ package.name
+ for package in pkgutil.iter_modules(__path__)
+ if package.ispkg
+ ]
- for module in pkgutil.iter_modules([Path("bot/seasons")]):
- if module.ispkg:
- seasons.append(module.name)
return seasons
diff --git a/bot/utils/persist.py b/bot/utils/persist.py
index 3539375a..e5db4d5d 100644
--- a/bot/utils/persist.py
+++ b/bot/utils/persist.py
@@ -2,7 +2,7 @@ import sqlite3
from pathlib import Path
from shutil import copyfile
-from bot.seasons import get_seasons
+from bot.seasons import get_season_names
DIRECTORY = Path("data") # directory that has a persistent volume mapped to it
@@ -41,7 +41,7 @@ def make_persistent(file_path: Path) -> Path:
raise OSError(f"File not found at {file_path}.")
# detect season in datafile path for assigning to subdirectory
- season = next((s for s in get_seasons() if s in file_path.parts), None)
+ season = next((s for s in get_season_names() if s in file_path.parts), None)
if season:
# make sure subdirectory exists first