aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar kwzrd <[email protected]>2020-03-28 15:24:43 +0100
committerGravatar kwzrd <[email protected]>2020-03-28 15:24:43 +0100
commitd89a60d018bc470bb2d970e5a6b0d0044438cdc5 (patch)
tree7d80040d95503f4189264f6a2446c0f95223062a
parentDeseasonify: separate seasonal definitions into new module (diff)
Deseasonify: rename utility function
To avoid confusion, the packages should no longer be referred to as 'seasons'.
-rw-r--r--bot/exts/__init__.py6
-rw-r--r--bot/utils/persist.py4
2 files changed, 5 insertions, 5 deletions
diff --git a/bot/exts/__init__.py b/bot/exts/__init__.py
index ceb472d2..03a686df 100644
--- a/bot/exts/__init__.py
+++ b/bot/exts/__init__.py
@@ -3,12 +3,12 @@ import pkgutil
from pathlib import Path
from typing import List
-__all__ = ("get_season_names", "get_extensions")
+__all__ = ("get_package_names", "get_extensions")
log = logging.getLogger(__name__)
-def get_season_names() -> List[str]:
+def get_package_names() -> List[str]:
"""Return names of all packages located in /bot/exts/."""
seasons = [
package.name
@@ -29,7 +29,7 @@ def get_extensions() -> List[str]:
base_path = Path(__path__[0])
extensions = []
- for season in get_season_names():
+ for season in get_package_names():
for module in pkgutil.iter_modules([base_path.joinpath(season)]):
extensions.append(f"bot.exts.{season}.{module.name}")
diff --git a/bot/utils/persist.py b/bot/utils/persist.py
index 6f6507fa..d78e5420 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.exts import get_season_names
+from bot.exts import get_package_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_season_names() if s in file_path.parts), None)
+ season = next((s for s in get_package_names() if s in file_path.parts), None)
if season:
# make sure subdirectory exists first