nix_shell_utils
simple shell-like commands for Python
nix_shell_utils is a collection of Python function wrappers around commonly used shell commands. The idea is to move all the small shell scripts heavily using cp, mkdir, rm and shell globbing that tend to be used for automation into one’s Python codebase.
The package is not multiplatform: it will only work in unix-like systems (only tested in Ubuntu & RHEL).
Dependencies
Python version required: 3.7+
If documentation is to be generated sphinx and sphinx_rtd_theme packages are required:
pip install sphinx sphinx_rtd_theme
Installation
Simply type
pip install nix_shell_utils
Documentation
Documentation can be found @ readthedocs
Examples
cp, cd, mkdir: the following python
from unix_shell_utils import *
dest = '$PRJ_HOME/sv/src'
src = '$PRJ_HOME/gen/sv/out'
mkdir(dest) # make destination folder
with cd(src): # change to src directory - returns automatically to current folder
cp('*.sv',dest) # copy all .sv files in src to dest folder
is equivalent to this shell code:
dest=$PRJ_HOME/sv/src
src=$PRJ_HOME/gen/sv/out
mkdir -p $dest
curdir=$PWD
cd $src
cp *.sv $dest
cd $curdir
removing files: the following code
with cd('$PRJ_HOME/logs/'):
rm('*.log')
is equivalent to the following shell commands:
curdir=$PWD
cd $PRJ_HOME/logs
rm -rf *.log
cd $curdir
temporary environment: the code under the tmpenv context manager
with tmpenv('HOME', FOO='BAR'):
print(os.environ['FOO'] # ==> 'BAR'
...
will modify temporarily the os.environ in place so that HOME env variable is deleted, and a new environment variable FOO is added. Upon leaving the with block, os.environ is returned to its prior state.
Development
clone this repository (or download a zip and unzip it somewhere)
git clone https://github.com/alb-garcia/nix_shell_utils.git
inside the cloned folder, make a editable installation
pip install -e .
To run tests (pytest needs to be installed):
cd test; pytest -vvv
Documentation Generation
To generate the documentation (assuming the clone repository lives @ $NIX_SHELL_UTILS_DIR:
cd $NIX_SHELL_UTILS_DIR/docs
make html
the documentation can be then accessed @ $NIX_SHELL_UTILS_DIR/docs/_build/html/index.htm
Metadata
Release files for nix-shell-utils 0.0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nix_shell_utils-0.0.12.tar.gz | 8.5 kB | Without provenance | Details for nix_shell_utils-0.0.12.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nix_shell_utils-0.0.12-py3-none-any.whl | Python 3 | none | any | Details for nix_shell_utils-0.0.12-py3-none-any.whl |
Total release size: 15.5 kB
Release files / nix_shell_utils-0.0.12.tar.gz
| Download URL | nix_shell_utils-0.0.12.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
36c787f3e0890145f018a1e33315b68fb080949f3fa04dcec6f8982ca6951c41
|
|
BLAKE2b-256 checksum How to use checksums |
7d4ce9b6179980ba2425caf1e32b84962e0b5432c45094bd3c85ee00435e06a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.6
|
Release files / nix_shell_utils-0.0.12-py3-none-any.whl
| Download URL | nix_shell_utils-0.0.12-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
629d723e1229d7fd803e7c7bd918e53e396eb1c23811bf8bcd88975a1829c07e
|
|
BLAKE2b-256 checksum How to use checksums |
216d2b7fe0da7d78ae0017646ac7dbb7d08674d231e93b75f59a0f3919432313
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.6
|
Security for nix-shell-utils 0.0.12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.