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.15.12.33.tar.gz
(9.5 kB
view hashes)
Built Distribution
Close
Hashes for shil-2023.7.15.12.33-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec2e3cd81a99388059da0f60148f76b6dd955be654ab1ca2544d496aadab5f7d |
|
MD5 | 7acd23b78c06bf2d5ffa7570ec3b7efc |
|
BLAKE2b-256 | 275ab6b110bba0d0ac52be9ce6239d3eec24e87345c86e61a30bd76cf0d3e608 |