Python embedded DSL for generating shell scripts
Project description
Pyshup
Pyshup (pronounced “push-up”) is a Python embedded DSL for generating shell scripts.
Write structured Python code with Pythonic constructs that transpiles into portable, readable shell scripts.
Features
- Embedded DSL in Python for shell scripting
- context-manager driven AST builder
- Declarative control flow (
If,Else, loops) - Variables, commands, and output handling
- Generates clean, executable shell scripts
- Composable and structured, making scripts easier to maintain
Usage
from pyshup import Script, Variable, If, For, Command, Print
script = Script()
with script as s:
v1 = Variable('v1', 10)
v2 = Variable('v2', 20)
v3 = Variable('v3', 0)
v3.v = v1 + v2
with If(v3 == 30).Then() as c:
Print("They're Equal!")
with c.Else().Then() as c:
Print("Error, your cpu is bugged")
with For(v3.set(0), v3 < v1 + v2, v3.set(v3 + 1)).Then():
Print(v3)
script.write('./test.sh')
And the resulting generated shell:
v1=10
v2=20
v3=0
v3=$(("$v1" + "$v2"))
if [ $(("$v3" == 30)) -ne 0 ]; then
echo "They're Equal!"
else
echo "Error, your cpu is bugged!"
fi
v3=0
while [ $(("$v3" < $(("$v1" + "$v2")))) -ne 0 ]; do
echo "$v3"
v3=$(("$v3" + 1))
done
Installation
You can install Pyshup via pip:
pip install pyshup
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
pyshup-0.1.2.tar.gz
(22.5 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
pyshup-0.1.2-py3-none-any.whl
(23.0 kB
view details)
File details
Details for the file pyshup-0.1.2.tar.gz.
File metadata
- Download URL: pyshup-0.1.2.tar.gz
- Upload date:
- Size: 22.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4958998ad60542ad285e4b43c623709333993ba6d00b87c04e3de0ecbf41edd3
|
|
| MD5 |
c8624015786f1542dfa904a54e91cd3f
|
|
| BLAKE2b-256 |
583c49cd2d8ff9255fa8f65de37b80749b27fdc1b2149c3e572f600bd3b8fe17
|
File details
Details for the file pyshup-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pyshup-0.1.2-py3-none-any.whl
- Upload date:
- Size: 23.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19381f9d1328bd714a994f96053a49cd2d69a020685a5506638c5c68ef71c559
|
|
| MD5 |
9db366a834826634768772134e8d4612
|
|
| BLAKE2b-256 |
8e9a2e4ccd120d97a1791e8d6386470eba6c12d96795ec2318671409d4b3719c
|