Name
jjcli - python module for command-line filter
Synopsis
as ascript:
jjcli skel ## a initial filter skeleton
jjcli ## manual
as a module:
from jjcli import * ## re.* functions also imported
cl=clfilter(opt="do:", doc=__doc__)
## options in cl.opt (...if "-d" in cl.opt:)
## autostrip (def=True)
## inplace (def=False)
## fs (for csvrow()) (def=",")
## doc=__doc__ (for --help)
## longopts=["op1",...]
for line in cl.input():... ## process one rstriped line at the time
for txt in cl.text():... ## process one striped text at the time
## process txt ## (end of line spaces and \\r also removed)
for par in cl.paragraph():... ## process one striped paragraph at the time
for tup in cl.csvrow():... ## process one csv row at the time
for tup in cl.tsvrow():... ## process one tsv row at the time
cl.lineno() ## line number
cl.filelineno()
cl.parno() ## paragraph number
cl.fileparno()
cl.filename() ## filename or "<stdin>"
cl.nextfile()
cl.isfirstline()
cl.args cl.opt ## command line arguments and options (after clfilter())
Description
jjcli is a opinioned Python module that tries to simplify the creation of unix filters. It is based on:
- getopt (for command line options and args)
- fileinput (for [files/stdin] arguments)
- re (regular expressions should be native)
- glob (glob.glob should be native)
- csv (for csv and tsv inputs)
- urllib.request (to deal with input argumens that are url)
- subprocess
Regular expressions
We want to have all re.* functions available (as if they were native functions).
In order to enable re flags, use: re.I re.X re.S
Subprocesses (qx, qxlines, qxsystem, qxerr)
a=qx( "ls" )
for x in qxlines("find | grep '\.jpg$'"):
...
qxsystem("vim myfile")
Execute command return its stdout-str
qx(*x) → returns subprocess.getoutput(x)
Execute command return its stdout-str lines
qxlines(*x) → returns subprocess.getoutput(x).splitlines()
Execute command and return its (stdout-str, stderr-str)
out,err = qxexec(*x) → returns Popen(x,PIPE, PIPE,shell=True).communicate()
STDERR - warn, die
warn(*args) → print to stderr
die(*args) → warn and exit 1
Other functions
slurpurlutf8(self,f)
filename = lambda s : F.filename() # inherited from fileinput
lineno = lambda s : F.lineno()
filelineno = lambda s : F.filelineno()
parno = lambda s : s.parno_ # paragraph number
fileparno = lambda s : s.fileparno_
nextfile = lambda s : F.nextfile()
isfirstline = lambda s : F.isfirstline()
isfirstpar = lambda s : s.fileparno == 1
close = lambda s : F.close()
Metadata
Release files for jjcli 0.1.29
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 | |
|---|---|---|---|---|
| jjcli-0.1.29.tar.gz | 5.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jjcli-0.1.29-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 11.1 kB
Release files / jjcli-0.1.29.tar.gz
| Download URL | jjcli-0.1.29.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
33302441fa91ee016ac761202dd72032af593f60a4ab627291e777ce44fd1eb9
|
|
BLAKE2b-256 checksum How to use checksums |
3f8f9e6f95709709f4e234f9d3357333641b8d14f5f8e60ab5fe3d08086760eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.28.1
|
Release files / jjcli-0.1.29-py2.py3-none-any.whl
| Download URL | jjcli-0.1.29-py2.py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
676780b2ff911d9439340297495bdd6734068f0d634bd3f5f5037ef7c430e68b
|
|
BLAKE2b-256 checksum How to use checksums |
1debbea7274b1595158dff39800c61611342f25f43c959a87b3478d535f91369
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.28.1
|
Security for jjcli 0.1.29
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.