diff options
| author | 2020-03-08 15:25:47 +0100 | |
|---|---|---|
| committer | 2020-03-08 15:25:47 +0100 | |
| commit | 696327a6b23bf8e41806abfd55f739dee195a284 (patch) | |
| tree | 914e01c3f1a0bca17659736c58288ed507ba5882 /bot | |
| parent | Deseasonify: remove redundant import (diff) | |
Deseasonify: allow `get_extensions` to find cogs in `seasons`
Add a conditional check to handle cases where `package` is, in fact,
just a plain module, and should be loaded directly rather than being
searched for modules.
The naming here could be improved: `package` does not necessarily have
to be a package.
Diffstat (limited to 'bot')
| -rw-r--r-- | bot/seasons/__init__.py | 10 | 
1 files changed, 7 insertions, 3 deletions
| diff --git a/bot/seasons/__init__.py b/bot/seasons/__init__.py index 1569f29a..1292485c 100644 --- a/bot/seasons/__init__.py +++ b/bot/seasons/__init__.py @@ -29,10 +29,14 @@ def get_extensions() -> List[str]:      extensions = []      for package in pkgutil.iter_modules([base_path]): -        package_path = base_path.joinpath(package.name) -        for module in pkgutil.iter_modules([package_path]): -            extensions.append(f"bot.seasons.{package.name}.{module.name}") +        if package.ispkg: +            package_path = base_path.joinpath(package.name) + +            for module in pkgutil.iter_modules([package_path]): +                extensions.append(f"bot.seasons.{package.name}.{module.name}") +        else: +            extensions.append(f"bot.seasons.{package.name}")      return extensions | 
