libbot 3.2.1__tar.gz → 3.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {libbot-3.2.1/src/libbot.egg-info → libbot-3.2.2}/PKG-INFO +1 -1
- {libbot-3.2.1 → libbot-3.2.2}/src/libbot/__init__.py +1 -1
- {libbot-3.2.1 → libbot-3.2.2}/src/libbot/__main__.py +2 -1
- libbot-3.2.2/src/libbot/_utils.py +22 -0
- {libbot-3.2.1 → libbot-3.2.2}/src/libbot/sync/__main__.py +2 -1
- {libbot-3.2.1 → libbot-3.2.2/src/libbot.egg-info}/PKG-INFO +1 -1
- {libbot-3.2.1 → libbot-3.2.2}/src/libbot.egg-info/SOURCES.txt +3 -1
- libbot-3.2.2/tests/test_utils.py +24 -0
- {libbot-3.2.1 → libbot-3.2.2}/LICENSE +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/README.md +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/pyproject.toml +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/requirements/_.txt +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/requirements/dev.txt +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/requirements/pycord.txt +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/requirements/pyrogram.txt +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/requirements/speed.txt +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/setup.cfg +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/src/libbot/errors/__init__.py +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/src/libbot/errors/config.py +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/src/libbot/i18n/__init__.py +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/src/libbot/i18n/classes/bot_locale.py +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/src/libbot/i18n/sync/__init__.py +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/src/libbot/pycord/classes/__init__.py +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/src/libbot/pycord/classes/bot.py +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/src/libbot/pyrogram/classes/__init__.py +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/src/libbot/pyrogram/classes/client.py +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/src/libbot/pyrogram/classes/command.py +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/src/libbot/pyrogram/classes/commandset.py +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/src/libbot/sync/__init__.py +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/src/libbot/sync/_nested.py +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/src/libbot.egg-info/dependency_links.txt +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/src/libbot.egg-info/requires.txt +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/src/libbot.egg-info/top_level.txt +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/tests/test_bot_locale.py +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/tests/test_config_async.py +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/tests/test_config_sync.py +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/tests/test_i18n_async.py +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/tests/test_i18n_sync.py +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/tests/test_json_async.py +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/tests/test_json_sync.py +0 -0
- {libbot-3.2.1 → libbot-3.2.2}/tests/test_nested_set.py +0 -0
|
@@ -8,6 +8,7 @@ try:
|
|
|
8
8
|
except ImportError:
|
|
9
9
|
from json import dumps, loads
|
|
10
10
|
|
|
11
|
+
from ._utils import supports_argument
|
|
11
12
|
from .sync._nested import nested_delete, nested_set
|
|
12
13
|
|
|
13
14
|
|
|
@@ -36,7 +37,7 @@ async def json_write(data: Any, path: Union[str, Path]) -> None:
|
|
|
36
37
|
async with aiofiles.open(str(path), mode="w", encoding="utf-8") as f:
|
|
37
38
|
await f.write(
|
|
38
39
|
dumps(data, ensure_ascii=False, escape_forward_slashes=False, indent=4)
|
|
39
|
-
if
|
|
40
|
+
if supports_argument(dumps, "escape_forward_slashes")
|
|
40
41
|
else dumps(data, ensure_ascii=False, indent=4)
|
|
41
42
|
)
|
|
42
43
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import inspect
|
|
2
|
+
from typing import Callable
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def supports_argument(func: Callable, arg_name: str) -> bool:
|
|
6
|
+
"""Check whether a function has a specific argument
|
|
7
|
+
|
|
8
|
+
### Args:
|
|
9
|
+
* func (`Callable`): Function to be inspected
|
|
10
|
+
* arg_name (`str`): Argument to be checked
|
|
11
|
+
|
|
12
|
+
### Returns:
|
|
13
|
+
* `bool`: `True` if argument is supported and `False` if not
|
|
14
|
+
"""
|
|
15
|
+
if hasattr(func, "__code__"):
|
|
16
|
+
return arg_name in inspect.signature(func).parameters
|
|
17
|
+
elif hasattr(func, "__doc__"):
|
|
18
|
+
if doc := func.__doc__:
|
|
19
|
+
first_line = doc.splitlines()[0]
|
|
20
|
+
return arg_name in first_line
|
|
21
|
+
|
|
22
|
+
return False
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
from typing import Any, Union
|
|
3
3
|
|
|
4
|
+
from .._utils import supports_argument
|
|
4
5
|
from ._nested import nested_delete, nested_set
|
|
5
6
|
|
|
6
7
|
try:
|
|
@@ -34,7 +35,7 @@ def json_write(data: Any, path: Union[str, Path]) -> None:
|
|
|
34
35
|
with open(str(path), mode="w", encoding="utf-8") as f:
|
|
35
36
|
f.write(
|
|
36
37
|
dumps(data, ensure_ascii=False, escape_forward_slashes=False, indent=4)
|
|
37
|
-
if
|
|
38
|
+
if supports_argument(dumps, "escape_forward_slashes")
|
|
38
39
|
else dumps(data, ensure_ascii=False, indent=4)
|
|
39
40
|
)
|
|
40
41
|
|
|
@@ -8,6 +8,7 @@ requirements/pyrogram.txt
|
|
|
8
8
|
requirements/speed.txt
|
|
9
9
|
src/libbot/__init__.py
|
|
10
10
|
src/libbot/__main__.py
|
|
11
|
+
src/libbot/_utils.py
|
|
11
12
|
src/libbot.egg-info/PKG-INFO
|
|
12
13
|
src/libbot.egg-info/SOURCES.txt
|
|
13
14
|
src/libbot.egg-info/dependency_links.txt
|
|
@@ -34,4 +35,5 @@ tests/test_i18n_async.py
|
|
|
34
35
|
tests/test_i18n_sync.py
|
|
35
36
|
tests/test_json_async.py
|
|
36
37
|
tests/test_json_sync.py
|
|
37
|
-
tests/test_nested_set.py
|
|
38
|
+
tests/test_nested_set.py
|
|
39
|
+
tests/test_utils.py
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from typing import Callable
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from libbot._utils import supports_argument
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def func1(foo: str, bar: str):
|
|
9
|
+
pass
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def func2(foo: str):
|
|
13
|
+
pass
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@pytest.mark.parametrize(
|
|
17
|
+
"func, arg_name, result",
|
|
18
|
+
[
|
|
19
|
+
(func1, "foo", True),
|
|
20
|
+
(func2, "bar", False),
|
|
21
|
+
],
|
|
22
|
+
)
|
|
23
|
+
def test_supports_argument(func: Callable, arg_name: str, result: bool):
|
|
24
|
+
assert supports_argument(func, arg_name) == result
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|