dshellInterpreter 1.2.0.22__tar.gz → 1.2.1.1__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 (53) hide show
  1. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DISCORD_COMMANDS/dshell_channel.py +2 -2
  2. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DISCORD_COMMANDS/dshell_ui.py +26 -21
  3. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DshellInterpreteur/dshell_interpreter.py +11 -2
  4. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DshellParser/ast_nodes.py +0 -21
  5. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DshellParser/dshell_parser.py +2 -6
  6. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DshellTokenizer/dshell_keywords.py +2 -1
  7. {dshellinterpreter-1.2.0.22/dshellInterpreter.egg-info → dshellinterpreter-1.2.1.1}/PKG-INFO +1 -1
  8. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1/dshellInterpreter.egg-info}/PKG-INFO +1 -1
  9. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/setup.py +1 -1
  10. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DISCORD_COMMANDS/__init__.py +0 -0
  11. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DISCORD_COMMANDS/dshell_embed.py +0 -0
  12. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DISCORD_COMMANDS/dshell_file.py +0 -0
  13. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DISCORD_COMMANDS/dshell_interaction.py +0 -0
  14. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DISCORD_COMMANDS/dshell_member.py +0 -0
  15. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DISCORD_COMMANDS/dshell_message.py +0 -0
  16. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DISCORD_COMMANDS/dshell_pastbin.py +0 -0
  17. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DISCORD_COMMANDS/dshell_role.py +0 -0
  18. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DISCORD_COMMANDS/utils/__init__.py +0 -0
  19. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DISCORD_COMMANDS/utils/utils_embed.py +0 -0
  20. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DISCORD_COMMANDS/utils/utils_file.py +0 -0
  21. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DISCORD_COMMANDS/utils/utils_global.py +0 -0
  22. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DISCORD_COMMANDS/utils/utils_list.py +0 -0
  23. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DISCORD_COMMANDS/utils/utils_member.py +0 -0
  24. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DISCORD_COMMANDS/utils/utils_message.py +0 -0
  25. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DISCORD_COMMANDS/utils/utils_numbers.py +0 -0
  26. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DISCORD_COMMANDS/utils/utils_permissions.py +0 -0
  27. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DISCORD_COMMANDS/utils/utils_string.py +0 -0
  28. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DISCORD_COMMANDS/utils/utils_thread.py +0 -0
  29. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DISCORD_COMMANDS/utils/utils_type_validation.py +0 -0
  30. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DshellInterpreteur/__init__.py +0 -0
  31. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DshellInterpreteur/cached_messages.py +0 -0
  32. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DshellInterpreteur/dshell_arguments.py +0 -0
  33. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DshellInterpreteur/dshell_global_variables.py +0 -0
  34. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DshellInterpreteur/dshell_scope.py +0 -0
  35. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DshellInterpreteur/errors.py +0 -0
  36. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DshellInterpreteur/utils_interpreter.py +0 -0
  37. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DshellParser/__init__.py +0 -0
  38. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DshellParser/errors.py +0 -0
  39. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DshellPreProcess/__init__.py +0 -0
  40. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DshellPreProcess/dshell_preprocess.py +0 -0
  41. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DshellTokenizer/__init__.py +0 -0
  42. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DshellTokenizer/dshell_token_type.py +0 -0
  43. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/DshellTokenizer/dshell_tokenizer.py +0 -0
  44. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/__init__.py +0 -0
  45. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/full_import.py +0 -0
  46. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/Dshell/regex_test.py +0 -0
  47. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/LICENSE +0 -0
  48. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/README.md +0 -0
  49. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/dshellInterpreter.egg-info/SOURCES.txt +0 -0
  50. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/dshellInterpreter.egg-info/dependency_links.txt +0 -0
  51. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/dshellInterpreter.egg-info/requires.txt +0 -0
  52. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/dshellInterpreter.egg-info/top_level.txt +0 -0
  53. {dshellinterpreter-1.2.0.22 → dshellinterpreter-1.2.1.1}/setup.cfg +0 -0
@@ -158,7 +158,7 @@ async def dshell_create_text_channel(ctx: Message,
158
158
 
159
159
  channel_category = ctx.channel.category if category is None else ctx.channel.guild.get_channel(category)
160
160
 
161
- final_permissions = permissions.value if not MISSING else permissions
161
+ final_permissions = permissions.value if not isinstance(permissions, _MissingSentinel) else permissions
162
162
 
163
163
  created_channel = await ctx.guild.create_text_channel(str(name),
164
164
  category=channel_category,
@@ -198,7 +198,7 @@ async def dshell_create_voice_channel(ctx: Message,
198
198
 
199
199
  channel_category = ctx.channel.category if category is None else ctx.channel.guild.get_channel(category)
200
200
 
201
- final_permissions = permissions.value if not MISSING else permissions
201
+ final_permissions = permissions.value if not isinstance(permissions, _MissingSentinel) else permissions
202
202
 
203
203
  created_channel = await ctx.guild.create_voice_channel(StrNode(name),
204
204
  category=channel_category,
@@ -47,18 +47,24 @@ async def build_ui_button_parameters(ui_button_node: UiButtonNode, interpreter:
47
47
 
48
48
  code = args_button.pop('code', None)
49
49
  style = args_button.pop('style', 'primary').lower()
50
- custom_id = args_button.pop('custom_id', 'ui_button_'+str(random()))
51
- row = args_button.pop('row', 0)
50
+ custom_id = args_button.pop('custom_id', StrNode('ui_button_'+str(random())))
51
+ row = args_button.pop('row', IntNode(0))
52
52
  emoji = utils_refactor_emoji(args_button.pop('emoji', None))
53
53
 
54
54
  _validate_optional_code_node(code, "Button code", "build_ui_button")
55
55
 
56
- if not isinstance(custom_id, str):
56
+ if not isinstance(custom_id, StrNode):
57
57
  raise TypeError(f"Button custom_id must be a string, not {type(custom_id)} !")
58
58
 
59
59
  if style not in ButtonStyleValues:
60
60
  raise ValueError(f"Button style must be one of {', '.join(ButtonStyleValues)}, not '{style}' !")
61
61
 
62
+ if not isinstance(row, IntNode):
63
+ raise TypeError(f"Buttton row must be a int, not {type(row)} !")
64
+
65
+ if not isinstance(emoji, StrNode):
66
+ raise TypeError(f"Button emoji must be a str, not {type(emoji)} !")
67
+
62
68
  args_button['custom_id'] = custom_id
63
69
  args_button['row'] = row
64
70
  args_button['style'] = ButtonStyle[style]
@@ -78,7 +84,7 @@ async def build_ui_select_parameters(ui_select_node: UiSelectNode, interpreter:
78
84
  args_select: dict[str, list[Any]] = regrouped_parameters.get_dict_parameters()
79
85
 
80
86
  code = args_select.pop('code', None)
81
- custom_id = args_select.pop('custom_id', 'ui_select_'+str(random()))
87
+ custom_id = args_select.pop('custom_id', StrNode('ui_select_'+str(random())))
82
88
  select_type = args_select.pop('type', 'string').lower()
83
89
 
84
90
  disabled = args_select.get('disabled', False)
@@ -89,22 +95,22 @@ async def build_ui_select_parameters(ui_select_node: UiSelectNode, interpreter:
89
95
 
90
96
  _validate_optional_code_node(code, "Select code", "build_ui_select")
91
97
 
92
- if not isinstance(custom_id, str):
98
+ if not isinstance(custom_id, StrNode):
93
99
  raise TypeError(f"Select custom_id must be a string, not {type(custom_id)} !")
94
100
 
95
- if select_type is None or not isinstance(select_type, str) or select_type not in SelectSyleValues:
101
+ if select_type is None or not isinstance(select_type, StrNode) or select_type not in SelectSyleValues:
96
102
  raise TypeError(f"Select type must be a string, not {type(select_type)} !")
97
103
 
98
- if not isinstance(disabled, bool):
104
+ if not isinstance(disabled, BoolNode):
99
105
  raise TypeError(f"Select disabled must be a bool, not {type(disabled)} !")
100
106
 
101
- if not isinstance(max_values, int):
107
+ if not isinstance(max_values, IntNode):
102
108
  raise TypeError(f"Select max_values must be an int, not {type(max_values)} !")
103
109
 
104
- if not isinstance(min_values, int):
110
+ if not isinstance(min_values, IntNode):
105
111
  raise TypeError(f"Select min_values must be an int, not {type(min_values)} !")
106
112
 
107
- if not isinstance(placeholder, str):
113
+ if not isinstance(placeholder, StrNode):
108
114
  raise TypeError(f"Select placeholder must be a string, not {type(placeholder)} !")
109
115
 
110
116
  _validate_optional_int(row, "Select row", "build_ui_select")
@@ -186,7 +192,6 @@ async def build_ui(ui_node: Union[UiButtonNode, UiSelectNode], interpreter: "Dsh
186
192
 
187
193
  if isinstance(ui_node, UiButtonNode):
188
194
  async for _, args_button, code in build_ui_button_parameters(ui_node, interpreter):
189
- print(args_button)
190
195
  b = ui.Button(**args_button)
191
196
  view.add_items(b)
192
197
  view.set_callable(b.custom_id, _callable=ui_button_callback, data={'code': code, 'interpreter': interpreter})
@@ -288,8 +293,8 @@ async def ui_button_callback(button: ui.Button, interaction: Interaction, data:
288
293
  :param data:
289
294
  :return:
290
295
  """
291
- code = data.pop('code', None)
292
- interpreter: "DshellInterpreteur" = data.pop('interpreter', None)
296
+ code = data.get('code', None)
297
+ interpreter: "DshellInterpreteur" = data.get('interpreter', None)
293
298
  if code is not None:
294
299
  message = interaction
295
300
  local_env = {
@@ -377,14 +382,16 @@ async def ui_button_callback(button: ui.Button, interaction: Interaction, data:
377
382
  }
378
383
  )
379
384
 
380
- local_env.update(data)
385
+ #local_env.update(data)
381
386
  from ..DshellInterpreteur.dshell_interpreter import DshellInterpreteur
382
- with new_scope(interpreter, local_env):
383
- await DshellInterpreteur(code, ctx=interaction, debug=False, vars_env=interpreter.env).execute()
387
+
388
+ new_interpreter = DshellInterpreteur(code, ctx=interaction, debug=False, vars_env=interpreter.env)
389
+ with new_scope(new_interpreter, local_env):
390
+ await new_interpreter.execute()
391
+
384
392
  else:
385
393
  await interaction.response.defer(invisible=True)
386
394
 
387
- data.update({'code': code, 'interpreter': interpreter})
388
395
 
389
396
  async def ui_select_callback(select: ui.Select, interaction: Interaction, data: dict[str, Any]):
390
397
  """
@@ -395,8 +402,8 @@ async def ui_select_callback(select: ui.Select, interaction: Interaction, data:
395
402
  :param data:
396
403
  :return:
397
404
  """
398
- code = data.pop('code', None)
399
- interpreter: "DshellInterpreteur" = data.pop('interpreter', None)
405
+ code = data.get('code', None)
406
+ interpreter: "DshellInterpreteur" = data.get('interpreter', None)
400
407
 
401
408
  message = interaction
402
409
  if code is not None:
@@ -515,5 +522,3 @@ async def ui_select_callback(select: ui.Select, interaction: Interaction, data:
515
522
  await DshellInterpreteur(code, ctx=interaction, debug=False, vars_env=interpreter.env).execute()
516
523
  else:
517
524
  await interaction.response.defer(invisible=True)
518
-
519
- data.update({'code': code, 'interpreter': interpreter})
@@ -1,6 +1,6 @@
1
1
  from ..DshellTokenizer.dshell_token_type import Token
2
2
  from ..DshellTokenizer.dshell_token_type import DshellTokenType as DTT
3
- from ..DshellInterpreteur.errors import DshellInterpreterStopExecution
3
+ from ..DshellInterpreteur.errors import DshellInterpreterStopExecution, DshellInterpreterError
4
4
  from Dshell.full_import import TypeVar, Union, Optional, Any, Callable, sleep, findall
5
5
  from ..DshellParser.ast_nodes import *
6
6
  from Dshell.full_import import AutoShardedBot, Interaction, Message, PrivateChannel
@@ -120,6 +120,7 @@ class DshellInterpreteur:
120
120
  print_ast(self.ast)
121
121
 
122
122
  self.raise_error = False
123
+ self.end_program: bool = False
123
124
 
124
125
  async def _execute_command_node(self, node: CommandNode):
125
126
  """Execute a command node."""
@@ -155,6 +156,9 @@ class DshellInterpreteur:
155
156
  self.env.set('__break__', BoolNode(0))
156
157
  break
157
158
 
159
+ if self.end_program:
160
+ break
161
+
158
162
  async def _execute_break_node(self, node: BreakNode):
159
163
  """Execute a break node."""
160
164
  self.env.set('__break__', BoolNode(1))
@@ -223,9 +227,14 @@ class DshellInterpreteur:
223
227
 
224
228
  for node in ast:
225
229
 
230
+ # cut the current program if an EndNode is encountred with the parameter "error_message" to False
231
+ if self.end_program:
232
+ return
233
+
226
234
  try:
227
235
  if isinstance(node, StartNode):
228
236
  await self.execute(node.body)
237
+ return
229
238
 
230
239
  if isinstance(node, CommandNode):
231
240
  await self._execute_command_node(node)
@@ -260,7 +269,7 @@ class DshellInterpreteur:
260
269
  if await self.eval_data_token(node.error_message):
261
270
  raise RuntimeError("Execution stopped - EndNode encountered")
262
271
  else:
263
- raise DshellInterpreterStopExecution("Execution stopped without error")
272
+ self.end_program = True
264
273
 
265
274
  except Exception as e:
266
275
  if not self.raise_error:
@@ -35,7 +35,6 @@ __all__ = [
35
35
  'UiButtonNode',
36
36
  'UiSelectNode',
37
37
  'OptionUiSelectNode',
38
- 'ScanNode',
39
38
  'FileNode',
40
39
  'FileStreamNode'
41
40
  ]
@@ -337,26 +336,6 @@ class ArgsCommandNode(ASTNode):
337
336
  "body": [token.to_dict() for token in self.body]
338
337
  }
339
338
 
340
- class ScanNode(ASTNode):
341
- """
342
- Node representing a scan message in the AST
343
- """
344
- def __init__(self, body: ArgsCommandNode, line: int):
345
- super().__init__(line)
346
- self.body = body
347
-
348
- def __repr__(self):
349
- return StrNode(f"<SCAN> - {self.body}")
350
-
351
- def to_dict(self):
352
- """
353
- Convert the ScanNode to a dictionary representation.
354
- :return: Dictionary representation of the ScanNode.
355
- """
356
- return {
357
- "type": "ScanNode",
358
- "body": self.body.to_dict()
359
- }
360
339
 
361
340
  class CommandNode(ASTNode):
362
341
  """
@@ -221,18 +221,14 @@ def parse(token_lines: list[list[Token]], start_node: ASTNode) -> tuple[list[AST
221
221
  return_node = ReturnNode(body=tokens_by_line[1:], line=line)
222
222
  last_block.body.append(return_node)
223
223
 
224
- elif first_token_line.value == 'scan':
225
- scan_node = ScanNode(ArgsCommandNode(body=tokens_by_line[1:], line=line), line=line)
226
- last_block.body.append(scan_node)
227
-
228
224
  elif first_token_line.value == '#end': # node pour arrêter le programme si elle est rencontré
229
- error_message = True
225
+ error_message = BoolNode(1)
230
226
  if len_tokens_by_line_since_command_name > 0:
231
227
  if tokens_by_line[1].type != DTT.BOOL:
232
228
  raise TypeError(f'[#END] the variable given must be a boolean, not {tokens_by_line[1].type}')
233
229
  else:
234
230
  error_message = tokens_by_line[1]
235
- end_node = EndNode(error_message)
231
+ end_node = EndNode(line=line, error_message=error_message)
236
232
  last_block.body.append(end_node)
237
233
 
238
234
  ############################## DISCORD KEYWORDS ##############################
@@ -11,7 +11,6 @@ __all__ = [
11
11
  from ..DISCORD_COMMANDS import *
12
12
 
13
13
  from Dshell.full_import import Callable
14
- from ..DISCORD_COMMANDS.dshell_file import dshell_read_file, dshell_write_file, dshell_get_message_files
15
14
 
16
15
  dshell_keyword: set[str] = {
17
16
  'if', 'else', 'elif', 'loop', '#end', 'var', '#loop', '#if', 'sleep', 'param', '#param', 'code', '#code', 'eval', 'return', 'break'
@@ -184,6 +183,8 @@ dshell_mathematical_operators: dict[str, tuple[Callable, int, int, int]] = {
184
183
  r"%": (lambda a, b: a % b, 7, 2, 2),
185
184
  r"-": (lambda a, b=None: a-b if b is not None else -a, 6, 1, 2),
186
185
  r"+": (lambda a, b: a + b, 6, 2, 2),
186
+ r"..": (lambda a, b: ListNode([IntNode(i) for i in range(IntNode(a), IntNode(b))])
187
+ if a <= b else ListNode([IntNode(i) for i in range(IntNode(a), IntNode(b), -1)]), 5, 2, 2)
187
188
  # warning: ambiguity between unary and binary to be handled in your parser
188
189
 
189
190
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dshellInterpreter
3
- Version: 1.2.0.22
3
+ Version: 1.2.1.1
4
4
  Summary: A Discord bot interpreter for creating custom commands and automations.
5
5
  Home-page: https://github.com/BOXERRMD/Dshell_Interpreter
6
6
  Author: Chronos
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dshellInterpreter
3
- Version: 1.2.0.22
3
+ Version: 1.2.1.1
4
4
  Summary: A Discord bot interpreter for creating custom commands and automations.
5
5
  Home-page: https://github.com/BOXERRMD/Dshell_Interpreter
6
6
  Author: Chronos
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setup(
7
7
  name="dshellInterpreter",
8
- version="1.2.0.22",
8
+ version="1.2.1.1",
9
9
  author="Chronos",
10
10
  author_email="vagabonwalybi@gmail.com",
11
11
  description="A Discord bot interpreter for creating custom commands and automations.",