yamlscript 0.0.1__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {yamlscript-0.0.1/lib/yamlscript.egg-info → yamlscript-0.1.2}/PKG-INFO +4 -2
- yamlscript-0.1.2/ReadMe.md +82 -0
- yamlscript-0.1.2/lib/yamlscript/__init__.py +20 -0
- yamlscript-0.1.2/lib/yamlscript/loader.py +53 -0
- {yamlscript-0.0.1 → yamlscript-0.1.2/lib/yamlscript.egg-info}/PKG-INFO +4 -2
- {yamlscript-0.0.1 → yamlscript-0.1.2}/lib/yamlscript.egg-info/SOURCES.txt +1 -0
- {yamlscript-0.0.1 → yamlscript-0.1.2}/setup.py +1 -1
- {yamlscript-0.0.1 → yamlscript-0.1.2}/test/test.py +1 -1
- yamlscript-0.0.1/ReadMe.md +0 -31
- yamlscript-0.0.1/lib/yamlscript/__init__.py +0 -1
- {yamlscript-0.0.1 → yamlscript-0.1.2}/.long_description.md +0 -0
- {yamlscript-0.0.1 → yamlscript-0.1.2}/MANIFEST.in +0 -0
- {yamlscript-0.0.1 → yamlscript-0.1.2}/lib/yamlscript.egg-info/dependency_links.txt +0 -0
- {yamlscript-0.0.1 → yamlscript-0.1.2}/lib/yamlscript.egg-info/requires.txt +0 -0
- {yamlscript-0.0.1 → yamlscript-0.1.2}/lib/yamlscript.egg-info/top_level.txt +0 -0
- {yamlscript-0.0.1 → yamlscript-0.1.2}/setup.cfg +0 -0
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: yamlscript
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Program in YAML
|
|
5
5
|
Home-page: https://github.com/ingydotnet/yamlscript
|
|
6
6
|
Author: Ingy döt Net
|
|
7
7
|
Author-email: ingy@ingy.net
|
|
8
8
|
License: MIT
|
|
9
|
-
Description: UNKNOWN
|
|
10
9
|
Keywords: yaml,language
|
|
11
10
|
Platform: UNKNOWN
|
|
12
11
|
Classifier: Development Status :: 3 - Alpha
|
|
@@ -20,3 +19,6 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
20
19
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
20
|
Requires-Python: >=3.6, <4
|
|
22
21
|
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
UNKNOWN
|
|
24
|
+
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
yamlscript
|
|
2
|
+
==========
|
|
3
|
+
|
|
4
|
+
Program in YAML
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Synopsis
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
#!/usr/bin/env ys-0
|
|
11
|
+
|
|
12
|
+
defn main(name):
|
|
13
|
+
say: "Hello, $name!"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## Description
|
|
18
|
+
|
|
19
|
+
YAMLScript is a functional programming language with a stylized YAML syntax.
|
|
20
|
+
|
|
21
|
+
YAMLScript can be used for:
|
|
22
|
+
|
|
23
|
+
* Writing new programs and applications
|
|
24
|
+
* Run with `ys file.ys`
|
|
25
|
+
* Or compile to binary with `ys -C file.ys`
|
|
26
|
+
* Writing reusable shared libraries
|
|
27
|
+
* Bindable to almost any programming language
|
|
28
|
+
* Using as a YAML loader module in many programming languages
|
|
29
|
+
* Plain / existing YAML files
|
|
30
|
+
* YAML files with new functional magics
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## Installing `yamlscript.py`
|
|
34
|
+
|
|
35
|
+
You can install this module from https://pypi.org like any other Python module,
|
|
36
|
+
but you will need to have a system install of `libyamlscript.so`.
|
|
37
|
+
|
|
38
|
+
One simple way to do that is with:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
curl https://yamlscript.org/install-libyamlscript | sudo bash
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
See: https://github.com/yaml/yamlscript for more info
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## API
|
|
48
|
+
|
|
49
|
+
Us the `yamlscript` module in your Python program like this:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
import yamlscript
|
|
53
|
+
|
|
54
|
+
ys_file = open('file.ys')
|
|
55
|
+
ys_code = open('file.ys').read()
|
|
56
|
+
|
|
57
|
+
# Class method
|
|
58
|
+
data = yamlscript.load(ys_file)
|
|
59
|
+
data = yamlscript.load(ys_code)
|
|
60
|
+
|
|
61
|
+
# Instance method
|
|
62
|
+
ys = yamlscript.YAMLScript()
|
|
63
|
+
data = ys.load(ys_file)
|
|
64
|
+
data = ys.load(ys_code)
|
|
65
|
+
|
|
66
|
+
# Error handling
|
|
67
|
+
try:
|
|
68
|
+
yamlscript.load("a: b: c")
|
|
69
|
+
except Exception as e:
|
|
70
|
+
print(e)
|
|
71
|
+
print(ys.error['cause'])
|
|
72
|
+
print(ys.error['trace'])
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
## License & Copyright
|
|
77
|
+
|
|
78
|
+
This project is licensed under the terms of the `MIT` license.
|
|
79
|
+
See [LICENSE](https://github.com/yaml/pyyaml-future/blob/main/LICENSE) for
|
|
80
|
+
more details.
|
|
81
|
+
|
|
82
|
+
Copyright 2022-2023 Ingy döt Net <ingy@ingy.net>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import io
|
|
2
|
+
from . import loader
|
|
3
|
+
|
|
4
|
+
class YAMLScript():
|
|
5
|
+
def load(self, input):
|
|
6
|
+
if isinstance(input, str):
|
|
7
|
+
return self._load_string(input)
|
|
8
|
+
elif isinstance(input, io.IOBase):
|
|
9
|
+
return self._load_string(input.read())
|
|
10
|
+
|
|
11
|
+
def _load_string(self, input):
|
|
12
|
+
self.error = None
|
|
13
|
+
resp = loader.Loader().load(input)
|
|
14
|
+
error = self.error = resp.get('error')
|
|
15
|
+
if error:
|
|
16
|
+
raise Exception(error['cause'])
|
|
17
|
+
return resp['data']
|
|
18
|
+
|
|
19
|
+
def load(input):
|
|
20
|
+
return YAMLScript().load(input)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import os, sys
|
|
2
|
+
import ctypes
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
yamlscript_version = '0.1.32'
|
|
6
|
+
|
|
7
|
+
so = 'dylib' if sys.platform == 'darwin' else 'so'
|
|
8
|
+
libys_name = 'libyamlscript.' + so + '.' + yamlscript_version
|
|
9
|
+
|
|
10
|
+
ld_library_path = os.environ.get('LD_LIBRARY_PATH')
|
|
11
|
+
ld_library_paths = ld_library_path.split(':') if ld_library_path else []
|
|
12
|
+
ld_library_paths.append('/usr/local/lib')
|
|
13
|
+
|
|
14
|
+
libys_path = ''
|
|
15
|
+
for path in ld_library_paths:
|
|
16
|
+
path = path + '/' + libys_name
|
|
17
|
+
if os.path.isfile(path):
|
|
18
|
+
libys_path = path
|
|
19
|
+
break
|
|
20
|
+
|
|
21
|
+
if not libys_path:
|
|
22
|
+
raise Exception("Shared library file '%s' not found." % libys_name)
|
|
23
|
+
|
|
24
|
+
# Load libyamlscript shared library:
|
|
25
|
+
libys = ctypes.CDLL(libys_path)
|
|
26
|
+
|
|
27
|
+
isolate = ctypes.c_void_p()
|
|
28
|
+
isolatethread = ctypes.c_void_p()
|
|
29
|
+
libys.graal_create_isolate(
|
|
30
|
+
None,
|
|
31
|
+
ctypes.byref(isolate),
|
|
32
|
+
ctypes.byref(isolatethread),
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
load_ys_to_json = libys.load_ys_to_json
|
|
36
|
+
load_ys_to_json.restype = ctypes.c_char_p
|
|
37
|
+
|
|
38
|
+
# User API class:
|
|
39
|
+
class Loader():
|
|
40
|
+
"""
|
|
41
|
+
Send YAMLScript string to be evaluated by shared library.
|
|
42
|
+
The library converts YAMLScript to Clojure and runs it using SCI.
|
|
43
|
+
The code produces a data value, which is encoded in JSON and returned.
|
|
44
|
+
Load the returned JSON into a Python value and return that.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
def load(self, ys_input):
|
|
48
|
+
data_json = load_ys_to_json(
|
|
49
|
+
isolatethread,
|
|
50
|
+
ctypes.c_char_p(bytes(ys_input, "utf8")),
|
|
51
|
+
).decode()
|
|
52
|
+
|
|
53
|
+
return json.loads(data_json)
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: yamlscript
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Program in YAML
|
|
5
5
|
Home-page: https://github.com/ingydotnet/yamlscript
|
|
6
6
|
Author: Ingy döt Net
|
|
7
7
|
Author-email: ingy@ingy.net
|
|
8
8
|
License: MIT
|
|
9
|
-
Description: UNKNOWN
|
|
10
9
|
Keywords: yaml,language
|
|
11
10
|
Platform: UNKNOWN
|
|
12
11
|
Classifier: Development Status :: 3 - Alpha
|
|
@@ -20,3 +19,6 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
20
19
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
20
|
Requires-Python: >=3.6, <4
|
|
22
21
|
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
UNKNOWN
|
|
24
|
+
|
yamlscript-0.0.1/ReadMe.md
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
yamlscript
|
|
2
|
-
==========
|
|
3
|
-
|
|
4
|
-
Programming in YAML
|
|
5
|
-
|
|
6
|
-
## Synopsis
|
|
7
|
-
```
|
|
8
|
-
#!/usr/bin/env yamlscript.py
|
|
9
|
-
- $greetee: world
|
|
10
|
-
- +say: Hello, $greetee!
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Status
|
|
14
|
-
|
|
15
|
-
This module is *very* **ALPHA**.
|
|
16
|
-
|
|
17
|
-
YAMLScript is still being defined.
|
|
18
|
-
|
|
19
|
-
Use with caution for now.
|
|
20
|
-
|
|
21
|
-
## Description
|
|
22
|
-
|
|
23
|
-
YAMLScript is a programming language encoded in YAML.
|
|
24
|
-
|
|
25
|
-
## License & Copyright
|
|
26
|
-
|
|
27
|
-
This project is licensed under the terms of the `MIT` license.
|
|
28
|
-
See [LICENSE](https://github.com/yaml/pyyaml-future/blob/main/LICENSE) for more
|
|
29
|
-
details.
|
|
30
|
-
|
|
31
|
-
Copyright 2022 Ingy döt Net <ingy@ingy.net>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
pass
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|