Skip to content

Commit 7c15387

Browse files
committed
Remove disutil, undo lowercasing escape seq
1 parent 444d4aa commit 7c15387

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

core/utils.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import typing
66
from datetime import datetime, timezone
77
from difflib import get_close_matches
8-
from distutils.util import strtobool as _stb # pylint: disable=import-error
98
from itertools import takewhile, zip_longest
109
from urllib import parse
1110

@@ -56,15 +55,12 @@
5655
def strtobool(val):
5756
if isinstance(val, bool):
5857
return val
59-
try:
60-
return _stb(str(val))
61-
except ValueError:
62-
val = val.lower()
63-
if val == "enable":
64-
return 1
65-
if val == "disable":
66-
return 0
67-
raise
58+
val = str(val).lower()
59+
if val in ("y", "yes", "on", "1", "true", "t", "enable"):
60+
return 1
61+
if val in ("n", "no", "off", "0", "false", "f", "disable"):
62+
return 0
63+
raise ValueError(f"invalid truth value {val}")
6864

6965

7066
class User(commands.MemberConverter):
@@ -373,7 +369,7 @@ def create_not_found_embed(word, possibilities, name, n=2, cutoff=0.6) -> discor
373369

374370
def parse_alias(alias, *, split=True):
375371
def encode_alias(m):
376-
return "\x1aU" + base64.b64encode(m.group(1).encode()).decode() + "\x1aU"
372+
return "\x1AU" + base64.b64encode(m.group(1).encode()).decode() + "\x1AU"
377373

378374
def decode_alias(m):
379375
return base64.b64decode(m.group(1).encode()).decode()
@@ -395,7 +391,7 @@ def decode_alias(m):
395391
iterate = [alias]
396392

397393
for a in iterate:
398-
a = re.sub("\x1aU(.+?)\x1aU", decode_alias, a)
394+
a = re.sub(r"\x1AU(.+?)\x1AU", decode_alias, a)
399395
if a[0] == a[-1] == '"':
400396
a = a[1:-1]
401397
aliases.append(a)
@@ -617,7 +613,6 @@ def return_or_truncate(text, max_length):
617613
class AcceptButton(discord.ui.Button):
618614
def __init__(self, custom_id: str, emoji: str):
619615
super().__init__(style=discord.ButtonStyle.gray, emoji=emoji, custom_id=custom_id)
620-
self.view: ConfirmThreadCreationView
621616

622617
async def callback(self, interaction: discord.Interaction):
623618
self.view.value = True
@@ -628,7 +623,6 @@ async def callback(self, interaction: discord.Interaction):
628623
class DenyButton(discord.ui.Button):
629624
def __init__(self, custom_id: str, emoji: str):
630625
super().__init__(style=discord.ButtonStyle.gray, emoji=emoji, custom_id=custom_id)
631-
self.view: ConfirmThreadCreationView
632626

633627
async def callback(self, interaction: discord.Interaction):
634628
self.view.value = False

0 commit comments

Comments
 (0)