A sUTL implementation for python
Project description
# sUTL_py
sUTL Universal Transform Language for Python
This is a python implementation of sUTL. See the [sUTL spec](https://github.com/emlynoregan/sUTL-spec) here.
Import sUTL like this:
from sUTL_py import sUTL
Evaluate a transform like this:
transform = {
"&": "+",
"a": "^@",
"b": 5
}
source = 6
result = sUTL.evaluate(source, transform, {})
# here result is 11
To use library distributions, do the following:
1: Load the libraries. The following loads the core library.
coreString = urllib2.urlopen("http://emlynoregan.github.io/sUTL-spec/sUTL_core.json").read()
distributions = [json.loads(coreString)]
2: Add your transform to a declaration
transform = {
"&": "map_core",
"list": "^@",
"t": {":": {
"&": "+",
"a": "^@.item",
"b": 1
}}
}
declaration = {
"transform-t": transform,
"requires": ["map_core"]
}
3: Compile a set of libraries from the distribution
lib = sUTL.compilelib([declaration], distributions, false)
4: Evaluate your transform
source = [1, 2, 3, 4]
result = sUTL.evaluate(source, transform, lib)
# here result is [2, 3, 4, 5]
sUTL Universal Transform Language for Python
This is a python implementation of sUTL. See the [sUTL spec](https://github.com/emlynoregan/sUTL-spec) here.
Import sUTL like this:
from sUTL_py import sUTL
Evaluate a transform like this:
transform = {
"&": "+",
"a": "^@",
"b": 5
}
source = 6
result = sUTL.evaluate(source, transform, {})
# here result is 11
To use library distributions, do the following:
1: Load the libraries. The following loads the core library.
coreString = urllib2.urlopen("http://emlynoregan.github.io/sUTL-spec/sUTL_core.json").read()
distributions = [json.loads(coreString)]
2: Add your transform to a declaration
transform = {
"&": "map_core",
"list": "^@",
"t": {":": {
"&": "+",
"a": "^@.item",
"b": 1
}}
}
declaration = {
"transform-t": transform,
"requires": ["map_core"]
}
3: Compile a set of libraries from the distribution
lib = sUTL.compilelib([declaration], distributions, false)
4: Evaluate your transform
source = [1, 2, 3, 4]
result = sUTL.evaluate(source, transform, lib)
# here result is [2, 3, 4, 5]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sUTL-1.0.5b7.tar.gz
(7.6 kB
view hashes)
Built Distribution
Close
Hashes for sUTL-1.0.5b7-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5025406901f82d5de0fb16fad2dd534f98bcfbe7742db2c4ac72d60cdfc29bec |
|
MD5 | a188f839f07ab11750e22b1d0067def0 |
|
BLAKE2b-256 | 9b935f42ea1b14cfb4b825f5be8042b911732f4ad7a674d7486631e49c7e0afc |