dshellInterpreter 0.2.17.3__py3-none-any.whl → 0.2.18.0__py3-none-any.whl
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.
Potentially problematic release.
This version of dshellInterpreter might be problematic. Click here for more details.
- Dshell/DISCORD_COMMANDS/utils/utils_string.py +96 -0
- Dshell/_DshellTokenizer/dshell_keywords.py +9 -0
- {dshellinterpreter-0.2.17.3.dist-info → dshellinterpreter-0.2.18.0.dist-info}/METADATA +1 -1
- {dshellinterpreter-0.2.17.3.dist-info → dshellinterpreter-0.2.18.0.dist-info}/RECORD +7 -6
- {dshellinterpreter-0.2.17.3.dist-info → dshellinterpreter-0.2.18.0.dist-info}/WHEEL +0 -0
- {dshellinterpreter-0.2.17.3.dist-info → dshellinterpreter-0.2.18.0.dist-info}/licenses/LICENSE +0 -0
- {dshellinterpreter-0.2.17.3.dist-info → dshellinterpreter-0.2.18.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
__all__ = [
|
|
2
|
+
"utils_split_string",
|
|
3
|
+
"utils_upper_string",
|
|
4
|
+
"utils_lower_string",
|
|
5
|
+
"utils_title_string",
|
|
6
|
+
"utils_strip_string",
|
|
7
|
+
"utils_replace_string"
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
from discord import Message
|
|
11
|
+
|
|
12
|
+
async def utils_split_string(ctx: Message, value: str, separator: str = ' ') -> "ListNode":
|
|
13
|
+
"""
|
|
14
|
+
Split a string into a list of strings using the specified separator.
|
|
15
|
+
:param value:
|
|
16
|
+
:param separator:
|
|
17
|
+
:return:
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
if not isinstance(value, str):
|
|
21
|
+
raise TypeError(f"value must be a str in split command, not {type(value)}")
|
|
22
|
+
|
|
23
|
+
if not isinstance(separator, str):
|
|
24
|
+
raise TypeError(f"separator must be a str in split command, not {type(separator)}")
|
|
25
|
+
|
|
26
|
+
from ..._DshellParser.ast_nodes import ListNode
|
|
27
|
+
|
|
28
|
+
return ListNode(value.split(separator))
|
|
29
|
+
|
|
30
|
+
async def utils_upper_string(ctx: Message, value: str) -> str:
|
|
31
|
+
"""
|
|
32
|
+
Convert a string to uppercase.
|
|
33
|
+
:param value:
|
|
34
|
+
:return:
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
if not isinstance(value, str):
|
|
38
|
+
raise TypeError(f"value must be a str in upper command, not {type(value)}")
|
|
39
|
+
|
|
40
|
+
return value.upper()
|
|
41
|
+
|
|
42
|
+
async def utils_lower_string(ctx: Message, value: str) -> str:
|
|
43
|
+
"""
|
|
44
|
+
Convert a string to lowercase.
|
|
45
|
+
:param value:
|
|
46
|
+
:return:
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
if not isinstance(value, str):
|
|
50
|
+
raise TypeError(f"value must be a str in lower command, not {type(value)}")
|
|
51
|
+
|
|
52
|
+
return value.lower()
|
|
53
|
+
|
|
54
|
+
async def utils_title_string(ctx: Message, value: str) -> str:
|
|
55
|
+
"""
|
|
56
|
+
Convert a string to title case.
|
|
57
|
+
:param value:
|
|
58
|
+
:return:
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
if not isinstance(value, str):
|
|
62
|
+
raise TypeError(f"value must be a str in title command, not {type(value)}")
|
|
63
|
+
|
|
64
|
+
return value.title()
|
|
65
|
+
|
|
66
|
+
async def utils_strip_string(ctx: Message, value: str) -> str:
|
|
67
|
+
"""
|
|
68
|
+
Strip whitespace from the beginning and end of a string.
|
|
69
|
+
:param value:
|
|
70
|
+
:return:
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
if not isinstance(value, str):
|
|
74
|
+
raise TypeError(f"value must be a str in strip command, not {type(value)}")
|
|
75
|
+
|
|
76
|
+
return value.strip()
|
|
77
|
+
|
|
78
|
+
async def utils_replace_string(ctx: Message, value: str, old: str, new: str) -> str:
|
|
79
|
+
"""
|
|
80
|
+
Replace all occurrences of old with new in a string.
|
|
81
|
+
:param value:
|
|
82
|
+
:param old:
|
|
83
|
+
:param new:
|
|
84
|
+
:return:
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
if not isinstance(value, str):
|
|
88
|
+
raise TypeError(f"value must be a str in replace command, not {type(value)}")
|
|
89
|
+
|
|
90
|
+
if not isinstance(old, str):
|
|
91
|
+
raise TypeError(f"old must be a str in replace command, not {type(old)}")
|
|
92
|
+
|
|
93
|
+
if not isinstance(new, str):
|
|
94
|
+
raise TypeError(f"new must be a str in replace command, not {type(new)}")
|
|
95
|
+
|
|
96
|
+
return value.replace(old, new)
|
|
@@ -19,6 +19,7 @@ from ..DISCORD_COMMANDS.dshell_interaction import *
|
|
|
19
19
|
from ..DISCORD_COMMANDS.utils.utils_global import *
|
|
20
20
|
from ..DISCORD_COMMANDS.utils.utils_list import *
|
|
21
21
|
from ..DISCORD_COMMANDS.utils.utils_member import *
|
|
22
|
+
from ..DISCORD_COMMANDS.utils.utils_string import *
|
|
22
23
|
|
|
23
24
|
dshell_keyword: set[str] = {
|
|
24
25
|
'if', 'else', 'elif', 'loop', '#end', 'var', '#loop', '#if', 'sleep', 'param', '#param'
|
|
@@ -43,6 +44,14 @@ dshell_commands: dict[str, Callable] = {
|
|
|
43
44
|
'reverse': utils_list_reverse,
|
|
44
45
|
'get': utils_list_get_value,
|
|
45
46
|
|
|
47
|
+
## String utils
|
|
48
|
+
'split': utils_split_string,
|
|
49
|
+
'upper': utils_upper_string,
|
|
50
|
+
'lower': utils_lower_string,
|
|
51
|
+
'title': utils_title_string,
|
|
52
|
+
'strip': utils_strip_string,
|
|
53
|
+
'replace': utils_replace_string,
|
|
54
|
+
|
|
46
55
|
## Discord utils
|
|
47
56
|
'name': utils_get_name, # get the name from id (channel, role, member)
|
|
48
57
|
'id': utils_get_id, # get the id from name (channel, role, member)
|
|
@@ -13,6 +13,7 @@ Dshell/DISCORD_COMMANDS/utils/utils_list.py,sha256=zqImMWvD-1UnbPP1TZewnvZpq7qs1
|
|
|
13
13
|
Dshell/DISCORD_COMMANDS/utils/utils_member.py,sha256=1EoHooxwijc7AFJGnuae3ccjQk0x69MELtZ5ES5abLY,1165
|
|
14
14
|
Dshell/DISCORD_COMMANDS/utils/utils_message.py,sha256=cQvJ15f49ddOjybARwkJKNFe3ITYQciF-pZHERFPkr0,2964
|
|
15
15
|
Dshell/DISCORD_COMMANDS/utils/utils_permissions.py,sha256=Gi6vpCA2yXUZ20OCay5dkX6HeN4LglVROwcvTWVCsKg,3600
|
|
16
|
+
Dshell/DISCORD_COMMANDS/utils/utils_string.py,sha256=wElUdUn3nEeR_ZiJZZDonlCFukBrar8Bxy9-bVlZAvE,2686
|
|
16
17
|
Dshell/DISCORD_COMMANDS/utils/utils_thread.py,sha256=tVl4msEwrWHY-0AytI6eY3JSs-eIFUigDSJfK9mT1ww,1457
|
|
17
18
|
Dshell/_DshellInterpreteur/__init__.py,sha256=jl_gH8MoqerW--I-IHXwUZTo80JOtfr7AOA57xVgeGQ,58
|
|
18
19
|
Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=PcwfNPz44v6gsl-xNcvNwV5lcLhpJ6yDdjwHHnE6OUE,29493
|
|
@@ -21,11 +22,11 @@ Dshell/_DshellParser/__init__.py,sha256=ONDfhZMvClqP_6tE8SLjp-cf3pXL-auQYnfYRrHZ
|
|
|
21
22
|
Dshell/_DshellParser/ast_nodes.py,sha256=RLlylX9bvbJEG3BDMGS4mnMxU8ufnZYIF59NVf_pW7A,18883
|
|
22
23
|
Dshell/_DshellParser/dshell_parser.py,sha256=cpukpWFJlioP1pIZZMGg24GrXfnnz1nuPCIKRNsxAcE,18949
|
|
23
24
|
Dshell/_DshellTokenizer/__init__.py,sha256=LIQSRhDx2B9pmPx5ADMwwD0Xr9ybneVLhHH8qrJWw_s,172
|
|
24
|
-
Dshell/_DshellTokenizer/dshell_keywords.py,sha256=
|
|
25
|
+
Dshell/_DshellTokenizer/dshell_keywords.py,sha256=hW9ajfKMXN2XNwOnibW5Vn2XhgMfu1hUqUy1WdDQSTs,7123
|
|
25
26
|
Dshell/_DshellTokenizer/dshell_token_type.py,sha256=gYIb2XN2YcgeRgmar_rBDS5CGmwfmxihu8mOW_d6lbE,1533
|
|
26
27
|
Dshell/_DshellTokenizer/dshell_tokenizer.py,sha256=AJnUocD6hbU6wvjRAN5uDha5QQieTwXlHzZVtgRGaZQ,7307
|
|
27
|
-
dshellinterpreter-0.2.
|
|
28
|
-
dshellinterpreter-0.2.
|
|
29
|
-
dshellinterpreter-0.2.
|
|
30
|
-
dshellinterpreter-0.2.
|
|
31
|
-
dshellinterpreter-0.2.
|
|
28
|
+
dshellinterpreter-0.2.18.0.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
|
|
29
|
+
dshellinterpreter-0.2.18.0.dist-info/METADATA,sha256=e4rNTDr91A1ug4oFQk1Shx4Y15MOC9buN5qzbVPL0Bw,1151
|
|
30
|
+
dshellinterpreter-0.2.18.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
31
|
+
dshellinterpreter-0.2.18.0.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
|
|
32
|
+
dshellinterpreter-0.2.18.0.dist-info/RECORD,,
|
|
File without changes
|
{dshellinterpreter-0.2.17.3.dist-info → dshellinterpreter-0.2.18.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|