dshellInterpreter 0.1.23__py3-none-any.whl → 0.1.25__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/dshell_message.py +2 -2
- Dshell/_DshellInterpreteur/dshell_interpreter.py +13 -1
- Dshell/_DshellTokenizer/dshell_token_type.py +1 -0
- Dshell/_DshellTokenizer/dshell_tokenizer.py +12 -7
- {dshellinterpreter-0.1.23.dist-info → dshellinterpreter-0.1.25.dist-info}/METADATA +1 -1
- {dshellinterpreter-0.1.23.dist-info → dshellinterpreter-0.1.25.dist-info}/RECORD +9 -9
- {dshellinterpreter-0.1.23.dist-info → dshellinterpreter-0.1.25.dist-info}/WHEEL +0 -0
- {dshellinterpreter-0.1.23.dist-info → dshellinterpreter-0.1.25.dist-info}/licenses/LICENSE +0 -0
- {dshellinterpreter-0.1.23.dist-info → dshellinterpreter-0.1.25.dist-info}/top_level.txt +0 -0
|
@@ -42,12 +42,12 @@ async def dshell_send_message(ctx: Message, message=None, delete=None, channel=N
|
|
|
42
42
|
return sended_message.id
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
async def dshell_delete_message(ctx: Message, message, reason=None, delay=0):
|
|
45
|
+
async def dshell_delete_message(ctx: Message, message=None, reason=None, delay=0):
|
|
46
46
|
"""
|
|
47
47
|
Deletes a message
|
|
48
48
|
"""
|
|
49
49
|
|
|
50
|
-
delete_message = ctx.channel.get_partial_message(message) # builds a reference to the message (even if it doesn't exist)
|
|
50
|
+
delete_message = ctx if message is None else ctx.channel.get_partial_message(message) # builds a reference to the message (even if it doesn't exist)
|
|
51
51
|
|
|
52
52
|
if delay > 3600:
|
|
53
53
|
raise Exception(f'The message deletion delay is too long! ({delay} seconds)')
|
|
@@ -186,6 +186,8 @@ def get_params(node: ParamNode, interpreter: DshellInterpreteur) -> dict[str, An
|
|
|
186
186
|
if regrouped_args[key] == '*':
|
|
187
187
|
raise Exception(f"'{key}' is an obligatory parameter, but no value was given for it.")
|
|
188
188
|
|
|
189
|
+
print(regrouped_args)
|
|
190
|
+
|
|
189
191
|
return regrouped_args
|
|
190
192
|
|
|
191
193
|
def eval_expression_inline(if_node: IfNode, interpreter: DshellInterpreteur) -> Token:
|
|
@@ -278,6 +280,7 @@ def regroupe_commandes(body: list[Token], interpreter: DshellInterpreteur) -> li
|
|
|
278
280
|
|
|
279
281
|
i = 0
|
|
280
282
|
while i < n:
|
|
283
|
+
|
|
281
284
|
if body[i].type == DTT.SEPARATOR and body[
|
|
282
285
|
i + 1].type == DTT.IDENT: # Check if it's a separator and if the next token is an IDENT
|
|
283
286
|
current_arg = body[i + 1].value # change the current argument. It will be impossible to return to '*'
|
|
@@ -291,7 +294,15 @@ def regroupe_commandes(body: list[Token], interpreter: DshellInterpreteur) -> li
|
|
|
291
294
|
type_=DTT.SEPARATOR, value=body[i].value, position=body[i].position)
|
|
292
295
|
] + body[i + 1:], interpreter
|
|
293
296
|
) # add a sub-dictionary for sub-commands
|
|
294
|
-
return list_tokens
|
|
297
|
+
#return list_tokens
|
|
298
|
+
|
|
299
|
+
elif (body[i].type == DTT.SEPARATOR and
|
|
300
|
+
(body[i + 1].type == DTT.MATHS_OPERATOR and body[i + 1].value == '*') and
|
|
301
|
+
body[i + 2].type == DTT.IDENT and
|
|
302
|
+
body[i + 3].type == DTT.ENGLOBE_SEPARATOR):
|
|
303
|
+
current_arg = body[i + 2].value # change the current argument
|
|
304
|
+
tokens[current_arg] = body[i + 3].value
|
|
305
|
+
i += 4
|
|
295
306
|
|
|
296
307
|
else:
|
|
297
308
|
if current_arg == '*':
|
|
@@ -299,6 +310,7 @@ def regroupe_commandes(body: list[Token], interpreter: DshellInterpreteur) -> li
|
|
|
299
310
|
else:
|
|
300
311
|
tokens[current_arg] = interpreter.eval_data_token(body[i]) # add the token to the current argument
|
|
301
312
|
i += 1
|
|
313
|
+
|
|
302
314
|
return list_tokens
|
|
303
315
|
|
|
304
316
|
|
|
@@ -25,6 +25,7 @@ class DshellTokenType(Enum):
|
|
|
25
25
|
DISCORD_KEYWORD = auto() # embed, #embed...
|
|
26
26
|
COMMAND = auto()
|
|
27
27
|
SEPARATOR = auto() # --
|
|
28
|
+
ENGLOBE_SEPARATOR = auto(), # --*
|
|
28
29
|
SUB_SEPARATOR = auto(), # ~~
|
|
29
30
|
MATHS_OPERATOR = auto() # ==, +, -, *, etc.
|
|
30
31
|
LOGIC_OPERATOR = auto(),
|
|
@@ -15,15 +15,15 @@ MASK_CHARACTER = '§'
|
|
|
15
15
|
|
|
16
16
|
table_regex: dict[DTT, Pattern] = {
|
|
17
17
|
DTT.COMMENT: compile(r"::(.*?)"),
|
|
18
|
-
|
|
18
|
+
DTT.ENGLOBE_SEPARATOR: compile(rf"--\*\w+\s*(.*)"),
|
|
19
19
|
DTT.STR: compile(r'"(.*?)"', flags=DOTALL),
|
|
20
20
|
DTT.LIST: compile(r"\[(.*?)\]"),
|
|
21
21
|
DTT.CALL_ARGS: compile(r"\((.*?)\)"),
|
|
22
22
|
DTT.MENTION: compile(r'<(?:@!?|@&|#)([0-9]+)>'),
|
|
23
|
-
DTT.KEYWORD: compile(rf"(?<!\w)(#?{'|'.join(dshell_keyword)})(?!\w)"),
|
|
24
|
-
DTT.DISCORD_KEYWORD: compile(rf"(?<!\w|-)(#?{'|'.join(dshell_discord_keyword)})(?!\w|-)"),
|
|
25
23
|
DTT.SEPARATOR: compile(rf"(--)"),
|
|
26
24
|
DTT.SUB_SEPARATOR: compile(rf"(~~)"),
|
|
25
|
+
DTT.KEYWORD: compile(rf"(?<!\w)(#?{'|'.join(dshell_keyword)})(?!\w)"),
|
|
26
|
+
DTT.DISCORD_KEYWORD: compile(rf"(?<!\w|-)(#?{'|'.join(dshell_discord_keyword)})(?!\w|-)"),
|
|
27
27
|
DTT.COMMAND: compile(rf"\b({'|'.join(dshell_commands.keys())})\b"),
|
|
28
28
|
DTT.MATHS_OPERATOR: compile(rf"({'|'.join([escape(i) for i in dshell_mathematical_operators.keys()])})"),
|
|
29
29
|
DTT.LOGIC_OPERATOR: compile(rf"(?<!\w)({'|'.join([escape(i) for i in dshell_logical_operators.keys()])})(?<!\w)"),
|
|
@@ -66,8 +66,13 @@ class DshellTokenizer:
|
|
|
66
66
|
for token_type, pattern in table_regex.items(): # iter la table de régex pour tous les tester sur la ligne
|
|
67
67
|
|
|
68
68
|
for match in finditer(pattern, ligne): # iter les résultat du match pour avoir leur position
|
|
69
|
+
|
|
70
|
+
start_match = match.start() # position de début du match
|
|
71
|
+
if token_type == DTT.ENGLOBE_SEPARATOR:
|
|
72
|
+
start_match += len(match.group(0)) - len(match.group(1)) # si c'est un séparateur englobant, on enlève les --* du début
|
|
73
|
+
|
|
69
74
|
if token_type != DTT.COMMENT: # si ce n'est pas un commentaire
|
|
70
|
-
token = Token(token_type, match.group(1), (line_number,
|
|
75
|
+
token = Token(token_type, match.group(1), (line_number, start_match)) # on enregistre son token
|
|
71
76
|
tokens_par_ligne.append(token)
|
|
72
77
|
|
|
73
78
|
if token_type in (
|
|
@@ -81,15 +86,15 @@ class DshellTokenizer:
|
|
|
81
86
|
token_in_list.position = (line_number, token_in_list.position[1])
|
|
82
87
|
|
|
83
88
|
for token_in_line in range(len(tokens_par_ligne)-1):
|
|
84
|
-
if tokens_par_ligne[token_in_line].position[1] >
|
|
89
|
+
if tokens_par_ligne[token_in_line].position[1] > start_match:
|
|
85
90
|
str_tokens_in_list = tokens_par_ligne[token_in_line:-1]
|
|
86
91
|
tokens_par_ligne = tokens_par_ligne[:token_in_line] + [tokens_par_ligne[-1]]
|
|
87
92
|
token.value.extend(str_tokens_in_list)
|
|
88
93
|
token.value.sort(key=lambda t: t.position[1]) # trie les tokens par rapport à leur position
|
|
89
94
|
break
|
|
90
95
|
|
|
91
|
-
len_match = len(match.group(0))
|
|
92
|
-
ligne = ligne[:
|
|
96
|
+
len_match = len(match.group(0)) # longueur du match trouvé
|
|
97
|
+
ligne = ligne[:start_match] + (MASK_CHARACTER * len_match) + ligne[
|
|
93
98
|
match.end():] # remplace la match qui vient d'avoir lieu pour ne pas le rematch une seconde fois
|
|
94
99
|
|
|
95
100
|
tokens_par_ligne.sort(key=lambda
|
|
@@ -2,18 +2,18 @@ Dshell/__init__.py,sha256=UPvXnewe_8FX9aoevMA78UN1k8AY-u8LTY3vEVxaDxw,72
|
|
|
2
2
|
Dshell/DISCORD_COMMANDS/__init__.py,sha256=unbZE4sxFCbUQ4Qptr1BhWu-nwhvI2oRzcDLtRmX6Ug,92
|
|
3
3
|
Dshell/DISCORD_COMMANDS/dshell_channel.py,sha256=_qHfhVaeXLQMI926AJI3uYpjDXxVNF3sZ84EwWU-jz0,6450
|
|
4
4
|
Dshell/DISCORD_COMMANDS/dshell_member.py,sha256=4cmpcu9RGHVUOGcF9pSnnxh7kEJQWAel4BBQ6Vicvbs,3126
|
|
5
|
-
Dshell/DISCORD_COMMANDS/dshell_message.py,sha256=
|
|
5
|
+
Dshell/DISCORD_COMMANDS/dshell_message.py,sha256=L5upeKAsski5bNjQTwzMNc2fVnUoz5_9TitQ5qJMuF0,4460
|
|
6
6
|
Dshell/_DshellInterpreteur/__init__.py,sha256=xy5-J-R3YmY99JF3NBHTRRLsComFxpjnCA5xacISctU,35
|
|
7
|
-
Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=
|
|
7
|
+
Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=5TzoiFZWXKBKdLmUZrAqSoScAffp5qrlqFQZ0UMuvvk,19916
|
|
8
8
|
Dshell/_DshellParser/__init__.py,sha256=ONDfhZMvClqP_6tE8SLjp-cf3pXL-auQYnfYRrHZxC4,56
|
|
9
9
|
Dshell/_DshellParser/ast_nodes.py,sha256=-zFmSeb6FnvcXd2gB3koy93apVJ-PiCY8PTUFj-_bG8,15307
|
|
10
10
|
Dshell/_DshellParser/dshell_parser.py,sha256=jCnwxY_J-_u1W_tEotQznp4_Y0aeAH4pTcPl6_Fx9f8,15525
|
|
11
11
|
Dshell/_DshellTokenizer/__init__.py,sha256=LIQSRhDx2B9pmPx5ADMwwD0Xr9ybneVLhHH8qrJWw_s,172
|
|
12
12
|
Dshell/_DshellTokenizer/dshell_keywords.py,sha256=10VctszIRg8AX5Nsr7kwRIjdwzUgTfrrJYbD7QfYR5s,4253
|
|
13
|
-
Dshell/_DshellTokenizer/dshell_token_type.py,sha256=
|
|
14
|
-
Dshell/_DshellTokenizer/dshell_tokenizer.py,sha256=
|
|
15
|
-
dshellinterpreter-0.1.
|
|
16
|
-
dshellinterpreter-0.1.
|
|
17
|
-
dshellinterpreter-0.1.
|
|
18
|
-
dshellinterpreter-0.1.
|
|
19
|
-
dshellinterpreter-0.1.
|
|
13
|
+
Dshell/_DshellTokenizer/dshell_token_type.py,sha256=pWzvmj6EFGkDwNHooOAjdyysi1vZRVEostFIZSW1Ais,1483
|
|
14
|
+
Dshell/_DshellTokenizer/dshell_tokenizer.py,sha256=a4HJdeIT3HP0a5ekUwq5Nb9Wohnjk5A44yGEneCUBjQ,7020
|
|
15
|
+
dshellinterpreter-0.1.25.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
|
|
16
|
+
dshellinterpreter-0.1.25.dist-info/METADATA,sha256=mHOnOkPg00JKNG1J9ku8d6RehNiUJqzvkQD74vsrnw8,1096
|
|
17
|
+
dshellinterpreter-0.1.25.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
18
|
+
dshellinterpreter-0.1.25.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
|
|
19
|
+
dshellinterpreter-0.1.25.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|