Python implementation of the Abstract Workflow Language (AWL / AWL-LD)
Project description
awl-python
Python implementation of the Abstract Workflow Language (AWL / AWL-LD)
Install
pip install awl
Usage
from awl import AstSerialization
ast_serialization = AstSerialization()
# python source code example
source = """if a == 1:
b = 1
else:
b = 'test'"""
# generate ast document
ast_dict = ast_serialization.parse(source)
print(ast_serialization.dumps())
# regenerate source code
src_code = ast_serialization.unparse(ast_dict)
assert src_code == source
# manipulate ast_dict: set b = 2
ast_dict["body"][0]["body"][0]["value"]["value"] = 2
src_code = ast_serialization.unparse(ast_dict)
assert src_code == """if a == 1:
b = 2
else:
b = 'test'"""
# export as json-ld
jsonld_doc = ast_serialization.to_jsonld()
# import into a graph
from rdflib import Graph
g = Graph()
g.parse(data=jsonld_doc, format="json-ld")
# dump graph as turtle
print(g.serialize(format="turtle"))
# query for all possible values of b
qres = g.query(
"""
PREFIX awl: <https://w3id.org/awl/schema/>
PREFIX ex: <https://example.org/>
SELECT ?v
WHERE {
?a a awl:Assign .
?a awl:HasTarget ex:b .
?a awl:HasValue ?v .
}
"""
)
possible_values = [row[0].toPython() for row in qres]
assert possible_values == [1, "test"]
Development
git clone https://github.com/OO-LD/awl-python
cd awl-python
pip install -e .[dev,testing]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
awl-0.3.2.tar.gz
(22.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
awl-0.3.2-py3-none-any.whl
(12.5 kB
view details)
File details
Details for the file awl-0.3.2.tar.gz.
File metadata
- Download URL: awl-0.3.2.tar.gz
- Upload date:
- Size: 22.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad0074e9fb9af41ef1bee8ba4144a7e2fb17be1a5915f8932406b9f278722c9c
|
|
| MD5 |
b0ca3eb3c33e85ddb7a5f1bb26cae338
|
|
| BLAKE2b-256 |
0c36090c38e897f40d14174247d17dfb0556c09d03e94a58aa7579a7848ca66b
|
File details
Details for the file awl-0.3.2-py3-none-any.whl.
File metadata
- Download URL: awl-0.3.2-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcad2300917789cd7054b54400af972d1f857d80719d3845de405f5de27826bb
|
|
| MD5 |
ec31b98b8ac7cf46f03dc2993d4a64db
|
|
| BLAKE2b-256 |
f18ed6fea8c34c931435ae3cc747993954e8e388c20de1d3689be6b99d5503b6
|