bare-script 5.0.5__tar.gz → 5.1.1__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.
- {bare_script-5.0.5/src/bare_script.egg-info → bare_script-5.1.1}/PKG-INFO +28 -30
- {bare_script-5.0.5 → bare_script-5.1.1}/README.md +27 -29
- {bare_script-5.0.5 → bare_script-5.1.1}/setup.cfg +1 -1
- {bare_script-5.0.5 → bare_script-5.1.1}/src/bare_script/__init__.py +5 -13
- {bare_script-5.0.5 → bare_script-5.1.1}/src/bare_script/bare.py +4 -6
- {bare_script-5.0.5 → bare_script-5.1.1}/src/bare_script/include.py +62 -9
- bare_script-5.1.1/src/bare_script/include_source.py +5344 -0
- {bare_script-5.0.5 → bare_script-5.1.1}/src/bare_script/library.py +0 -18
- {bare_script-5.0.5 → bare_script-5.1.1}/src/bare_script/runtime.py +198 -5
- {bare_script-5.0.5 → bare_script-5.1.1}/src/bare_script/runtime_c.c +18 -20
- {bare_script-5.0.5 → bare_script-5.1.1/src/bare_script.egg-info}/PKG-INFO +28 -30
- {bare_script-5.0.5 → bare_script-5.1.1}/src/bare_script.egg-info/SOURCES.txt +0 -3
- bare_script-5.0.5/src/bare_script/include_source.py +0 -12042
- bare_script-5.0.5/src/bare_script/lint.py +0 -234
- bare_script-5.0.5/src/bare_script/model.py +0 -319
- bare_script-5.0.5/src/bare_script/parser.py +0 -885
- {bare_script-5.0.5 → bare_script-5.1.1}/LICENSE +0 -0
- {bare_script-5.0.5 → bare_script-5.1.1}/pyproject.toml +0 -0
- {bare_script-5.0.5 → bare_script-5.1.1}/setup.py +0 -0
- {bare_script-5.0.5 → bare_script-5.1.1}/src/bare_script/__main__.py +0 -0
- {bare_script-5.0.5 → bare_script-5.1.1}/src/bare_script/options.py +0 -0
- {bare_script-5.0.5 → bare_script-5.1.1}/src/bare_script/value.py +0 -0
- {bare_script-5.0.5 → bare_script-5.1.1}/src/bare_script.egg-info/dependency_links.txt +0 -0
- {bare_script-5.0.5 → bare_script-5.1.1}/src/bare_script.egg-info/entry_points.txt +0 -0
- {bare_script-5.0.5 → bare_script-5.1.1}/src/bare_script.egg-info/requires.txt +0 -0
- {bare_script-5.0.5 → bare_script-5.1.1}/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: 5.
|
|
3
|
+
Version: 5.1.1
|
|
4
4
|
Summary: bare-script
|
|
5
5
|
Home-page: https://github.com/craigahobbs/bare-script
|
|
6
6
|
Author: Craig A. Hobbs
|
|
@@ -55,16 +55,16 @@ confident that BareScript will execute the same regardless of the underlying run
|
|
|
55
55
|
## Executing BareScript Scripts
|
|
56
56
|
|
|
57
57
|
To execute a BareScript script, parse the script using the
|
|
58
|
-
[
|
|
58
|
+
[barescript_parse_script](https://craigahobbs.github.io/bare-script-py/scripts.html#barescript-parse-script)
|
|
59
59
|
function. Then execute the script using the
|
|
60
60
|
[execute_script](https://craigahobbs.github.io/bare-script-py/scripts.html#execute-script)
|
|
61
61
|
function. For example:
|
|
62
62
|
|
|
63
63
|
``` python
|
|
64
|
-
from bare_script import
|
|
64
|
+
from bare_script import barescript_parse_script, execute_script
|
|
65
65
|
|
|
66
66
|
# Parse the script
|
|
67
|
-
script =
|
|
67
|
+
script = barescript_parse_script('''\
|
|
68
68
|
# Double a number
|
|
69
69
|
function double(n):
|
|
70
70
|
return n * 2
|
|
@@ -91,18 +91,18 @@ This outputs:
|
|
|
91
91
|
includes a set of built-in functions for mathematical operations, object manipulation, array
|
|
92
92
|
manipulation, regular expressions, HTTP fetch and more. The following example demonstrates the use
|
|
93
93
|
of the
|
|
94
|
-
[systemFetch](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='
|
|
95
|
-
[objectGet](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='
|
|
96
|
-
[arrayLength](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='
|
|
94
|
+
[systemFetch](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='system'&systemfetch),
|
|
95
|
+
[objectGet](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='object'&objectget), and
|
|
96
|
+
[arrayLength](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='array'&arraylength)
|
|
97
97
|
functions.
|
|
98
98
|
|
|
99
99
|
``` python
|
|
100
100
|
import urllib.request
|
|
101
101
|
|
|
102
|
-
from bare_script import execute_script, fetch_http
|
|
102
|
+
from bare_script import barescript_parse_script, execute_script, fetch_http
|
|
103
103
|
|
|
104
104
|
# Parse the script
|
|
105
|
-
script =
|
|
105
|
+
script = barescript_parse_script('''\
|
|
106
106
|
# Fetch the BareScript builtin library documentation JSON
|
|
107
107
|
docs = jsonParse(systemFetch('https://craigahobbs.github.io/bare-script-py/library/library-builtin.json'))
|
|
108
108
|
|
|
@@ -126,7 +126,7 @@ The BareScript Library has 108 builtin functions
|
|
|
126
126
|
To evaluate a
|
|
127
127
|
[BareScript expression](https://craigahobbs.github.io/bare-script-py/language/#expressions),
|
|
128
128
|
parse the expression using the
|
|
129
|
-
[
|
|
129
|
+
[barescript_parse_expression](https://craigahobbs.github.io/bare-script-py/expressions.html#barescript-parse-expression)
|
|
130
130
|
function. Then evaluate the expression using the
|
|
131
131
|
[evaluate_expression](https://craigahobbs.github.io/bare-script-py/expressions.html#evaluate-expression)
|
|
132
132
|
function.
|
|
@@ -138,10 +138,10 @@ a set of built-in, spreadsheet-like functions.
|
|
|
138
138
|
For example:
|
|
139
139
|
|
|
140
140
|
``` python
|
|
141
|
-
from bare_script import
|
|
141
|
+
from bare_script import barescript_parse_expression, evaluate_expression
|
|
142
142
|
|
|
143
143
|
# Parse the expression
|
|
144
|
-
expr =
|
|
144
|
+
expr = barescript_parse_expression('2 * max(a, b, c)')
|
|
145
145
|
|
|
146
146
|
# Evaluate the expression
|
|
147
147
|
variables = {'a': 1, 'b': 2, 'c': 3}
|
|
@@ -200,12 +200,10 @@ bare script.bare
|
|
|
200
200
|
```
|
|
201
201
|
|
|
202
202
|
**Note:** In the BareScript CLI, import statements and the
|
|
203
|
-
[systemFetch](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='
|
|
203
|
+
[systemFetch](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='system'&systemfetch)
|
|
204
204
|
function read non-URL paths from the local file system.
|
|
205
|
-
[systemFetch](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='
|
|
206
|
-
calls with a non-URL path and a
|
|
207
|
-
[request body](https://craigahobbs.github.io/bare-script-py/library/model.html#var.vName='SystemFetchRequest')
|
|
208
|
-
write the body to the path.
|
|
205
|
+
[systemFetch](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='system'&systemfetch)
|
|
206
|
+
calls with a non-URL path and a request body write the body to the path.
|
|
209
207
|
|
|
210
208
|
|
|
211
209
|
## MarkdownUp, a Markdown Viewer with BareScript
|
|
@@ -251,21 +249,21 @@ without a native Python equivalent are omitted.
|
|
|
251
249
|
|
|
252
250
|
| Test | Language | Time (ms) | Multiple |
|
|
253
251
|
| ---------------- | ---------------- | --------: | -------: |
|
|
254
|
-
| mandelbrot | Python |
|
|
255
|
-
| | BareScript (PyC) |
|
|
256
|
-
| | BareScript (Py) |
|
|
257
|
-
| schemaValidate | Python | 21.
|
|
258
|
-
| | BareScript (PyC) |
|
|
259
|
-
| | BareScript (Py) |
|
|
252
|
+
| mandelbrot | Python | 4720.8 | |
|
|
253
|
+
| | BareScript (PyC) | 10800.0 | 2.3x |
|
|
254
|
+
| | BareScript (Py) | 334100.0 | 70.8x |
|
|
255
|
+
| schemaValidate | Python | 21.0 | |
|
|
256
|
+
| | BareScript (PyC) | 101.6 | 4.8x |
|
|
257
|
+
| | BareScript (Py) | 1404.8 | 67.0x |
|
|
260
258
|
| urlEncode | Python | 1.1 | |
|
|
261
|
-
| | BareScript (PyC) | 5.
|
|
262
|
-
| | BareScript (Py) |
|
|
263
|
-
| schemaParse | Python | 17.
|
|
264
|
-
| | BareScript (PyC) |
|
|
265
|
-
| | BareScript (Py) |
|
|
259
|
+
| | BareScript (PyC) | 5.6 | 5.3x |
|
|
260
|
+
| | BareScript (Py) | 39.1 | 37.1x |
|
|
261
|
+
| schemaParse | Python | 17.1 | |
|
|
262
|
+
| | BareScript (PyC) | 120.4 | 7.1x |
|
|
263
|
+
| | BareScript (Py) | 882.4 | 51.7x |
|
|
266
264
|
| urlDecode | Python | 1.2 | |
|
|
267
|
-
| | BareScript (PyC) |
|
|
268
|
-
| | BareScript (Py) |
|
|
265
|
+
| | BareScript (PyC) | 13.1 | 10.8x |
|
|
266
|
+
| | BareScript (Py) | 68.5 | 56.6x |
|
|
269
267
|
|
|
270
268
|
|
|
271
269
|
## Using BareScript with an AI Assistant
|
|
@@ -31,16 +31,16 @@ confident that BareScript will execute the same regardless of the underlying run
|
|
|
31
31
|
## Executing BareScript Scripts
|
|
32
32
|
|
|
33
33
|
To execute a BareScript script, parse the script using the
|
|
34
|
-
[
|
|
34
|
+
[barescript_parse_script](https://craigahobbs.github.io/bare-script-py/scripts.html#barescript-parse-script)
|
|
35
35
|
function. Then execute the script using the
|
|
36
36
|
[execute_script](https://craigahobbs.github.io/bare-script-py/scripts.html#execute-script)
|
|
37
37
|
function. For example:
|
|
38
38
|
|
|
39
39
|
``` python
|
|
40
|
-
from bare_script import
|
|
40
|
+
from bare_script import barescript_parse_script, execute_script
|
|
41
41
|
|
|
42
42
|
# Parse the script
|
|
43
|
-
script =
|
|
43
|
+
script = barescript_parse_script('''\
|
|
44
44
|
# Double a number
|
|
45
45
|
function double(n):
|
|
46
46
|
return n * 2
|
|
@@ -67,18 +67,18 @@ This outputs:
|
|
|
67
67
|
includes a set of built-in functions for mathematical operations, object manipulation, array
|
|
68
68
|
manipulation, regular expressions, HTTP fetch and more. The following example demonstrates the use
|
|
69
69
|
of the
|
|
70
|
-
[systemFetch](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='
|
|
71
|
-
[objectGet](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='
|
|
72
|
-
[arrayLength](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='
|
|
70
|
+
[systemFetch](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='system'&systemfetch),
|
|
71
|
+
[objectGet](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='object'&objectget), and
|
|
72
|
+
[arrayLength](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='array'&arraylength)
|
|
73
73
|
functions.
|
|
74
74
|
|
|
75
75
|
``` python
|
|
76
76
|
import urllib.request
|
|
77
77
|
|
|
78
|
-
from bare_script import execute_script, fetch_http
|
|
78
|
+
from bare_script import barescript_parse_script, execute_script, fetch_http
|
|
79
79
|
|
|
80
80
|
# Parse the script
|
|
81
|
-
script =
|
|
81
|
+
script = barescript_parse_script('''\
|
|
82
82
|
# Fetch the BareScript builtin library documentation JSON
|
|
83
83
|
docs = jsonParse(systemFetch('https://craigahobbs.github.io/bare-script-py/library/library-builtin.json'))
|
|
84
84
|
|
|
@@ -102,7 +102,7 @@ The BareScript Library has 108 builtin functions
|
|
|
102
102
|
To evaluate a
|
|
103
103
|
[BareScript expression](https://craigahobbs.github.io/bare-script-py/language/#expressions),
|
|
104
104
|
parse the expression using the
|
|
105
|
-
[
|
|
105
|
+
[barescript_parse_expression](https://craigahobbs.github.io/bare-script-py/expressions.html#barescript-parse-expression)
|
|
106
106
|
function. Then evaluate the expression using the
|
|
107
107
|
[evaluate_expression](https://craigahobbs.github.io/bare-script-py/expressions.html#evaluate-expression)
|
|
108
108
|
function.
|
|
@@ -114,10 +114,10 @@ a set of built-in, spreadsheet-like functions.
|
|
|
114
114
|
For example:
|
|
115
115
|
|
|
116
116
|
``` python
|
|
117
|
-
from bare_script import
|
|
117
|
+
from bare_script import barescript_parse_expression, evaluate_expression
|
|
118
118
|
|
|
119
119
|
# Parse the expression
|
|
120
|
-
expr =
|
|
120
|
+
expr = barescript_parse_expression('2 * max(a, b, c)')
|
|
121
121
|
|
|
122
122
|
# Evaluate the expression
|
|
123
123
|
variables = {'a': 1, 'b': 2, 'c': 3}
|
|
@@ -176,12 +176,10 @@ bare script.bare
|
|
|
176
176
|
```
|
|
177
177
|
|
|
178
178
|
**Note:** In the BareScript CLI, import statements and the
|
|
179
|
-
[systemFetch](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='
|
|
179
|
+
[systemFetch](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='system'&systemfetch)
|
|
180
180
|
function read non-URL paths from the local file system.
|
|
181
|
-
[systemFetch](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='
|
|
182
|
-
calls with a non-URL path and a
|
|
183
|
-
[request body](https://craigahobbs.github.io/bare-script-py/library/model.html#var.vName='SystemFetchRequest')
|
|
184
|
-
write the body to the path.
|
|
181
|
+
[systemFetch](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='system'&systemfetch)
|
|
182
|
+
calls with a non-URL path and a request body write the body to the path.
|
|
185
183
|
|
|
186
184
|
|
|
187
185
|
## MarkdownUp, a Markdown Viewer with BareScript
|
|
@@ -227,21 +225,21 @@ without a native Python equivalent are omitted.
|
|
|
227
225
|
|
|
228
226
|
| Test | Language | Time (ms) | Multiple |
|
|
229
227
|
| ---------------- | ---------------- | --------: | -------: |
|
|
230
|
-
| mandelbrot | Python |
|
|
231
|
-
| | BareScript (PyC) |
|
|
232
|
-
| | BareScript (Py) |
|
|
233
|
-
| schemaValidate | Python | 21.
|
|
234
|
-
| | BareScript (PyC) |
|
|
235
|
-
| | BareScript (Py) |
|
|
228
|
+
| mandelbrot | Python | 4720.8 | |
|
|
229
|
+
| | BareScript (PyC) | 10800.0 | 2.3x |
|
|
230
|
+
| | BareScript (Py) | 334100.0 | 70.8x |
|
|
231
|
+
| schemaValidate | Python | 21.0 | |
|
|
232
|
+
| | BareScript (PyC) | 101.6 | 4.8x |
|
|
233
|
+
| | BareScript (Py) | 1404.8 | 67.0x |
|
|
236
234
|
| urlEncode | Python | 1.1 | |
|
|
237
|
-
| | BareScript (PyC) | 5.
|
|
238
|
-
| | BareScript (Py) |
|
|
239
|
-
| schemaParse | Python | 17.
|
|
240
|
-
| | BareScript (PyC) |
|
|
241
|
-
| | BareScript (Py) |
|
|
235
|
+
| | BareScript (PyC) | 5.6 | 5.3x |
|
|
236
|
+
| | BareScript (Py) | 39.1 | 37.1x |
|
|
237
|
+
| schemaParse | Python | 17.1 | |
|
|
238
|
+
| | BareScript (PyC) | 120.4 | 7.1x |
|
|
239
|
+
| | BareScript (Py) | 882.4 | 51.7x |
|
|
242
240
|
| urlDecode | Python | 1.2 | |
|
|
243
|
-
| | BareScript (PyC) |
|
|
244
|
-
| | BareScript (Py) |
|
|
241
|
+
| | BareScript (PyC) | 13.1 | 10.8x |
|
|
242
|
+
| | BareScript (Py) | 68.5 | 56.6x |
|
|
245
243
|
|
|
246
244
|
|
|
247
245
|
## Using BareScript with an AI Assistant
|
|
@@ -7,13 +7,6 @@ bare-script package
|
|
|
7
7
|
|
|
8
8
|
import os
|
|
9
9
|
|
|
10
|
-
from .lint import \
|
|
11
|
-
lint_script
|
|
12
|
-
|
|
13
|
-
from .model import \
|
|
14
|
-
validate_expression, \
|
|
15
|
-
validate_script
|
|
16
|
-
|
|
17
10
|
from .options import \
|
|
18
11
|
fetch_http, \
|
|
19
12
|
fetch_read_only, \
|
|
@@ -21,13 +14,12 @@ from .options import \
|
|
|
21
14
|
log_stdout, \
|
|
22
15
|
url_file_relative
|
|
23
16
|
|
|
24
|
-
from .parser import \
|
|
25
|
-
BareScriptParserError, \
|
|
26
|
-
parse_expression, \
|
|
27
|
-
parse_script
|
|
28
|
-
|
|
29
17
|
from .runtime import \
|
|
30
|
-
|
|
18
|
+
BareScriptParserError, \
|
|
19
|
+
BareScriptRuntimeError, \
|
|
20
|
+
barescript_lint_script, \
|
|
21
|
+
barescript_parse_expression, \
|
|
22
|
+
barescript_parse_script
|
|
31
23
|
|
|
32
24
|
if not os.environ.get('BARESCRIPT_RUNTIME_PY'): # pragma: no cover
|
|
33
25
|
try:
|
|
@@ -11,10 +11,8 @@ import os
|
|
|
11
11
|
import sys
|
|
12
12
|
import time
|
|
13
13
|
|
|
14
|
-
from .lint import lint_script
|
|
15
14
|
from .options import fetch_read_write, log_stdout, url_file_relative
|
|
16
|
-
from .
|
|
17
|
-
from .runtime import SYSTEM_GLOBAL_INCLUDES_NAME
|
|
15
|
+
from .runtime import SYSTEM_GLOBAL_INCLUDES_NAME, barescript_lint_script, barescript_parse_expression, barescript_parse_script
|
|
18
16
|
from .value import value_boolean
|
|
19
17
|
if not os.environ.get('BARESCRIPT_RUNTIME_PY'): # pragma: no cover
|
|
20
18
|
try:
|
|
@@ -56,7 +54,7 @@ def main(argv=None):
|
|
|
56
54
|
# Evaluate the global variable expression arguments
|
|
57
55
|
globals_ = {}
|
|
58
56
|
for var_name, var_expr in args.var:
|
|
59
|
-
globals_[var_name] = evaluate_expression(
|
|
57
|
+
globals_[var_name] = evaluate_expression(barescript_parse_expression(var_expr))
|
|
60
58
|
|
|
61
59
|
# Get the scripts to run
|
|
62
60
|
scripts = args.scripts
|
|
@@ -102,7 +100,7 @@ def main(argv=None):
|
|
|
102
100
|
script_source = script_value
|
|
103
101
|
|
|
104
102
|
# Parse the script source
|
|
105
|
-
script =
|
|
103
|
+
script = barescript_parse_script(script_source, 1, script_name)
|
|
106
104
|
|
|
107
105
|
# Execute?
|
|
108
106
|
static_globals = None
|
|
@@ -138,7 +136,7 @@ def main(argv=None):
|
|
|
138
136
|
|
|
139
137
|
# Run the bare-script linter?
|
|
140
138
|
if args.static and ix_script >= ix_user_script:
|
|
141
|
-
warnings =
|
|
139
|
+
warnings = barescript_lint_script(script, static_globals)
|
|
142
140
|
if not warnings:
|
|
143
141
|
print(f'BareScript static analysis "{script_name}" ... OK')
|
|
144
142
|
else:
|
|
@@ -22,6 +22,7 @@ execute_script(
|
|
|
22
22
|
{
|
|
23
23
|
'statements': [
|
|
24
24
|
{'include': {'includes': [
|
|
25
|
+
{'url': 'barescriptModel.bare', 'system': True},
|
|
25
26
|
{'url': 'data.bare', 'system': True},
|
|
26
27
|
{'url': 'dataLineChart.bare', 'system': True},
|
|
27
28
|
{'url': 'dataTable.bare', 'system': True},
|
|
@@ -69,6 +70,56 @@ def _include_options():
|
|
|
69
70
|
return {'globals': _INCLUDE_GLOBALS}
|
|
70
71
|
|
|
71
72
|
|
|
73
|
+
#
|
|
74
|
+
# barescriptModel.bare
|
|
75
|
+
#
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def barescript_type_model():
|
|
79
|
+
"""
|
|
80
|
+
Get the BareScript type model
|
|
81
|
+
|
|
82
|
+
:return: The BareScript `type model <https://craigahobbs.github.io/bare-script/model/>`__
|
|
83
|
+
:rtype: dict
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
return _INCLUDE_GLOBALS['barescriptTypeModel']([], _include_options())
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def barescript_validate_expression(expr):
|
|
90
|
+
"""
|
|
91
|
+
Validate an expression model
|
|
92
|
+
|
|
93
|
+
:param expr: The `expression model <https://craigahobbs.github.io/bare-script/model/#var.vName='Expression'>`__
|
|
94
|
+
:type expr: dict
|
|
95
|
+
:return: The validated expression model
|
|
96
|
+
:rtype: dict
|
|
97
|
+
:raises SchemaValidationError: A validation error occurred
|
|
98
|
+
"""
|
|
99
|
+
|
|
100
|
+
result = _INCLUDE_GLOBALS['barescriptValidateExpressionEx']([expr], _include_options())
|
|
101
|
+
if 'error' in result:
|
|
102
|
+
raise SchemaValidationError(result['error'], result['memberFqn'])
|
|
103
|
+
return result['result']
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def barescript_validate_script(script):
|
|
107
|
+
"""
|
|
108
|
+
Validate a BareScript model
|
|
109
|
+
|
|
110
|
+
:param script: The `BareScript model <https://craigahobbs.github.io/bare-script/model/#var.vName='BareScript'>`__
|
|
111
|
+
:type script: dict
|
|
112
|
+
:return: The validated BareScript model
|
|
113
|
+
:rtype: dict
|
|
114
|
+
:raises SchemaValidationError: A validation error occurred
|
|
115
|
+
"""
|
|
116
|
+
|
|
117
|
+
result = _INCLUDE_GLOBALS['barescriptValidateScriptEx']([script], _include_options())
|
|
118
|
+
if 'error' in result:
|
|
119
|
+
raise SchemaValidationError(result['error'], result['memberFqn'])
|
|
120
|
+
return result['result']
|
|
121
|
+
|
|
122
|
+
|
|
72
123
|
#
|
|
73
124
|
# data.bare
|
|
74
125
|
#
|
|
@@ -492,7 +543,7 @@ def schema_get_enum_values(types, enum_model):
|
|
|
492
543
|
"""
|
|
493
544
|
Get an enum's values (inherited values first)
|
|
494
545
|
|
|
495
|
-
:param types: The schema's `type model <https://craigahobbs.github.io/bare-script/model/#var.vName='Types'>`__
|
|
546
|
+
:param types: The schema's `type model <https://craigahobbs.github.io/bare-script/model/#var.vName='Types'&var.vURL=''>`__
|
|
496
547
|
:type types: dict
|
|
497
548
|
:param enum_model: The enum model
|
|
498
549
|
:type enum_model: dict
|
|
@@ -507,7 +558,7 @@ def schema_get_referenced_types(types, type_name, referenced_types=None):
|
|
|
507
558
|
"""
|
|
508
559
|
Get a user type's referenced type model
|
|
509
560
|
|
|
510
|
-
:param types: The schema's `type model <https://craigahobbs.github.io/bare-script/model/#var.vName='Types'>`__
|
|
561
|
+
:param types: The schema's `type model <https://craigahobbs.github.io/bare-script/model/#var.vName='Types'&var.vURL=''>`__
|
|
511
562
|
:type types: dict
|
|
512
563
|
:param str type_name: The type name
|
|
513
564
|
:param referenced_types: A map of referenced user type name to user type model to update
|
|
@@ -523,7 +574,7 @@ def schema_get_struct_members(types, struct):
|
|
|
523
574
|
"""
|
|
524
575
|
Get a struct's members (inherited members first)
|
|
525
576
|
|
|
526
|
-
:param types: The schema's `type model <https://craigahobbs.github.io/bare-script/model/#var.vName='Types'>`__
|
|
577
|
+
:param types: The schema's `type model <https://craigahobbs.github.io/bare-script/model/#var.vName='Types'&var.vURL=''>`__
|
|
527
578
|
:type types: dict
|
|
528
579
|
:param struct: The struct model
|
|
529
580
|
:type struct: dict
|
|
@@ -538,7 +589,7 @@ def schema_validate(types, type_name, value, member_fqn=None):
|
|
|
538
589
|
"""
|
|
539
590
|
Validate a value using a schema type model
|
|
540
591
|
|
|
541
|
-
:param types: The schema's `type model <https://craigahobbs.github.io/bare-script/model/#var.vName='Types'>`__
|
|
592
|
+
:param types: The schema's `type model <https://craigahobbs.github.io/bare-script/model/#var.vName='Types'&var.vURL=''>`__
|
|
542
593
|
:type types: dict
|
|
543
594
|
:param str type_name: The type name
|
|
544
595
|
:param value: The value to validate
|
|
@@ -563,7 +614,7 @@ def schema_doc_markdown(types, type_name, options=None):
|
|
|
563
614
|
"""
|
|
564
615
|
Generate the Schema Markdown user type documentation as an array of Markdown text lines
|
|
565
616
|
|
|
566
|
-
:param types: The schema's `type model <https://craigahobbs.github.io/bare-script/model/#var.vName='Types'>`__
|
|
617
|
+
:param types: The schema's `type model <https://craigahobbs.github.io/bare-script/model/#var.vName='Types'&var.vURL=''>`__
|
|
567
618
|
:type types: dict
|
|
568
619
|
:param str type_name: The type name
|
|
569
620
|
:param options: The schema documentation options object
|
|
@@ -586,13 +637,14 @@ def schema_parse(text, types=None, filename=None, validate=None):
|
|
|
586
637
|
|
|
587
638
|
:param text: The `Schema Markdown <https://craigahobbs.github.io/schema-markdown-js/language/>`__ text
|
|
588
639
|
:type text: str or list(str)
|
|
589
|
-
:param types: The schema's
|
|
640
|
+
:param types: The schema's
|
|
641
|
+
`type model <https://craigahobbs.github.io/bare-script/model/#var.vName='Types'&var.vURL=''>`__ to update
|
|
590
642
|
:type types: dict or None, optional
|
|
591
643
|
:param filename: The file name (for error messages)
|
|
592
644
|
:type filename: str or None, optional
|
|
593
645
|
:param validate: If True (the default), validate the type model after parsing
|
|
594
646
|
:type validate: bool or None, optional
|
|
595
|
-
:return: The schema's `type model <https://craigahobbs.github.io/bare-script/model/#var.vName='Types'>`__
|
|
647
|
+
:return: The schema's `type model <https://craigahobbs.github.io/bare-script/model/#var.vName='Types'&var.vURL=''>`__
|
|
596
648
|
:rtype: dict
|
|
597
649
|
:raises SchemaParserError: A parsing error occurred
|
|
598
650
|
"""
|
|
@@ -612,7 +664,7 @@ def schema_type_model():
|
|
|
612
664
|
"""
|
|
613
665
|
Get the Schema Markdown type model
|
|
614
666
|
|
|
615
|
-
:return: The Schema Markdown `type model <https://craigahobbs.github.io/bare-script/model/#var.vName='Types'>`__
|
|
667
|
+
:return: The Schema Markdown `type model <https://craigahobbs.github.io/bare-script/model/#var.vName='Types'&var.vURL=''>`__
|
|
616
668
|
:rtype: dict
|
|
617
669
|
"""
|
|
618
670
|
|
|
@@ -623,7 +675,8 @@ def schema_type_model_validate(types):
|
|
|
623
675
|
"""
|
|
624
676
|
Validate a Schema Markdown type model
|
|
625
677
|
|
|
626
|
-
:param types: The schema's
|
|
678
|
+
:param types: The schema's
|
|
679
|
+
`type model <https://craigahobbs.github.io/bare-script/model/#var.vName='Types'&var.vURL=''>`__ to validate
|
|
627
680
|
:type types: dict
|
|
628
681
|
:return: The validated type model
|
|
629
682
|
:rtype: dict
|