refactor(all): add black to all code

This commit is contained in:
Romain J 2020-06-06 18:51:47 +02:00
commit 9869312ee8
19 changed files with 428 additions and 391 deletions
tuxbot/core/utils/functions

View file

@ -43,22 +43,22 @@ def bordered(*columns: dict) -> str:
sep = " " * 4 # Separator between boxes
widths = tuple(
max(
len(row) for row in column.get('rows')
) + 9
for column in columns
max(len(row) for row in column.get("rows")) + 9 for column in columns
) # width of each col
cols_done = [False] * len(columns) # whether or not each column is done
lines = [""]
for i, column in enumerate(columns):
lines[0] += "{TL}" + "{HZ}" + column.get('title') \
+ "{HZ}" * (widths[i] - len(column.get('title')) - 1) \
+ "{TR}" + sep
lines[0] += (
"{TL}"
+ "{HZ}"
+ column.get("title")
+ "{HZ}" * (widths[i] - len(column.get("title")) - 1)
+ "{TR}"
+ sep
)
for line in itertools.zip_longest(
*[column.get('rows') for column in columns]
):
for line in itertools.zip_longest(*[column.get("rows") for column in columns]):
row = []
for colidx, column in enumerate(line):
width = widths[colidx]

View file

@ -6,25 +6,23 @@ from discord.ext import commands, flags
class ContextPlus(commands.Context):
async def send(self, content=None, *args, **kwargs):
if (hasattr(self.command, 'deletable')
and self.command.deletable) \
and kwargs.pop('deletable', True):
if (
hasattr(self.command, "deletable") and self.command.deletable
) and kwargs.pop("deletable", True):
message = await super().send(content, *args, **kwargs)
await message.add_reaction('🗑')
await message.add_reaction("🗑")
def check(reaction: discord.Reaction, user: discord.User):
return user == self.author \
and str(reaction.emoji) == '🗑' \
and reaction.message.id == message.id
return (
user == self.author
and str(reaction.emoji) == "🗑"
and reaction.message.id == message.id
)
try:
await self.bot.wait_for(
'reaction_add',
timeout=60.0,
check=check
)
await self.bot.wait_for("reaction_add", timeout=60.0, check=check)
except asyncio.TimeoutError:
await message.remove_reaction('🗑', self.bot.user)
await message.remove_reaction("🗑", self.bot.user)
else:
await message.delete()
return message