# Name
Project description
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
c=clfilter(opt="do:") ## options in c.opt (...if "-d" in c.opt:)
## autostrip (def=True)
## inplace (def=False)
## fs (for csvrow()) (def=",")
for line in c.input():... ## process one rstriped line at the time
for txt in c.slurp():... ## process one striped text at the time
## process txt ## (end of line spaces and \r also removed)
for par in c.paragraph():... ## process one striped paragraph at the time
for tup in c.csvrow():... ## process one csv row at the time
for tup in c.tsvrow():... ## process one tsv row at the time
c.lineno() ## line number
c.filelineno()
c.parno() ## paragraph number
c.fileparno()
c.filename() ## filename or "<stdin>"
c.nextfile()
c.isfirstline()
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)
- 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)
a=qx( "ls" )
for x in qxlines("find | grep '\.jpg$'"):
...
qxsystem("vim myfile")
Execute command return its stdout
qx(*x) → returns subprocess.getoutput(x)
Execute command return its stdout lines
qxlines(*x) → returns subprocess.getoutput(x).splitlines()
Execute command -- system
qxsystem(*x) → calls subprocess.call(x,shell=True)
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()
close = lambda s : F.close()
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jjcli-0.1.17.tar.gz.
File metadata
- Download URL: jjcli-0.1.17.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.23.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
422b1039e4a7bbcbdc3bfd60a43162a650e4aa2a4585969133637143f966d4a2
|
|
| MD5 |
e60679237426c5f2a6e48453c5aebd11
|
|
| BLAKE2b-256 |
a3b8ba60b03bc965c4f5f6f7531df3f3275daa2362d93b60ed84da67a70a767b
|
File details
Details for the file jjcli-0.1.17-py2.py3-none-any.whl.
File metadata
- Download URL: jjcli-0.1.17-py2.py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.23.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4eb87e2246e5f84950d86c17ed4c6cb664bc66908585ae9d106f7d8c5181804
|
|
| MD5 |
e9430a804c4a07b244ec3ca6baecf8d7
|
|
| BLAKE2b-256 |
ab3660f8368b7fe91b6b851ea83f26035e7bd240340935352260902e45db9915
|