From dc760a8b674eab186bcc8e660aff71971a062984 Mon Sep 17 00:00:00 2001 From: Profitroll <47523801+profitrollgame@users.noreply.github.com> Date: Sun, 14 May 2023 23:40:45 +0200 Subject: [PATCH] ujson is now optional --- libbot/__main__.py | 6 +++++- libbot/sync/__init__.py | 5 ++++- pyproject.toml | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libbot/__main__.py b/libbot/__main__.py index 5c05af0..a801c9d 100644 --- a/libbot/__main__.py +++ b/libbot/__main__.py @@ -2,7 +2,11 @@ from pathlib import Path from typing import Any, Union import aiofiles -from ujson import dumps, loads + +try: + from ujson import dumps, loads +except ImportError: + from json import dumps, loads from libbot.sync import nested_set diff --git a/libbot/sync/__init__.py b/libbot/sync/__init__.py index 5b89d75..6667519 100644 --- a/libbot/sync/__init__.py +++ b/libbot/sync/__init__.py @@ -1,7 +1,10 @@ from pathlib import Path from typing import Any, Union -from ujson import dumps, loads +try: + from ujson import dumps, loads +except ImportError: + from json import dumps, loads def json_read(path: Union[str, Path]) -> Any: diff --git a/pyproject.toml b/pyproject.toml index f5a77d7..db5e5b1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,11 +23,12 @@ classifiers = [ "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities", ] -dependencies = ["aiofiles~=23.1.0", "ujson==5.7.0"] +dependencies = ["aiofiles~=23.1.0"] [project.optional-dependencies] pycord = ["py-cord>=2.0.0"] pyrogram = ["pyrogram>=2.0.0"] +speed = ["ujson==5.7.0"] [project.urls] Source = "https://git.end-play.xyz/profitroll/LibBotUniversal"