Compare commits
14 Commits
4ee704b41e
...
v3.3.0
Author | SHA1 | Date | |
---|---|---|---|
1b60257bc5 | |||
7e03a0c779 | |||
5f4d0b09f9 | |||
f6596d1db6 | |||
cbc4fc36a1 | |||
d20d07bb6a | |||
171e36a491 | |||
c419c684aa | |||
748b2b2abb | |||
52c2e5cc13 | |||
55c61e3fce | |||
b9550032ba | |||
5ba763246b | |||
f0ffdf096d |
@@ -2,10 +2,10 @@ black==24.10.0
|
|||||||
build==1.2.2.post1
|
build==1.2.2.post1
|
||||||
isort==5.13.2
|
isort==5.13.2
|
||||||
mypy==1.13.0
|
mypy==1.13.0
|
||||||
pylint==3.3.1
|
pylint==3.3.2
|
||||||
pytest-asyncio==0.24.0
|
pytest-asyncio==0.25.0
|
||||||
pytest-cov==6.0.0
|
pytest-cov==6.0.0
|
||||||
pytest==8.3.3
|
pytest==8.3.4
|
||||||
tox==4.23.2
|
tox==4.23.2
|
||||||
types-aiofiles==24.1.0.20240626
|
types-aiofiles==24.1.0.20240626
|
||||||
types-ujson==5.10.0.20240515
|
types-ujson==5.10.0.20240515
|
@@ -1,2 +1,2 @@
|
|||||||
apscheduler~=3.10.4
|
apscheduler~=3.11.0
|
||||||
py-cord~=2.6.0
|
py-cord~=2.6.0
|
@@ -1,2 +1,2 @@
|
|||||||
apscheduler~=3.10.4
|
apscheduler~=3.11.0
|
||||||
pyrofork~=2.3.32
|
pyrofork~=2.3.32
|
@@ -11,6 +11,8 @@ except ImportError:
|
|||||||
from ._utils import supports_argument
|
from ._utils import supports_argument
|
||||||
from .sync._nested import nested_delete, nested_set
|
from .sync._nested import nested_delete, nested_set
|
||||||
|
|
||||||
|
DEFAULT_CONFIG_LOCATION: str = "config.json"
|
||||||
|
|
||||||
|
|
||||||
async def json_read(path: Union[str, Path]) -> Any:
|
async def json_read(path: Union[str, Path]) -> Any:
|
||||||
"""Read contents of a JSON file
|
"""Read contents of a JSON file
|
||||||
@@ -43,7 +45,7 @@ async def json_write(data: Any, path: Union[str, Path]) -> None:
|
|||||||
|
|
||||||
|
|
||||||
async def config_get(
|
async def config_get(
|
||||||
key: str, *path: str, config_file: Union[str, Path] = "config.json"
|
key: str, *path: str, config_file: Union[str, Path] = DEFAULT_CONFIG_LOCATION
|
||||||
) -> Any:
|
) -> Any:
|
||||||
"""Get a value of the config key by its path provided
|
"""Get a value of the config key by its path provided
|
||||||
For example, `foo.bar.key` has a path of `"foo", "bar"` and the key `"key"`
|
For example, `foo.bar.key` has a path of `"foo", "bar"` and the key `"key"`
|
||||||
@@ -83,7 +85,7 @@ async def config_get(
|
|||||||
|
|
||||||
|
|
||||||
async def config_set(
|
async def config_set(
|
||||||
key: str, value: Any, *path: str, config_file: Union[str, Path] = "config.json"
|
key: str, value: Any, *path: str, config_file: Union[str, Path] = DEFAULT_CONFIG_LOCATION
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set config's key by its path to the value
|
"""Set config's key by its path to the value
|
||||||
|
|
||||||
@@ -99,14 +101,13 @@ async def config_set(
|
|||||||
await json_write(
|
await json_write(
|
||||||
nested_set(await json_read(config_file), value, *(*path, key)), config_file
|
nested_set(await json_read(config_file), value, *(*path, key)), config_file
|
||||||
)
|
)
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
async def config_delete(
|
async def config_delete(
|
||||||
key: str,
|
key: str,
|
||||||
*path: str,
|
*path: str,
|
||||||
missing_ok: bool = False,
|
missing_ok: bool = False,
|
||||||
config_file: Union[str, Path] = "config.json",
|
config_file: Union[str, Path] = DEFAULT_CONFIG_LOCATION,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set config's key by its path
|
"""Set config's key by its path
|
||||||
|
|
||||||
|
@@ -358,7 +358,8 @@ class PyroClient(Client):
|
|||||||
]
|
]
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"Registering commands %s with a default scope 'BotCommandScopeDefault'"
|
"Registering commands %s with a default scope 'BotCommandScopeDefault'",
|
||||||
|
commands
|
||||||
)
|
)
|
||||||
|
|
||||||
await self.set_bot_commands(commands)
|
await self.set_bot_commands(commands)
|
||||||
|
@@ -9,6 +9,8 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
from json import dumps, loads
|
from json import dumps, loads
|
||||||
|
|
||||||
|
DEFAULT_CONFIG_LOCATION: str = "config.json"
|
||||||
|
|
||||||
|
|
||||||
def json_read(path: Union[str, Path]) -> Any:
|
def json_read(path: Union[str, Path]) -> Any:
|
||||||
"""Read contents of a JSON file
|
"""Read contents of a JSON file
|
||||||
@@ -41,7 +43,7 @@ def json_write(data: Any, path: Union[str, Path]) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def config_get(
|
def config_get(
|
||||||
key: str, *path: str, config_file: Union[str, Path] = "config.json"
|
key: str, *path: str, config_file: Union[str, Path] = DEFAULT_CONFIG_LOCATION
|
||||||
) -> Any:
|
) -> Any:
|
||||||
"""Get a value of the config key by its path provided
|
"""Get a value of the config key by its path provided
|
||||||
For example, `foo.bar.key` has a path of `"foo", "bar"` and the key `"key"`
|
For example, `foo.bar.key` has a path of `"foo", "bar"` and the key `"key"`
|
||||||
@@ -81,7 +83,7 @@ def config_get(
|
|||||||
|
|
||||||
|
|
||||||
def config_set(
|
def config_set(
|
||||||
key: str, value: Any, *path: str, config_file: Union[str, Path] = "config.json"
|
key: str, value: Any, *path: str, config_file: Union[str, Path] = DEFAULT_CONFIG_LOCATION
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set config's key by its path to the value
|
"""Set config's key by its path to the value
|
||||||
|
|
||||||
@@ -95,14 +97,13 @@ def config_set(
|
|||||||
* `KeyError`: Key is not found under path provided
|
* `KeyError`: Key is not found under path provided
|
||||||
"""
|
"""
|
||||||
json_write(nested_set(json_read(config_file), value, *(*path, key)), config_file)
|
json_write(nested_set(json_read(config_file), value, *(*path, key)), config_file)
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
def config_delete(
|
def config_delete(
|
||||||
key: str,
|
key: str,
|
||||||
*path: str,
|
*path: str,
|
||||||
missing_ok: bool = False,
|
missing_ok: bool = False,
|
||||||
config_file: Union[str, Path] = "config.json",
|
config_file: Union[str, Path] = DEFAULT_CONFIG_LOCATION,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set config's key by its path
|
"""Set config's key by its path
|
||||||
|
|
||||||
|
@@ -6,10 +6,12 @@ from libbot._utils import supports_argument
|
|||||||
|
|
||||||
|
|
||||||
def func1(foo: str, bar: str):
|
def func1(foo: str, bar: str):
|
||||||
|
"""Dummy function with specific arguments"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def func2(foo: str):
|
def func2(foo: str):
|
||||||
|
"""Dummy function with specific arguments"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user