easycoder 250317.4__py2.py3-none-any.whl → 250403.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 +1 -1
- easycoder/__init__.sync-conflict-20250331-210244-M3XB3VD.py +12 -0
- easycoder/ec_core.py +72 -59
- easycoder/ec_core.sync-conflict-20250331-210238-M3XB3VD.py +2564 -0
- easycoder/ec_graphics.py +38 -1
- easycoder/ec_program.py +0 -3
- {easycoder-250317.4.dist-info → easycoder-250403.1.dist-info}/METADATA +3 -2
- easycoder-250403.1.dist-info/RECORD +19 -0
- {easycoder-250317.4.dist-info → easycoder-250403.1.dist-info}/WHEEL +1 -1
- easycoder-250317.4.dist-info/RECORD +0 -17
- {easycoder-250317.4.dist-info → easycoder-250403.1.dist-info}/entry_points.txt +0 -0
- {easycoder-250317.4.dist-info → easycoder-250403.1.dist-info/licenses}/LICENSE +0 -0
easycoder/__init__.py
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'''EasyCoder for Python'''
|
|
2
|
+
|
|
3
|
+
from .ec_classes import *
|
|
4
|
+
from .ec_compiler import *
|
|
5
|
+
from .ec_condition import *
|
|
6
|
+
from .ec_core import *
|
|
7
|
+
from .ec_handler import *
|
|
8
|
+
from .ec_program import *
|
|
9
|
+
from .ec_timestamp import *
|
|
10
|
+
from .ec_value import *
|
|
11
|
+
|
|
12
|
+
__version__ = "250302.1"
|
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
|
|
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
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
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
|
|
1784
|
-
|
|
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,27 +2412,19 @@ 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
|
|
2419
|
+
return condition
|
|
2396
2420
|
|
|
2397
2421
|
if self.getToken() == 'file':
|
|
2398
2422
|
path = self.nextValue()
|
|
2399
|
-
|
|
2400
|
-
if token == 'exists':
|
|
2423
|
+
if self.peek() == 'exists':
|
|
2401
2424
|
condition.type = 'exists'
|
|
2402
2425
|
condition.path = path
|
|
2426
|
+
self.nextToken()
|
|
2403
2427
|
return condition
|
|
2404
|
-
if token == 'does':
|
|
2405
|
-
if self.nextIs('not'):
|
|
2406
|
-
if self.nextIs('exist'):
|
|
2407
|
-
condition.type = 'exists'
|
|
2408
|
-
condition.path = path
|
|
2409
|
-
condition.negate = True
|
|
2410
|
-
return condition
|
|
2411
2428
|
return None
|
|
2412
2429
|
|
|
2413
2430
|
value = self.getValue()
|
|
@@ -2501,13 +2518,10 @@ class Core(Handler):
|
|
|
2501
2518
|
|
|
2502
2519
|
def c_empty(self, condition):
|
|
2503
2520
|
value = self.getRuntimeValue(condition.value1)
|
|
2504
|
-
if
|
|
2505
|
-
comparison =
|
|
2521
|
+
if value == None:
|
|
2522
|
+
comparison = True
|
|
2506
2523
|
else:
|
|
2507
|
-
|
|
2508
|
-
comparison = True
|
|
2509
|
-
else:
|
|
2510
|
-
comparison = len(value) == 0
|
|
2524
|
+
comparison = len(value) == 0
|
|
2511
2525
|
return not comparison if condition.negate else comparison
|
|
2512
2526
|
|
|
2513
2527
|
def c_ends(self, condition):
|
|
@@ -2520,8 +2534,7 @@ class Core(Handler):
|
|
|
2520
2534
|
|
|
2521
2535
|
def c_exists(self, condition):
|
|
2522
2536
|
path = self.getRuntimeValue(condition.path)
|
|
2523
|
-
|
|
2524
|
-
return comparison <= 0 if condition.negate else comparison > 0
|
|
2537
|
+
return os.path.exists(path)
|
|
2525
2538
|
|
|
2526
2539
|
def c_greater(self, condition):
|
|
2527
2540
|
comparison = self.program.compare(condition.value1, condition.value2)
|