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
- 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(inject_capture=True)
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 bash:
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.1.tar.gz
(21.1 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.1-py3-none-any.whl
(21.9 kB
view details)
File details
Details for the file pyshup-0.1.1.tar.gz.
File metadata
- Download URL: pyshup-0.1.1.tar.gz
- Upload date:
- Size: 21.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2494756e5cbd619fbd564351a5fb772caa7d9ac2b2bd361d99de69ad7183b3c4
|
|
| MD5 |
8e1d437e66842d1c5d4421e2109741d5
|
|
| BLAKE2b-256 |
15ae09ac0f54a2dc8adae887b59c1d5fbc8ac7162bd636f6e0e34f4713295125
|
File details
Details for the file pyshup-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pyshup-0.1.1-py3-none-any.whl
- Upload date:
- Size: 21.9 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 |
35e9eae340742d49ab887e5164adf154e5e7fc07c44875ca420a2e4a95871046
|
|
| MD5 |
7517c9dddb5476f9c75e0d7875581016
|
|
| BLAKE2b-256 |
d3728488d7dfb4fd85118a3cd86eed5c218eba18b8d8c3ba4d580e87966d91fb
|