easycoder 250317.4__py2.py3-none-any.whl → 250403.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__ = "250317.4"
12
+ __version__ = "250403.2"
easycoder/ec_core.py CHANGED
@@ -1,4 +1,4 @@
1
- import json, math, hashlib, threading, os, subprocess, sys, requests, time, numbers, base64, binascii
1
+ import json, math, hashlib, threading, os, subprocess, sys, requests, time, numbers, base64, binascii, random
2
2
  from psutil import Process
3
3
  from datetime import datetime, timezone
4
4
  from random import randrange
@@ -144,7 +144,7 @@ class Core(Handler):
144
144
  else:
145
145
  return self.compileFromHere(['end'])
146
146
 
147
- # Clear (set False)
147
+ # Clear (set false)
148
148
  # clear {variable}
149
149
  def k_clear(self, command):
150
150
  if self.nextIsSymbol():
@@ -405,36 +405,40 @@ class Core(Handler):
405
405
  else:
406
406
  FatalError(self.compiler, f'Variable "{symbolRecord["name"]}" does not hold a value')
407
407
  if self.nextIs('from'):
408
- command['url'] = self.nextValue()
409
- command['or'] = None
410
- get = self.getPC()
411
- if self.peek() == 'timeout':
412
- self.nextToken()
413
- command['timeout'] = self.nextValue()
414
- else:
415
- timeout = {}
416
- timeout['type'] = 'int'
417
- timeout['content'] = 5
418
- command['timeout'] = timeout
419
- self.addCommand(command)
420
- if self.peek() == 'or':
421
- self.nextToken()
422
- self.nextToken()
423
- # Add a 'goto' to skip the 'or'
424
- cmd = {}
425
- cmd['lino'] = command['lino']
426
- cmd['domain'] = 'core'
427
- cmd['keyword'] = 'gotoPC'
428
- cmd['goto'] = 0
429
- cmd['debug'] = False
430
- skip = self.getPC()
431
- self.addCommand(cmd)
432
- # Process the 'or'
433
- self.getCommandAt(get)['or'] = self.getPC()
434
- self.compileOne()
435
- # Fixup the skip
436
- self.getCommandAt(skip)['goto'] = self.getPC()
437
- return True
408
+ if self.nextIs('url'):
409
+ url = self.nextValue()
410
+ if url != None:
411
+ command['url'] = url
412
+ command['or'] = None
413
+ get = self.getPC()
414
+ if self.peek() == 'timeout':
415
+ self.nextToken()
416
+ command['timeout'] = self.nextValue()
417
+ else:
418
+ timeout = {}
419
+ timeout['type'] = 'int'
420
+ timeout['content'] = 5
421
+ command['timeout'] = timeout
422
+ self.addCommand(command)
423
+ if self.peek() == 'or':
424
+ self.nextToken()
425
+ self.nextToken()
426
+ # Add a 'goto' to skip the 'or'
427
+ cmd = {}
428
+ cmd['lino'] = command['lino']
429
+ cmd['domain'] = 'core'
430
+ cmd['keyword'] = 'gotoPC'
431
+ cmd['goto'] = 0
432
+ cmd['debug'] = False
433
+ skip = self.getPC()
434
+ self.addCommand(cmd)
435
+ # Process the 'or'
436
+ self.getCommandAt(get)['or'] = self.getPC()
437
+ self.compileOne()
438
+ # Fixup the skip
439
+ self.getCommandAt(skip)['goto'] = self.getPC()
440
+ return True
441
+ return False
438
442
 
439
443
  def r_get(self, command):
440
444
  global errorCode, errorReason
@@ -1414,6 +1418,33 @@ class Core(Handler):
1414
1418
 
1415
1419
  return self.nextPC()
1416
1420
 
1421
+ # Shuffle a list
1422
+ def k_shuffle(self, command):
1423
+ if self.nextIsSymbol():
1424
+ symbolRecord = self.getSymbolRecord()
1425
+ if symbolRecord['valueHolder']:
1426
+ command['target'] = self.getToken()
1427
+ self.add(command)
1428
+ return True
1429
+ self.warning(f'Core.negate: Variable "{symbolRecord["name"]}" does not hold a value')
1430
+ return False
1431
+
1432
+ def r_shuffle(self, command):
1433
+ symbolRecord = self.getVariable(command['target'])
1434
+ if not symbolRecord['valueHolder']:
1435
+ RuntimeError(self.program, f'{symbolRecord["name"]} does not hold a value')
1436
+ return None
1437
+ value = self.getSymbolValue(symbolRecord)
1438
+ if value == None:
1439
+ RuntimeError(self.program, f'{symbolRecord["name"]} has not been initialised')
1440
+ content = value['content']
1441
+ if isinstance(content, list):
1442
+ random.shuffle(content)
1443
+ value['content'] = content
1444
+ self.putSymbolValue(symbolRecord, value)
1445
+ return self.nextPC()
1446
+ RuntimeError(self.program, f'{symbolRecord["name"]} is not a list')
1447
+
1417
1448
  # Declare a stack variable
1418
1449
  def k_stack(self, command):
1419
1450
  return self.compileVariable(command)
@@ -1780,8 +1811,8 @@ class Core(Handler):
1780
1811
  token = self.getToken()
1781
1812
  value['type'] = token
1782
1813
 
1783
- if token in ['args', 'directory']:
1784
- return value
1814
+ if token == 'args':
1815
+ return value
1785
1816
 
1786
1817
  if token == 'elements':
1787
1818
  if self.nextIs('of'):
@@ -2013,12 +2044,6 @@ class Core(Handler):
2013
2044
  value = v
2014
2045
  return value
2015
2046
 
2016
- def v_directory(self, v):
2017
- value = {}
2018
- value['type'] = 'text'
2019
- value['content'] = os.getcwd()
2020
- return value
2021
-
2022
2047
  def v_element(self, v):
2023
2048
  index = self.getRuntimeValue(v['index'])
2024
2049
  target = self.getVariable(v['target'])
@@ -2387,26 +2412,23 @@ class Core(Handler):
2387
2412
  # Compile a condition
2388
2413
  def compileCondition(self):
2389
2414
  condition = Condition()
2390
- condition.negate = False
2391
2415
 
2392
2416
  if self.getToken() == 'not':
2393
2417
  condition.type = 'not'
2394
2418
  condition.value = self.nextValue()
2395
- return not condition
2419
+ return condition
2396
2420
 
2397
2421
  if self.getToken() == 'file':
2398
2422
  path = self.nextValue()
2423
+ condition.path = path
2424
+ condition.type = 'exists'
2399
2425
  token = self.nextToken()
2400
2426
  if token == 'exists':
2401
- condition.type = 'exists'
2402
- condition.path = path
2403
2427
  return condition
2404
- if token == 'does':
2428
+ elif token == 'does':
2405
2429
  if self.nextIs('not'):
2406
2430
  if self.nextIs('exist'):
2407
- condition.type = 'exists'
2408
- condition.path = path
2409
- condition.negate = True
2431
+ condition.negate = not condition.negate
2410
2432
  return condition
2411
2433
  return None
2412
2434
 
@@ -2501,13 +2523,10 @@ class Core(Handler):
2501
2523
 
2502
2524
  def c_empty(self, condition):
2503
2525
  value = self.getRuntimeValue(condition.value1)
2504
- if type(value) == dict:
2505
- comparison = len(value) == 0
2526
+ if value == None:
2527
+ comparison = True
2506
2528
  else:
2507
- if value == None:
2508
- comparison = True
2509
- else:
2510
- comparison = len(value) == 0
2529
+ comparison = len(value) == 0
2511
2530
  return not comparison if condition.negate else comparison
2512
2531
 
2513
2532
  def c_ends(self, condition):
@@ -2520,8 +2539,7 @@ class Core(Handler):
2520
2539
 
2521
2540
  def c_exists(self, condition):
2522
2541
  path = self.getRuntimeValue(condition.path)
2523
- comparison = os.path.exists(path)
2524
- return comparison <= 0 if condition.negate else comparison > 0
2542
+ return os.path.exists(path)
2525
2543
 
2526
2544
  def c_greater(self, condition):
2527
2545
  comparison = self.program.compare(condition.value1, condition.value2)
easycoder/ec_graphics.py CHANGED
@@ -161,6 +161,41 @@ class Graphics(Handler):
161
161
  def r_frame(self, command):
162
162
  return self.nextPC()
163
163
 
164
+ # get {variable} from popup {type} {message} {title}
165
+ def k_get(self, command):
166
+ if self.nextIsSymbol():
167
+ symbolRecord = self.getSymbolRecord()
168
+ if symbolRecord['valueHolder']:
169
+ command['target'] = self.getToken()
170
+ else:
171
+ FatalError(self.compiler, f'Variable "{symbolRecord["name"]}" does not hold a value')
172
+ if symbolRecord['valueHolder']:
173
+ if self.nextIs('from'):
174
+ if self.nextIs('popup'):
175
+ command['ptype'] = self.nextToken()
176
+ command['message'] = self.nextValue()
177
+ command['title'] = self.nextValue()
178
+ self.addCommand(command)
179
+ return True
180
+ return False
181
+
182
+ def r_get(self, command):
183
+ target = self.getVariable(command['target'])
184
+ ptype = command['ptype']
185
+ if ptype == 'text':
186
+ text = psg.popup_get_text(self.getRuntimeValue(command['message']), title=self.getRuntimeValue(command['title']))
187
+ elif ptype == 'ok-cancel':
188
+ text = psg.popup_ok_cancel(self.getRuntimeValue(command['message']), title=self.getRuntimeValue(command['title']))
189
+ elif ptype == 'yes-no':
190
+ text = psg.popup_yes_no(self.getRuntimeValue(command['message']), title=self.getRuntimeValue(command['title']))
191
+ else:
192
+ return None
193
+ v = {}
194
+ v['type'] = 'text'
195
+ v['content'] = text
196
+ self.program.putSymbolValue(target, v)
197
+ return self.nextPC()
198
+
164
199
  def k_init(self, command):
165
200
  if self.nextIsSymbol():
166
201
  symbolRecord = self.getSymbolRecord()
@@ -219,13 +254,15 @@ class Graphics(Handler):
219
254
  window['eventHandlers'][key] = lambda: self.run(command['goto'])
220
255
  return self.nextPC()
221
256
 
257
+ # popup {message} {title}
222
258
  def k_popup(self, command):
223
259
  command['message'] = self.nextValue()
260
+ command['title'] = self.nextValue()
224
261
  self.addCommand(command)
225
262
  return True
226
263
 
227
264
  def r_popup(self, command):
228
- psg.popup(self.getRuntimeValue(command['message']))
265
+ psg.popup(self.getRuntimeValue(command['message']), title=self.getRuntimeValue(command['title']))
229
266
  return self.nextPC()
230
267
 
231
268
  def k_refresh(self, command):
easycoder/ec_program.py CHANGED
@@ -375,9 +375,6 @@ class Program:
375
375
  if type(v2) == int:
376
376
  if type(v1) != int:
377
377
  v2 = f'{v2}'
378
- if type(v1) == dict and type(v2) == dict:
379
- v1 = json.dumps(v1)
380
- v2 = json.dumps(v2)
381
378
  if v1 > v2:
382
379
  return 1
383
380
  if v1 < v2:
@@ -1,11 +1,12 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: easycoder
3
- Version: 250317.4
3
+ Version: 250403.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>
7
7
  Description-Content-Type: text/markdown
8
8
  Classifier: License :: OSI Approved :: MIT License
9
+ License-File: LICENSE
9
10
  Requires-Dist: pytz
10
11
  Project-URL: Home, https://github.com/easycoder/easycoder-py
11
12
 
@@ -44,32 +45,37 @@ fi
44
45
  Now write a test script, 'hello.ecs', containing the following:
45
46
  ```
46
47
  print `Hello, world!`
48
+ exit
47
49
  ```
48
50
  (Note the backticks.) This is traditionally the first program to be written in virtually any language. To run it, use `easycoder hello.ecs`.
49
51
 
50
- The output will look like this (the version number will differ):
52
+ The output will look like this (the version number will likely differ):
51
53
  ```
52
- EasyCoder version 250101.1
54
+ EasyCoder version 250403.1
53
55
  Compiled <anon>: 1 lines (2 tokens) in 0 ms
54
56
  Run <anon>
55
- 1-> Hello, world!
57
+ Hello, world!
56
58
  ```
57
59
 
60
+ Why the `exit`? Because EasyCoder can't tell that the program is finished. It might contain elements that are waiting for outside events, so without `exit` it just stops and waits. You can kill it by typing Control-C.
61
+
58
62
  It's conventional to add a program title to a script:
59
63
  ```
60
64
  ! Test script
61
65
  script Test
62
- print `Hello, world!`
66
+ log `Hello, world!`
67
+ exit
63
68
  ```
64
- The first line here is just a comment and has no effect on the running of the script. The second line gives the script a name, which is useful in debugging as it says which script was running. When run, the output is now
69
+
70
+ The first line here is just a comment and has no effect on the running of the script. The second line gives the script a name, which is useful in debugging as it says which script was running. I've also changed `print` to `log` to get more information from the script. When run, the output is now
65
71
  ```
66
- EasyCoder version 250101.1
72
+ EasyCoder version 250403.1
67
73
  Compiled Test: 3 lines (4 tokens) in 0 ms
68
74
  Run Test
69
- 3-> Hello, world!
75
+ 16:37:39.132311: 3-> Hello, world!
70
76
  ```
71
77
 
72
- As you might guess from the above, the print command shows the line in the script it was called from. This is very useful in tracking down debugging print commands in large scripts.
78
+ As you might guess from the above, the `log` command shows the time and the line in the script it was called from. This is very useful in tracking down debugging print commands in large scripts.
73
79
 
74
80
  Here in the repository is a folder called `scripts` containing some sample scripts:
75
81
 
@@ -77,7 +83,7 @@ Here in the repository is a folder called `scripts` containing some sample scrip
77
83
  `tests.ecs` is a test program containing many of the **_EasyCoder_** features
78
84
  `benchmark.ecs` allows the performance of **_EasyCoder_** to be compared to other languages if a similar script is written for each one.
79
85
 
80
- ## Graphical programmming
86
+ ## Graphical programming
81
87
  **_EasyCoder_** includes a graphical programming environment that is in the early stages of development. Some demo scripts will be included in the `scripts` directory; these can be recognised by the extension`.ecg`. To run them, first install `tkinter`. On Linux this is done with
82
88
  ```
83
89
  sudo apt install python3-tk
@@ -0,0 +1,17 @@
1
+ easycoder/README.md,sha256=BVXmYphcTJ6q6RN_9L6HtQukgCnOjSLVIsTM3lk-9aM,587
2
+ easycoder/__init__.py,sha256=pk5KcaeSSqFM8gNQsBKwFnRWtTaZbrUhpghX8PtwLRk,262
3
+ easycoder/ec_classes.py,sha256=xnWBNak8oKydkFoxHLlq9wo3lIsB3aMnTDrqbtCfoWo,1512
4
+ easycoder/ec_compiler.py,sha256=rtxFEWnhW0550MtWEDvYHOw9cYkeTcR0oG3t-kmgnBk,4795
5
+ easycoder/ec_condition.py,sha256=YXvSBQKEzKGCcgUGo3Qp8iHolXmm2BpEm0NimSDszIM,785
6
+ easycoder/ec_core.py,sha256=fBfi6BvOqcmjqMvsKHPQLi-x4-CnuJlXldfRjGm4LzM,90287
7
+ easycoder/ec_graphics.py,sha256=ScGLNxW_sxu0WyoO-Od-9MM0bhpVvf-vGa5UmoHYRCA,16073
8
+ easycoder/ec_gutils.py,sha256=yqu4RRQ6VdRkC5B2ADBYsXzgNu76dLnekd9aUjdEgPw,6399
9
+ easycoder/ec_handler.py,sha256=K7nBuQTH8l0k8hX1o2b4KhTnhZHGdf2fkEuX4FJXJs8,2277
10
+ easycoder/ec_program.py,sha256=BDwU7aGHiaw6WdbQvVFDhGVaHsvwQ1CWa4wb5MPmOe8,10013
11
+ easycoder/ec_timestamp.py,sha256=_3QFJPzIWZ9Rzk3SQOQJ-gwmvB07pg78k23SPntoZtY,288
12
+ easycoder/ec_value.py,sha256=zgDJTJhIg3yOvmnnKIfccIizmIhGbtvL_ghLTL1T5fg,2516
13
+ easycoder-250403.2.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
14
+ easycoder-250403.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
15
+ easycoder-250403.2.dist-info/WHEEL,sha256=Dyt6SBfaasWElUrURkknVFAZDHSTwxg3PaTza7RSbkY,100
16
+ easycoder-250403.2.dist-info/METADATA,sha256=aavGnyy5UUUQLxzFAdJI4eUS-r1C_9CasJkZGIfS1eA,6520
17
+ easycoder-250403.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: flit 3.10.1
2
+ Generator: flit 3.12.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py2-none-any
5
5
  Tag: py3-none-any
@@ -1,17 +0,0 @@
1
- easycoder/README.md,sha256=BVXmYphcTJ6q6RN_9L6HtQukgCnOjSLVIsTM3lk-9aM,587
2
- easycoder/__init__.py,sha256=Pu1BNwq6pDEu7S4vA2SrZfUJ3jCtyUTA9n6v51HF3w8,262
3
- easycoder/ec_classes.py,sha256=xnWBNak8oKydkFoxHLlq9wo3lIsB3aMnTDrqbtCfoWo,1512
4
- easycoder/ec_compiler.py,sha256=rtxFEWnhW0550MtWEDvYHOw9cYkeTcR0oG3t-kmgnBk,4795
5
- easycoder/ec_condition.py,sha256=YXvSBQKEzKGCcgUGo3Qp8iHolXmm2BpEm0NimSDszIM,785
6
- easycoder/ec_core.py,sha256=q6bHq26_AsaoCi6roQeacclhhBv3H6b6ii4AZi48iyw,89127
7
- easycoder/ec_graphics.py,sha256=sOQlSDpMMjwilLzGkC57-iHdaRqIUWl1SJxc0NbLs1M,14377
8
- easycoder/ec_gutils.py,sha256=yqu4RRQ6VdRkC5B2ADBYsXzgNu76dLnekd9aUjdEgPw,6399
9
- easycoder/ec_handler.py,sha256=K7nBuQTH8l0k8hX1o2b4KhTnhZHGdf2fkEuX4FJXJs8,2277
10
- easycoder/ec_program.py,sha256=Ms-GOtd22TjqvxXkNtfNer725WgQmZiHXlNHLlwMGvs,10103
11
- easycoder/ec_timestamp.py,sha256=_3QFJPzIWZ9Rzk3SQOQJ-gwmvB07pg78k23SPntoZtY,288
12
- easycoder/ec_value.py,sha256=zgDJTJhIg3yOvmnnKIfccIizmIhGbtvL_ghLTL1T5fg,2516
13
- easycoder-250317.4.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
14
- easycoder-250317.4.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
15
- easycoder-250317.4.dist-info/WHEEL,sha256=ssQ84EZ5gH1pCOujd3iW7HClo_O_aDaClUbX4B8bjKY,100
16
- easycoder-250317.4.dist-info/METADATA,sha256=ULfbfg_rxDcgz3gbpvahx4r6mchZMXVK4iN7cS_u5Vc,6155
17
- easycoder-250317.4.dist-info/RECORD,,