bare-script 4.0.2__tar.gz → 4.1.0__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.0.2/src/bare_script.egg-info → bare_script-4.1.0}/PKG-INFO +10 -1
  2. {bare_script-4.0.2 → bare_script-4.1.0}/README.md +9 -0
  3. {bare_script-4.0.2 → bare_script-4.1.0}/setup.cfg +1 -1
  4. bare_script-4.1.0/setup.py +46 -0
  5. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/__init__.py +10 -3
  6. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/bare.py +9 -1
  7. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/include/dataLineChart.bare +12 -6
  8. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/library.py +8 -5
  9. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/runtime.py +5 -1
  10. bare_script-4.1.0/src/bare_script/runtime_c.c +1693 -0
  11. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/value.py +4 -8
  12. {bare_script-4.0.2 → bare_script-4.1.0/src/bare_script.egg-info}/PKG-INFO +10 -1
  13. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script.egg-info/SOURCES.txt +2 -0
  14. {bare_script-4.0.2 → bare_script-4.1.0}/LICENSE +0 -0
  15. {bare_script-4.0.2 → bare_script-4.1.0}/pyproject.toml +0 -0
  16. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/__main__.py +0 -0
  17. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/include/__init__.py +0 -0
  18. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/include/args.bare +0 -0
  19. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/include/baredoc.bare +0 -0
  20. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/include/baredocCLI.bare +0 -0
  21. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/include/data.bare +0 -0
  22. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/include/dataTable.bare +0 -0
  23. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/include/dataUtil.bare +0 -0
  24. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/include/diff.bare +0 -0
  25. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/include/draw.bare +0 -0
  26. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/include/elementModel.bare +0 -0
  27. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/include/forms.bare +0 -0
  28. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/include/markdown.bare +0 -0
  29. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/include/markdownElements.bare +0 -0
  30. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/include/markdownHighlight.bare +0 -0
  31. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/include/markdownParser.bare +0 -0
  32. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/include/markdownUp.bare +0 -0
  33. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/include/pager.bare +0 -0
  34. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/include/qrcode.bare +0 -0
  35. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/include/schemaDoc.bare +0 -0
  36. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/include/unittest.bare +0 -0
  37. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/include/unittestMock.bare +0 -0
  38. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/model.py +0 -0
  39. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/options.py +0 -0
  40. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script/parser.py +0 -0
  41. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script.egg-info/dependency_links.txt +0 -0
  42. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script.egg-info/entry_points.txt +0 -0
  43. {bare_script-4.0.2 → bare_script-4.1.0}/src/bare_script.egg-info/requires.txt +0 -0
  44. {bare_script-4.0.2 → bare_script-4.1.0}/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.0.2
3
+ Version: 4.1.0
4
4
  Summary: bare-script
5
5
  Home-page: https://github.com/craigahobbs/bare-script
6
6
  Author: Craig A. Hobbs
@@ -48,6 +48,7 @@ confident that BareScript will execute the same regardless of the underlying run
48
48
 
49
49
  - [The BareScript Language](https://craigahobbs.github.io/bare-script-py/language/)
50
50
  - [The BareScript Library](https://craigahobbs.github.io/bare-script-py/library/)
51
+ - [The BareScript Include Library Tests](https://craigahobbs.github.io/bare-script/include/test/)
51
52
  - [API Documentation](https://craigahobbs.github.io/bare-script-py/)
52
53
  - [Source code](https://github.com/craigahobbs/bare-script-py)
53
54
 
@@ -190,6 +191,14 @@ markdownPrint('Hello, Markdown!')
190
191
  ~~~
191
192
 
192
193
 
194
+ ## C Runtime
195
+
196
+ The package ships with an optional CPython C extension (`runtime_c`) that mirrors the pure-Python
197
+ runtime for faster script execution. When the compiled extension is available, it is used
198
+ automatically; otherwise the pure-Python runtime is used as a fallback. Set the environment
199
+ variable `BARESCRIPT_RUNTIME_PY=1` to force the pure-Python runtime.
200
+
201
+
193
202
  ## Development
194
203
 
195
204
  This package is developed using [python-build](https://github.com/craigahobbs/python-build#readme).
@@ -23,6 +23,7 @@ confident that BareScript will execute the same regardless of the underlying run
23
23
 
24
24
  - [The BareScript Language](https://craigahobbs.github.io/bare-script-py/language/)
25
25
  - [The BareScript Library](https://craigahobbs.github.io/bare-script-py/library/)
26
+ - [The BareScript Include Library Tests](https://craigahobbs.github.io/bare-script/include/test/)
26
27
  - [API Documentation](https://craigahobbs.github.io/bare-script-py/)
27
28
  - [Source code](https://github.com/craigahobbs/bare-script-py)
28
29
 
@@ -165,6 +166,14 @@ markdownPrint('Hello, Markdown!')
165
166
  ~~~
166
167
 
167
168
 
169
+ ## C Runtime
170
+
171
+ The package ships with an optional CPython C extension (`runtime_c`) that mirrors the pure-Python
172
+ runtime for faster script execution. When the compiled extension is available, it is used
173
+ automatically; otherwise the pure-Python runtime is used as a fallback. Set the environment
174
+ variable `BARESCRIPT_RUNTIME_PY=1` to force the pure-Python runtime.
175
+
176
+
168
177
  ## Development
169
178
 
170
179
  This package is developed using [python-build](https://github.com/craigahobbs/python-build#readme).
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = bare-script
3
- version = 4.0.2
3
+ version = 4.1.0
4
4
  url = https://github.com/craigahobbs/bare-script
5
5
  author = Craig A. Hobbs
6
6
  author_email = craigahobbs@gmail.com
@@ -0,0 +1,46 @@
1
+ # Licensed under the MIT License
2
+ # https://github.com/craigahobbs/bare-script-py/blob/main/LICENSE
3
+
4
+ """
5
+ bare-script setup
6
+ """
7
+
8
+ from setuptools import setup, Extension
9
+ from setuptools.command.build_ext import build_ext
10
+
11
+
12
+ class OptionalBuildExt(build_ext):
13
+ """
14
+ Build C extensions optionally - if compilation fails, the package still installs
15
+ and falls back to the pure-Python implementation.
16
+ """
17
+
18
+ def run(self):
19
+ try:
20
+ super().run()
21
+ except Exception: # pylint: disable=broad-except
22
+ self._unavailable()
23
+
24
+ def build_extension(self, ext):
25
+ try:
26
+ super().build_extension(ext)
27
+ except Exception: # pylint: disable=broad-except
28
+ self._unavailable()
29
+
30
+ @staticmethod
31
+ def _unavailable():
32
+ print('*' * 70)
33
+ print('WARNING: C extension could not be compiled.')
34
+ print(' Falling back to pure-Python implementation.')
35
+ print('*' * 70)
36
+
37
+
38
+ setup(
39
+ ext_modules=[
40
+ Extension(
41
+ 'bare_script.runtime_c',
42
+ sources=['src/bare_script/runtime_c.c']
43
+ )
44
+ ],
45
+ cmdclass={'build_ext': OptionalBuildExt}
46
+ )
@@ -5,6 +5,8 @@
5
5
  bare-script package
6
6
  """
7
7
 
8
+ import os as _os
9
+
8
10
  from .model import \
9
11
  lint_script, \
10
12
  validate_expression, \
@@ -25,6 +27,11 @@ from .parser import \
25
27
  parse_script
26
28
 
27
29
  from .runtime import \
28
- BareScriptRuntimeError, \
29
- evaluate_expression, \
30
- execute_script
30
+ BareScriptRuntimeError
31
+ if not _os.environ.get('BARESCRIPT_RUNTIME_PY'): # pragma: no cover
32
+ try:
33
+ from .runtime_c import evaluate_expression, execute_script
34
+ except ImportError:
35
+ from .runtime import evaluate_expression, execute_script
36
+ else:
37
+ from .runtime import evaluate_expression, execute_script
@@ -7,14 +7,22 @@ bare-script command-line interface (CLI)
7
7
 
8
8
  import argparse
9
9
  from functools import partial
10
+ import os as _os
10
11
  import sys
11
12
  import time
12
13
 
13
14
  from .model import lint_script
14
15
  from .options import FETCH_SYSTEM_PREFIX, fetch_read_write, fetch_system, log_stdout, url_file_relative
15
16
  from .parser import parse_expression, parse_script
16
- from .runtime import SYSTEM_GLOBAL_INCLUDES_NAME, evaluate_expression, execute_script
17
+ from .runtime import SYSTEM_GLOBAL_INCLUDES_NAME
17
18
  from .value import value_boolean
19
+ if not _os.environ.get('BARESCRIPT_RUNTIME_PY'): # pragma: no cover
20
+ try:
21
+ from .runtime_c import evaluate_expression, execute_script
22
+ except ImportError:
23
+ from .runtime import evaluate_expression, execute_script
24
+ else:
25
+ from .runtime import evaluate_expression, execute_script
18
26
 
19
27
 
20
28
  def main(argv=None):
@@ -174,12 +174,18 @@ endfunction
174
174
  # $arg options: - **fontSize** - The font size, in pixels
175
175
  # $return: The line chart [element model](https://github.com/craigahobbs/element-model#readme)
176
176
  function dataLineChartElements(data, lineChart, options):
177
- chartFontSize = if(options, objectGet(options, 'fontSize', dataLineChartChartFontDefaultSizePx), dataLineChartChartFontDefaultSizePx)
178
177
  xField = objectGet(lineChart, 'x')
179
178
  yFields = objectGet(lineChart, 'y')
180
179
  colorField = objectGet(lineChart, 'color')
181
180
  colorOrder = objectGet(lineChart, 'colorOrder')
182
181
 
182
+ # Determine the font size
183
+ fontSize = if(options, objectGet(options, 'fontSize'))
184
+ if !fontSize:
185
+ documentFontSize = systemGlobalGet('documentFontSize')
186
+ fontSize = if(documentFontSize, documentFontSize(), dataLineChartChartFontDefaultSizePx)
187
+ endif
188
+
183
189
  # Sort the rows by the X field
184
190
  arraySort(data, systemPartial(dataLineChartSortCompare, xField))
185
191
 
@@ -331,13 +337,13 @@ function dataLineChartElements(data, lineChart, options):
331
337
  endif
332
338
 
333
339
  # Chart title calculations
334
- chartBorderSize = chartFontSize
335
- chartTitleFontSize = 1.1 * chartFontSize
340
+ chartBorderSize = fontSize
341
+ chartTitleFontSize = 1.1 * fontSize
336
342
  chartTitleHeight = if(chartTitle != null, 1.5 * chartTitleFontSize, 0)
337
343
 
338
344
  # Y-axis calculations
339
- axisTitleFontSize = 1 * chartFontSize
340
- axisLabelFontSize = chartFontSize
345
+ axisTitleFontSize = 1 * fontSize
346
+ axisLabelFontSize = fontSize
341
347
  yAxisTitle = if(arrayLength(yFields) == 1, arrayGet(yFields, 0))
342
348
  yAxisTitleWidth = if(yAxisTitle != null, 1.8 * axisTitleFontSize, 0)
343
349
  yAxisLabelWidth = 0
@@ -370,7 +376,7 @@ function dataLineChartElements(data, lineChart, options):
370
376
  xAnnotationLabelOffsetY = 0.1 * annotationLabelFontSize
371
377
 
372
378
  # Color legend calculations
373
- colorLegendFontSize = chartFontSize
379
+ colorLegendFontSize = fontSize
374
380
  colorLegendGap = 0.5 * colorLegendFontSize
375
381
  colorLegendLabelHeight = colorLegendFontSize
376
382
  colorLegendLabelGap = 0.35 * colorLegendLabelHeight
@@ -11,6 +11,7 @@ import functools
11
11
  import importlib
12
12
  import json
13
13
  import math
14
+ import os as _os
14
15
  import random
15
16
  import re
16
17
  import urllib
@@ -27,16 +28,18 @@ from .value import R_NUMBER_CLEANUP, ValueArgsError, value_args_model, value_arg
27
28
  # Helper to dynamically import evaluate_expression to avoid the circular dependency
28
29
  def _import_evaluate_expression():
29
30
  if not _EVALUATE_EXPRESSION:
30
- _EVALUATE_EXPRESSION.append(importlib.import_module('bare_script.runtime').evaluate_expression)
31
+ if not _os.environ.get('BARESCRIPT_RUNTIME_PY'): # pragma: no cover
32
+ try:
33
+ _EVALUATE_EXPRESSION.append(importlib.import_module('bare_script.runtime_c').evaluate_expression)
34
+ except (ImportError, AttributeError):
35
+ _EVALUATE_EXPRESSION.append(importlib.import_module('bare_script.runtime').evaluate_expression)
36
+ else:
37
+ _EVALUATE_EXPRESSION.append(importlib.import_module('bare_script.runtime').evaluate_expression)
31
38
  return _EVALUATE_EXPRESSION[0]
32
39
 
33
40
  _EVALUATE_EXPRESSION = []
34
41
 
35
42
 
36
- # The default maximum statements for executeScript
37
- DEFAULT_MAX_STATEMENTS = 1e9
38
-
39
-
40
43
  #
41
44
  # Array functions
42
45
  #
@@ -8,13 +8,17 @@ The BareScript runtime
8
8
  import datetime
9
9
  import functools
10
10
 
11
- from .library import DEFAULT_MAX_STATEMENTS, EXPRESSION_FUNCTIONS, SCRIPT_FUNCTIONS
11
+ from .library import EXPRESSION_FUNCTIONS, SCRIPT_FUNCTIONS
12
12
  from .model import lint_script
13
13
  from .options import url_file_relative
14
14
  from .parser import parse_script
15
15
  from .value import ValueArgsError, value_boolean, value_compare, value_normalize_datetime, value_round_number, value_string
16
16
 
17
17
 
18
+ # The default maximum statements for executeScript
19
+ DEFAULT_MAX_STATEMENTS = 1e9
20
+
21
+
18
22
  # Coverage configuration object global variable name
19
23
  SYSTEM_GLOBAL_COVERAGE_NAME = '__barescriptCoverage'
20
24