Skip to content

Commit 31ae943

Browse files
committed
remove fork optimizations
1 parent 5715084 commit 31ae943

File tree

14 files changed

+21
-103
lines changed

14 files changed

+21
-103
lines changed

adminutils/adminutils.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
from redbot.core.utils.mod import get_audit_reason
1212
from redbot.core.utils.predicates import MessagePredicate
1313

14-
try:
15-
from redbot import json # support of Draper's branch
16-
except ImportError:
17-
import json
18-
1914
_ = Translator("AdminUtils", __file__)
2015

2116
EMOJI_RE = re.compile(r"(<(a)?:[a-zA-Z0-9_]+:([0-9]+)>)")
@@ -30,7 +25,7 @@ class AdminUtils(commands.Cog):
3025
# noinspection PyMissingConstructor
3126
def __init__(self, bot):
3227
self.bot = bot
33-
self.session = aiohttp.ClientSession(json_serialize=json.dumps)
28+
self.session = aiohttp.ClientSession()
3429

3530
def cog_unload(self):
3631
self.bot.loop.create_task(self.session.close())
@@ -207,8 +202,6 @@ async def emoji_add(self, ctx, name: str, url: str, *roles: discord.Role):
207202
else None,
208203
),
209204
)
210-
except discord.InvalidArgument:
211-
await ctx.send(chat.error(_("This image type is unsupported, or link is incorrect")))
212205
except discord.HTTPException as e:
213206
await ctx.send(chat.error(_("An error occurred on adding an emoji: {}").format(e)))
214207
else:
@@ -251,13 +244,6 @@ async def emote_steal(
251244
),
252245
)
253246
await ctx.tick()
254-
except discord.InvalidArgument:
255-
await ctx.send(
256-
_(
257-
"This image type is not supported anymore or Discord returned incorrect data. Try again later."
258-
)
259-
)
260-
return
261247
except discord.HTTPException as e:
262248
await ctx.send(chat.error(_("An error occurred on adding an emoji: {}").format(e)))
263249

godvilledata/godvilledata.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55

66
from .godvilleuser import GodvilleUser
77

8-
try:
9-
from redbot import json # support of Draper's branch
10-
except ImportError:
11-
import json
12-
138
BASE_API = "https://godville.net/gods/api"
149
BASE_API_GLOBAL = "http://godvillegame.com/gods/api"
1510

@@ -60,7 +55,7 @@ def __init__(self, bot):
6055
"godvillegame": {"apikey": None, "godname": None},
6156
}
6257
self.config.register_user(**default_user)
63-
self.session = aiohttp.ClientSession(json_serialize=json.dumps)
58+
self.session = aiohttp.ClientSession()
6459

6560
def cog_unload(self):
6661
self.bot.loop.create_task(self.session.close())

minecraftdata/minecraftdata.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@
1313

1414
from .minecraftplayer import MCPlayer
1515

16-
try:
17-
from redbot import json # support of Draper's branch
18-
except ImportError:
19-
import json
20-
21-
2216
_ = Translator("MinecraftData", __file__)
2317

2418

@@ -31,7 +25,7 @@ class MinecraftData(commands.Cog):
3125
# noinspection PyMissingConstructor
3226
def __init__(self, bot):
3327
self.bot = bot
34-
self.session = aiohttp.ClientSession(json_serialize=json.dumps)
28+
self.session = aiohttp.ClientSession()
3529

3630
def cog_unload(self):
3731
self.bot.loop.create_task(self.session.close())
@@ -206,7 +200,7 @@ async def fivezig(self, ctx, player: MCPlayer):
206200
async with self.session.get(
207201
f"http://textures.5zig.net/textures/2/{uuid}", raise_for_status=True
208202
) as data:
209-
response_data = await data.json(content_type=None, loads=json.loads)
203+
response_data = await data.json(content_type=None)
210204
cape = response_data["cape"]
211205
except aiohttp.ClientResponseError as e:
212206
if e.status == 404:
@@ -233,7 +227,7 @@ async def fivezig_animated(self, ctx, player: MCPlayer):
233227
async with self.session.get(
234228
f"http://textures.5zig.net/textures/2/{uuid}", raise_for_status=True
235229
) as data:
236-
response_data = await data.json(content_type=None, loads=json.loads)
230+
response_data = await data.json(content_type=None)
237231
if "animatedCape" not in response_data:
238232
await ctx.send(
239233
chat.error(_("{} doesn't have animated 5zig cape")).format(player.name)

minecraftdata/minecraftplayer.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
from redbot.core.commands import BadArgument
55
from redbot.core.i18n import Translator
66

7-
try:
8-
from redbot import json # support of Draper's branch
9-
except ImportError:
10-
import json
11-
127
_ = Translator("MinecraftData", __file__)
138

149

@@ -28,7 +23,7 @@ async def convert(cls, ctx, argument):
2823
f"https://api.mojang.com/users/profiles/minecraft/{argument}",
2924
raise_for_status=True,
3025
) as data:
31-
response_data = await data.json(loads=json.loads)
26+
response_data = await data.json()
3227
except ContentTypeError:
3328
response_data = None
3429
except ClientResponseError as e:

moreutils/moreutils.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
from redbot.core.utils import chat_formatting as chat
1010
from tabulate import tabulate
1111

12-
try:
13-
from redbot import json # support of Draper's branch
14-
except ImportError:
15-
import json
16-
17-
1812
T_ = Translator("MoreUtils", __file__)
1913
_ = lambda s: s
2014

@@ -99,7 +93,7 @@ class MoreUtils(commands.Cog):
9993
# noinspection PyMissingConstructor
10094
def __init__(self, bot):
10195
self.bot = bot
102-
self.session = aiohttp.ClientSession(json_serialize=json.dumps)
96+
self.session = aiohttp.ClientSession()
10397

10498
def cog_unload(self):
10599
self.bot.loop.create_task(self.session.close())
@@ -159,7 +153,7 @@ async def color(self, ctx, *, color: discord.Color):
159153
async with self.session.get(
160154
"https://www.thecolorapi.com/id", params={"hex": str(color)[1:]}
161155
) as data:
162-
color_response = await data.json(loads=json.loads)
156+
color_response = await data.json()
163157
em.description = (
164158
_("`Name:` {} ({})\n").format(
165159
color_response.get("name", {}).get("value", "?"),
@@ -208,7 +202,7 @@ async def discordstatus(self, ctx):
208202
async with self.session.get(
209203
"https://srhpyqt94yxb.statuspage.io/api/v2/summary.json"
210204
) as data:
211-
response = await data.json(loads=json.loads)
205+
response = await data.json()
212206
except Exception as e:
213207
await ctx.send(
214208
chat.error(

personalroles/personalroles.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616

1717
from .discord_py_future import edit_role_icon
1818

19-
try:
20-
from redbot import json # support of Draper's branch
21-
except ImportError:
22-
import json
23-
2419
_ = Translator("PersonalRoles", __file__)
2520

2621

@@ -47,7 +42,7 @@ class PersonalRoles(commands.Cog):
4742
# noinspection PyMissingConstructor
4843
def __init__(self, bot):
4944
self.bot = bot
50-
self.session = aiohttp.ClientSession(json_serialize=json.dumps)
45+
self.session = aiohttp.ClientSession()
5146
self.config = Config.get_conf(self, identifier=0x3D86BBD3E2B744AE8AA8B5D986EB4DD8)
5247
default_member = {"role": None}
5348
default_guild = {"blacklist": [], "role_persistence": True}
@@ -303,8 +298,6 @@ async def icon_emoji(self, ctx, *, emoji: Union[discord.Emoji, discord.PartialEm
303298
await ctx.send(
304299
chat.error(_("Unable to edit role.\nRole must be lower than my top role"))
305300
)
306-
except discord.InvalidArgument:
307-
await ctx.send(chat.error(_("This image type is unsupported, or link is incorrect")))
308301
except discord.HTTPException as e:
309302
ctx.command.reset_cooldown(ctx)
310303
await ctx.send(chat.error(_("Unable to edit role: {}").format(e)))
@@ -341,8 +334,6 @@ async def icon_image(self, ctx, *, url: str = None):
341334
await ctx.send(
342335
chat.error(_("Unable to edit role.\nRole must be lower than my top role"))
343336
)
344-
except discord.InvalidArgument:
345-
await ctx.send(chat.error(_("This image type is unsupported, or link is incorrect")))
346337
except discord.HTTPException as e:
347338
ctx.command.reset_cooldown(ctx)
348339
await ctx.send(chat.error(_("Unable to edit role: {}").format(e)))

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fonttools
99
git+https://github.com/fixator10/F10-Cogs-Utils
1010
mcstatus>=5.1.1
1111
motor>=2.5,<3.0
12-
pillow>=6
12+
pillow==9.2.0
1313
pillow>=6.2.1
1414
pybase64
1515
pymongo>=3.10,<3.12.3

reverseimagesearch/reverseimagesearch.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
from .saucenao import SauceNAO
1414
from .tracemoe import TraceMoe
1515

16-
try:
17-
from redbot import json # support of Draper's branch
18-
except ImportError:
19-
import json
20-
2116
_ = Translator("ReverseImageSearch", __file__)
2217

2318

@@ -67,7 +62,7 @@ def __init__(self, bot):
6762
"long_remaining": None,
6863
"short_remaining": None,
6964
}
70-
self.session = aiohttp.ClientSession(json_serialize=json.dumps)
65+
self.session = aiohttp.ClientSession()
7166
self.config = Config.get_conf(self, identifier=0x02E801D017C140A9A0C840BA01A25066)
7267
default_global = {"numres": 6}
7368
self.config.register_global(**default_global)

reverseimagesearch/saucenao.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
from dateutil.parser import parse
66
from redbot.core.i18n import Translator
77

8-
try:
9-
from redbot import json # support of Draper's branch
10-
except ImportError:
11-
import json
12-
138
_ = Translator("ReverseImageSearch", __file__)
149

1510
BASE_API_URL = "https://saucenao.com/search.php"
@@ -88,7 +83,7 @@ async def from_image(cls, ctx, image_url):
8883
async with ctx.cog.session.get(
8984
BASE_API_URL, params=params, raise_for_status=True
9085
) as data:
91-
data = await data.json(loads=json.loads)
86+
data = await data.json()
9287
if data.get("status", 0) != 0:
9388
if data.get("status") > 0:
9489
raise ValueError(

reverseimagesearch/tracemoe.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
from PIL import Image, UnidentifiedImageError
66
from redbot.core.i18n import Translator
77

8-
try:
9-
from redbot import json # support of Draper's branch
10-
except ImportError:
11-
import json
12-
138
_ = Translator("ReverseImageSearch", __file__)
149

1510
BASE_URL = "https://trace.moe"
@@ -95,7 +90,7 @@ async def from_image(cls, ctx, image_url):
9590
data=data,
9691
) as data:
9792
# image file closed by aiohttp
98-
resp = await data.json(loads=json.loads)
93+
resp = await data.json()
9994
if data.status != 200 or (error := resp.get("error")):
10095
raise ValueError(
10196
_("An error occurred during search: {}").format(
@@ -113,7 +108,7 @@ async def from_image(cls, ctx, image_url):
113108
@classmethod
114109
async def me(cls, ctx):
115110
async with ctx.cog.session.get(f"{BASE_API_URL}/me") as data:
116-
data = await data.json(loads=json.loads)
111+
data = await data.json()
117112
me_tuple = namedtuple(
118113
"me",
119114
"user_id,priority,concurrency,quota,quotaUsed",

0 commit comments

Comments
 (0)