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]
Metadata
Release files for awl 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| awl-0.3.2.tar.gz | 22.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| awl-0.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.1 kB
Release files / awl-0.3.2.tar.gz
| Download URL | awl-0.3.2.tar.gz |
|---|---|
| Size | 22.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad0074e9fb9af41ef1bee8ba4144a7e2fb17be1a5915f8932406b9f278722c9c
|
|
BLAKE2b-256 checksum How to use checksums |
0c36090c38e897f40d14174247d17dfb0556c09d03e94a58aa7579a7848ca66b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / awl-0.3.2-py3-none-any.whl
| Download URL | awl-0.3.2-py3-none-any.whl |
|---|---|
| Size | 12.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bcad2300917789cd7054b54400af972d1f857d80719d3845de405f5de27826bb
|
|
BLAKE2b-256 checksum How to use checksums |
f18ed6fea8c34c931435ae3cc747993954e8e388c20de1d3689be6b99d5503b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|