diff options
| author | 2019-03-30 10:37:59 -0400 | |
|---|---|---|
| committer | 2019-03-30 10:37:59 -0400 | |
| commit | 5fe5b7c688e19e533fe34d98b8c754bc67a58beb (patch) | |
| tree | 16c2946f97f85facf6b994b3c48099d369ee7f5a /bot/seasons/evergreen/snakes/converter.py | |
| parent | Merge pull request #163 from python-discord/easter_announce (diff) | |
| parent | Blank line required between summary line and description. (diff) | |
Merge pull request #146 from python-discord/flake8-docstring
Implement flake8-docstrings
Diffstat (limited to 'bot/seasons/evergreen/snakes/converter.py')
| -rw-r--r-- | bot/seasons/evergreen/snakes/converter.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/bot/seasons/evergreen/snakes/converter.py b/bot/seasons/evergreen/snakes/converter.py index c091d9c1..ec9c9870 100644 --- a/bot/seasons/evergreen/snakes/converter.py +++ b/bot/seasons/evergreen/snakes/converter.py @@ -13,10 +13,14 @@ log = logging.getLogger(__name__) class Snake(Converter): + """Snake converter for the Snakes Cog.""" + snakes = None special_cases = None async def convert(self, ctx, name): + """Convert the input snake name to the closest matching Snake object.""" + await self.build_list() name = name.lower() @@ -56,6 +60,8 @@ class Snake(Converter): @classmethod async def build_list(cls): + """Build list of snakes from the static snake resources.""" + # Get all the snakes if cls.snakes is None: with (SNAKE_RESOURCES / "snake_names.json").open() as snakefile: @@ -70,11 +76,14 @@ class Snake(Converter): @classmethod async def random(cls): """ - This is stupid. We should find a way to - somehow get the global session into a - global context, so I can get it from here. + Get a random Snake from the loaded resources. + + This is stupid. We should find a way to somehow get the global session into a global context, + so I can get it from here. + :return: """ + await cls.build_list() names = [snake['scientific'] for snake in cls.snakes] return random.choice(names) |