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.
Files changed (41) hide show
  1. {libbot-3.2.1/src/libbot.egg-info → libbot-3.2.2}/PKG-INFO +1 -1
  2. {libbot-3.2.1 → libbot-3.2.2}/src/libbot/__init__.py +1 -1
  3. {libbot-3.2.1 → libbot-3.2.2}/src/libbot/__main__.py +2 -1
  4. libbot-3.2.2/src/libbot/_utils.py +22 -0
  5. {libbot-3.2.1 → libbot-3.2.2}/src/libbot/sync/__main__.py +2 -1
  6. {libbot-3.2.1 → libbot-3.2.2/src/libbot.egg-info}/PKG-INFO +1 -1
  7. {libbot-3.2.1 → libbot-3.2.2}/src/libbot.egg-info/SOURCES.txt +3 -1
  8. libbot-3.2.2/tests/test_utils.py +24 -0
  9. {libbot-3.2.1 → libbot-3.2.2}/LICENSE +0 -0
  10. {libbot-3.2.1 → libbot-3.2.2}/README.md +0 -0
  11. {libbot-3.2.1 → libbot-3.2.2}/pyproject.toml +0 -0
  12. {libbot-3.2.1 → libbot-3.2.2}/requirements/_.txt +0 -0
  13. {libbot-3.2.1 → libbot-3.2.2}/requirements/dev.txt +0 -0
  14. {libbot-3.2.1 → libbot-3.2.2}/requirements/pycord.txt +0 -0
  15. {libbot-3.2.1 → libbot-3.2.2}/requirements/pyrogram.txt +0 -0
  16. {libbot-3.2.1 → libbot-3.2.2}/requirements/speed.txt +0 -0
  17. {libbot-3.2.1 → libbot-3.2.2}/setup.cfg +0 -0
  18. {libbot-3.2.1 → libbot-3.2.2}/src/libbot/errors/__init__.py +0 -0
  19. {libbot-3.2.1 → libbot-3.2.2}/src/libbot/errors/config.py +0 -0
  20. {libbot-3.2.1 → libbot-3.2.2}/src/libbot/i18n/__init__.py +0 -0
  21. {libbot-3.2.1 → libbot-3.2.2}/src/libbot/i18n/classes/bot_locale.py +0 -0
  22. {libbot-3.2.1 → libbot-3.2.2}/src/libbot/i18n/sync/__init__.py +0 -0
  23. {libbot-3.2.1 → libbot-3.2.2}/src/libbot/pycord/classes/__init__.py +0 -0
  24. {libbot-3.2.1 → libbot-3.2.2}/src/libbot/pycord/classes/bot.py +0 -0
  25. {libbot-3.2.1 → libbot-3.2.2}/src/libbot/pyrogram/classes/__init__.py +0 -0
  26. {libbot-3.2.1 → libbot-3.2.2}/src/libbot/pyrogram/classes/client.py +0 -0
  27. {libbot-3.2.1 → libbot-3.2.2}/src/libbot/pyrogram/classes/command.py +0 -0
  28. {libbot-3.2.1 → libbot-3.2.2}/src/libbot/pyrogram/classes/commandset.py +0 -0
  29. {libbot-3.2.1 → libbot-3.2.2}/src/libbot/sync/__init__.py +0 -0
  30. {libbot-3.2.1 → libbot-3.2.2}/src/libbot/sync/_nested.py +0 -0
  31. {libbot-3.2.1 → libbot-3.2.2}/src/libbot.egg-info/dependency_links.txt +0 -0
  32. {libbot-3.2.1 → libbot-3.2.2}/src/libbot.egg-info/requires.txt +0 -0
  33. {libbot-3.2.1 → libbot-3.2.2}/src/libbot.egg-info/top_level.txt +0 -0
  34. {libbot-3.2.1 → libbot-3.2.2}/tests/test_bot_locale.py +0 -0
  35. {libbot-3.2.1 → libbot-3.2.2}/tests/test_config_async.py +0 -0
  36. {libbot-3.2.1 → libbot-3.2.2}/tests/test_config_sync.py +0 -0
  37. {libbot-3.2.1 → libbot-3.2.2}/tests/test_i18n_async.py +0 -0
  38. {libbot-3.2.1 → libbot-3.2.2}/tests/test_i18n_sync.py +0 -0
  39. {libbot-3.2.1 → libbot-3.2.2}/tests/test_json_async.py +0 -0
  40. {libbot-3.2.1 → libbot-3.2.2}/tests/test_json_sync.py +0 -0
  41. {libbot-3.2.1 → libbot-3.2.2}/tests/test_nested_set.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: libbot
3
- Version: 3.2.1
3
+ Version: 3.2.2
4
4
  Summary: Universal bot library with functions needed for basic Discord/Telegram bot development.
5
5
  Author: Profitroll
6
6
  License: GPLv3
@@ -1,4 +1,4 @@
1
- __version__ = "3.2.1"
1
+ __version__ = "3.2.2"
2
2
  __license__ = "GPL3"
3
3
  __author__ = "Profitroll"
4
4
 
@@ -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 hasattr(dumps, "escape_forward_slashes")
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 hasattr(dumps, "escape_forward_slashes")
38
+ if supports_argument(dumps, "escape_forward_slashes")
38
39
  else dumps(data, ensure_ascii=False, indent=4)
39
40
  )
40
41
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: libbot
3
- Version: 3.2.1
3
+ Version: 3.2.2
4
4
  Summary: Universal bot library with functions needed for basic Discord/Telegram bot development.
5
5
  Author: Profitroll
6
6
  License: GPLv3
@@ -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