bare-script 3.0.9__tar.gz → 3.0.10__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-3.0.10/PKG-INFO +206 -0
- bare-script-3.0.10/README.md +182 -0
- {bare-script-3.0.9 → bare-script-3.0.10}/setup.cfg +3 -3
- bare-script-3.0.10/src/bare_script.egg-info/PKG-INFO +206 -0
- {bare-script-3.0.9 → bare-script-3.0.10}/src/bare_script.egg-info/SOURCES.txt +1 -1
- bare-script-3.0.9/PKG-INFO +0 -209
- bare-script-3.0.9/README.rst +0 -185
- bare-script-3.0.9/src/bare_script.egg-info/PKG-INFO +0 -209
- {bare-script-3.0.9 → bare-script-3.0.10}/LICENSE +0 -0
- {bare-script-3.0.9 → bare-script-3.0.10}/pyproject.toml +0 -0
- {bare-script-3.0.9 → bare-script-3.0.10}/src/bare_script/__init__.py +0 -0
- {bare-script-3.0.9 → bare-script-3.0.10}/src/bare_script/__main__.py +0 -0
- {bare-script-3.0.9 → bare-script-3.0.10}/src/bare_script/bare.py +0 -0
- {bare-script-3.0.9 → bare-script-3.0.10}/src/bare_script/baredoc.py +0 -0
- {bare-script-3.0.9 → bare-script-3.0.10}/src/bare_script/data.py +0 -0
- {bare-script-3.0.9 → bare-script-3.0.10}/src/bare_script/library.py +0 -0
- {bare-script-3.0.9 → bare-script-3.0.10}/src/bare_script/model.py +0 -0
- {bare-script-3.0.9 → bare-script-3.0.10}/src/bare_script/options.py +0 -0
- {bare-script-3.0.9 → bare-script-3.0.10}/src/bare_script/parser.py +0 -0
- {bare-script-3.0.9 → bare-script-3.0.10}/src/bare_script/runtime.py +0 -0
- {bare-script-3.0.9 → bare-script-3.0.10}/src/bare_script/value.py +0 -0
- {bare-script-3.0.9 → bare-script-3.0.10}/src/bare_script.egg-info/dependency_links.txt +0 -0
- {bare-script-3.0.9 → bare-script-3.0.10}/src/bare_script.egg-info/entry_points.txt +0 -0
- {bare-script-3.0.9 → bare-script-3.0.10}/src/bare_script.egg-info/requires.txt +0 -0
- {bare-script-3.0.9 → bare-script-3.0.10}/src/bare_script.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: bare-script
|
|
3
|
+
Version: 3.0.10
|
|
4
|
+
Summary: bare-script
|
|
5
|
+
Home-page: https://github.com/craigahobbs/bare-script
|
|
6
|
+
Author: Craig A. Hobbs
|
|
7
|
+
Author-email: craigahobbs@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: bare-script
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Interpreters
|
|
20
|
+
Classifier: Topic :: Utilities
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: schema-markdown>=1.2.0
|
|
24
|
+
|
|
25
|
+
# bare-script
|
|
26
|
+
|
|
27
|
+
[](https://pypi.org/project/bare-script/)
|
|
28
|
+
[](https://pypi.org/project/bare-script/)
|
|
29
|
+
[](https://github.com/craigahobbs/bare-script-py/blob/main/LICENSE)
|
|
30
|
+
[](https://pypi.org/project/bare-script/)
|
|
31
|
+
|
|
32
|
+
[BareScript](https://craigahobbs.github.io/bare-script/language/)
|
|
33
|
+
is a simple, lightweight, and portable programming language. Its Pythonic syntax is influenced by
|
|
34
|
+
JavaScript, C, and the Unix Shell. BareScript also has a library of built-in functions for common
|
|
35
|
+
programming operations. BareScript can be embedded within applications or used as a stand-alone
|
|
36
|
+
programming language using the command-line interface.
|
|
37
|
+
|
|
38
|
+
There are two implementations of BareScript:
|
|
39
|
+
[BareScript for Python](https://github.com/craigahobbs/bare-script-py#readme)
|
|
40
|
+
(this package) and
|
|
41
|
+
[BareScript for JavaScript](https://github.com/craigahobbs/bare-script#readme).
|
|
42
|
+
Both implementations have 100% unit test coverage with identical unit test suites, so you can be
|
|
43
|
+
confident that BareScript will execute the same regardless of the underlying runtime environment.
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## Links
|
|
47
|
+
|
|
48
|
+
- [The BareScript Language](https://craigahobbs.github.io/bare-script/language/)
|
|
49
|
+
- [The BareScript Library](https://craigahobbs.github.io/bare-script-py/library/)
|
|
50
|
+
- [The BareScript Expression Library](https://craigahobbs.github.io/bare-script-py/library/expression.html)
|
|
51
|
+
- [API Documentation](https://craigahobbs.github.io/bare-script-py/)
|
|
52
|
+
- [Source code](https://github.com/craigahobbs/bare-script-py)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
## Executing BareScript Scripts
|
|
56
|
+
|
|
57
|
+
To execute a BareScript script, parse the script using the
|
|
58
|
+
[parse_script](https://craigahobbs.github.io/bare-script-py/scripts.html#parse-script)
|
|
59
|
+
function. Then execute the script using the
|
|
60
|
+
[execute_script](https://craigahobbs.github.io/bare-script-py/scripts.html#execute-script)
|
|
61
|
+
function. For example:
|
|
62
|
+
|
|
63
|
+
~~~ python
|
|
64
|
+
from bare_script import execute_script, parse_script
|
|
65
|
+
|
|
66
|
+
# Parse the script
|
|
67
|
+
script = parse_script('''\
|
|
68
|
+
# Double a number
|
|
69
|
+
function double(n):
|
|
70
|
+
return n * 2
|
|
71
|
+
endfunction
|
|
72
|
+
|
|
73
|
+
return N + ' times 2 is ' + double(N)
|
|
74
|
+
''')
|
|
75
|
+
|
|
76
|
+
# Execute the script
|
|
77
|
+
globals = {'N': 10}
|
|
78
|
+
print(execute_script(script, {'globals': globals}))
|
|
79
|
+
~~~
|
|
80
|
+
|
|
81
|
+
This outputs:
|
|
82
|
+
|
|
83
|
+
~~~
|
|
84
|
+
10 times 2 is 20
|
|
85
|
+
~~~
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
### The BareScript Library
|
|
89
|
+
|
|
90
|
+
[The BareScript Library](https://craigahobbs.github.io/bare-script-py/library/)
|
|
91
|
+
includes a set of built-in functions for mathematical operations, object manipulation, array
|
|
92
|
+
manipulation, regular expressions, HTTP fetch and more. The following example demonstrates the use
|
|
93
|
+
of the
|
|
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
|
+
functions.
|
|
98
|
+
|
|
99
|
+
~~~ python
|
|
100
|
+
import urllib.request
|
|
101
|
+
|
|
102
|
+
from bare_script import execute_script, fetch_http, parse_script
|
|
103
|
+
|
|
104
|
+
# Parse the script
|
|
105
|
+
script = parse_script('''\
|
|
106
|
+
# Fetch the BareScript library documentation JSON
|
|
107
|
+
docs = jsonParse(systemFetch('https://craigahobbs.github.io/bare-script-py/library/library.json'))
|
|
108
|
+
|
|
109
|
+
# Return the number of library functions
|
|
110
|
+
return 'The BareScript Library has ' + arrayLength(objectGet(docs, 'functions')) + ' functions'
|
|
111
|
+
''')
|
|
112
|
+
|
|
113
|
+
# Execute the script
|
|
114
|
+
print(execute_script(script, {'fetchFn': fetch_http}))
|
|
115
|
+
~~~
|
|
116
|
+
|
|
117
|
+
This outputs:
|
|
118
|
+
|
|
119
|
+
~~~
|
|
120
|
+
The BareScript Library has 105 functions
|
|
121
|
+
~~~
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
## Evaluating BareScript Expressions
|
|
125
|
+
|
|
126
|
+
To evaluate a
|
|
127
|
+
[BareScript expression](https://craigahobbs.github.io/bare-script/language/#expressions),
|
|
128
|
+
parse the expression using the
|
|
129
|
+
[parse_expression](https://craigahobbs.github.io/bare-script-py/expressions.html#parse-expression)
|
|
130
|
+
function. Then evaluate the expression using the
|
|
131
|
+
[evaluate_expression](https://craigahobbs.github.io/bare-script-py/expressions.html#evaluate-expression)
|
|
132
|
+
function.
|
|
133
|
+
|
|
134
|
+
Expression evaluation includes the
|
|
135
|
+
[BareScript Expression Library](https://craigahobbs.github.io/bare-script-py/library/expression.html),
|
|
136
|
+
a set of built-in, spreadsheet-like functions.
|
|
137
|
+
|
|
138
|
+
For example:
|
|
139
|
+
|
|
140
|
+
~~~ python
|
|
141
|
+
from bare_script import evaluate_expression, parse_expression
|
|
142
|
+
|
|
143
|
+
# Parse the expression
|
|
144
|
+
expr = parse_expression('2 * max(a, b, c)')
|
|
145
|
+
|
|
146
|
+
# Evaluate the expression
|
|
147
|
+
variables = {'a': 1, 'b': 2, 'c': 3}
|
|
148
|
+
print(evaluate_expression(expr, None, variables))
|
|
149
|
+
~~~
|
|
150
|
+
|
|
151
|
+
This outputs:
|
|
152
|
+
|
|
153
|
+
~~~
|
|
154
|
+
6
|
|
155
|
+
~~~
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
## The BareScript Command-Line Interface (CLI)
|
|
159
|
+
|
|
160
|
+
You can run BareScript from the command line using the BareScript CLI, "bare". BareScript script
|
|
161
|
+
files use the ".bare" file extension.
|
|
162
|
+
|
|
163
|
+
~~~
|
|
164
|
+
bare script.bare
|
|
165
|
+
~~~
|
|
166
|
+
|
|
167
|
+
**Note:** In the BareScript CLI, import statements and the
|
|
168
|
+
[systemFetch](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='System'&systemfetch)
|
|
169
|
+
function read non-URL paths from the local file system.
|
|
170
|
+
[systemFetch](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='System'&systemfetch)
|
|
171
|
+
calls with a non-URL path and a
|
|
172
|
+
[request body](https://craigahobbs.github.io/bare-script-py/library/model.html#var.vName='SystemFetchRequest')
|
|
173
|
+
write the body to the path.
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
## MarkdownUp, a Markdown Viewer with BareScript
|
|
177
|
+
|
|
178
|
+
[MarkdownUp](https://craigahobbs.github.io/markdown-up/)
|
|
179
|
+
is a Markdown Viewer that executes BareScript embedded within Markdown documents.
|
|
180
|
+
MarkdownUp includes the
|
|
181
|
+
[MarkdownUp Library](https://craigahobbs.github.io/markdown-up/library/),
|
|
182
|
+
which extends the
|
|
183
|
+
[BareScript Library](https://craigahobbs.github.io/bare-script-py/library/)
|
|
184
|
+
with functions for dynamically rendering Markdown text, drawing SVG images, etc.
|
|
185
|
+
|
|
186
|
+
For example:
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
# Markdown Application
|
|
190
|
+
|
|
191
|
+
This is a Markdown document with embedded BareScript:
|
|
192
|
+
|
|
193
|
+
~~~ markdown-script
|
|
194
|
+
markdownPrint('Hello, Markdown!')
|
|
195
|
+
~~~
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
## Development
|
|
200
|
+
|
|
201
|
+
This package is developed using [python-build](https://github.com/craigahobbs/python-build#readme).
|
|
202
|
+
It was started using [python-template](https://github.com/craigahobbs/python-template#readme) as follows:
|
|
203
|
+
|
|
204
|
+
~~~
|
|
205
|
+
template-specialize python-template/template/ bare-script-py/ -k package bare-script -k name 'Craig A. Hobbs' -k email 'craigahobbs@gmail.com' -k github 'craigahobbs'
|
|
206
|
+
~~~
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# bare-script
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/bare-script/)
|
|
4
|
+
[](https://pypi.org/project/bare-script/)
|
|
5
|
+
[](https://github.com/craigahobbs/bare-script-py/blob/main/LICENSE)
|
|
6
|
+
[](https://pypi.org/project/bare-script/)
|
|
7
|
+
|
|
8
|
+
[BareScript](https://craigahobbs.github.io/bare-script/language/)
|
|
9
|
+
is a simple, lightweight, and portable programming language. Its Pythonic syntax is influenced by
|
|
10
|
+
JavaScript, C, and the Unix Shell. BareScript also has a library of built-in functions for common
|
|
11
|
+
programming operations. BareScript can be embedded within applications or used as a stand-alone
|
|
12
|
+
programming language using the command-line interface.
|
|
13
|
+
|
|
14
|
+
There are two implementations of BareScript:
|
|
15
|
+
[BareScript for Python](https://github.com/craigahobbs/bare-script-py#readme)
|
|
16
|
+
(this package) and
|
|
17
|
+
[BareScript for JavaScript](https://github.com/craigahobbs/bare-script#readme).
|
|
18
|
+
Both implementations have 100% unit test coverage with identical unit test suites, so you can be
|
|
19
|
+
confident that BareScript will execute the same regardless of the underlying runtime environment.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## Links
|
|
23
|
+
|
|
24
|
+
- [The BareScript Language](https://craigahobbs.github.io/bare-script/language/)
|
|
25
|
+
- [The BareScript Library](https://craigahobbs.github.io/bare-script-py/library/)
|
|
26
|
+
- [The BareScript Expression Library](https://craigahobbs.github.io/bare-script-py/library/expression.html)
|
|
27
|
+
- [API Documentation](https://craigahobbs.github.io/bare-script-py/)
|
|
28
|
+
- [Source code](https://github.com/craigahobbs/bare-script-py)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## Executing BareScript Scripts
|
|
32
|
+
|
|
33
|
+
To execute a BareScript script, parse the script using the
|
|
34
|
+
[parse_script](https://craigahobbs.github.io/bare-script-py/scripts.html#parse-script)
|
|
35
|
+
function. Then execute the script using the
|
|
36
|
+
[execute_script](https://craigahobbs.github.io/bare-script-py/scripts.html#execute-script)
|
|
37
|
+
function. For example:
|
|
38
|
+
|
|
39
|
+
~~~ python
|
|
40
|
+
from bare_script import execute_script, parse_script
|
|
41
|
+
|
|
42
|
+
# Parse the script
|
|
43
|
+
script = parse_script('''\
|
|
44
|
+
# Double a number
|
|
45
|
+
function double(n):
|
|
46
|
+
return n * 2
|
|
47
|
+
endfunction
|
|
48
|
+
|
|
49
|
+
return N + ' times 2 is ' + double(N)
|
|
50
|
+
''')
|
|
51
|
+
|
|
52
|
+
# Execute the script
|
|
53
|
+
globals = {'N': 10}
|
|
54
|
+
print(execute_script(script, {'globals': globals}))
|
|
55
|
+
~~~
|
|
56
|
+
|
|
57
|
+
This outputs:
|
|
58
|
+
|
|
59
|
+
~~~
|
|
60
|
+
10 times 2 is 20
|
|
61
|
+
~~~
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
### The BareScript Library
|
|
65
|
+
|
|
66
|
+
[The BareScript Library](https://craigahobbs.github.io/bare-script-py/library/)
|
|
67
|
+
includes a set of built-in functions for mathematical operations, object manipulation, array
|
|
68
|
+
manipulation, regular expressions, HTTP fetch and more. The following example demonstrates the use
|
|
69
|
+
of the
|
|
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
|
+
functions.
|
|
74
|
+
|
|
75
|
+
~~~ python
|
|
76
|
+
import urllib.request
|
|
77
|
+
|
|
78
|
+
from bare_script import execute_script, fetch_http, parse_script
|
|
79
|
+
|
|
80
|
+
# Parse the script
|
|
81
|
+
script = parse_script('''\
|
|
82
|
+
# Fetch the BareScript library documentation JSON
|
|
83
|
+
docs = jsonParse(systemFetch('https://craigahobbs.github.io/bare-script-py/library/library.json'))
|
|
84
|
+
|
|
85
|
+
# Return the number of library functions
|
|
86
|
+
return 'The BareScript Library has ' + arrayLength(objectGet(docs, 'functions')) + ' functions'
|
|
87
|
+
''')
|
|
88
|
+
|
|
89
|
+
# Execute the script
|
|
90
|
+
print(execute_script(script, {'fetchFn': fetch_http}))
|
|
91
|
+
~~~
|
|
92
|
+
|
|
93
|
+
This outputs:
|
|
94
|
+
|
|
95
|
+
~~~
|
|
96
|
+
The BareScript Library has 105 functions
|
|
97
|
+
~~~
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
## Evaluating BareScript Expressions
|
|
101
|
+
|
|
102
|
+
To evaluate a
|
|
103
|
+
[BareScript expression](https://craigahobbs.github.io/bare-script/language/#expressions),
|
|
104
|
+
parse the expression using the
|
|
105
|
+
[parse_expression](https://craigahobbs.github.io/bare-script-py/expressions.html#parse-expression)
|
|
106
|
+
function. Then evaluate the expression using the
|
|
107
|
+
[evaluate_expression](https://craigahobbs.github.io/bare-script-py/expressions.html#evaluate-expression)
|
|
108
|
+
function.
|
|
109
|
+
|
|
110
|
+
Expression evaluation includes the
|
|
111
|
+
[BareScript Expression Library](https://craigahobbs.github.io/bare-script-py/library/expression.html),
|
|
112
|
+
a set of built-in, spreadsheet-like functions.
|
|
113
|
+
|
|
114
|
+
For example:
|
|
115
|
+
|
|
116
|
+
~~~ python
|
|
117
|
+
from bare_script import evaluate_expression, parse_expression
|
|
118
|
+
|
|
119
|
+
# Parse the expression
|
|
120
|
+
expr = parse_expression('2 * max(a, b, c)')
|
|
121
|
+
|
|
122
|
+
# Evaluate the expression
|
|
123
|
+
variables = {'a': 1, 'b': 2, 'c': 3}
|
|
124
|
+
print(evaluate_expression(expr, None, variables))
|
|
125
|
+
~~~
|
|
126
|
+
|
|
127
|
+
This outputs:
|
|
128
|
+
|
|
129
|
+
~~~
|
|
130
|
+
6
|
|
131
|
+
~~~
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
## The BareScript Command-Line Interface (CLI)
|
|
135
|
+
|
|
136
|
+
You can run BareScript from the command line using the BareScript CLI, "bare". BareScript script
|
|
137
|
+
files use the ".bare" file extension.
|
|
138
|
+
|
|
139
|
+
~~~
|
|
140
|
+
bare script.bare
|
|
141
|
+
~~~
|
|
142
|
+
|
|
143
|
+
**Note:** In the BareScript CLI, import statements and the
|
|
144
|
+
[systemFetch](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='System'&systemfetch)
|
|
145
|
+
function read non-URL paths from the local file system.
|
|
146
|
+
[systemFetch](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='System'&systemfetch)
|
|
147
|
+
calls with a non-URL path and a
|
|
148
|
+
[request body](https://craigahobbs.github.io/bare-script-py/library/model.html#var.vName='SystemFetchRequest')
|
|
149
|
+
write the body to the path.
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
## MarkdownUp, a Markdown Viewer with BareScript
|
|
153
|
+
|
|
154
|
+
[MarkdownUp](https://craigahobbs.github.io/markdown-up/)
|
|
155
|
+
is a Markdown Viewer that executes BareScript embedded within Markdown documents.
|
|
156
|
+
MarkdownUp includes the
|
|
157
|
+
[MarkdownUp Library](https://craigahobbs.github.io/markdown-up/library/),
|
|
158
|
+
which extends the
|
|
159
|
+
[BareScript Library](https://craigahobbs.github.io/bare-script-py/library/)
|
|
160
|
+
with functions for dynamically rendering Markdown text, drawing SVG images, etc.
|
|
161
|
+
|
|
162
|
+
For example:
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
# Markdown Application
|
|
166
|
+
|
|
167
|
+
This is a Markdown document with embedded BareScript:
|
|
168
|
+
|
|
169
|
+
~~~ markdown-script
|
|
170
|
+
markdownPrint('Hello, Markdown!')
|
|
171
|
+
~~~
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
## Development
|
|
176
|
+
|
|
177
|
+
This package is developed using [python-build](https://github.com/craigahobbs/python-build#readme).
|
|
178
|
+
It was started using [python-template](https://github.com/craigahobbs/python-template#readme) as follows:
|
|
179
|
+
|
|
180
|
+
~~~
|
|
181
|
+
template-specialize python-template/template/ bare-script-py/ -k package bare-script -k name 'Craig A. Hobbs' -k email 'craigahobbs@gmail.com' -k github 'craigahobbs'
|
|
182
|
+
~~~
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
[metadata]
|
|
2
2
|
name = bare-script
|
|
3
|
-
version = 3.0.
|
|
3
|
+
version = 3.0.10
|
|
4
4
|
url = https://github.com/craigahobbs/bare-script
|
|
5
5
|
author = Craig A. Hobbs
|
|
6
6
|
author_email = craigahobbs@gmail.com
|
|
7
7
|
license = MIT
|
|
8
8
|
description = bare-script
|
|
9
|
-
long_description = file:README.
|
|
10
|
-
long_description_content_type = text/
|
|
9
|
+
long_description = file:README.md
|
|
10
|
+
long_description_content_type = text/markdown
|
|
11
11
|
keywords = bare-script
|
|
12
12
|
classifiers =
|
|
13
13
|
Development Status :: 5 - Production/Stable
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: bare-script
|
|
3
|
+
Version: 3.0.10
|
|
4
|
+
Summary: bare-script
|
|
5
|
+
Home-page: https://github.com/craigahobbs/bare-script
|
|
6
|
+
Author: Craig A. Hobbs
|
|
7
|
+
Author-email: craigahobbs@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: bare-script
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Interpreters
|
|
20
|
+
Classifier: Topic :: Utilities
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: schema-markdown>=1.2.0
|
|
24
|
+
|
|
25
|
+
# bare-script
|
|
26
|
+
|
|
27
|
+
[](https://pypi.org/project/bare-script/)
|
|
28
|
+
[](https://pypi.org/project/bare-script/)
|
|
29
|
+
[](https://github.com/craigahobbs/bare-script-py/blob/main/LICENSE)
|
|
30
|
+
[](https://pypi.org/project/bare-script/)
|
|
31
|
+
|
|
32
|
+
[BareScript](https://craigahobbs.github.io/bare-script/language/)
|
|
33
|
+
is a simple, lightweight, and portable programming language. Its Pythonic syntax is influenced by
|
|
34
|
+
JavaScript, C, and the Unix Shell. BareScript also has a library of built-in functions for common
|
|
35
|
+
programming operations. BareScript can be embedded within applications or used as a stand-alone
|
|
36
|
+
programming language using the command-line interface.
|
|
37
|
+
|
|
38
|
+
There are two implementations of BareScript:
|
|
39
|
+
[BareScript for Python](https://github.com/craigahobbs/bare-script-py#readme)
|
|
40
|
+
(this package) and
|
|
41
|
+
[BareScript for JavaScript](https://github.com/craigahobbs/bare-script#readme).
|
|
42
|
+
Both implementations have 100% unit test coverage with identical unit test suites, so you can be
|
|
43
|
+
confident that BareScript will execute the same regardless of the underlying runtime environment.
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## Links
|
|
47
|
+
|
|
48
|
+
- [The BareScript Language](https://craigahobbs.github.io/bare-script/language/)
|
|
49
|
+
- [The BareScript Library](https://craigahobbs.github.io/bare-script-py/library/)
|
|
50
|
+
- [The BareScript Expression Library](https://craigahobbs.github.io/bare-script-py/library/expression.html)
|
|
51
|
+
- [API Documentation](https://craigahobbs.github.io/bare-script-py/)
|
|
52
|
+
- [Source code](https://github.com/craigahobbs/bare-script-py)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
## Executing BareScript Scripts
|
|
56
|
+
|
|
57
|
+
To execute a BareScript script, parse the script using the
|
|
58
|
+
[parse_script](https://craigahobbs.github.io/bare-script-py/scripts.html#parse-script)
|
|
59
|
+
function. Then execute the script using the
|
|
60
|
+
[execute_script](https://craigahobbs.github.io/bare-script-py/scripts.html#execute-script)
|
|
61
|
+
function. For example:
|
|
62
|
+
|
|
63
|
+
~~~ python
|
|
64
|
+
from bare_script import execute_script, parse_script
|
|
65
|
+
|
|
66
|
+
# Parse the script
|
|
67
|
+
script = parse_script('''\
|
|
68
|
+
# Double a number
|
|
69
|
+
function double(n):
|
|
70
|
+
return n * 2
|
|
71
|
+
endfunction
|
|
72
|
+
|
|
73
|
+
return N + ' times 2 is ' + double(N)
|
|
74
|
+
''')
|
|
75
|
+
|
|
76
|
+
# Execute the script
|
|
77
|
+
globals = {'N': 10}
|
|
78
|
+
print(execute_script(script, {'globals': globals}))
|
|
79
|
+
~~~
|
|
80
|
+
|
|
81
|
+
This outputs:
|
|
82
|
+
|
|
83
|
+
~~~
|
|
84
|
+
10 times 2 is 20
|
|
85
|
+
~~~
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
### The BareScript Library
|
|
89
|
+
|
|
90
|
+
[The BareScript Library](https://craigahobbs.github.io/bare-script-py/library/)
|
|
91
|
+
includes a set of built-in functions for mathematical operations, object manipulation, array
|
|
92
|
+
manipulation, regular expressions, HTTP fetch and more. The following example demonstrates the use
|
|
93
|
+
of the
|
|
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
|
+
functions.
|
|
98
|
+
|
|
99
|
+
~~~ python
|
|
100
|
+
import urllib.request
|
|
101
|
+
|
|
102
|
+
from bare_script import execute_script, fetch_http, parse_script
|
|
103
|
+
|
|
104
|
+
# Parse the script
|
|
105
|
+
script = parse_script('''\
|
|
106
|
+
# Fetch the BareScript library documentation JSON
|
|
107
|
+
docs = jsonParse(systemFetch('https://craigahobbs.github.io/bare-script-py/library/library.json'))
|
|
108
|
+
|
|
109
|
+
# Return the number of library functions
|
|
110
|
+
return 'The BareScript Library has ' + arrayLength(objectGet(docs, 'functions')) + ' functions'
|
|
111
|
+
''')
|
|
112
|
+
|
|
113
|
+
# Execute the script
|
|
114
|
+
print(execute_script(script, {'fetchFn': fetch_http}))
|
|
115
|
+
~~~
|
|
116
|
+
|
|
117
|
+
This outputs:
|
|
118
|
+
|
|
119
|
+
~~~
|
|
120
|
+
The BareScript Library has 105 functions
|
|
121
|
+
~~~
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
## Evaluating BareScript Expressions
|
|
125
|
+
|
|
126
|
+
To evaluate a
|
|
127
|
+
[BareScript expression](https://craigahobbs.github.io/bare-script/language/#expressions),
|
|
128
|
+
parse the expression using the
|
|
129
|
+
[parse_expression](https://craigahobbs.github.io/bare-script-py/expressions.html#parse-expression)
|
|
130
|
+
function. Then evaluate the expression using the
|
|
131
|
+
[evaluate_expression](https://craigahobbs.github.io/bare-script-py/expressions.html#evaluate-expression)
|
|
132
|
+
function.
|
|
133
|
+
|
|
134
|
+
Expression evaluation includes the
|
|
135
|
+
[BareScript Expression Library](https://craigahobbs.github.io/bare-script-py/library/expression.html),
|
|
136
|
+
a set of built-in, spreadsheet-like functions.
|
|
137
|
+
|
|
138
|
+
For example:
|
|
139
|
+
|
|
140
|
+
~~~ python
|
|
141
|
+
from bare_script import evaluate_expression, parse_expression
|
|
142
|
+
|
|
143
|
+
# Parse the expression
|
|
144
|
+
expr = parse_expression('2 * max(a, b, c)')
|
|
145
|
+
|
|
146
|
+
# Evaluate the expression
|
|
147
|
+
variables = {'a': 1, 'b': 2, 'c': 3}
|
|
148
|
+
print(evaluate_expression(expr, None, variables))
|
|
149
|
+
~~~
|
|
150
|
+
|
|
151
|
+
This outputs:
|
|
152
|
+
|
|
153
|
+
~~~
|
|
154
|
+
6
|
|
155
|
+
~~~
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
## The BareScript Command-Line Interface (CLI)
|
|
159
|
+
|
|
160
|
+
You can run BareScript from the command line using the BareScript CLI, "bare". BareScript script
|
|
161
|
+
files use the ".bare" file extension.
|
|
162
|
+
|
|
163
|
+
~~~
|
|
164
|
+
bare script.bare
|
|
165
|
+
~~~
|
|
166
|
+
|
|
167
|
+
**Note:** In the BareScript CLI, import statements and the
|
|
168
|
+
[systemFetch](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='System'&systemfetch)
|
|
169
|
+
function read non-URL paths from the local file system.
|
|
170
|
+
[systemFetch](https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='System'&systemfetch)
|
|
171
|
+
calls with a non-URL path and a
|
|
172
|
+
[request body](https://craigahobbs.github.io/bare-script-py/library/model.html#var.vName='SystemFetchRequest')
|
|
173
|
+
write the body to the path.
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
## MarkdownUp, a Markdown Viewer with BareScript
|
|
177
|
+
|
|
178
|
+
[MarkdownUp](https://craigahobbs.github.io/markdown-up/)
|
|
179
|
+
is a Markdown Viewer that executes BareScript embedded within Markdown documents.
|
|
180
|
+
MarkdownUp includes the
|
|
181
|
+
[MarkdownUp Library](https://craigahobbs.github.io/markdown-up/library/),
|
|
182
|
+
which extends the
|
|
183
|
+
[BareScript Library](https://craigahobbs.github.io/bare-script-py/library/)
|
|
184
|
+
with functions for dynamically rendering Markdown text, drawing SVG images, etc.
|
|
185
|
+
|
|
186
|
+
For example:
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
# Markdown Application
|
|
190
|
+
|
|
191
|
+
This is a Markdown document with embedded BareScript:
|
|
192
|
+
|
|
193
|
+
~~~ markdown-script
|
|
194
|
+
markdownPrint('Hello, Markdown!')
|
|
195
|
+
~~~
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
## Development
|
|
200
|
+
|
|
201
|
+
This package is developed using [python-build](https://github.com/craigahobbs/python-build#readme).
|
|
202
|
+
It was started using [python-template](https://github.com/craigahobbs/python-template#readme) as follows:
|
|
203
|
+
|
|
204
|
+
~~~
|
|
205
|
+
template-specialize python-template/template/ bare-script-py/ -k package bare-script -k name 'Craig A. Hobbs' -k email 'craigahobbs@gmail.com' -k github 'craigahobbs'
|
|
206
|
+
~~~
|
bare-script-3.0.9/PKG-INFO
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: bare-script
|
|
3
|
-
Version: 3.0.9
|
|
4
|
-
Summary: bare-script
|
|
5
|
-
Home-page: https://github.com/craigahobbs/bare-script
|
|
6
|
-
Author: Craig A. Hobbs
|
|
7
|
-
Author-email: craigahobbs@gmail.com
|
|
8
|
-
License: MIT
|
|
9
|
-
Keywords: bare-script
|
|
10
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
-
Classifier: Intended Audience :: Developers
|
|
12
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
-
Classifier: Operating System :: OS Independent
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
-
Classifier: Topic :: Software Development :: Interpreters
|
|
20
|
-
Classifier: Topic :: Utilities
|
|
21
|
-
Description-Content-Type: text/x-rst
|
|
22
|
-
License-File: LICENSE
|
|
23
|
-
Requires-Dist: schema-markdown>=1.2.0
|
|
24
|
-
|
|
25
|
-
bare-script
|
|
26
|
-
===========
|
|
27
|
-
|
|
28
|
-
.. |badge-status| image:: https://img.shields.io/pypi/status/bare-script
|
|
29
|
-
:alt: PyPI - Status
|
|
30
|
-
:target: https://pypi.python.org/pypi/bare-script/
|
|
31
|
-
|
|
32
|
-
.. |badge-version| image:: https://img.shields.io/pypi/v/bare-script
|
|
33
|
-
:alt: PyPI
|
|
34
|
-
:target: https://pypi.python.org/pypi/bare-script/
|
|
35
|
-
|
|
36
|
-
.. |badge-license| image:: https://img.shields.io/github/license/craigahobbs/bare-script-py
|
|
37
|
-
:alt: GitHub
|
|
38
|
-
:target: https://github.com/craigahobbs/bare-script-py/blob/main/LICENSE
|
|
39
|
-
|
|
40
|
-
.. |badge-python| image:: https://img.shields.io/pypi/pyversions/bare-script
|
|
41
|
-
:alt: PyPI - Python Version
|
|
42
|
-
:target: https://www.python.org/downloads/
|
|
43
|
-
|
|
44
|
-
|badge-status| |badge-version| |badge-license| |badge-python|
|
|
45
|
-
|
|
46
|
-
`BareScript <https://craigahobbs.github.io/bare-script/language/>`__
|
|
47
|
-
is a simple, lightweight, and portable programming language. Its Pythonic syntax is influenced by
|
|
48
|
-
JavaScript, C, and the Unix Shell. BareScript also has a
|
|
49
|
-
`library of built-in functions <#the-barescript-library>`__
|
|
50
|
-
for common programming operations. BareScript can be
|
|
51
|
-
`embedded within applications <#markdownup-a-markdown-viewer-with-barescript>`__
|
|
52
|
-
or used as a
|
|
53
|
-
stand-alone programming language using the
|
|
54
|
-
`command-line interface <#the-barescript-command-line-interface-cli>`__.
|
|
55
|
-
|
|
56
|
-
There are two implementations of BareScript:
|
|
57
|
-
`BareScript for Python <https://github.com/craigahobbs/bare-script-py#readme>`__
|
|
58
|
-
(this package) and
|
|
59
|
-
`BareScript for JavaScript <https://github.com/craigahobbs/bare-script#readme>`__.
|
|
60
|
-
Both implementations have 100% unit test coverage with identical unit test suites, so you can be
|
|
61
|
-
confident that BareScript will execute the same regardless of the underlying runtime environment.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
Links
|
|
65
|
-
-----
|
|
66
|
-
|
|
67
|
-
- `The BareScript Language <https://craigahobbs.github.io/bare-script/language/>`__
|
|
68
|
-
- `The BareScript Library <https://craigahobbs.github.io/bare-script-py/library/>`__
|
|
69
|
-
- `The BareScript Expression Library <https://craigahobbs.github.io/bare-script-py/library/expression.html>`__
|
|
70
|
-
- `API Documentation <https://craigahobbs.github.io/bare-script-py/>`__
|
|
71
|
-
- `Source code <https://github.com/craigahobbs/bare-script-py>`__
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
Executing BareScript
|
|
75
|
-
--------------------
|
|
76
|
-
|
|
77
|
-
To execute a BareScript script, parse the script using the
|
|
78
|
-
`parse_script <https://craigahobbs.github.io/bare-script-py/scripts.html#parse-script>`__
|
|
79
|
-
function. Then execute the script using the
|
|
80
|
-
`execute_script <https://craigahobbs.github.io/bare-script-py/scripts.html#execute-script>`__
|
|
81
|
-
function. For example:
|
|
82
|
-
|
|
83
|
-
>>> from bare_script import execute_script, parse_script
|
|
84
|
-
...
|
|
85
|
-
>>> # Parse the script
|
|
86
|
-
... script = parse_script('''\
|
|
87
|
-
... # Double a number
|
|
88
|
-
... function double(n):
|
|
89
|
-
... return n * 2
|
|
90
|
-
... endfunction
|
|
91
|
-
...
|
|
92
|
-
... return N + ' times 2 is ' + double(N)
|
|
93
|
-
... ''')
|
|
94
|
-
...
|
|
95
|
-
>>> # Execute the script
|
|
96
|
-
... globals = {'N': 10}
|
|
97
|
-
>>> print(execute_script(script, {'globals': globals}))
|
|
98
|
-
10 times 2 is 20
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
The BareScript Library
|
|
102
|
-
^^^^^^^^^^^^^^^^^^^^^^
|
|
103
|
-
|
|
104
|
-
`The BareScript Library <https://craigahobbs.github.io/bare-script-py/library/>`__
|
|
105
|
-
includes a set of built-in functions for mathematical operations, object manipulation, array
|
|
106
|
-
manipulation, regular expressions, HTTP fetch and more. The following example demonstrates the use
|
|
107
|
-
of the
|
|
108
|
-
`systemFetch <https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='System'&systemfetch>`__,
|
|
109
|
-
`objectGet <https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='Object'&objectget>`__, and
|
|
110
|
-
`arrayLength <https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='Array'&arraylength>`__
|
|
111
|
-
functions.
|
|
112
|
-
|
|
113
|
-
>>> import urllib.request
|
|
114
|
-
...
|
|
115
|
-
>>> from bare_script import execute_script, fetch_http, parse_script
|
|
116
|
-
...
|
|
117
|
-
>>> # Parse the script
|
|
118
|
-
... script = parse_script('''\
|
|
119
|
-
... # Fetch the BareScript library documentation JSON
|
|
120
|
-
... docs = jsonParse(systemFetch('https://craigahobbs.github.io/bare-script-py/library/library.json'))
|
|
121
|
-
...
|
|
122
|
-
... # Return the number of library functions
|
|
123
|
-
... return 'The BareScript Library has ' + arrayLength(objectGet(docs, 'functions')) + ' functions'
|
|
124
|
-
... ''')
|
|
125
|
-
...
|
|
126
|
-
>>> # Execute the script
|
|
127
|
-
... print(execute_script(script, {'fetchFn': fetch_http}))
|
|
128
|
-
The BareScript Library has 105 functions
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
Evaluating BareScript Expressions
|
|
132
|
-
---------------------------------
|
|
133
|
-
|
|
134
|
-
To evaluate a
|
|
135
|
-
`BareScript expression <https://craigahobbs.github.io/bare-script/language/#expressions>`__,
|
|
136
|
-
parse the expression using the
|
|
137
|
-
`parse_expression <https://craigahobbs.github.io/bare-script-py/expressions.html#parse-expression>`__
|
|
138
|
-
function. Then evaluate the expression using the
|
|
139
|
-
`evaluate_expression <https://craigahobbs.github.io/bare-script-py/expressions.html#evaluate-expression>`__
|
|
140
|
-
function.
|
|
141
|
-
|
|
142
|
-
Expression evaluation includes the
|
|
143
|
-
`BareScript Expression Library <https://craigahobbs.github.io/bare-script-py/library/expression.html>`__,
|
|
144
|
-
a set of built-in, spreadsheet-like functions.
|
|
145
|
-
|
|
146
|
-
For example:
|
|
147
|
-
|
|
148
|
-
>>> from bare_script import evaluate_expression, parse_expression
|
|
149
|
-
...
|
|
150
|
-
>>> # Parse the expression
|
|
151
|
-
... expr = parse_expression('2 * max(a, b, c)')
|
|
152
|
-
...
|
|
153
|
-
>>> # Evaluate the expression
|
|
154
|
-
... variables = {'a': 1, 'b': 2, 'c': 3}
|
|
155
|
-
>>> print(evaluate_expression(expr, None, variables))
|
|
156
|
-
6.0
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
The BareScript Command-Line Interface (CLI)
|
|
160
|
-
-------------------------------------------
|
|
161
|
-
|
|
162
|
-
You can run BareScript from the command line using the BareScript CLI, "bare". BareScript script
|
|
163
|
-
files use the ".bare" file extension.
|
|
164
|
-
|
|
165
|
-
.. code-block:: sh
|
|
166
|
-
|
|
167
|
-
bare script.bare
|
|
168
|
-
|
|
169
|
-
**Note:** In the BareScript CLI, import statements and the
|
|
170
|
-
`systemFetch <https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='System'&systemfetch>`__
|
|
171
|
-
function read non-URL paths from the local file system.
|
|
172
|
-
`systemFetch <https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='System'&systemfetch>`__
|
|
173
|
-
calls with a non-URL path and a
|
|
174
|
-
`request body <https://craigahobbs.github.io/bare-script-py/library/model.html#var.vName='SystemFetchRequest'>`__
|
|
175
|
-
write the body to the path.
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
MarkdownUp, a Markdown Viewer with BareScript
|
|
179
|
-
---------------------------------------------
|
|
180
|
-
|
|
181
|
-
`MarkdownUp <https://craigahobbs.github.io/markdown-up/>`__
|
|
182
|
-
is a Markdown Viewer that executes BareScript embedded within Markdown documents.
|
|
183
|
-
`MarkdownUp <https://craigahobbs.github.io/markdown-up/>`__
|
|
184
|
-
extends its
|
|
185
|
-
`standard library <https://craigahobbs.github.io/markdown-up/library/>`__
|
|
186
|
-
with functions for dynamically rendering Markdown text, drawing SVG images, etc.
|
|
187
|
-
|
|
188
|
-
For example:
|
|
189
|
-
|
|
190
|
-
.. code-block:: markdown
|
|
191
|
-
|
|
192
|
-
# Markdown Application
|
|
193
|
-
|
|
194
|
-
This is a Markdown document with embedded BareScript:
|
|
195
|
-
|
|
196
|
-
~~~ markdown-script
|
|
197
|
-
markdownPrint('Hello, Markdown!')
|
|
198
|
-
~~~
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
Development
|
|
202
|
-
-----------
|
|
203
|
-
|
|
204
|
-
This package is developed using `python-build <https://github.com/craigahobbs/python-build#readme>`__.
|
|
205
|
-
It was started using `python-template <https://github.com/craigahobbs/python-template#readme>`__ as follows:
|
|
206
|
-
|
|
207
|
-
.. code-block:: sh
|
|
208
|
-
|
|
209
|
-
template-specialize python-template/template/ bare-script-py/ -k package bare-script -k name 'Craig A. Hobbs' -k email 'craigahobbs@gmail.com' -k github 'craigahobbs'
|
bare-script-3.0.9/README.rst
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
bare-script
|
|
2
|
-
===========
|
|
3
|
-
|
|
4
|
-
.. |badge-status| image:: https://img.shields.io/pypi/status/bare-script
|
|
5
|
-
:alt: PyPI - Status
|
|
6
|
-
:target: https://pypi.python.org/pypi/bare-script/
|
|
7
|
-
|
|
8
|
-
.. |badge-version| image:: https://img.shields.io/pypi/v/bare-script
|
|
9
|
-
:alt: PyPI
|
|
10
|
-
:target: https://pypi.python.org/pypi/bare-script/
|
|
11
|
-
|
|
12
|
-
.. |badge-license| image:: https://img.shields.io/github/license/craigahobbs/bare-script-py
|
|
13
|
-
:alt: GitHub
|
|
14
|
-
:target: https://github.com/craigahobbs/bare-script-py/blob/main/LICENSE
|
|
15
|
-
|
|
16
|
-
.. |badge-python| image:: https://img.shields.io/pypi/pyversions/bare-script
|
|
17
|
-
:alt: PyPI - Python Version
|
|
18
|
-
:target: https://www.python.org/downloads/
|
|
19
|
-
|
|
20
|
-
|badge-status| |badge-version| |badge-license| |badge-python|
|
|
21
|
-
|
|
22
|
-
`BareScript <https://craigahobbs.github.io/bare-script/language/>`__
|
|
23
|
-
is a simple, lightweight, and portable programming language. Its Pythonic syntax is influenced by
|
|
24
|
-
JavaScript, C, and the Unix Shell. BareScript also has a
|
|
25
|
-
`library of built-in functions <#the-barescript-library>`__
|
|
26
|
-
for common programming operations. BareScript can be
|
|
27
|
-
`embedded within applications <#markdownup-a-markdown-viewer-with-barescript>`__
|
|
28
|
-
or used as a
|
|
29
|
-
stand-alone programming language using the
|
|
30
|
-
`command-line interface <#the-barescript-command-line-interface-cli>`__.
|
|
31
|
-
|
|
32
|
-
There are two implementations of BareScript:
|
|
33
|
-
`BareScript for Python <https://github.com/craigahobbs/bare-script-py#readme>`__
|
|
34
|
-
(this package) and
|
|
35
|
-
`BareScript for JavaScript <https://github.com/craigahobbs/bare-script#readme>`__.
|
|
36
|
-
Both implementations have 100% unit test coverage with identical unit test suites, so you can be
|
|
37
|
-
confident that BareScript will execute the same regardless of the underlying runtime environment.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
Links
|
|
41
|
-
-----
|
|
42
|
-
|
|
43
|
-
- `The BareScript Language <https://craigahobbs.github.io/bare-script/language/>`__
|
|
44
|
-
- `The BareScript Library <https://craigahobbs.github.io/bare-script-py/library/>`__
|
|
45
|
-
- `The BareScript Expression Library <https://craigahobbs.github.io/bare-script-py/library/expression.html>`__
|
|
46
|
-
- `API Documentation <https://craigahobbs.github.io/bare-script-py/>`__
|
|
47
|
-
- `Source code <https://github.com/craigahobbs/bare-script-py>`__
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Executing BareScript
|
|
51
|
-
--------------------
|
|
52
|
-
|
|
53
|
-
To execute a BareScript script, parse the script using the
|
|
54
|
-
`parse_script <https://craigahobbs.github.io/bare-script-py/scripts.html#parse-script>`__
|
|
55
|
-
function. Then execute the script using the
|
|
56
|
-
`execute_script <https://craigahobbs.github.io/bare-script-py/scripts.html#execute-script>`__
|
|
57
|
-
function. For example:
|
|
58
|
-
|
|
59
|
-
>>> from bare_script import execute_script, parse_script
|
|
60
|
-
...
|
|
61
|
-
>>> # Parse the script
|
|
62
|
-
... script = parse_script('''\
|
|
63
|
-
... # Double a number
|
|
64
|
-
... function double(n):
|
|
65
|
-
... return n * 2
|
|
66
|
-
... endfunction
|
|
67
|
-
...
|
|
68
|
-
... return N + ' times 2 is ' + double(N)
|
|
69
|
-
... ''')
|
|
70
|
-
...
|
|
71
|
-
>>> # Execute the script
|
|
72
|
-
... globals = {'N': 10}
|
|
73
|
-
>>> print(execute_script(script, {'globals': globals}))
|
|
74
|
-
10 times 2 is 20
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
The BareScript Library
|
|
78
|
-
^^^^^^^^^^^^^^^^^^^^^^
|
|
79
|
-
|
|
80
|
-
`The BareScript Library <https://craigahobbs.github.io/bare-script-py/library/>`__
|
|
81
|
-
includes a set of built-in functions for mathematical operations, object manipulation, array
|
|
82
|
-
manipulation, regular expressions, HTTP fetch and more. The following example demonstrates the use
|
|
83
|
-
of the
|
|
84
|
-
`systemFetch <https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='System'&systemfetch>`__,
|
|
85
|
-
`objectGet <https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='Object'&objectget>`__, and
|
|
86
|
-
`arrayLength <https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='Array'&arraylength>`__
|
|
87
|
-
functions.
|
|
88
|
-
|
|
89
|
-
>>> import urllib.request
|
|
90
|
-
...
|
|
91
|
-
>>> from bare_script import execute_script, fetch_http, parse_script
|
|
92
|
-
...
|
|
93
|
-
>>> # Parse the script
|
|
94
|
-
... script = parse_script('''\
|
|
95
|
-
... # Fetch the BareScript library documentation JSON
|
|
96
|
-
... docs = jsonParse(systemFetch('https://craigahobbs.github.io/bare-script-py/library/library.json'))
|
|
97
|
-
...
|
|
98
|
-
... # Return the number of library functions
|
|
99
|
-
... return 'The BareScript Library has ' + arrayLength(objectGet(docs, 'functions')) + ' functions'
|
|
100
|
-
... ''')
|
|
101
|
-
...
|
|
102
|
-
>>> # Execute the script
|
|
103
|
-
... print(execute_script(script, {'fetchFn': fetch_http}))
|
|
104
|
-
The BareScript Library has 105 functions
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
Evaluating BareScript Expressions
|
|
108
|
-
---------------------------------
|
|
109
|
-
|
|
110
|
-
To evaluate a
|
|
111
|
-
`BareScript expression <https://craigahobbs.github.io/bare-script/language/#expressions>`__,
|
|
112
|
-
parse the expression using the
|
|
113
|
-
`parse_expression <https://craigahobbs.github.io/bare-script-py/expressions.html#parse-expression>`__
|
|
114
|
-
function. Then evaluate the expression using the
|
|
115
|
-
`evaluate_expression <https://craigahobbs.github.io/bare-script-py/expressions.html#evaluate-expression>`__
|
|
116
|
-
function.
|
|
117
|
-
|
|
118
|
-
Expression evaluation includes the
|
|
119
|
-
`BareScript Expression Library <https://craigahobbs.github.io/bare-script-py/library/expression.html>`__,
|
|
120
|
-
a set of built-in, spreadsheet-like functions.
|
|
121
|
-
|
|
122
|
-
For example:
|
|
123
|
-
|
|
124
|
-
>>> from bare_script import evaluate_expression, parse_expression
|
|
125
|
-
...
|
|
126
|
-
>>> # Parse the expression
|
|
127
|
-
... expr = parse_expression('2 * max(a, b, c)')
|
|
128
|
-
...
|
|
129
|
-
>>> # Evaluate the expression
|
|
130
|
-
... variables = {'a': 1, 'b': 2, 'c': 3}
|
|
131
|
-
>>> print(evaluate_expression(expr, None, variables))
|
|
132
|
-
6.0
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
The BareScript Command-Line Interface (CLI)
|
|
136
|
-
-------------------------------------------
|
|
137
|
-
|
|
138
|
-
You can run BareScript from the command line using the BareScript CLI, "bare". BareScript script
|
|
139
|
-
files use the ".bare" file extension.
|
|
140
|
-
|
|
141
|
-
.. code-block:: sh
|
|
142
|
-
|
|
143
|
-
bare script.bare
|
|
144
|
-
|
|
145
|
-
**Note:** In the BareScript CLI, import statements and the
|
|
146
|
-
`systemFetch <https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='System'&systemfetch>`__
|
|
147
|
-
function read non-URL paths from the local file system.
|
|
148
|
-
`systemFetch <https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='System'&systemfetch>`__
|
|
149
|
-
calls with a non-URL path and a
|
|
150
|
-
`request body <https://craigahobbs.github.io/bare-script-py/library/model.html#var.vName='SystemFetchRequest'>`__
|
|
151
|
-
write the body to the path.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
MarkdownUp, a Markdown Viewer with BareScript
|
|
155
|
-
---------------------------------------------
|
|
156
|
-
|
|
157
|
-
`MarkdownUp <https://craigahobbs.github.io/markdown-up/>`__
|
|
158
|
-
is a Markdown Viewer that executes BareScript embedded within Markdown documents.
|
|
159
|
-
`MarkdownUp <https://craigahobbs.github.io/markdown-up/>`__
|
|
160
|
-
extends its
|
|
161
|
-
`standard library <https://craigahobbs.github.io/markdown-up/library/>`__
|
|
162
|
-
with functions for dynamically rendering Markdown text, drawing SVG images, etc.
|
|
163
|
-
|
|
164
|
-
For example:
|
|
165
|
-
|
|
166
|
-
.. code-block:: markdown
|
|
167
|
-
|
|
168
|
-
# Markdown Application
|
|
169
|
-
|
|
170
|
-
This is a Markdown document with embedded BareScript:
|
|
171
|
-
|
|
172
|
-
~~~ markdown-script
|
|
173
|
-
markdownPrint('Hello, Markdown!')
|
|
174
|
-
~~~
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
Development
|
|
178
|
-
-----------
|
|
179
|
-
|
|
180
|
-
This package is developed using `python-build <https://github.com/craigahobbs/python-build#readme>`__.
|
|
181
|
-
It was started using `python-template <https://github.com/craigahobbs/python-template#readme>`__ as follows:
|
|
182
|
-
|
|
183
|
-
.. code-block:: sh
|
|
184
|
-
|
|
185
|
-
template-specialize python-template/template/ bare-script-py/ -k package bare-script -k name 'Craig A. Hobbs' -k email 'craigahobbs@gmail.com' -k github 'craigahobbs'
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: bare-script
|
|
3
|
-
Version: 3.0.9
|
|
4
|
-
Summary: bare-script
|
|
5
|
-
Home-page: https://github.com/craigahobbs/bare-script
|
|
6
|
-
Author: Craig A. Hobbs
|
|
7
|
-
Author-email: craigahobbs@gmail.com
|
|
8
|
-
License: MIT
|
|
9
|
-
Keywords: bare-script
|
|
10
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
-
Classifier: Intended Audience :: Developers
|
|
12
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
-
Classifier: Operating System :: OS Independent
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
-
Classifier: Topic :: Software Development :: Interpreters
|
|
20
|
-
Classifier: Topic :: Utilities
|
|
21
|
-
Description-Content-Type: text/x-rst
|
|
22
|
-
License-File: LICENSE
|
|
23
|
-
Requires-Dist: schema-markdown>=1.2.0
|
|
24
|
-
|
|
25
|
-
bare-script
|
|
26
|
-
===========
|
|
27
|
-
|
|
28
|
-
.. |badge-status| image:: https://img.shields.io/pypi/status/bare-script
|
|
29
|
-
:alt: PyPI - Status
|
|
30
|
-
:target: https://pypi.python.org/pypi/bare-script/
|
|
31
|
-
|
|
32
|
-
.. |badge-version| image:: https://img.shields.io/pypi/v/bare-script
|
|
33
|
-
:alt: PyPI
|
|
34
|
-
:target: https://pypi.python.org/pypi/bare-script/
|
|
35
|
-
|
|
36
|
-
.. |badge-license| image:: https://img.shields.io/github/license/craigahobbs/bare-script-py
|
|
37
|
-
:alt: GitHub
|
|
38
|
-
:target: https://github.com/craigahobbs/bare-script-py/blob/main/LICENSE
|
|
39
|
-
|
|
40
|
-
.. |badge-python| image:: https://img.shields.io/pypi/pyversions/bare-script
|
|
41
|
-
:alt: PyPI - Python Version
|
|
42
|
-
:target: https://www.python.org/downloads/
|
|
43
|
-
|
|
44
|
-
|badge-status| |badge-version| |badge-license| |badge-python|
|
|
45
|
-
|
|
46
|
-
`BareScript <https://craigahobbs.github.io/bare-script/language/>`__
|
|
47
|
-
is a simple, lightweight, and portable programming language. Its Pythonic syntax is influenced by
|
|
48
|
-
JavaScript, C, and the Unix Shell. BareScript also has a
|
|
49
|
-
`library of built-in functions <#the-barescript-library>`__
|
|
50
|
-
for common programming operations. BareScript can be
|
|
51
|
-
`embedded within applications <#markdownup-a-markdown-viewer-with-barescript>`__
|
|
52
|
-
or used as a
|
|
53
|
-
stand-alone programming language using the
|
|
54
|
-
`command-line interface <#the-barescript-command-line-interface-cli>`__.
|
|
55
|
-
|
|
56
|
-
There are two implementations of BareScript:
|
|
57
|
-
`BareScript for Python <https://github.com/craigahobbs/bare-script-py#readme>`__
|
|
58
|
-
(this package) and
|
|
59
|
-
`BareScript for JavaScript <https://github.com/craigahobbs/bare-script#readme>`__.
|
|
60
|
-
Both implementations have 100% unit test coverage with identical unit test suites, so you can be
|
|
61
|
-
confident that BareScript will execute the same regardless of the underlying runtime environment.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
Links
|
|
65
|
-
-----
|
|
66
|
-
|
|
67
|
-
- `The BareScript Language <https://craigahobbs.github.io/bare-script/language/>`__
|
|
68
|
-
- `The BareScript Library <https://craigahobbs.github.io/bare-script-py/library/>`__
|
|
69
|
-
- `The BareScript Expression Library <https://craigahobbs.github.io/bare-script-py/library/expression.html>`__
|
|
70
|
-
- `API Documentation <https://craigahobbs.github.io/bare-script-py/>`__
|
|
71
|
-
- `Source code <https://github.com/craigahobbs/bare-script-py>`__
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
Executing BareScript
|
|
75
|
-
--------------------
|
|
76
|
-
|
|
77
|
-
To execute a BareScript script, parse the script using the
|
|
78
|
-
`parse_script <https://craigahobbs.github.io/bare-script-py/scripts.html#parse-script>`__
|
|
79
|
-
function. Then execute the script using the
|
|
80
|
-
`execute_script <https://craigahobbs.github.io/bare-script-py/scripts.html#execute-script>`__
|
|
81
|
-
function. For example:
|
|
82
|
-
|
|
83
|
-
>>> from bare_script import execute_script, parse_script
|
|
84
|
-
...
|
|
85
|
-
>>> # Parse the script
|
|
86
|
-
... script = parse_script('''\
|
|
87
|
-
... # Double a number
|
|
88
|
-
... function double(n):
|
|
89
|
-
... return n * 2
|
|
90
|
-
... endfunction
|
|
91
|
-
...
|
|
92
|
-
... return N + ' times 2 is ' + double(N)
|
|
93
|
-
... ''')
|
|
94
|
-
...
|
|
95
|
-
>>> # Execute the script
|
|
96
|
-
... globals = {'N': 10}
|
|
97
|
-
>>> print(execute_script(script, {'globals': globals}))
|
|
98
|
-
10 times 2 is 20
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
The BareScript Library
|
|
102
|
-
^^^^^^^^^^^^^^^^^^^^^^
|
|
103
|
-
|
|
104
|
-
`The BareScript Library <https://craigahobbs.github.io/bare-script-py/library/>`__
|
|
105
|
-
includes a set of built-in functions for mathematical operations, object manipulation, array
|
|
106
|
-
manipulation, regular expressions, HTTP fetch and more. The following example demonstrates the use
|
|
107
|
-
of the
|
|
108
|
-
`systemFetch <https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='System'&systemfetch>`__,
|
|
109
|
-
`objectGet <https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='Object'&objectget>`__, and
|
|
110
|
-
`arrayLength <https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='Array'&arraylength>`__
|
|
111
|
-
functions.
|
|
112
|
-
|
|
113
|
-
>>> import urllib.request
|
|
114
|
-
...
|
|
115
|
-
>>> from bare_script import execute_script, fetch_http, parse_script
|
|
116
|
-
...
|
|
117
|
-
>>> # Parse the script
|
|
118
|
-
... script = parse_script('''\
|
|
119
|
-
... # Fetch the BareScript library documentation JSON
|
|
120
|
-
... docs = jsonParse(systemFetch('https://craigahobbs.github.io/bare-script-py/library/library.json'))
|
|
121
|
-
...
|
|
122
|
-
... # Return the number of library functions
|
|
123
|
-
... return 'The BareScript Library has ' + arrayLength(objectGet(docs, 'functions')) + ' functions'
|
|
124
|
-
... ''')
|
|
125
|
-
...
|
|
126
|
-
>>> # Execute the script
|
|
127
|
-
... print(execute_script(script, {'fetchFn': fetch_http}))
|
|
128
|
-
The BareScript Library has 105 functions
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
Evaluating BareScript Expressions
|
|
132
|
-
---------------------------------
|
|
133
|
-
|
|
134
|
-
To evaluate a
|
|
135
|
-
`BareScript expression <https://craigahobbs.github.io/bare-script/language/#expressions>`__,
|
|
136
|
-
parse the expression using the
|
|
137
|
-
`parse_expression <https://craigahobbs.github.io/bare-script-py/expressions.html#parse-expression>`__
|
|
138
|
-
function. Then evaluate the expression using the
|
|
139
|
-
`evaluate_expression <https://craigahobbs.github.io/bare-script-py/expressions.html#evaluate-expression>`__
|
|
140
|
-
function.
|
|
141
|
-
|
|
142
|
-
Expression evaluation includes the
|
|
143
|
-
`BareScript Expression Library <https://craigahobbs.github.io/bare-script-py/library/expression.html>`__,
|
|
144
|
-
a set of built-in, spreadsheet-like functions.
|
|
145
|
-
|
|
146
|
-
For example:
|
|
147
|
-
|
|
148
|
-
>>> from bare_script import evaluate_expression, parse_expression
|
|
149
|
-
...
|
|
150
|
-
>>> # Parse the expression
|
|
151
|
-
... expr = parse_expression('2 * max(a, b, c)')
|
|
152
|
-
...
|
|
153
|
-
>>> # Evaluate the expression
|
|
154
|
-
... variables = {'a': 1, 'b': 2, 'c': 3}
|
|
155
|
-
>>> print(evaluate_expression(expr, None, variables))
|
|
156
|
-
6.0
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
The BareScript Command-Line Interface (CLI)
|
|
160
|
-
-------------------------------------------
|
|
161
|
-
|
|
162
|
-
You can run BareScript from the command line using the BareScript CLI, "bare". BareScript script
|
|
163
|
-
files use the ".bare" file extension.
|
|
164
|
-
|
|
165
|
-
.. code-block:: sh
|
|
166
|
-
|
|
167
|
-
bare script.bare
|
|
168
|
-
|
|
169
|
-
**Note:** In the BareScript CLI, import statements and the
|
|
170
|
-
`systemFetch <https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='System'&systemfetch>`__
|
|
171
|
-
function read non-URL paths from the local file system.
|
|
172
|
-
`systemFetch <https://craigahobbs.github.io/bare-script-py/library/#var.vGroup='System'&systemfetch>`__
|
|
173
|
-
calls with a non-URL path and a
|
|
174
|
-
`request body <https://craigahobbs.github.io/bare-script-py/library/model.html#var.vName='SystemFetchRequest'>`__
|
|
175
|
-
write the body to the path.
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
MarkdownUp, a Markdown Viewer with BareScript
|
|
179
|
-
---------------------------------------------
|
|
180
|
-
|
|
181
|
-
`MarkdownUp <https://craigahobbs.github.io/markdown-up/>`__
|
|
182
|
-
is a Markdown Viewer that executes BareScript embedded within Markdown documents.
|
|
183
|
-
`MarkdownUp <https://craigahobbs.github.io/markdown-up/>`__
|
|
184
|
-
extends its
|
|
185
|
-
`standard library <https://craigahobbs.github.io/markdown-up/library/>`__
|
|
186
|
-
with functions for dynamically rendering Markdown text, drawing SVG images, etc.
|
|
187
|
-
|
|
188
|
-
For example:
|
|
189
|
-
|
|
190
|
-
.. code-block:: markdown
|
|
191
|
-
|
|
192
|
-
# Markdown Application
|
|
193
|
-
|
|
194
|
-
This is a Markdown document with embedded BareScript:
|
|
195
|
-
|
|
196
|
-
~~~ markdown-script
|
|
197
|
-
markdownPrint('Hello, Markdown!')
|
|
198
|
-
~~~
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
Development
|
|
202
|
-
-----------
|
|
203
|
-
|
|
204
|
-
This package is developed using `python-build <https://github.com/craigahobbs/python-build#readme>`__.
|
|
205
|
-
It was started using `python-template <https://github.com/craigahobbs/python-template#readme>`__ as follows:
|
|
206
|
-
|
|
207
|
-
.. code-block:: sh
|
|
208
|
-
|
|
209
|
-
template-specialize python-template/template/ bare-script-py/ -k package bare-script -k name 'Craig A. Hobbs' -k email 'craigahobbs@gmail.com' -k github 'craigahobbs'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|