rill
Python library providing simple text-stream processing functionality
Table of contents
Introduction
With grep, sed, wc, cat, sort, uniq, head, tail, tr, etc., we have a set of extremely powerful and time-proven tools for pipeline-processing text on the command line ubiquitously available.
But some tasks that start out as a simple one-liner, over time, can mutate into a mess ("write-only code"), especially if the requirements grow or some edge cases need special handling, such that having things in a "normal" programming language would be more convenient.
This is where rill comes into play. It provides simple text-stream processing functionality in Python. And while it is much less powerful (features and throughput, hence the name "rill") compared to the good old Unix tools, there is the advantage that one-liners written using rill can easily be expanded to longer Python scripts.
Also, in case one is already familiar with Python, but not (yet) with the Unix tools, it can be a somewhat more convenient entry point to text-stream processing.
Examples
Assuming you have an example_input.txt like so:
Hello, fellow dev,
this test file helps to show
the thrilling things
you can do with rill. ;)
You can do stuff like the following:
# Drop all lines not containing "rill", and replace "rill" with "RILL".
python3 -c 'import rill; rill.inp().grep("rill").replace("rill", "RILL").show()' example_input.txt
# Same as: grep rill example_input.txt | sed 's/rill/RILL/g'
Output:
the thRILLing things
you can do with RILL. ;)
# Count the number of lines containing an "e".
python3 -c 'import rill; rill.inp().grep("e").line_count().show()' example_input.txt
# Same as: cat example_input.txt | grep e | wc -l
Output:
3
You can also use it as part of normal Unix pipelines, e.g.:
cat example_input.txt | grep 'rill' | python3 -c 'import rill; rill.inp().replace("rill", "RILL").show()'
Output:
the thRILLing things
you can do with RILL. ;)
And extend your script infinitely, e.g.:
cat example_input.txt | python3 -c 'import rill
import codecs
def caesar(text):
return str(codecs.encode(text, "rot_13"))
rill.inp().grep("rill").map_lines(caesar).show()'
Output:
gur guevyyvat guvatf
lbh pna qb jvgu evyy. ;)
At this point, it probably makes sense to move your code into a file and use it like a normal Python script.
python3 my_script.py example_input.txt
Requirements and Installation
pip install rill
Or, if you like to use the latest version from this repository:
git clone https://github.com/Dobiasd/rill
cd rill
pip install .
License
Distributed under the MIT License.
(See accompanying file LICENSE or at
https://opensource.org/licenses/MIT)
Metadata
Release files for rill 0.1.2
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 |
|---|---|---|---|---|
| rill-0.1.2.tar.gz | 4.3 kB | Without provenance | Details for rill-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rill-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for rill-0.1.2-py3-none-any.whl |
Total release size: 9.7 kB
Release files / rill-0.1.2.tar.gz
| Download URL | rill-0.1.2.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
167cb816141afedd08e2ec81fa334ce278d824ecd88776c7024a802479cf1fcc
|
|
BLAKE2b-256 checksum How to use checksums |
6e5cc66551e64b9173890f697222d02f41a87ca67d2c6967a464a6d5d3b51e19
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.27.1 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
|
Release files / rill-0.1.2-py3-none-any.whl
| Download URL | rill-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5ebc90228304ba3ed4a50a57101f7243518e492695b928e619421193cccd6acf
|
|
BLAKE2b-256 checksum How to use checksums |
98b53866515945259377c6a70feab8a26de07e5a8d0e4537186ddc6d75d6956a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.27.1 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
|
Security for rill 0.1.2
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.