dshellInterpreter 0.2.17.1__py3-none-any.whl → 0.2.17.2__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_global.py +17 -1
- Dshell/_DshellInterpreteur/__init__.py +1 -0
- Dshell/_DshellInterpreteur/dshell_interpreter.py +5 -1
- Dshell/_DshellInterpreteur/errors.py +8 -0
- Dshell/_DshellParser/ast_nodes.py +5 -4
- Dshell/_DshellParser/dshell_parser.py +7 -1
- Dshell/_DshellTokenizer/dshell_keywords.py +3 -0
- Dshell/__init__.py +1 -0
- {dshellinterpreter-0.2.17.1.dist-info → dshellinterpreter-0.2.17.2.dist-info}/METADATA +1 -1
- {dshellinterpreter-0.2.17.1.dist-info → dshellinterpreter-0.2.17.2.dist-info}/RECORD +13 -12
- {dshellinterpreter-0.2.17.1.dist-info → dshellinterpreter-0.2.17.2.dist-info}/WHEEL +0 -0
- {dshellinterpreter-0.2.17.1.dist-info → dshellinterpreter-0.2.17.2.dist-info}/licenses/LICENSE +0 -0
- {dshellinterpreter-0.2.17.1.dist-info → dshellinterpreter-0.2.17.2.dist-info}/top_level.txt +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
__all__ = [
|
|
2
2
|
"utils_len",
|
|
3
|
+
"utils_random",
|
|
3
4
|
"utils_get_name",
|
|
4
5
|
"utils_get_id",
|
|
5
6
|
"utils_get_roles",
|
|
@@ -7,8 +8,9 @@ __all__ = [
|
|
|
7
8
|
|
|
8
9
|
from discord import Message, Role, TextChannel, VoiceChannel, CategoryChannel, ForumChannel, Thread, Member, Guild
|
|
9
10
|
from discord.utils import get
|
|
10
|
-
from typing import Union
|
|
11
|
+
from typing import Union, Optional
|
|
11
12
|
from enum import StrEnum
|
|
13
|
+
from random import random, choice
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
class DiscordType(StrEnum):
|
|
@@ -65,6 +67,20 @@ async def utils_len(ctx: Message, value):
|
|
|
65
67
|
|
|
66
68
|
return len(value)
|
|
67
69
|
|
|
70
|
+
async def utils_random(ctx: Message, value: Optional["ListNode"] = None):
|
|
71
|
+
"""
|
|
72
|
+
Return a random element from a list, or a random integer between 0 and value
|
|
73
|
+
:param value:
|
|
74
|
+
:return:
|
|
75
|
+
"""
|
|
76
|
+
from ..._DshellParser.ast_nodes import ListNode
|
|
77
|
+
if value is not None and not isinstance(value, ListNode):
|
|
78
|
+
raise TypeError(f"value must be a list in random command, not {type(value)}")
|
|
79
|
+
|
|
80
|
+
if value is None:
|
|
81
|
+
return random()
|
|
82
|
+
return choice(value)
|
|
83
|
+
|
|
68
84
|
async def utils_get_name(ctx : Message, value: int) -> Union[str, None]:
|
|
69
85
|
"""
|
|
70
86
|
Return the name of a role, member, or channel.
|
|
@@ -9,6 +9,7 @@ from discord import AutoShardedBot, Embed, Colour, PermissionOverwrite, Permissi
|
|
|
9
9
|
from discord.ui import Button
|
|
10
10
|
from discord.abc import PrivateChannel
|
|
11
11
|
|
|
12
|
+
from .errors import *
|
|
12
13
|
from .._DshellParser.ast_nodes import *
|
|
13
14
|
from ..DISCORD_COMMANDS.utils.utils_permissions import DshellPermissions
|
|
14
15
|
from .._DshellParser.dshell_parser import parse
|
|
@@ -194,7 +195,10 @@ class DshellInterpreteur:
|
|
|
194
195
|
|
|
195
196
|
|
|
196
197
|
elif isinstance(node, EndNode):
|
|
197
|
-
|
|
198
|
+
if node.error_message:
|
|
199
|
+
raise RuntimeError("Execution stopped - EndNode encountered")
|
|
200
|
+
else:
|
|
201
|
+
raise DshellInterpreterStopExecution()
|
|
198
202
|
|
|
199
203
|
def eval_data_token(self, token: Token):
|
|
200
204
|
"""
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from random import randint
|
|
2
|
-
from typing import Optional, Any
|
|
2
|
+
from typing import Optional, Any, Union
|
|
3
3
|
|
|
4
4
|
from .._DshellTokenizer.dshell_token_type import Token
|
|
5
5
|
|
|
@@ -286,8 +286,8 @@ class EndNode(ASTNode):
|
|
|
286
286
|
Node representing the end of the AST.
|
|
287
287
|
"""
|
|
288
288
|
|
|
289
|
-
def __init__(self):
|
|
290
|
-
|
|
289
|
+
def __init__(self, error_message: Union[Token, bool] = True):
|
|
290
|
+
self.error_message: bool = error_message
|
|
291
291
|
|
|
292
292
|
def __repr__(self):
|
|
293
293
|
return f"<END>"
|
|
@@ -298,7 +298,8 @@ class EndNode(ASTNode):
|
|
|
298
298
|
:return: Dictionary representation of the EndNode.
|
|
299
299
|
"""
|
|
300
300
|
return {
|
|
301
|
-
"type": "EndNode"
|
|
301
|
+
"type": "EndNode",
|
|
302
|
+
"error_message": self.error_message
|
|
302
303
|
}
|
|
303
304
|
|
|
304
305
|
|
|
@@ -158,7 +158,13 @@ def parse(token_lines: list[list[Token]], start_node: ASTNode) -> tuple[list[AST
|
|
|
158
158
|
return blocks, pointeur # on renvoie les informations parsé à la dernière paramètre ouverte
|
|
159
159
|
|
|
160
160
|
elif first_token_line.value == '#end': # node pour arrêter le programme si elle est rencontré
|
|
161
|
-
|
|
161
|
+
error_message = True
|
|
162
|
+
if len(tokens_by_line) > 1:
|
|
163
|
+
if tokens_by_line[1].type != DTT.BOOL:
|
|
164
|
+
raise TypeError(f'[#END] the variable given must be a boolean, not {tokens_by_line[1].type}')
|
|
165
|
+
else:
|
|
166
|
+
error_message = tokens_by_line[1]
|
|
167
|
+
end_node = EndNode(error_message)
|
|
162
168
|
last_block.body.append(end_node)
|
|
163
169
|
|
|
164
170
|
############################## DISCORD KEYWORDS ##############################
|
Dshell/__init__.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Dshell/__init__.py,sha256=
|
|
1
|
+
Dshell/__init__.py,sha256=gEgfeYoyHn4bUepMd0F-MSx36rR8WgQGxNpgDKo2qbA,136
|
|
2
2
|
Dshell/_utils.py,sha256=PJ3fwn8IMqUMnW9oTwfr9v4--rzHIhhLQoVVqjwjoJU,23
|
|
3
3
|
Dshell/DISCORD_COMMANDS/__init__.py,sha256=87-YpGU74m-m7AqUQni7PGbw73JRlioQkywW_61Whms,208
|
|
4
4
|
Dshell/DISCORD_COMMANDS/dshell_channel.py,sha256=PDXpxrRRWPSucdp_3ITJk0Ur3coneRJKWEl2i7GZ2EM,15696
|
|
@@ -8,23 +8,24 @@ Dshell/DISCORD_COMMANDS/dshell_message.py,sha256=zcWl6Y1W31h9MTHS-j9tLDwcrRiE_wG
|
|
|
8
8
|
Dshell/DISCORD_COMMANDS/dshell_pastbin.py,sha256=H0tUJOwdzYBXvxqipK3mzoNZUKrSLcVm4EZlWbBRScs,796
|
|
9
9
|
Dshell/DISCORD_COMMANDS/dshell_role.py,sha256=t_yRZRD0FKE2gT4dIDIsHz2PSZZztDVEkkqkG_OkNh4,5002
|
|
10
10
|
Dshell/DISCORD_COMMANDS/utils/__init__.py,sha256=-amNcYysjgx3YDpDSnbQmJhnm3lbJere9K9aDH-YnJg,115
|
|
11
|
-
Dshell/DISCORD_COMMANDS/utils/utils_global.py,sha256=
|
|
11
|
+
Dshell/DISCORD_COMMANDS/utils/utils_global.py,sha256=G_gH9iF6roT-0QR2FUZj6_P1ADr06JrxZgELOy9yIP8,4768
|
|
12
12
|
Dshell/DISCORD_COMMANDS/utils/utils_list.py,sha256=zqImMWvD-1UnbPP1TZewnvZpq7qs1sOTT1YhbJ5I8h8,3160
|
|
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
16
|
Dshell/DISCORD_COMMANDS/utils/utils_thread.py,sha256=tVl4msEwrWHY-0AytI6eY3JSs-eIFUigDSJfK9mT1ww,1457
|
|
17
|
-
Dshell/_DshellInterpreteur/__init__.py,sha256=
|
|
18
|
-
Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=
|
|
17
|
+
Dshell/_DshellInterpreteur/__init__.py,sha256=jl_gH8MoqerW--I-IHXwUZTo80JOtfr7AOA57xVgeGQ,58
|
|
18
|
+
Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=Ru9usKKGPOCoCjdK6NIC6K9uKqqsqyT77Ffhktw7xB4,29471
|
|
19
|
+
Dshell/_DshellInterpreteur/errors.py,sha256=0PJz_VYZfNZeKR_PEHxw3tRkgKNNUerV0wwrq2r1luA,250
|
|
19
20
|
Dshell/_DshellParser/__init__.py,sha256=ONDfhZMvClqP_6tE8SLjp-cf3pXL-auQYnfYRrHZxC4,56
|
|
20
|
-
Dshell/_DshellParser/ast_nodes.py,sha256=
|
|
21
|
-
Dshell/_DshellParser/dshell_parser.py,sha256=
|
|
21
|
+
Dshell/_DshellParser/ast_nodes.py,sha256=RLlylX9bvbJEG3BDMGS4mnMxU8ufnZYIF59NVf_pW7A,18883
|
|
22
|
+
Dshell/_DshellParser/dshell_parser.py,sha256=cpukpWFJlioP1pIZZMGg24GrXfnnz1nuPCIKRNsxAcE,18949
|
|
22
23
|
Dshell/_DshellTokenizer/__init__.py,sha256=LIQSRhDx2B9pmPx5ADMwwD0Xr9ybneVLhHH8qrJWw_s,172
|
|
23
|
-
Dshell/_DshellTokenizer/dshell_keywords.py,sha256=
|
|
24
|
+
Dshell/_DshellTokenizer/dshell_keywords.py,sha256=MUTt4NCHzu2gqBgCS1fS0ULHR5K0crCMajE7WiglcJY,6839
|
|
24
25
|
Dshell/_DshellTokenizer/dshell_token_type.py,sha256=gYIb2XN2YcgeRgmar_rBDS5CGmwfmxihu8mOW_d6lbE,1533
|
|
25
26
|
Dshell/_DshellTokenizer/dshell_tokenizer.py,sha256=AJnUocD6hbU6wvjRAN5uDha5QQieTwXlHzZVtgRGaZQ,7307
|
|
26
|
-
dshellinterpreter-0.2.17.
|
|
27
|
-
dshellinterpreter-0.2.17.
|
|
28
|
-
dshellinterpreter-0.2.17.
|
|
29
|
-
dshellinterpreter-0.2.17.
|
|
30
|
-
dshellinterpreter-0.2.17.
|
|
27
|
+
dshellinterpreter-0.2.17.2.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
|
|
28
|
+
dshellinterpreter-0.2.17.2.dist-info/METADATA,sha256=FL9niNWhnpZU8N6MZ4nT3aBk9qT_Gj3k-PMXJM8XPdU,1151
|
|
29
|
+
dshellinterpreter-0.2.17.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
30
|
+
dshellinterpreter-0.2.17.2.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
|
|
31
|
+
dshellinterpreter-0.2.17.2.dist-info/RECORD,,
|
|
File without changes
|
{dshellinterpreter-0.2.17.1.dist-info → dshellinterpreter-0.2.17.2.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|