Python syntactical sugar for embedded shell commands
Project description
Watiba
Watiba documentation can be found in doc/watiba.md
Watiba, pronounced wah-TEE-bah, is a lightweight Python pre-compiler for embedding Linux shell commands within Python applications. It is similar to other languages' syntactical enhancements where XML or HTML is integrated into a language such as JavaScript. That is the concept applied here but integrating BASH shell commands with Python.
As you browse this document, you'll find Watiba is rich with features for shell command integration with Python.
Features:
- Shell command integration with Python code
- Current directory context maintained across commands throughout your Python code
- Async/promise support for integrated shell commands
- Remote shell command execution
- Remote shell command chaining and piping
Usage
Watiba files, suffixed with ".wt", are Python programs containing embedded shell commands. Shell commands are expressed within backtick characters emulating BASH's original capture syntax. They can be placed in any Python statement or expression. Watiba keeps track of the current working directory after the execution of any shell command so that all subsequent shell commands keep context. For example:
#!/usr/bin/python3
if __name__ == "__main__":
`cd /tmp`
for l in `ls -lrt`.stdout:
print(l)
Installation
PIP
If you installed this as a Python package, e.g. pip, then the pre-compiler can be found where the package was installed. For example:
/home/{user}/.local/lib/python3.8/site-packages/watiba/watiba-c.py
This file can be copied to any directory in your PATH. It is stand-alone and can be copied anywhere you need.
GITHUB
If you cloned this from github, you'll still need to install the package with pip, first, for the watbia module. Follow these steps to install Watiba locally.
# Must install Watiba package
pip3 install watiba
# Now edit makefile and run make
cd {to where you git cloned watiba}/watiba
# 1. Edit makefile
# 2. Change the top two variables to your target destinations
# 3. venv = /home/rwalk/Projects/python3/venv/lib64/python3.8/site-packages/
# bin = /home/rwalk/bin/watiba-c
# -- CHANGE TO --
# venv = {your Python venv environment}
# bin = {your bin directory and file name}
# Execute command
make
Pre-compiling
Once you've installed watiba-c.py into your path, you can execute it to pre-compile your .wt (Watiba) code. Output will be written to STDOUT, so you'll need to redirect it to your final Python file. Example follows:
watiba-c.py my_file.wt > my_file.py
chmod +x my_file.py
./my_file.py
To show the Watiba version of your pre-compiler, enter:
watiba-c.py version
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
File details
Details for the file watiba-0.2.31.tar.gz.
File metadata
- Download URL: watiba-0.2.31.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.23.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
549b035a662c6055d58ac111e2400986d78abbf6bec3f713e90076b924d3622a
|
|
| MD5 |
2daaf981ba761c3f8455723e2be11162
|
|
| BLAKE2b-256 |
e568c637419d83c718c470e3b0e5143970ae4848159c4716d520cf23b52a3dd9
|