From e3e6d34677de3a66e6a117f436ebc8c84a104f20 Mon Sep 17 00:00:00 2001 From: profitroll Date: Sun, 23 Apr 2023 10:44:21 +0200 Subject: [PATCH] Replaced json with ujson --- glorybot.py | 10 +++------- requirements.txt | 3 ++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/glorybot.py b/glorybot.py index 7e36fd7..6c404ea 100644 --- a/glorybot.py +++ b/glorybot.py @@ -1,16 +1,14 @@ import asyncio from datetime import datetime from random import choice -import time import traceback from typing import List -import discord, json # type: ignore +import discord, ujson import os from modules.booruGet import booruGet from discord import Embed, ButtonStyle, ApplicationContext, Option # type: ignore -from discord.enums import ChannelType # type: ignore #from discord_slash import SlashCommand, SlashContext @@ -26,13 +24,11 @@ def logWrite(message): def jsonSave(filename, value): with open(filename, 'w', encoding="utf-8") as f: - json.dump(value, f, indent=4, ensure_ascii=False) - f.close() + f.write(ujson.dumps(value, indent=4, ensure_ascii=False)) def jsonLoad(filename): with open(filename, 'r', encoding="utf-8") as f: - value = json.load(f) - f.close() + value = ujson.loads(f.read()) return value #========================================================================================================================= diff --git a/requirements.txt b/requirements.txt index e41d50d..c2f32e5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ py-cord[speed]==2.4.1 -requests==2.28.2 \ No newline at end of file +requests==2.28.2 +ujson==5.7.0 \ No newline at end of file