Shell helper utilities for python
Project description
shil | |
Shell-util library for python. Includes helpers for subprocess invocation, shell-formatters / pretty-printers, and more. |
Overview
The shil
library provides various shell-utilities for python.
Features
- Helpers for subprocess invocation
- Shell-formatters / pretty-printers
- A somewhat usable parser / grammer for bash
- Support or rich protocols
Installation
See pypi for available releases.
pip install shil
Usage
See also:
- the unit-tests for some examples of library usage
- the smoke-tests for example usage of stand-alone scripts
import shil
import json
# Working with models for Invocation/InvocationResponse:
req = cmd = shil.Invocation(command='ls /tmp')
resp = cmd()
print(resp.stdout)
# More functional approach:
resp = shil.invoke('ls /tmp')
# Loading data when command-output is JSON
req = cmd = shil.Invocation(command='echo {"foo":"bar"}')
resp = cmd()
print(resp.data)
assert type(resp.data)==type({})
# Uses pydantic, so serialization is straightforward
json.loads(resp.json())
json.loads(req.json())
for k,v in req.dict().items():
assert getattr(resp,k)==v
# Rich console output for Invocations and InvocationResponse
import rich
rich.print(resp)
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
shil-2023.7.17.7.1.tar.gz
(9.8 kB
view hashes)
Built Distribution
Close
Hashes for shil-2023.7.17.7.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb2833998ef10058dbf94d3d48f64570f5eb1f53739679e3572f1336e0daa56c |
|
MD5 | 0679c1b3ec9cfe177d3854ac32ce8554 |
|
BLAKE2b-256 | 1759c68c14e10b52101db82d526e97a0f01f918daf992e93d96f8f249c806163 |