easycoder 251104.1__py2.py3-none-any.whl → 260108.1__py2.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 easycoder might be problematic. Click here for more details.

Files changed (60) hide show
  1. easycoder/__init__.py +6 -3
  2. easycoder/debugger/__init__.py +5 -0
  3. easycoder/debugger/ec_dbg_value_display copy.py +195 -0
  4. easycoder/debugger/ec_dbg_value_display.py +24 -0
  5. easycoder/debugger/ec_dbg_watch_list copy.py +219 -0
  6. easycoder/debugger/ec_dbg_watchlist.py +293 -0
  7. easycoder/debugger/ec_debug.py +1025 -0
  8. easycoder/ec_border.py +15 -11
  9. easycoder/ec_classes.py +494 -7
  10. easycoder/ec_compiler.py +82 -44
  11. easycoder/ec_condition.py +1 -1
  12. easycoder/ec_core.py +1043 -1089
  13. easycoder/ec_gclasses.py +236 -0
  14. easycoder/ec_graphics.py +1683 -0
  15. easycoder/ec_handler.py +18 -13
  16. easycoder/ec_keyboard.py +50 -50
  17. easycoder/ec_mqtt.py +249 -0
  18. easycoder/ec_program.py +313 -152
  19. easycoder/ec_psutil.py +48 -0
  20. easycoder/ec_timestamp.py +2 -1
  21. easycoder/ec_value.py +65 -47
  22. easycoder/icons/exit.png +0 -0
  23. easycoder/icons/run.png +0 -0
  24. easycoder/icons/step.png +0 -0
  25. easycoder/icons/stop.png +0 -0
  26. easycoder/pre/README.md +3 -0
  27. easycoder/pre/__init__.py +17 -0
  28. easycoder/pre/debugger/__init__.py +5 -0
  29. easycoder/pre/debugger/ec_dbg_value_display copy.py +195 -0
  30. easycoder/pre/debugger/ec_dbg_value_display.py +24 -0
  31. easycoder/pre/debugger/ec_dbg_watch_list copy.py +219 -0
  32. easycoder/pre/debugger/ec_dbg_watchlist.py +293 -0
  33. easycoder/pre/debugger/ec_debug.py +1014 -0
  34. easycoder/pre/ec_border.py +67 -0
  35. easycoder/pre/ec_classes.py +470 -0
  36. easycoder/pre/ec_compiler.py +291 -0
  37. easycoder/pre/ec_condition.py +27 -0
  38. easycoder/pre/ec_core.py +2772 -0
  39. easycoder/pre/ec_gclasses.py +230 -0
  40. easycoder/{ec_pyside.py → pre/ec_graphics.py} +631 -494
  41. easycoder/pre/ec_handler.py +79 -0
  42. easycoder/pre/ec_keyboard.py +439 -0
  43. easycoder/pre/ec_program.py +557 -0
  44. easycoder/pre/ec_psutil.py +48 -0
  45. easycoder/pre/ec_timestamp.py +11 -0
  46. easycoder/pre/ec_value.py +124 -0
  47. easycoder/pre/icons/close.png +0 -0
  48. easycoder/pre/icons/exit.png +0 -0
  49. easycoder/pre/icons/run.png +0 -0
  50. easycoder/pre/icons/step.png +0 -0
  51. easycoder/pre/icons/stop.png +0 -0
  52. easycoder/pre/icons/tick.png +0 -0
  53. {easycoder-251104.1.dist-info → easycoder-260108.1.dist-info}/METADATA +11 -1
  54. easycoder-260108.1.dist-info/RECORD +59 -0
  55. easycoder-251104.1.dist-info/RECORD +0 -19
  56. /easycoder/{close.png → icons/close.png} +0 -0
  57. /easycoder/{tick.png → icons/tick.png} +0 -0
  58. {easycoder-251104.1.dist-info → easycoder-260108.1.dist-info}/WHEEL +0 -0
  59. {easycoder-251104.1.dist-info → easycoder-260108.1.dist-info}/entry_points.txt +0 -0
  60. {easycoder-251104.1.dist-info → easycoder-260108.1.dist-info}/licenses/LICENSE +0 -0
easycoder/ec_compiler.py CHANGED
@@ -1,3 +1,4 @@
1
+ import sys
1
2
  from .ec_classes import FatalError
2
3
  from .ec_value import Value
3
4
  from .ec_condition import Condition
@@ -55,10 +56,12 @@ class Compiler:
55
56
 
56
57
  # Get a value
57
58
  def getValue(self):
59
+ self.program.ensureNotRunning()
58
60
  return self.value.compileValue()
59
61
 
60
62
  # Get the next value
61
63
  def nextValue(self):
64
+ self.program.ensureNotRunning()
62
65
  self.index += 1
63
66
  return self.value.compileValue()
64
67
 
@@ -84,7 +87,9 @@ class Compiler:
84
87
  return self.program.code[pc]
85
88
 
86
89
  # Add a command to the code list
87
- def addCommand(self, command):
90
+ def addCommand(self, command, debug=True):
91
+ command['debug'] = debug
92
+ command['bp'] = False
88
93
  self.code.append(command)
89
94
 
90
95
  # Test if the current token is a symbol
@@ -109,7 +114,19 @@ class Compiler:
109
114
  if next == item:
110
115
  self.nextToken()
111
116
  return
112
- elif next == token: self.nextToken()
117
+ elif next == token:
118
+ self.nextToken()
119
+
120
+ # Skip common articles (optional syntactic noise for readability/disambiguation)
121
+ # Consumes leading articles ('the', 'a', 'an') at the next position
122
+ def skipArticles(self):
123
+ # Consume leading articles at next position(s) — like skip() but for multiple
124
+ while True:
125
+ next_tok = self.peek()
126
+ if next_tok in ['the', 'a', 'an']:
127
+ self.nextToken()
128
+ else:
129
+ break
113
130
 
114
131
  # Rewind to a given position in the code list
115
132
  def rewindTo(self, index):
@@ -131,58 +148,83 @@ class Compiler:
131
148
  print(warning)
132
149
 
133
150
  # Get the symbol record for the current token (assumes it is a symbol name)
134
- def getSymbolRecord(self):
135
- token = self.getToken()
136
- if not token in self.symbols:
137
- FatalError(self, f'Undefined symbol name "{token}"')
151
+ def getSymbolRecord(self, name=None):
152
+ self.program.ensureNotRunning()
153
+ if name == None: name = self.getToken()
154
+ if not name in self.symbols:
155
+ FatalError(self, f'Undefined symbol name "{name}"')
138
156
  return None
139
- symbol = self.symbols[token]
157
+ symbol = self.symbols[name]
140
158
  if symbol == None: return None
141
- symbolRecord = self.code[symbol]
142
- symbolRecord['used'] = True
143
- return symbolRecord
159
+ record = self.code[symbol]
160
+ record['used'] = True
161
+ return record
144
162
 
145
163
  # Add a value type
146
164
  def addValueType(self):
147
- self.valueTypes[self.getToken()] = True
165
+ name = self.peek()
166
+ record = None
167
+ try:
168
+ record = self.symbols[name]
169
+ except:
170
+ pass
171
+ if record != None:
172
+ raise FatalError(self, f'Duplicate symbol name "{name}"')
173
+ self.valueTypes[name] = True
148
174
 
149
175
  # Test if a given value is in the value types list
150
176
  def hasValue(self, type):
151
177
  return type in self.valueTypes
152
-
153
- # Compile a program label (a symbol ending with ':')
154
- def compileLabel(self, command):
155
- return self.compileSymbol(command, self.getToken())
178
+
179
+ # Instantiate an object of the given class name
180
+ def instantiate(self, classname):
181
+ # Search through all loaded modules for the class
182
+ items = sys.modules.items()
183
+ for module_name, module in items:
184
+ if module is None:
185
+ continue
186
+ try:
187
+ if hasattr(module, classname):
188
+ cls = getattr(module, classname)
189
+ # Verify it's actually a class
190
+ if isinstance(cls, type):
191
+ # Attempt to instantiate
192
+ try:
193
+ return cls()
194
+ except TypeError as ex:
195
+ raise FatalError(self, f"Object instantiation error: {ex}")
196
+ except Exception:
197
+ continue
198
+ return None
156
199
 
157
200
  # Compile a variable
158
- def compileVariable(self, command, extra=None):
159
- return self.compileSymbol(command, self.nextToken(), extra)
201
+ def compileVariable(self, command, classname):
202
+ return self.compileSymbol(command, self.nextToken(), classname)
160
203
 
161
204
  # Compile a symbol
162
- def compileSymbol(self, command, name, extra=None):
163
- try:
164
- v = self.symbols[name]
165
- except:
166
- v = None
167
- if v:
168
- FatalError(self, f'Duplicate symbol name "{name}"')
169
- return False
170
- self.symbols[name] = self.getCodeSize()
171
- command['program'] = self.program
172
- command['type'] = 'symbol'
205
+ def compileSymbol(self, command, name, classname):
206
+ # try:
207
+ # self.symbols[name]
208
+ # raise FatalError(self, f'Duplicate symbol name "{name}"')
209
+ # except: pass
173
210
  command['name'] = name
174
- command['elements'] = 1
175
- command['index'] = 0
176
- command['value'] = [None]
211
+ command['classname'] = classname
212
+ command['program'] = self.program
177
213
  command['used'] = False
178
- command['debug'] = False
179
- command['import'] = None
180
- command['locked'] = False
181
- command['extra'] = extra
182
- if 'keyword' in command: command['hasValue'] = self.hasValue(command['keyword'])
183
- self.addCommand(command)
214
+ self.symbols[name] = self.getCodeSize()
215
+ if classname != ':':
216
+ object = self.instantiate(classname)
217
+ command['object'] = object
218
+ if object != None:
219
+ command['type'] = 'symbol'
220
+ object.setName(name) # type: ignore
221
+ self.addCommand(command, False)
184
222
  return True
185
223
 
224
+ # Compile a program label (a symbol ending with ':')
225
+ def compileLabel(self, command):
226
+ return self.compileSymbol(command, self.getToken(), ':')
227
+
186
228
  # Compile the current token
187
229
  def compileToken(self):
188
230
  self.warnings = []
@@ -191,8 +233,8 @@ class Compiler:
191
233
  if not token:
192
234
  return False
193
235
  if len(self.code) == 0:
194
- if self.program.parent == None and hasattr(self.program, 'usingGraphics'):
195
- cmd = {'domain': 'graphics', 'keyword': 'init', 'debug': False}
236
+ if self.program.parent == None and self.program.graphics:
237
+ cmd = {'domain': 'graphics', 'keyword': 'init'}
196
238
  self.code.append(cmd)
197
239
  mark = self.getIndex()
198
240
  for domain in self.program.getDomains():
@@ -202,8 +244,6 @@ class Compiler:
202
244
  command['domain'] = domain.getName()
203
245
  command['lino'] = self.tokens[self.index].lino
204
246
  command['keyword'] = token
205
- command['type'] = None
206
- command['debug'] = True
207
247
  result = handler(command)
208
248
  if result:
209
249
  return result
@@ -232,9 +272,7 @@ class Compiler:
232
272
  self.index = index
233
273
  while True:
234
274
  token = self.tokens[self.index]
235
- # keyword = token.token
236
- if self.debugCompile: print(self.script.lines[token.lino])
237
- # if keyword != 'else':
275
+ if self.debugCompile: print(f'{token.lino + 1}: {self.script.lines[token.lino]}')
238
276
  if self.compileOne() == True:
239
277
  if self.index == len(self.tokens) - 1:
240
278
  return True
easycoder/ec_condition.py CHANGED
@@ -16,7 +16,7 @@ class Condition:
16
16
  for domain in self.compiler.program.getDomains():
17
17
  condition = domain.compileCondition()
18
18
  if condition != None:
19
- condition.domain= domain.getName()
19
+ condition.domain = domain.getName()
20
20
  return condition
21
21
  self.rewindTo(mark)
22
22
  return None