bare-script 4.1.1__tar.gz → 4.1.2__tar.gz

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.
Files changed (44) hide show
  1. {bare_script-4.1.1/src/bare_script.egg-info → bare_script-4.1.2}/PKG-INFO +1 -1
  2. {bare_script-4.1.1 → bare_script-4.1.2}/setup.cfg +1 -1
  3. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/__init__.py +2 -2
  4. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/bare.py +2 -2
  5. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/library.py +2 -2
  6. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/runtime.py +36 -32
  7. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/runtime_c.c +50 -34
  8. {bare_script-4.1.1 → bare_script-4.1.2/src/bare_script.egg-info}/PKG-INFO +1 -1
  9. {bare_script-4.1.1 → bare_script-4.1.2}/LICENSE +0 -0
  10. {bare_script-4.1.1 → bare_script-4.1.2}/README.md +0 -0
  11. {bare_script-4.1.1 → bare_script-4.1.2}/pyproject.toml +0 -0
  12. {bare_script-4.1.1 → bare_script-4.1.2}/setup.py +0 -0
  13. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/__main__.py +0 -0
  14. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/include/__init__.py +0 -0
  15. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/include/args.bare +0 -0
  16. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/include/baredoc.bare +0 -0
  17. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/include/baredocCLI.bare +0 -0
  18. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/include/data.bare +0 -0
  19. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/include/dataLineChart.bare +0 -0
  20. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/include/dataTable.bare +0 -0
  21. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/include/dataUtil.bare +0 -0
  22. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/include/diff.bare +0 -0
  23. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/include/draw.bare +0 -0
  24. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/include/elementModel.bare +0 -0
  25. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/include/forms.bare +0 -0
  26. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/include/markdown.bare +0 -0
  27. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/include/markdownElements.bare +0 -0
  28. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/include/markdownHighlight.bare +0 -0
  29. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/include/markdownParser.bare +0 -0
  30. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/include/markdownUp.bare +0 -0
  31. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/include/pager.bare +0 -0
  32. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/include/qrcode.bare +0 -0
  33. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/include/schemaDoc.bare +0 -0
  34. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/include/unittest.bare +0 -0
  35. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/include/unittestMock.bare +0 -0
  36. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/model.py +0 -0
  37. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/options.py +0 -0
  38. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/parser.py +0 -0
  39. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script/value.py +0 -0
  40. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script.egg-info/SOURCES.txt +0 -0
  41. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script.egg-info/dependency_links.txt +0 -0
  42. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script.egg-info/entry_points.txt +0 -0
  43. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script.egg-info/requires.txt +0 -0
  44. {bare_script-4.1.1 → bare_script-4.1.2}/src/bare_script.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bare-script
3
- Version: 4.1.1
3
+ Version: 4.1.2
4
4
  Summary: bare-script
5
5
  Home-page: https://github.com/craigahobbs/bare-script
6
6
  Author: Craig A. Hobbs
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = bare-script
3
- version = 4.1.1
3
+ version = 4.1.2
4
4
  url = https://github.com/craigahobbs/bare-script
5
5
  author = Craig A. Hobbs
6
6
  author_email = craigahobbs@gmail.com
@@ -5,7 +5,7 @@
5
5
  bare-script package
6
6
  """
7
7
 
8
- import os as _os
8
+ import os
9
9
 
10
10
  from .model import \
11
11
  lint_script, \
@@ -29,7 +29,7 @@ from .parser import \
29
29
  from .runtime import \
30
30
  BareScriptRuntimeError
31
31
 
32
- if not _os.environ.get('BARESCRIPT_RUNTIME_PY'): # pragma: no cover
32
+ if not os.environ.get('BARESCRIPT_RUNTIME_PY'): # pragma: no cover
33
33
  try:
34
34
  from .runtime_c import evaluate_expression, execute_script
35
35
  except ImportError:
@@ -7,7 +7,7 @@ bare-script command-line interface (CLI)
7
7
 
8
8
  import argparse
9
9
  from functools import partial
10
- import os as _os
10
+ import os
11
11
  import sys
12
12
  import time
13
13
 
@@ -16,7 +16,7 @@ from .options import FETCH_SYSTEM_PREFIX, fetch_read_write, fetch_system, log_st
16
16
  from .parser import parse_expression, parse_script
17
17
  from .runtime import SYSTEM_GLOBAL_INCLUDES_NAME
18
18
  from .value import value_boolean
19
- if not _os.environ.get('BARESCRIPT_RUNTIME_PY'): # pragma: no cover
19
+ if not os.environ.get('BARESCRIPT_RUNTIME_PY'): # pragma: no cover
20
20
  try:
21
21
  from .runtime_c import evaluate_expression, execute_script
22
22
  except ImportError:
@@ -11,7 +11,7 @@ import functools
11
11
  import importlib
12
12
  import json
13
13
  import math
14
- import os as _os
14
+ import os
15
15
  import random
16
16
  import re
17
17
  import urllib
@@ -28,7 +28,7 @@ from .value import R_NUMBER_CLEANUP, ValueArgsError, value_args_model, value_arg
28
28
  # Helper to dynamically import evaluate_expression to avoid the circular dependency
29
29
  def _import_evaluate_expression():
30
30
  if not _EVALUATE_EXPRESSION:
31
- if not _os.environ.get('BARESCRIPT_RUNTIME_PY'): # pragma: no cover
31
+ if not os.environ.get('BARESCRIPT_RUNTIME_PY'): # pragma: no cover
32
32
  try:
33
33
  _EVALUATE_EXPRESSION.append(importlib.import_module('bare_script.runtime_c').evaluate_expression)
34
34
  except (ImportError, AttributeError):
@@ -224,13 +224,17 @@ def _script_function(script, function, args, options):
224
224
  if func_args is not None:
225
225
  args_length = len(args)
226
226
  func_args_length = len(func_args)
227
- ix_arg_last = function.get('lastArgArray', None) and (func_args_length - 1)
228
- for ix_arg in range(func_args_length):
229
- arg_name = func_args[ix_arg]
230
- if ix_arg < args_length:
231
- func_locals[arg_name] = args[ix_arg] if ix_arg != ix_arg_last else args[ix_arg:]
232
- else:
233
- func_locals[arg_name] = [] if ix_arg == ix_arg_last else None
227
+ if function.get('lastArgArray'):
228
+ ix_arg_last = func_args_length - 1
229
+ for ix_arg in range(func_args_length):
230
+ arg_name = func_args[ix_arg]
231
+ if ix_arg < args_length:
232
+ func_locals[arg_name] = args[ix_arg] if ix_arg != ix_arg_last else args[ix_arg:]
233
+ else:
234
+ func_locals[arg_name] = [] if ix_arg == ix_arg_last else None
235
+ else:
236
+ for ix_arg in range(func_args_length):
237
+ func_locals[func_args[ix_arg]] = args[ix_arg] if ix_arg < args_length else None
234
238
  return _execute_script_helper(script, function['statements'], options, func_locals)
235
239
 
236
240
 
@@ -399,35 +403,35 @@ def evaluate_expression(expr, options=None, locals_=None, builtins=True, script=
399
403
  (right_type is int or right_type is float)):
400
404
  return left_value / right_value
401
405
 
402
- elif bin_op == '==':
403
- if (left_type is int or left_type is float) and (right_type is int or right_type is float):
404
- return left_value == right_value
405
- return value_compare(left_value, right_value) == 0
406
-
407
- elif bin_op == '!=':
406
+ elif bin_op == '<':
408
407
  if (left_type is int or left_type is float) and (right_type is int or right_type is float):
409
- return left_value != right_value
410
- return value_compare(left_value, right_value) != 0
408
+ return left_value < right_value
409
+ return value_compare(left_value, right_value) < 0
411
410
 
412
411
  elif bin_op == '<=':
413
412
  if (left_type is int or left_type is float) and (right_type is int or right_type is float):
414
413
  return left_value <= right_value
415
414
  return value_compare(left_value, right_value) <= 0
416
415
 
417
- elif bin_op == '<':
416
+ elif bin_op == '>':
418
417
  if (left_type is int or left_type is float) and (right_type is int or right_type is float):
419
- return left_value < right_value
420
- return value_compare(left_value, right_value) < 0
418
+ return left_value > right_value
419
+ return value_compare(left_value, right_value) > 0
421
420
 
422
421
  elif bin_op == '>=':
423
422
  if (left_type is int or left_type is float) and (right_type is int or right_type is float):
424
423
  return left_value >= right_value
425
424
  return value_compare(left_value, right_value) >= 0
426
425
 
427
- elif bin_op == '>':
426
+ elif bin_op == '==':
428
427
  if (left_type is int or left_type is float) and (right_type is int or right_type is float):
429
- return left_value > right_value
430
- return value_compare(left_value, right_value) > 0
428
+ return left_value == right_value
429
+ return value_compare(left_value, right_value) == 0
430
+
431
+ elif bin_op == '!=':
432
+ if (left_type is int or left_type is float) and (right_type is int or right_type is float):
433
+ return left_value != right_value
434
+ return value_compare(left_value, right_value) != 0
431
435
 
432
436
  elif bin_op == '%':
433
437
  # number % number
@@ -443,32 +447,32 @@ def evaluate_expression(expr, options=None, locals_=None, builtins=True, script=
443
447
 
444
448
  elif bin_op == '&':
445
449
  # int & int
446
- if ((left_type is int or left_type is float) and int(left_value) == left_value and
447
- (right_type is int or right_type is float) and int(right_value) == right_value):
450
+ if ((left_type is int or (left_type is float and left_value.is_integer())) and
451
+ (right_type is int or (right_type is float and right_value.is_integer()))):
448
452
  return int(left_value) & int(right_value)
449
453
 
450
454
  elif bin_op == '|':
451
455
  # int & int
452
- if ((left_type is int or left_type is float) and int(left_value) == left_value and
453
- (right_type is int or right_type is float) and int(right_value) == right_value):
456
+ if ((left_type is int or (left_type is float and left_value.is_integer())) and
457
+ (right_type is int or (right_type is float and right_value.is_integer()))):
454
458
  return int(left_value) | int(right_value)
455
459
 
456
460
  elif bin_op == '^':
457
461
  # int & int
458
- if ((left_type is int or left_type is float) and int(left_value) == left_value and
459
- (right_type is int or right_type is float) and int(right_value) == right_value):
462
+ if ((left_type is int or (left_type is float and left_value.is_integer())) and
463
+ (right_type is int or (right_type is float and right_value.is_integer()))):
460
464
  return int(left_value) ^ int(right_value)
461
465
 
462
466
  elif bin_op == '<<':
463
467
  # int & int
464
- if ((left_type is int or left_type is float) and int(left_value) == left_value and
465
- (right_type is int or right_type is float) and int(right_value) == right_value):
468
+ if ((left_type is int or (left_type is float and left_value.is_integer())) and
469
+ (right_type is int or (right_type is float and right_value.is_integer()))):
466
470
  return int(left_value) << int(right_value)
467
471
 
468
472
  else: # bin_op == '>>':
469
473
  # int & int
470
- if ((left_type is int or left_type is float) and int(left_value) == left_value and
471
- (right_type is int or right_type is float) and int(right_value) == right_value):
474
+ if ((left_type is int or (left_type is float and left_value.is_integer())) and
475
+ (right_type is int or (right_type is float and right_value.is_integer()))):
472
476
  return int(left_value) >> int(right_value)
473
477
 
474
478
  # Invalid operation values
@@ -486,7 +490,7 @@ def evaluate_expression(expr, options=None, locals_=None, builtins=True, script=
486
490
  if val_type is int or val_type is float:
487
491
  return -value
488
492
  else: # unary_op == '~':
489
- if (val_type is int or val_type is float) and int(value) == value:
493
+ if val_type is int or (val_type is float and value.is_integer()):
490
494
  return ~int(value)
491
495
 
492
496
  # Invalid operation value
@@ -400,42 +400,58 @@ script_function_call(PyObject *script, PyObject *function, PyObject *args, PyObj
400
400
 
401
401
  PyObject *last_arg_array = dict_getitem_borrow(function, K_lastArgArray);
402
402
  if (PyErr_Occurred()) { Py_DECREF(func_locals); return NULL; }
403
- Py_ssize_t ix_arg_last = -1;
404
- if (last_arg_array != NULL && PyObject_IsTrue(last_arg_array) == 1) {
405
- ix_arg_last = func_args_length - 1;
406
- }
407
-
408
- for (Py_ssize_t ix = 0; ix < func_args_length; ix++) {
409
- PyObject *arg_name = PyList_GET_ITEM(func_args, ix);
410
- PyObject *val = NULL;
411
- int needs_decref = 0;
412
- if (ix < args_length) {
413
- if (ix == ix_arg_last) {
414
- /* args[ix:] */
415
- if (PyList_Check(args)) {
416
- val = PyList_GetSlice(args, ix, args_length);
403
+ int has_last_arg_array = (last_arg_array != NULL && PyObject_IsTrue(last_arg_array) == 1);
404
+
405
+ if (has_last_arg_array) {
406
+ Py_ssize_t ix_arg_last = func_args_length - 1;
407
+ for (Py_ssize_t ix = 0; ix < func_args_length; ix++) {
408
+ PyObject *arg_name = PyList_GET_ITEM(func_args, ix);
409
+ PyObject *val = NULL;
410
+ int needs_decref = 0;
411
+ if (ix < args_length) {
412
+ if (ix == ix_arg_last) {
413
+ /* args[ix:] */
414
+ if (PyList_Check(args)) {
415
+ val = PyList_GetSlice(args, ix, args_length);
416
+ } else {
417
+ val = PySequence_GetSlice(args, ix, args_length);
418
+ }
419
+ if (!val) { Py_DECREF(func_locals); return NULL; }
420
+ needs_decref = 1;
417
421
  } else {
418
- val = PySequence_GetSlice(args, ix, args_length);
422
+ val = PySequence_GetItem(args, ix);
423
+ if (!val) { Py_DECREF(func_locals); return NULL; }
424
+ needs_decref = 1;
419
425
  }
420
- if (!val) { Py_DECREF(func_locals); return NULL; }
421
- needs_decref = 1;
422
426
  } else {
423
- val = PySequence_GetItem(args, ix);
424
- if (!val) { Py_DECREF(func_locals); return NULL; }
425
- needs_decref = 1;
427
+ if (ix == ix_arg_last) {
428
+ val = PyList_New(0);
429
+ if (!val) { Py_DECREF(func_locals); return NULL; }
430
+ needs_decref = 1;
431
+ } else {
432
+ val = Py_None;
433
+ }
426
434
  }
427
- } else {
428
- if (ix == ix_arg_last) {
429
- val = PyList_New(0);
435
+ int rc = PyDict_SetItem(func_locals, arg_name, val);
436
+ if (needs_decref) Py_DECREF(val);
437
+ if (rc < 0) { Py_DECREF(func_locals); return NULL; }
438
+ }
439
+ } else {
440
+ for (Py_ssize_t ix = 0; ix < func_args_length; ix++) {
441
+ PyObject *arg_name = PyList_GET_ITEM(func_args, ix);
442
+ PyObject *val;
443
+ int needs_decref = 0;
444
+ if (ix < args_length) {
445
+ val = PySequence_GetItem(args, ix);
430
446
  if (!val) { Py_DECREF(func_locals); return NULL; }
431
447
  needs_decref = 1;
432
448
  } else {
433
449
  val = Py_None;
434
450
  }
451
+ int rc = PyDict_SetItem(func_locals, arg_name, val);
452
+ if (needs_decref) Py_DECREF(val);
453
+ if (rc < 0) { Py_DECREF(func_locals); return NULL; }
435
454
  }
436
- int rc = PyDict_SetItem(func_locals, arg_name, val);
437
- if (needs_decref) Py_DECREF(val);
438
- if (rc < 0) { Py_DECREF(func_locals); return NULL; }
439
455
  }
440
456
  }
441
457
 
@@ -588,12 +604,12 @@ op_to_id(PyObject *op)
588
604
  if (op == K_op_minus) return OP_MINUS;
589
605
  if (op == K_op_star) return OP_STAR;
590
606
  if (op == K_op_slash) return OP_SLASH;
591
- if (op == K_op_eq) return OP_EQ;
592
- if (op == K_op_ne) return OP_NE;
593
- if (op == K_op_le) return OP_LE;
594
607
  if (op == K_op_lt) return OP_LT;
595
- if (op == K_op_ge) return OP_GE;
608
+ if (op == K_op_le) return OP_LE;
596
609
  if (op == K_op_gt) return OP_GT;
610
+ if (op == K_op_ge) return OP_GE;
611
+ if (op == K_op_eq) return OP_EQ;
612
+ if (op == K_op_ne) return OP_NE;
597
613
  if (op == K_op_pct) return OP_PCT;
598
614
  if (op == K_op_star_star) return OP_STAR_STAR;
599
615
  if (op == K_op_amp_amp) return OP_AND_AND;
@@ -611,12 +627,12 @@ op_to_id(PyObject *op)
611
627
  if (PyUnicode_Compare(op, K_op_minus) == 0) return OP_MINUS;
612
628
  if (PyUnicode_Compare(op, K_op_star) == 0) return OP_STAR;
613
629
  if (PyUnicode_Compare(op, K_op_slash) == 0) return OP_SLASH;
614
- if (PyUnicode_Compare(op, K_op_eq) == 0) return OP_EQ;
615
- if (PyUnicode_Compare(op, K_op_ne) == 0) return OP_NE;
616
- if (PyUnicode_Compare(op, K_op_le) == 0) return OP_LE;
617
630
  if (PyUnicode_Compare(op, K_op_lt) == 0) return OP_LT;
618
- if (PyUnicode_Compare(op, K_op_ge) == 0) return OP_GE;
631
+ if (PyUnicode_Compare(op, K_op_le) == 0) return OP_LE;
619
632
  if (PyUnicode_Compare(op, K_op_gt) == 0) return OP_GT;
633
+ if (PyUnicode_Compare(op, K_op_ge) == 0) return OP_GE;
634
+ if (PyUnicode_Compare(op, K_op_eq) == 0) return OP_EQ;
635
+ if (PyUnicode_Compare(op, K_op_ne) == 0) return OP_NE;
620
636
  if (PyUnicode_Compare(op, K_op_pct) == 0) return OP_PCT;
621
637
  if (PyUnicode_Compare(op, K_op_star_star) == 0) return OP_STAR_STAR;
622
638
  if (PyUnicode_Compare(op, K_op_amp_amp) == 0) return OP_AND_AND;
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bare-script
3
- Version: 4.1.1
3
+ Version: 4.1.2
4
4
  Summary: bare-script
5
5
  Home-page: https://github.com/craigahobbs/bare-script
6
6
  Author: Craig A. Hobbs
File without changes
File without changes
File without changes
File without changes