diff options
Diffstat (limited to '')
| -rw-r--r-- | bot/utils/__init__.py | 17 | ||||
| -rw-r--r-- | bot/utils/helpers.py | 12 | 
2 files changed, 14 insertions, 15 deletions
| diff --git a/bot/utils/__init__.py b/bot/utils/__init__.py index 2c8d57bd5..7c29a5981 100644 --- a/bot/utils/__init__.py +++ b/bot/utils/__init__.py @@ -1,25 +1,17 @@  import logging -from abc import ABCMeta  from typing import Optional  from aiohttp import ClientConnectorError, ClientSession -from discord.ext.commands import CogMeta  from bot.constants import URLs +from bot.utils.helpers import CogABCMeta, pad_base64  from bot.utils.redis_cache import RedisCache  log = logging.getLogger(__name__)  FAILED_REQUEST_ATTEMPTS = 3 - -__all__ = ['RedisCache', 'CogABCMeta', "send_to_paste_service"] - - -class CogABCMeta(CogMeta, ABCMeta): -    """Metaclass for ABCs meant to be implemented as Cogs.""" - -    pass +__all__ = ['RedisCache', 'CogABCMeta', "pad_base64", "send_to_paste_service"]  async def send_to_paste_service(http_session: ClientSession, contents: str, *, extension: str = "") -> Optional[str]: @@ -64,8 +56,3 @@ async def send_to_paste_service(http_session: ClientSession, contents: str, *, e              f"Got unexpected JSON response from paste service: {response_json}\n"              f"trying again ({attempt}/{FAILED_REQUEST_ATTEMPTS})."          ) - - -def pad_base64(data: str) -> str: -    """Return base64 `data` with padding characters to ensure its length is a multiple of 4.""" -    return data + "=" * (-len(data) % 4) diff --git a/bot/utils/helpers.py b/bot/utils/helpers.py new file mode 100644 index 000000000..cfbf47753 --- /dev/null +++ b/bot/utils/helpers.py @@ -0,0 +1,12 @@ +from abc import ABCMeta + +from discord.ext.commands import CogMeta + + +class CogABCMeta(CogMeta, ABCMeta): +    """Metaclass for ABCs meant to be implemented as Cogs.""" + + +def pad_base64(data: str) -> str: +    """Return base64 `data` with padding characters to ensure its length is a multiple of 4.""" +    return data + "=" * (-len(data) % 4) | 
