easycoder 250116.3__py2.py3-none-any.whl → 250118.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
@@ -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.3"
12
+ __version__ = "250118.1"
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,23 +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')
30
- elif token[0:2] == 'g_':
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)
34
+ else:
31
35
  command['type'] = token
32
36
  command['args'] = self.utils.getArgs(self)
33
- else: return False
34
37
  if self.nextIs('to'):
35
38
  if self.nextIsSymbol():
36
39
  symbolRecord = self.getSymbolRecord()
37
- if symbolRecord['keyword'] == 'layout':
40
+ if symbolRecord['keyword'] in ['column', 'frame', 'layout', 'tab']:
38
41
  command['target'] = symbolRecord['name']
39
42
  self.addCommand(command)
40
43
  return True
@@ -44,14 +47,19 @@ class Graphics(Handler):
44
47
  target = self.getVariable(command['target'])
45
48
  type = command['type']
46
49
  args = command['args']
50
+ param= None
47
51
  if not 'layout' in target:
48
52
  target['layout'] = []
49
53
  if args[0] == '{':
54
+ if type in ['Column', 'Frame', 'Tab']:
55
+ record = self.getVariable(command['name'])
56
+ param = record['layout']
50
57
  layout = json.loads(self.getRuntimeValue(json.loads(args)))
51
58
  default = self.utils.getDefaultArgs(type)
52
59
  for n in range(0, len(layout)):
53
60
  args = self.utils.decode(default, layout[n])
54
- target['layout'].append(self.utils.createElement(type, args))
61
+ item = self.utils.createElement(type, param, args)
62
+ target['layout'].append(item)
55
63
  else:
56
64
  v = self.getVariable(args)
57
65
  target['layout'].append(v['layout'])
@@ -86,6 +94,12 @@ class Graphics(Handler):
86
94
  target['window'].close()
87
95
  return self.nextPC()
88
96
 
97
+ def k_column(self, command):
98
+ return self.compileVariable(command)
99
+
100
+ def r_column(self, command):
101
+ return self.nextPC()
102
+
89
103
  # create {window} layout {layout}
90
104
  # create {element} {args...}
91
105
  def k_create(self, command):
@@ -111,14 +125,30 @@ class Graphics(Handler):
111
125
  if type == 'window':
112
126
  layout = self.getVariable(command['layout'])
113
127
  title = self.getRuntimeValue(command['title'])
114
- 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
115
131
  self.program.run(self.nextPC())
116
132
  self.mainLoop()
117
- self.program.kill()
133
+ # self.program.kill()
118
134
  return 0
119
135
  else:
120
136
  RuntimeError(self.program, 'Variable is not a window or an element')
121
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
+
122
152
  def k_layout(self, command):
123
153
  return self.compileVariable(command)
124
154
 
@@ -129,33 +159,38 @@ class Graphics(Handler):
129
159
  token = self.nextToken()
130
160
  if token == 'event':
131
161
  command['key'] = self.nextValue()
132
- command['goto'] = self.getPC() + 2
133
- self.add(command)
134
- self.nextToken()
135
- pcNext = self.getPC()
136
- cmd = {}
137
- cmd['domain'] = 'core'
138
- cmd['lino'] = command['lino']
139
- cmd['keyword'] = 'gotoPC'
140
- cmd['goto'] = 0
141
- cmd['debug'] = False
142
- self.addCommand(cmd)
143
- self.compileOne()
144
- cmd = {}
145
- cmd['domain'] = 'core'
146
- cmd['lino'] = command['lino']
147
- cmd['keyword'] = 'stop'
148
- cmd['debug'] = False
149
- self.addCommand(cmd)
150
- # Fixup the link
151
- self.getCommandAt(pcNext)['goto'] = self.getPC()
152
- 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
153
188
  return False
154
189
 
155
190
  def r_on(self, command):
156
191
  key = self.getRuntimeValue(command['key'])
157
- pc = command['goto']
158
- self.eventHandlers[key] = lambda: self.run(pc)
192
+ window = self.getVariable(command['window'])
193
+ window['eventHandlers'][key] = lambda: self.run(command['goto'])
159
194
  return self.nextPC()
160
195
 
161
196
  def k_popup(self, command):
@@ -222,13 +257,14 @@ class Graphics(Handler):
222
257
  return value
223
258
  return None
224
259
 
260
+ if self.getToken() == 'the':
261
+ self.nextToken()
262
+
263
+ token = self.getToken()
225
264
  value['type'] = token
226
265
 
227
- if token == 'test':
228
- value = {}
229
- value['type'] = 'text'
230
- value['content'] = 'test'
231
- return value
266
+ if token == 'event':
267
+ return value
232
268
 
233
269
  return None
234
270
 
@@ -247,7 +283,9 @@ class Graphics(Handler):
247
283
  else:
248
284
  return None
249
285
 
250
- def v_test(self, v):
286
+ def v_event(self, v):
287
+ v['type'] = 'text'
288
+ v['content'] = self.eventValues
251
289
  return v
252
290
 
253
291
  #############################################################################
@@ -262,13 +300,15 @@ class Graphics(Handler):
262
300
  #############################################################################
263
301
  # The main loop
264
302
  def mainLoop(self):
303
+ windowRecord = self.program.windowRecord
304
+ window = windowRecord['window']
305
+ eventHandlers = windowRecord['eventHandlers']
265
306
  while True:
266
- event, values = self.program.window.Read(timeout=100)
307
+ event, values = window.Read(timeout=100)
267
308
  if event == psg.WINDOW_CLOSED or event == "EXIT":
268
309
  break
269
310
  if event == '__TIMEOUT__': self.program.flushCB()
270
311
  else:
271
- if event in self.eventHandlers:
312
+ if event in eventHandlers:
272
313
  self.eventValues = values
273
- self.eventHandlers[event]()
274
-
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 == 'g_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
27
- elif type == 'g_input':
34
+ args['pad'] = (0, 0)
35
+ elif type == 'Input':
28
36
  args['key'] = None
29
37
  args['size'] = (None, None)
30
- elif type == 'g_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 == 'g_text': return psg.Text(text=args['text'], expand_x=args['expand_x'])
47
- elif type == 'g_input':
48
- size = args['size'].split()
49
- size = (size[0], size[1])
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'])
68
+ elif type == 'Input':
69
+ size = self.getSize(args)
50
70
  return psg.Input(key=args['key'], size=size)
51
- elif type == 'g_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])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: easycoder
3
- Version: 250116.3
3
+ Version: 250118.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>
@@ -1,17 +1,17 @@
1
1
  easycoder/README.md,sha256=PYqOc_SkIGiFbyCNs90y7JqoqWe4aO1xYIW-6bOnFKU,573
2
- easycoder/__init__.py,sha256=cxPTgZu3SQ4VrP87zrYqBbSfyYN9eFpLgxLd57elEQA,262
2
+ easycoder/__init__.py,sha256=eHRjGvRE1Q4gkU7LU7u5U422z1Krs_a2AdY1PHd2sQw,262
3
3
  easycoder/ec_classes.py,sha256=xnWBNak8oKydkFoxHLlq9wo3lIsB3aMnTDrqbtCfoWo,1512
4
4
  easycoder/ec_compiler.py,sha256=dFJEA_uOhD-HeSiAdBzmmA6q3LHThUVoJpSETanmSHs,4800
5
5
  easycoder/ec_condition.py,sha256=WSbONo4zs2sX1icOVpscZDFSCAEFmTsquoc2RGcLx_k,763
6
- easycoder/ec_core.py,sha256=yO7d5OyEFHBDGKSaC1Fhf1uGjzsttAl6VCvR1W5X5YE,86279
7
- easycoder/ec_graphics.py,sha256=zM0MDL0ES6WkcU0XizI6VTWp7NcJODMy1fIn7Rj2U4M,9469
8
- easycoder/ec_gutils.py,sha256=fqh0VKfm2ry5yjHoOE1ufF7uu741lOU7EEwTUEabJ4k,1624
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
9
  easycoder/ec_handler.py,sha256=IJvxcrJJSR53d6DS_8H5qPHKhp9y5-GV4WXAjhZxu_o,2250
10
10
  easycoder/ec_program.py,sha256=wU-vWRWAYK2Ie4EFnp8HeSPUL0bxz-j9HLQSNplObcc,9919
11
11
  easycoder/ec_timestamp.py,sha256=_3QFJPzIWZ9Rzk3SQOQJ-gwmvB07pg78k23SPntoZtY,288
12
12
  easycoder/ec_value.py,sha256=zgDJTJhIg3yOvmnnKIfccIizmIhGbtvL_ghLTL1T5fg,2516
13
- easycoder-250116.3.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
14
- easycoder-250116.3.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
15
- easycoder-250116.3.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
16
- easycoder-250116.3.dist-info/METADATA,sha256=f2ymQEg79v-tk57RqjgFFiMeWABBcGRLKv2OTR6iXPE,6162
17
- easycoder-250116.3.dist-info/RECORD,,
13
+ easycoder-250118.1.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
14
+ easycoder-250118.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
15
+ easycoder-250118.1.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
16
+ easycoder-250118.1.dist-info/METADATA,sha256=UvUpqmF2I9xQP44f6RKcYtsNPI9Y7eTbd128KE9QMZs,6162
17
+ easycoder-250118.1.dist-info/RECORD,,