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 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.1"
@@ -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 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,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 not condition
2419
+ return condition
2396
2420
 
2397
2421
  if self.getToken() == 'file':
2398
2422
  path = self.nextValue()
2399
- token = self.nextToken()
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 type(value) == dict:
2505
- comparison = len(value) == 0
2521
+ if value == None:
2522
+ comparison = True
2506
2523
  else:
2507
- if value == None:
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
- comparison = os.path.exists(path)
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)