easycoder 250116.4__py2.py3-none-any.whl → 250118.2__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
@@ -9,4 +9,4 @@ from .ec_program import *
9
9
  from .ec_timestamp import *
10
10
  from .ec_value import *
11
11
 
12
- __version__ = "250116.4"
12
+ __version__ = "250118.2"
easycoder/ec_core.py CHANGED
@@ -1427,7 +1427,6 @@ class Core(Handler):
1427
1427
 
1428
1428
  def r_system(self, command):
1429
1429
  value = self.getRuntimeValue(command['value'])
1430
- background = command['background']
1431
1430
  if value != None:
1432
1431
  if command['background']:
1433
1432
  subprocess.Popen(["sh",value,"&"])
@@ -1735,6 +1734,9 @@ class Core(Handler):
1735
1734
  if symbolRecord['valueHolder']:
1736
1735
  value['target'] = symbolRecord['name']
1737
1736
  return value
1737
+ else:
1738
+ value['value'] = self.getValue()
1739
+ return value
1738
1740
  self.warning(f'Core.compileValue: Token \'{self.getToken()}\' does not hold a value')
1739
1741
  return None
1740
1742
 
@@ -1900,6 +1902,10 @@ class Core(Handler):
1900
1902
  return value
1901
1903
  return None
1902
1904
 
1905
+ if token == 'system':
1906
+ value['command'] = self.nextValue()
1907
+ return value
1908
+
1903
1909
  return None
1904
1910
 
1905
1911
  #############################################################################
@@ -2199,13 +2205,16 @@ class Core(Handler):
2199
2205
 
2200
2206
  def v_property(self, v):
2201
2207
  propertyValue = self.getRuntimeValue(v['name'])
2202
- targetName = v['target']
2203
- target = self.getVariable(targetName)
2204
- targetValue = self.getRuntimeValue(target)
2208
+ if 'target' in v:
2209
+ targetName = v['target']
2210
+ target = self.getVariable(targetName)
2211
+ targetValue = self.getRuntimeValue(target)
2212
+ else:
2213
+ targetValue = self.getRuntimeValue(v['value'])
2205
2214
  try:
2206
2215
  val = targetValue[propertyValue]
2207
2216
  except:
2208
- RuntimeError(self.program, f'{targetName} does not have the property \'{propertyValue}\'')
2217
+ RuntimeError(self.program, f'This value does not have the property \'{propertyValue}\'')
2209
2218
  return None
2210
2219
  value = {}
2211
2220
  value['content'] = val
@@ -2247,13 +2256,19 @@ class Core(Handler):
2247
2256
 
2248
2257
  # This is used by the expression evaluator to get the value of a symbol
2249
2258
  def v_symbol(self, symbolRecord):
2250
- result = {}
2251
2259
  if symbolRecord['keyword'] == 'variable':
2252
- symbolValue = self.getSymbolValue(symbolRecord)
2253
- return symbolValue
2260
+ return self.getSymbolValue(symbolRecord)
2254
2261
  else:
2255
2262
  return None
2256
2263
 
2264
+ def v_system(self, v):
2265
+ command = self.getRuntimeValue(v['command'])
2266
+ result = os.popen(command).read()
2267
+ value = {}
2268
+ value['type'] = 'text'
2269
+ value['content'] = result
2270
+ return value
2271
+
2257
2272
  def v_tab(self, v):
2258
2273
  value = {}
2259
2274
  value['type'] = 'text'
easycoder/ec_graphics.py CHANGED
@@ -9,7 +9,6 @@ class Graphics(Handler):
9
9
  def __init__(self, compiler):
10
10
  Handler.__init__(self, compiler)
11
11
  self.utils = GUtils()
12
- self.eventHandlers = {}
13
12
 
14
13
  def getName(self):
15
14
  return 'graphics'
@@ -18,22 +17,27 @@ class Graphics(Handler):
18
17
  # Keyword handlers
19
18
 
20
19
  def k_add(self, command):
21
- elements = []
22
20
  token = self.nextToken()
23
21
  if self.isSymbol():
24
22
  symbolRecord = self.getSymbolRecord()
25
23
  name = symbolRecord['name']
26
- if symbolRecord['keyword'] == 'layout':
27
- elements.append(name)
24
+ keyword = symbolRecord['keyword']
25
+ if keyword == 'layout':
28
26
  command['args'] = name
29
- else: FatalError(self.compiler.program, f'\'{name}\' is not a layout')
27
+ elif keyword in ['column', 'frame', 'tab']:
28
+ command['name'] = name
29
+ command['type'] = token
30
+ if self.peek() == 'to':
31
+ command['args'] = []
32
+ else:
33
+ command['args'] = self.utils.getArgs(self)
30
34
  else:
31
35
  command['type'] = token
32
36
  command['args'] = self.utils.getArgs(self)
33
37
  if self.nextIs('to'):
34
38
  if self.nextIsSymbol():
35
39
  symbolRecord = self.getSymbolRecord()
36
- if symbolRecord['keyword'] == 'layout':
40
+ if symbolRecord['keyword'] in ['column', 'frame', 'layout', 'tab']:
37
41
  command['target'] = symbolRecord['name']
38
42
  self.addCommand(command)
39
43
  return True
@@ -43,14 +47,19 @@ class Graphics(Handler):
43
47
  target = self.getVariable(command['target'])
44
48
  type = command['type']
45
49
  args = command['args']
50
+ param= None
46
51
  if not 'layout' in target:
47
52
  target['layout'] = []
48
53
  if args[0] == '{':
54
+ if type in ['Column', 'Frame', 'Tab']:
55
+ record = self.getVariable(command['name'])
56
+ param = record['layout']
49
57
  layout = json.loads(self.getRuntimeValue(json.loads(args)))
50
58
  default = self.utils.getDefaultArgs(type)
51
59
  for n in range(0, len(layout)):
52
60
  args = self.utils.decode(default, layout[n])
53
- target['layout'].append(self.utils.createElement(type, args))
61
+ item = self.utils.createElement(type, param, args)
62
+ target['layout'].append(item)
54
63
  else:
55
64
  v = self.getVariable(args)
56
65
  target['layout'].append(v['layout'])
@@ -85,6 +94,12 @@ class Graphics(Handler):
85
94
  target['window'].close()
86
95
  return self.nextPC()
87
96
 
97
+ def k_column(self, command):
98
+ return self.compileVariable(command)
99
+
100
+ def r_column(self, command):
101
+ return self.nextPC()
102
+
88
103
  # create {window} layout {layout}
89
104
  # create {element} {args...}
90
105
  def k_create(self, command):
@@ -110,14 +125,30 @@ class Graphics(Handler):
110
125
  if type == 'window':
111
126
  layout = self.getVariable(command['layout'])
112
127
  title = self.getRuntimeValue(command['title'])
113
- self.program.window = psg.Window(title, layout['layout'], finalize=True)
128
+ record['window'] = psg.Window(title, layout['layout'], finalize=True)
129
+ record['eventHandlers'] = {}
130
+ self.program.windowRecord = record
114
131
  self.program.run(self.nextPC())
115
132
  self.mainLoop()
116
- self.program.kill()
133
+ # self.program.kill()
117
134
  return 0
118
135
  else:
119
136
  RuntimeError(self.program, 'Variable is not a window or an element')
120
137
 
138
+ def k_init(self, command):
139
+ if self.nextIsSymbol():
140
+ symbolRecord = self.getSymbolRecord()
141
+ if symbolRecord['keyword'] in ['column', 'frame', 'layout', 'tab']:
142
+ command['target'] = symbolRecord['name']
143
+ self.add(command)
144
+ return True
145
+ return False
146
+
147
+ def r_init(self, command):
148
+ target = self.getVariable(command['target'])
149
+ target['layout'] = []
150
+ return self.nextPC()
151
+
121
152
  def k_layout(self, command):
122
153
  return self.compileVariable(command)
123
154
 
@@ -128,33 +159,38 @@ class Graphics(Handler):
128
159
  token = self.nextToken()
129
160
  if token == 'event':
130
161
  command['key'] = self.nextValue()
131
- command['goto'] = self.getPC() + 2
132
- self.add(command)
133
- self.nextToken()
134
- pcNext = self.getPC()
135
- cmd = {}
136
- cmd['domain'] = 'core'
137
- cmd['lino'] = command['lino']
138
- cmd['keyword'] = 'gotoPC'
139
- cmd['goto'] = 0
140
- cmd['debug'] = False
141
- self.addCommand(cmd)
142
- self.compileOne()
143
- cmd = {}
144
- cmd['domain'] = 'core'
145
- cmd['lino'] = command['lino']
146
- cmd['keyword'] = 'stop'
147
- cmd['debug'] = False
148
- self.addCommand(cmd)
149
- # Fixup the link
150
- self.getCommandAt(pcNext)['goto'] = self.getPC()
151
- return True
162
+ if self.nextIs('in'):
163
+ if self.nextIsSymbol():
164
+ record = self.getSymbolRecord()
165
+ if record['keyword'] == 'window':
166
+ command['window'] = record['name']
167
+ command['goto'] = self.getPC() + 2
168
+ self.add(command)
169
+ self.nextToken()
170
+ pcNext = self.getPC()
171
+ cmd = {}
172
+ cmd['domain'] = 'core'
173
+ cmd['lino'] = command['lino']
174
+ cmd['keyword'] = 'gotoPC'
175
+ cmd['goto'] = 0
176
+ cmd['debug'] = False
177
+ self.addCommand(cmd)
178
+ self.compileOne()
179
+ cmd = {}
180
+ cmd['domain'] = 'core'
181
+ cmd['lino'] = command['lino']
182
+ cmd['keyword'] = 'stop'
183
+ cmd['debug'] = False
184
+ self.addCommand(cmd)
185
+ # Fixup the link
186
+ self.getCommandAt(pcNext)['goto'] = self.getPC()
187
+ return True
152
188
  return False
153
189
 
154
190
  def r_on(self, command):
155
191
  key = self.getRuntimeValue(command['key'])
156
- pc = command['goto']
157
- self.eventHandlers[key] = lambda: self.run(pc)
192
+ window = self.getVariable(command['window'])
193
+ window['eventHandlers'][key] = lambda: self.run(command['goto'])
158
194
  return self.nextPC()
159
195
 
160
196
  def k_popup(self, command):
@@ -221,13 +257,14 @@ class Graphics(Handler):
221
257
  return value
222
258
  return None
223
259
 
260
+ if self.getToken() == 'the':
261
+ self.nextToken()
262
+
263
+ token = self.getToken()
224
264
  value['type'] = token
225
265
 
226
- if token == 'test':
227
- value = {}
228
- value['type'] = 'text'
229
- value['content'] = 'test'
230
- return value
266
+ if token == 'event':
267
+ return value
231
268
 
232
269
  return None
233
270
 
@@ -246,7 +283,9 @@ class Graphics(Handler):
246
283
  else:
247
284
  return None
248
285
 
249
- def v_test(self, v):
286
+ def v_event(self, v):
287
+ v['type'] = 'text'
288
+ v['content'] = self.eventValues
250
289
  return v
251
290
 
252
291
  #############################################################################
@@ -261,13 +300,15 @@ class Graphics(Handler):
261
300
  #############################################################################
262
301
  # The main loop
263
302
  def mainLoop(self):
303
+ windowRecord = self.program.windowRecord
304
+ window = windowRecord['window']
305
+ eventHandlers = windowRecord['eventHandlers']
264
306
  while True:
265
- event, values = self.program.window.Read(timeout=100)
307
+ event, values = window.Read(timeout=100)
266
308
  if event == psg.WINDOW_CLOSED or event == "EXIT":
267
309
  break
268
310
  if event == '__TIMEOUT__': self.program.flushCB()
269
311
  else:
270
- if event in self.eventHandlers:
312
+ if event in eventHandlers:
271
313
  self.eventValues = values
272
- self.eventHandlers[event]()
273
-
314
+ eventHandlers[event]()
easycoder/ec_gutils.py CHANGED
@@ -21,14 +21,28 @@ class GUtils:
21
21
  # Get the default args for a graphic element
22
22
  def getDefaultArgs(self, type):
23
23
  args = {}
24
- if type == 'Text':
25
- args['text'] = '(empty)'
24
+ if type == 'Button':
25
+ args['button_text'] = '(empty)'
26
+ args['size'] = (None, None)
27
+ if type == 'Checkbox':
28
+ args['text'] = ''
29
+ args['key'] = None
30
+ args['size'] = (None, None)
31
+ args['expand_x'] = False
32
+ elif type == 'Column':
26
33
  args['expand_x'] = False
34
+ args['pad'] = (0, 0)
27
35
  elif type == 'Input':
28
36
  args['key'] = None
29
37
  args['size'] = (None, None)
30
- elif type == 'Button':
31
- args['button_text'] = '(empty)'
38
+ elif type == 'Multiline':
39
+ args['default_text'] = ''
40
+ args['key'] = None
41
+ args['size'] = (None, None)
42
+ elif type == 'Text':
43
+ args['text'] = '(empty)'
44
+ args['size'] = (None, None)
45
+ args['expand_x'] = False
32
46
  return args
33
47
 
34
48
  # Decode an argument at runtime
@@ -42,11 +56,29 @@ class GUtils:
42
56
  return None
43
57
 
44
58
  # Create an element
45
- def createElement(self, type, args):
46
- if type == 'Text': return psg.Text(text=args['text'], expand_x=args['expand_x'])
59
+ def createElement(self, type, param, args):
60
+ if type == 'Button':
61
+ size = self.getSize(args)
62
+ return psg.Button(button_text=args['button_text'], size=size)
63
+ if type == 'Checkbox':
64
+ size = self.getSize(args)
65
+ return psg.Checkbox(args['text'], key=args['key'], expand_x=args['expand_x'], size=size)
66
+ if type == 'Column':
67
+ return psg.Column(param, expand_x=args['expand_x'], pad=args['pad'])
47
68
  elif type == 'Input':
48
- size = args['size'].split()
49
- size = (size[0], size[1])
69
+ size = self.getSize(args)
50
70
  return psg.Input(key=args['key'], size=size)
51
- elif type == 'Button': return psg.Button(button_text=args['button_text'])
71
+ elif type == 'Multiline':
72
+ size = self.getSize(args)
73
+ return psg.Multiline(default_text=args['default_text'], key=args['key'], size=size)
74
+ elif type == 'Text':
75
+ size = self.getSize(args)
76
+ return psg.Text(text=args['text'], size=size, expand_x=args['expand_x'])
52
77
  else: return None
78
+
79
+ def getSize(self, args):
80
+ size = args['size']
81
+ if size == (None, None):
82
+ return size
83
+ size = size.split()
84
+ return (size[0], size[1])
easycoder/ec_program.py CHANGED
@@ -127,7 +127,7 @@ class Program:
127
127
 
128
128
  def doValue(self, value):
129
129
  if value == None:
130
- FatalError(self.compiler, f'Undefined value (variable not initialized?)')
130
+ RuntimeError(self, f'Undefined value (variable not initialized?)')
131
131
 
132
132
  result = {}
133
133
  valType = value['type']
@@ -150,7 +150,7 @@ class Program:
150
150
  name = value['name']
151
151
  symbolRecord = self.getSymbolRecord(name)
152
152
  if symbolRecord['value'] == [None]:
153
- RuntimeWarning(self.program, f'Variable "{name}" has no value')
153
+ RuntimeWarning(self, f'Variable "{name}" has no value')
154
154
  return None
155
155
  handler = self.domainIndex[symbolRecord['domain']].valueHandler('symbol')
156
156
  result = handler(symbolRecord)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: easycoder
3
- Version: 250116.4
3
+ Version: 250118.2
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,17 @@
1
+ easycoder/README.md,sha256=PYqOc_SkIGiFbyCNs90y7JqoqWe4aO1xYIW-6bOnFKU,573
2
+ easycoder/__init__.py,sha256=4mEv6h3EwPm3vhSmcaK94mJyEK-iZApgf69_QjY8w0k,262
3
+ easycoder/ec_classes.py,sha256=xnWBNak8oKydkFoxHLlq9wo3lIsB3aMnTDrqbtCfoWo,1512
4
+ easycoder/ec_compiler.py,sha256=dFJEA_uOhD-HeSiAdBzmmA6q3LHThUVoJpSETanmSHs,4800
5
+ easycoder/ec_condition.py,sha256=WSbONo4zs2sX1icOVpscZDFSCAEFmTsquoc2RGcLx_k,763
6
+ easycoder/ec_core.py,sha256=t4snx4DPIPvj1sLE7uPCrikGZaLajc5Rsq8M_RJiOIw,86727
7
+ easycoder/ec_graphics.py,sha256=W2IE6vCg5h8HPjxuaJQ4ftqCNnhwAnX5CSaeHi0nEG0,11239
8
+ easycoder/ec_gutils.py,sha256=6vO0yJbWc4sYMp2wR8LAwF4CZc5yqYERFfXUnHnFZxU,2819
9
+ easycoder/ec_handler.py,sha256=IJvxcrJJSR53d6DS_8H5qPHKhp9y5-GV4WXAjhZxu_o,2250
10
+ easycoder/ec_program.py,sha256=R8zMukA-pfRsOpcy9WqTw7fE_190dQfrMt2la23Yrs4,9904
11
+ easycoder/ec_timestamp.py,sha256=_3QFJPzIWZ9Rzk3SQOQJ-gwmvB07pg78k23SPntoZtY,288
12
+ easycoder/ec_value.py,sha256=zgDJTJhIg3yOvmnnKIfccIizmIhGbtvL_ghLTL1T5fg,2516
13
+ easycoder-250118.2.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
14
+ easycoder-250118.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
15
+ easycoder-250118.2.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
16
+ easycoder-250118.2.dist-info/METADATA,sha256=8EQtFh11Y7TD_fQnHjjFdazmOK2hoM2UB2DcuATTo7s,6162
17
+ easycoder-250118.2.dist-info/RECORD,,
@@ -1,17 +0,0 @@
1
- easycoder/README.md,sha256=PYqOc_SkIGiFbyCNs90y7JqoqWe4aO1xYIW-6bOnFKU,573
2
- easycoder/__init__.py,sha256=7P--K2LPePX1pCo332aXacQgLD3I3uHKC3Qr56PA15o,262
3
- easycoder/ec_classes.py,sha256=xnWBNak8oKydkFoxHLlq9wo3lIsB3aMnTDrqbtCfoWo,1512
4
- easycoder/ec_compiler.py,sha256=dFJEA_uOhD-HeSiAdBzmmA6q3LHThUVoJpSETanmSHs,4800
5
- easycoder/ec_condition.py,sha256=WSbONo4zs2sX1icOVpscZDFSCAEFmTsquoc2RGcLx_k,763
6
- easycoder/ec_core.py,sha256=yO7d5OyEFHBDGKSaC1Fhf1uGjzsttAl6VCvR1W5X5YE,86279
7
- easycoder/ec_graphics.py,sha256=sjSB7K66oVB4gn8Byjlfs-qPUFoSNVbvK_0plPHI7dI,9423
8
- easycoder/ec_gutils.py,sha256=9bjRCTBBSCEy6Z3pSkTaZIn_foWKZ79h6pswkLqCti4,1612
9
- easycoder/ec_handler.py,sha256=IJvxcrJJSR53d6DS_8H5qPHKhp9y5-GV4WXAjhZxu_o,2250
10
- easycoder/ec_program.py,sha256=wU-vWRWAYK2Ie4EFnp8HeSPUL0bxz-j9HLQSNplObcc,9919
11
- easycoder/ec_timestamp.py,sha256=_3QFJPzIWZ9Rzk3SQOQJ-gwmvB07pg78k23SPntoZtY,288
12
- easycoder/ec_value.py,sha256=zgDJTJhIg3yOvmnnKIfccIizmIhGbtvL_ghLTL1T5fg,2516
13
- easycoder-250116.4.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
14
- easycoder-250116.4.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
15
- easycoder-250116.4.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
16
- easycoder-250116.4.dist-info/METADATA,sha256=n5ZHkO3yF44XFEsO-x0DpIQBgmAT4XA0nZW7pG3DZ50,6162
17
- easycoder-250116.4.dist-info/RECORD,,