prs
prs is a small utility that lets you pipe things to Python and process them in a list comprehension.
If you've ever wished you could manipulate items in your shell with a Python list comprehension, prs is for you.
Installation
Just pip install prs.
Usage
prs is simple. You pipe stuff into it from the shell, it exposes whatever is piped as a list called i (without final
newlines) to a script, and expects the script to return either a string or an iterable to a variable called o. That
variable is then printed to stdout, so you can pipe it to sh for execution.
$ ls -1
LICENSE
prs/
README.md
setup.cfg
setup.py
$ ls -1 | prs "o = [l.lower() for l in i]"
license
prs
readme.md
setup.cfg
setup.py
Multiple lines can be separated by a semicolon.
Various libraries are already imported (but feel free to import your own):
- os
- re
- sys
- pathlib.Path
Examples
Note: The examples here won't actually run the commands, they will just display them so you can see what will actually
run. To run the commands for real, just append | sh to each example.
Append .bak to all files in the current directory:
$ ls -1 | prs "o = ['mv {} {}.bak'.format(l, l) for l in i if Path(l).is_file()]"
mv LICENSE LICENSE.bak
mv README.md README.md.bak
mv setup.cfg setup.cfg.bak
mv setup.py setup.py.bak
Concatenate all entries into one:
02:28:39 $ ls -1 | prs "o = 'touch ' + ' '.join(i)"
touch LICENSE prs README.md setup.cfg setup.py
Completely ignore all input:
02:29:35 $ ls -1 | prs "o = 'hi'"
hi
Change the extension of all files in all subdirectories:
$ prs 'o = ["mv %s %s" % (l, l.with_suffix(".2py")) for l in Path(".").glob("**/*.py")]'
mv setup.py setup.2py
mv build/lib/prs/cli.py build/lib/prs/cli.2py
mv build/lib/prs/__init__.py build/lib/prs/__init__.2py
mv prs/cli.py prs/cli.2py
mv prs/__init__.py prs/__init__.2py
Metadata
Release files for prs 0.0.7
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 |
|---|---|---|---|---|
| prs-0.0.7.tar.gz | 3.2 kB | Without provenance | Details for prs-0.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| prs-0.0.7-py3-none-any.whl | Python 3 | none | any | Details for prs-0.0.7-py3-none-any.whl |
Total release size: 6.5 kB
Release files / prs-0.0.7.tar.gz
| Download URL | prs-0.0.7.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
93533805a87cb545b478148530513ed428f7e7402b90b4bf7f1f86ef50ceb795
|
|
BLAKE2b-256 checksum How to use checksums |
9f4bc66421e6b8f9bf4762800e6a32a1def7661cd388b34797d4528d15b9d2a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.9.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.6
|
Release files / prs-0.0.7-py3-none-any.whl
| Download URL | prs-0.0.7-py3-none-any.whl |
|---|---|
| Size | 3.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1e723f8b40ca4e241c86b483cb8588b4de888afe5dc8a1a0e789f7043447db6b
|
|
BLAKE2b-256 checksum How to use checksums |
be266c556b1723cb985ebb44498c16c8b427604a41c76ddf16b11714903ef142
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.9.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.6
|
Security for prs 0.0.7
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.