easycoder 250104.1__py2.py3-none-any.whl → 250105.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.

easycoder/__init__.py CHANGED
@@ -10,4 +10,4 @@ from .ec_program import *
10
10
  from .ec_timestamp import *
11
11
  from .ec_value import *
12
12
 
13
- __version__ = "250104.1"
13
+ __version__ = "250105.1"
easycoder/ec_core.py CHANGED
@@ -552,27 +552,37 @@ class Core(Handler):
552
552
  self.program.pc += 1
553
553
  return self.program.pc
554
554
 
555
- # Import one or more variables
556
555
  def k_import(self, command):
557
- imports = []
558
- while True:
559
- keyword = self.nextToken()
560
- name = self.nextToken()
561
- item = [keyword, name]
562
- imports.append(item)
563
- self.symbols[name] = self.getPC()
564
- variable = {}
565
- variable['domain'] = None
566
- variable['name'] = name
567
- variable['keyword'] = keyword
568
- variable['import'] = None
569
- self.addCommand(variable)
570
- if self.peek() != 'and':
571
- break
556
+ if self.peek() == 'plugin':
557
+ # Import a plugin
572
558
  self.nextToken()
573
- command['imports'] = json.dumps(imports)
574
- self.add(command)
575
- return True
559
+ clazz = self.nextToken()
560
+ if self.nextIs('from'):
561
+ source = self.nextToken()
562
+ self.program.importPlugin(f'{source}:{clazz}')
563
+ return True
564
+ return False
565
+ else:
566
+ # Import one or more variables
567
+ imports = []
568
+ while True:
569
+ keyword = self.nextToken()
570
+ name = self.nextToken()
571
+ item = [keyword, name]
572
+ imports.append(item)
573
+ self.symbols[name] = self.getPC()
574
+ variable = {}
575
+ variable['domain'] = None
576
+ variable['name'] = name
577
+ variable['keyword'] = keyword
578
+ variable['import'] = None
579
+ self.addCommand(variable)
580
+ if self.peek() != 'and':
581
+ break
582
+ self.nextToken()
583
+ command['imports'] = json.dumps(imports)
584
+ self.add(command)
585
+ return True
576
586
 
577
587
  def r_import(self, command):
578
588
  exports = self.program.exports
@@ -694,11 +704,8 @@ class Core(Handler):
694
704
  return False
695
705
 
696
706
  def r_load(self, command):
697
- print(command)
698
707
  target = self.getVariable(command['target'])
699
- print(target)
700
708
  file = self.getRuntimeValue(command['file'])
701
- print(file)
702
709
  f = open(file, 'r')
703
710
  content = f.read()
704
711
  f.close()
@@ -810,6 +817,36 @@ class Core(Handler):
810
817
  def r_object(self, command):
811
818
  return self.nextPC()
812
819
 
820
+ # on message {action}
821
+ def k_on(self, command):
822
+ if self.nextIs('message'):
823
+ self.nextToken()
824
+ command['goto'] = 0
825
+ self.add(command)
826
+ cmd = {}
827
+ cmd['domain'] = 'core'
828
+ cmd['lino'] = command['lino']
829
+ cmd['keyword'] = 'gotoPC'
830
+ cmd['goto'] = 0
831
+ cmd['debug'] = False
832
+ self.addCommand(cmd)
833
+ # Add the action and a 'stop'
834
+ self.compileOne()
835
+ cmd = {}
836
+ cmd['domain'] = 'core'
837
+ cmd['lino'] = command['lino']
838
+ cmd['keyword'] = 'stop'
839
+ cmd['debug'] = False
840
+ self.addCommand(cmd)
841
+ # Fixup the link
842
+ command['goto'] = self.getPC()
843
+ return True
844
+ return False
845
+
846
+ def r_on(self, command):
847
+ self.program.onMessage(self.nextPC()+1)
848
+ return command['goto']
849
+
813
850
  # Open a file
814
851
  # open {file} for reading/writing/appending
815
852
  def k_open(self, command):
@@ -1002,13 +1039,13 @@ class Core(Handler):
1002
1039
  if self.nextIsSymbol():
1003
1040
  symbolRecord = self.getSymbolRecord()
1004
1041
  command['target'] = symbolRecord['name']
1005
- if symbolRecord['valueHolder']:
1042
+ if 'valueholder' in symbolRecord and symbolRecord['valueHolder'] == False:
1043
+ FatalError(self.program.compiler, f'Symbol {symbolRecord["name"]} is not a value holder')
1044
+ else:
1006
1045
  self.add(command)
1007
1046
  return True
1008
- else:
1009
- FatalError(self.program.compiler, f'Symbol {symbolRecord["name"]} is not a value holder')
1010
1047
  else:
1011
- FatalError(self.program.compiler, f'No such variable: "{self.getToken()}"')
1048
+ FatalError(self.program.compiler, f'Symbol {self.getToken()} is not a variable')
1012
1049
  return False
1013
1050
 
1014
1051
  def r_put(self, command):
@@ -1111,12 +1148,16 @@ class Core(Handler):
1111
1148
 
1112
1149
  # Compile and run a script
1113
1150
  def k_run(self, command):
1114
- if self.nextIsSymbol():
1115
- record = self.getSymbolRecord()
1116
- if record['keyword'] == 'module':
1117
- command['target'] = record['name']
1118
- if self.nextIs('as'):
1119
- command['path'] = self.nextValue()
1151
+ try:
1152
+ command['path'] = self.nextValue()
1153
+ except Exception as e:
1154
+ self.warning(f'Core.run: Path expected')
1155
+ return False
1156
+ if self.nextIs('as'):
1157
+ if self.nextIsSymbol():
1158
+ record = self.getSymbolRecord()
1159
+ if record['keyword'] == 'module':
1160
+ command['module'] = record['name']
1120
1161
  exports = []
1121
1162
  if self.nextIs('with'):
1122
1163
  while True:
@@ -1132,18 +1173,18 @@ class Core(Handler):
1132
1173
  return False
1133
1174
 
1134
1175
  def r_run(self, command):
1135
- target = self.getVariable(command['target'])
1176
+ module = self.getVariable(command['module'])
1136
1177
  path = self.getRuntimeValue(command['path'])
1137
1178
  exports = json.loads(command['exports'])
1138
1179
  for n in range(0, len(exports)):
1139
1180
  exports[n] = self.getVariable(exports[n])
1140
- target['path'] = path
1181
+ module['path'] = path
1141
1182
  parent = Object()
1142
1183
  parent.program = self.program
1143
1184
  parent.pc = self.nextPC()
1144
1185
  parent.waiting = True
1145
1186
  p = self.program.__class__
1146
- p(path).start(parent, exports)
1187
+ p(path).start(parent, module, exports)
1147
1188
  return 0
1148
1189
 
1149
1190
  # Provide a name for the script
@@ -1168,6 +1209,24 @@ class Core(Handler):
1168
1209
  f.close()
1169
1210
  return self.nextPC()
1170
1211
 
1212
+ # Send a message to a module
1213
+ def k_send(self, command):
1214
+ command['message'] = self.nextValue()
1215
+ if self.nextIs('to'):
1216
+ if self.nextIsSymbol():
1217
+ record = self.getSymbolRecord()
1218
+ if record['keyword'] == 'module':
1219
+ command['module'] = record['name']
1220
+ self.add(command)
1221
+ return True
1222
+ return False
1223
+
1224
+ def r_send(self, command):
1225
+ message = self.getRuntimeValue(command['message'])
1226
+ module = self.getVariable(command['module'])
1227
+ module['child'].handleMessage(message)
1228
+ return self.nextPC()
1229
+
1171
1230
  # Set a value
1172
1231
  # set {variable}
1173
1232
  # set the elements of {variable} to {value}
@@ -1791,7 +1850,6 @@ class Core(Handler):
1791
1850
  return value
1792
1851
 
1793
1852
  if token == 'message':
1794
- self.nextToken()
1795
1853
  return value
1796
1854
 
1797
1855
  if token == 'timestamp':
@@ -2097,6 +2155,12 @@ class Core(Handler):
2097
2155
  value['content'] = megabytes
2098
2156
  return value
2099
2157
 
2158
+ def v_message(self, v):
2159
+ value = {}
2160
+ value['type'] = 'text'
2161
+ value['content'] = self.program.message
2162
+ return value
2163
+
2100
2164
  def v_modification(self, v):
2101
2165
  fileName = self.getRuntimeValue(v['fileName'])
2102
2166
  ts = int(os.stat(fileName).st_mtime)
easycoder/ec_graphics.py CHANGED
@@ -176,7 +176,7 @@ class Graphics(Handler):
176
176
  self.windowSpec = Object()
177
177
  self.windowSpec.title = command['title']['content']
178
178
  self.windowSpec.flush = flush
179
- self.windowSpec.finish = self.program.finish
179
+ self.windowSpec.kill = self.program.kill
180
180
  self.windowSpec.pos = (self.getRuntimeValue(command['pos'][0]), self.getRuntimeValue(command['pos'][1]))
181
181
  self.windowSpec.size = (self.getRuntimeValue(command['size'][0]), self.getRuntimeValue(command['size'][1]))
182
182
  self.windowSpec.fill = (self.getRuntimeValue(command['fill'][0])/255, self.getRuntimeValue(command['fill'][1])/255, self.getRuntimeValue(command['fill'][2])/255)
easycoder/ec_program.py CHANGED
@@ -7,8 +7,6 @@ from .ec_core import Core
7
7
  import importlib
8
8
  from importlib.metadata import version
9
9
 
10
- queue = deque()
11
-
12
10
  # Flush the queue
13
11
  def flush():
14
12
  global queue
@@ -19,6 +17,7 @@ def flush():
19
17
  class Program:
20
18
 
21
19
  def __init__(self, argv):
20
+ global queue
22
21
  print(f'EasyCoder version {version("easycoder")}')
23
22
  if len(argv) == 0:
24
23
  print('No script supplied')
@@ -32,6 +31,7 @@ class Program:
32
31
  f = open(scriptName, 'r')
33
32
  source = f.read()
34
33
  f.close()
34
+ queue = deque()
35
35
  self.argv = argv
36
36
  self.domains = []
37
37
  self.domainIndex = {}
@@ -48,11 +48,13 @@ class Program:
48
48
  self.condition = self.compiler.condition
49
49
  self.processClasses()
50
50
  self.externalControl = False
51
- self.finished = False
51
+ self.running = True
52
52
 
53
- def start(self, parent=None, exports=[]):
53
+ def start(self, parent=None, module = None, exports=[]):
54
54
  self.parent = parent
55
55
  self.exports = exports
56
+ if module != None:
57
+ module['child'] = self
56
58
  startCompile = time.time()
57
59
  self.tokenise(self.script)
58
60
  if self.compiler.compileFrom(0, []):
@@ -70,7 +72,15 @@ class Program:
70
72
  self.run(0)
71
73
  else:
72
74
  self.compiler.showWarnings()
73
- return
75
+
76
+ # If this is the main script and there's no graphics, run a main loop
77
+ if parent == None and self.externalControl == False:
78
+ while True:
79
+ if self.running == True:
80
+ flush()
81
+ time.sleep(0.1)
82
+ else:
83
+ break
74
84
 
75
85
  # Import a plugin
76
86
  def importPlugin(self, source):
@@ -140,7 +150,7 @@ class Program:
140
150
  name = value['name']
141
151
  symbolRecord = self.getSymbolRecord(name)
142
152
  if symbolRecord['value'] == [None]:
143
- RuntimeWarning(self.compiler.program, f'Variable "{name}" has no value')
153
+ RuntimeWarning(self.program, f'Variable "{name}" has no value')
144
154
  return None
145
155
  handler = self.domainIndex[symbolRecord['domain']].valueHandler('symbol')
146
156
  result = handler(symbolRecord)
@@ -277,7 +287,6 @@ class Program:
277
287
  # Flush the queue
278
288
  def flush(self, pc):
279
289
  global queue
280
- self.running = True
281
290
  self.pc = pc
282
291
  while True:
283
292
  command = self.code[self.pc]
@@ -299,26 +308,23 @@ class Program:
299
308
  # Deal with 'exit'
300
309
  if self.pc == -1:
301
310
  queue = deque()
302
- self.running = False
303
311
  if self.parent != None:
304
312
  self.releaseParent()
305
- sys.exit()
313
+ else:
314
+ self.running = False
315
+ break
306
316
  elif self.pc == None or self.pc == 0 or self.pc >= len(self.code):
307
317
  break
308
318
 
309
319
  # Run the script
310
320
  def run(self, pc):
311
321
  global queue
312
- length = len(queue)
313
322
  item = Object()
314
323
  item.program = self
315
324
  item.pc = pc
316
325
  queue.append(item)
317
- if not self.externalControl:
318
- if length == 0:
319
- return flush()
320
326
 
321
- def finish(self):
327
+ def kill(self):
322
328
  self.running = False
323
329
 
324
330
  def setExternalControl(self):
@@ -368,6 +374,15 @@ class Program:
368
374
  if v1 < v2:
369
375
  return -1
370
376
  return 0
377
+
378
+ # Set up a message handler
379
+ def onMessage(self, pc):
380
+ self.onMessagePC = pc
381
+
382
+ # Handle a message from our parent program
383
+ def handleMessage(self, message):
384
+ self.message = message
385
+ self.run(self.onMessagePC)
371
386
 
372
387
  # This is the program launcher
373
388
  def Main():
easycoder/ec_renderer.py CHANGED
@@ -225,6 +225,7 @@ class Renderer(App):
225
225
 
226
226
  def request_close(self):
227
227
  print('close window')
228
+ self.kill()
228
229
  Window.close()
229
230
 
230
231
  def flushQueue(self, dt):
@@ -238,6 +239,7 @@ class Renderer(App):
238
239
  self.ui = UI()
239
240
  self.title = spec.title
240
241
  self.flush = spec.flush
242
+ self.kill = spec.kill
241
243
  Window.size = spec.size
242
244
  Window.left = spec.pos[0]
243
245
  Window.top = spec.pos[1]
easycoder/ec_value.py CHANGED
@@ -51,7 +51,7 @@ class Value:
51
51
  if item != None:
52
52
  return item
53
53
  self.compiler.rewindTo(mark)
54
- FatalError(self.compiler, f'I don\'t understand \'{token}\'')
54
+ self.compiler.warning(f'I don\'t understand \'{token}\'')
55
55
  return None
56
56
 
57
57
  def compileValue(self):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: easycoder
3
- Version: 250104.1
3
+ Version: 250105.1
4
4
  Summary: Rapid scripting in English
5
5
  Keywords: compiler,scripting,prototyping,programming,coding,python,low code,hypertalk,computer language,learn to code
6
6
  Author-email: Graham Trott <gtanyware@gmail.com>
@@ -0,0 +1,19 @@
1
+ easycoder/README.md,sha256=PYqOc_SkIGiFbyCNs90y7JqoqWe4aO1xYIW-6bOnFKU,573
2
+ easycoder/__init__.py,sha256=owNA7S9z8wlR3KRxJytrzPU-s4ngA04Xq8_EUinKwK8,283
3
+ easycoder/ec.py,sha256=Nj5PRl8GsKjfGJKq0FOM1a7FeK3cN68CoIFg8lswQEg,221
4
+ easycoder/ec_classes.py,sha256=xnWBNak8oKydkFoxHLlq9wo3lIsB3aMnTDrqbtCfoWo,1512
5
+ easycoder/ec_compiler.py,sha256=_xBh2L47mz_WOMYdruMYSHyyz2wfh7Hf28q559AWVSU,4781
6
+ easycoder/ec_condition.py,sha256=WSbONo4zs2sX1icOVpscZDFSCAEFmTsquoc2RGcLx_k,763
7
+ easycoder/ec_core.py,sha256=5woFkLx9divJomakFyeexmhqJeEPI1hUlzyB3MlAruI,86359
8
+ easycoder/ec_graphics.py,sha256=ylkdEOo04g8aOeY9xB1V9mf3aZWkoIUt-caXivuVje4,16427
9
+ easycoder/ec_handler.py,sha256=IJvxcrJJSR53d6DS_8H5qPHKhp9y5-GV4WXAjhZxu_o,2250
10
+ easycoder/ec_program.py,sha256=sdVPc1c8urLn5icov-NVyNkc78UR930ipDDONlZTge8,9831
11
+ easycoder/ec_renderer.py,sha256=oZ56OyJojQq-2ZPlVMFOrEyG_vj91D4yv9Nd5m92RQA,8031
12
+ easycoder/ec_screenspec.py,sha256=TeXgccfYoE--r7Rf9t9drV1V3fU-p-iBnZwtjHzIh8M,2524
13
+ easycoder/ec_timestamp.py,sha256=_3QFJPzIWZ9Rzk3SQOQJ-gwmvB07pg78k23SPntoZtY,288
14
+ easycoder/ec_value.py,sha256=KkSIxAum-bnb_qnaRgS1UiVUg_-khVPQrrEPiSXjQs4,2382
15
+ easycoder-250105.1.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
16
+ easycoder-250105.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
17
+ easycoder-250105.1.dist-info/WHEEL,sha256=ssQ84EZ5gH1pCOujd3iW7HClo_O_aDaClUbX4B8bjKY,100
18
+ easycoder-250105.1.dist-info/METADATA,sha256=hm-vw2r4-nH5eaa8ouO0Qpdx9nyeNFK60iXwS41GDxg,5817
19
+ easycoder-250105.1.dist-info/RECORD,,
@@ -1,19 +0,0 @@
1
- easycoder/README.md,sha256=PYqOc_SkIGiFbyCNs90y7JqoqWe4aO1xYIW-6bOnFKU,573
2
- easycoder/__init__.py,sha256=a3GF7mJ6MDX_VMS0m8eVDkxAksYnIfCeb4Rw6KgV2ys,283
3
- easycoder/ec.py,sha256=Nj5PRl8GsKjfGJKq0FOM1a7FeK3cN68CoIFg8lswQEg,221
4
- easycoder/ec_classes.py,sha256=xnWBNak8oKydkFoxHLlq9wo3lIsB3aMnTDrqbtCfoWo,1512
5
- easycoder/ec_compiler.py,sha256=_xBh2L47mz_WOMYdruMYSHyyz2wfh7Hf28q559AWVSU,4781
6
- easycoder/ec_condition.py,sha256=WSbONo4zs2sX1icOVpscZDFSCAEFmTsquoc2RGcLx_k,763
7
- easycoder/ec_core.py,sha256=VtsjZ0r3OKxgF-nnQoRJItbjhSHRUso84SwSz3EubG4,84152
8
- easycoder/ec_graphics.py,sha256=JLd5w1_RYVmSVmdWhxltMGfdQuKHroFl0HG7MCZ7E2E,16431
9
- easycoder/ec_handler.py,sha256=IJvxcrJJSR53d6DS_8H5qPHKhp9y5-GV4WXAjhZxu_o,2250
10
- easycoder/ec_program.py,sha256=4I7tICiY9zkigA15-K8zdHkH-H-UOr4W1liy0sfMtu8,9440
11
- easycoder/ec_renderer.py,sha256=1zdIXqk-Sfnu3ErU193iem0Y-r6GeVc8D1HsTB_G2bU,7981
12
- easycoder/ec_screenspec.py,sha256=TeXgccfYoE--r7Rf9t9drV1V3fU-p-iBnZwtjHzIh8M,2524
13
- easycoder/ec_timestamp.py,sha256=_3QFJPzIWZ9Rzk3SQOQJ-gwmvB07pg78k23SPntoZtY,288
14
- easycoder/ec_value.py,sha256=XIBtGhcCgh1abrzAn-Wy4l_xH_3cTWakMVIiSlBAZjM,2386
15
- easycoder-250104.1.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
16
- easycoder-250104.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
17
- easycoder-250104.1.dist-info/WHEEL,sha256=ssQ84EZ5gH1pCOujd3iW7HClo_O_aDaClUbX4B8bjKY,100
18
- easycoder-250104.1.dist-info/METADATA,sha256=MsBtZS8mH5qcs5vLAB4PSdnwIF51g7q0uxiKhCRQgo8,5817
19
- easycoder-250104.1.dist-info/RECORD,,