1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2026-04-03 17:44:07 +02:00

Compare commits

...

55 Commits

Author SHA1 Message Date
Kelly Brazil
9e3b88727c Merge pull request #91 from kellyjonbrazil/dev
Dev v1.14.0
2020-12-31 16:40:36 -08:00
Kelly Brazil
b12217466e spelling 2020-12-31 16:37:47 -08:00
Kelly Brazil
8b9c932f9b update date 2020-12-31 16:37:14 -08:00
Kelly Brazil
5986ce03db add printenv info 2020-12-31 16:36:27 -08:00
Kelly Brazil
a7b0e936e4 add vdir and printenv info 2020-12-31 14:21:24 -08:00
Kelly Brazil
cb02211424 add wc tests 2020-12-31 14:19:45 -08:00
Kelly Brazil
bd443bf392 add printenv to env docs 2020-12-31 14:11:25 -08:00
Kelly Brazil
1f547edd36 add printenv to env docs 2020-12-31 14:10:56 -08:00
Kelly Brazil
e4bac3a493 add wc parser 2020-12-31 14:10:37 -08:00
Kelly Brazil
5e6bfa681a add vdir info 2020-12-31 13:18:53 -08:00
Kelly Brazil
276160125e add new commands to README 2020-12-30 14:04:49 -08:00
Kelly Brazil
d4ae5543f2 add hash tests 2020-12-30 13:11:13 -08:00
Kelly Brazil
55f360e267 add hash command parser 2020-12-30 12:58:52 -08:00
Kelly Brazil
fdedab2a0c description updates 2020-12-30 11:33:29 -08:00
Kelly Brazil
a9be42e303 specify parser warnings for quiet option 2020-12-30 11:28:42 -08:00
Kelly Brazil
6da9510e46 add cksum tests 2020-12-30 11:22:17 -08:00
Kelly Brazil
0431798178 add cksum parser 2020-12-30 11:02:02 -08:00
Kelly Brazil
62432f3c48 update hashsum description 2020-12-30 09:59:54 -08:00
Kelly Brazil
9fbbc30906 add supported commands to docs 2020-12-29 13:09:03 -08:00
Kelly Brazil
d1567d1f62 add hashsum documentation 2020-12-29 13:05:04 -08:00
Kelly Brazil
6ca1f5970b Merge branch 'dev' of https://github.com/kellyjonbrazil/jc into dev 2020-12-29 12:59:02 -08:00
Kelly Brazil
1c880b9e24 force git tests 2020-12-29 12:58:04 -08:00
Kelly Brazil
3b7d54c720 add python 3.9 2020-12-29 12:55:30 -08:00
Kelly Brazil
44a7406057 add hashsum tests 2020-12-29 12:51:43 -08:00
Kelly Brazil
8157dcfdb1 fix for files with spaces in the name 2020-12-29 12:25:20 -08:00
Kelly Brazil
28762aea15 add hashsum parser 2020-12-29 11:36:20 -08:00
Kelly Brazil
439871ea9f add ubuntu 2020-11-19 07:07:30 -08:00
Kelly Brazil
c9180b005c formatting 2020-08-30 11:58:42 -07:00
Kelly Brazil
b14e0725f8 add ansible plugin blog post link 2020-08-30 11:57:55 -07:00
Kelly Brazil
70fe3dcb4d formatting 2020-08-26 15:21:45 -07:00
Kelly Brazil
8c554604a4 formatting 2020-08-26 14:41:01 -07:00
Kelly Brazil
a0a35454bd add link to the web demo 2020-08-26 14:39:40 -07:00
Kelly Brazil
e8467e2af5 remove extra space 2020-08-20 10:57:13 -07:00
Kelly Brazil
7515deb566 add ansible install command 2020-08-20 10:39:34 -07:00
Kelly Brazil
ed9e52af24 spelling 2020-08-20 10:37:15 -07:00
Kelly Brazil
592a380410 add Ansible note 2020-08-20 10:35:49 -07:00
Kelly Brazil
1a458d2d5b update link 2020-08-11 07:00:07 -07:00
Kelly Brazil
0e4cf53b92 add parser docs link 2020-08-11 06:36:30 -07:00
Kelly Brazil
e2f06ccb33 formatting 2020-08-06 13:00:33 -07:00
Kelly Brazil
8abff004cd indentation fix 2020-08-06 12:59:30 -07:00
Kelly Brazil
c4a0e2e3fe fix indentation 2020-08-06 12:58:53 -07:00
Kelly Brazil
4f10f79c73 standardize doc 2020-08-06 12:55:24 -07:00
Kelly Brazil
69e7a560fd add output info to docs 2020-08-06 07:48:08 -07:00
Kelly Brazil
59b1055808 enhance docs 2020-08-05 16:51:58 -07:00
Kelly Brazil
6ed48c6289 enhance docs 2020-08-05 15:34:17 -07:00
Kelly Brazil
f2fb4d3f41 improve docs 2020-08-05 15:10:48 -07:00
Kelly Brazil
6aeea59ea8 doc updates 2020-08-05 15:08:42 -07:00
Kelly Brazil
d016f3bbb3 improve documentation 2020-08-05 15:07:33 -07:00
Kelly Brazil
7131c29718 add module usage info to docs 2020-08-05 13:32:59 -07:00
Kelly Brazil
7432442983 add usage 2020-08-05 13:31:52 -07:00
Kelly Brazil
5344883394 spelling/add ping parser update 2020-08-05 11:35:52 -07:00
Kelly Brazil
3fcd2f6c2e version bump 2020-08-05 11:34:29 -07:00
Kelly Brazil
f3d84bd5bf tighten crontab and crontab-u parser variable detection 2020-08-05 11:28:37 -07:00
Kelly Brazil
549780c232 add debian/apt-get info 2020-08-05 11:04:07 -07:00
Kelly Brazil
2a6da69b82 improve linux/bsd check 2020-08-05 09:58:01 -07:00
164 changed files with 3627 additions and 452 deletions

View File

@@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: [3.6, 3.7, 3.8]
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2

View File

@@ -1,7 +1,20 @@
jc changelog
20201231 v1.14.0
- Add hashsum parser tested on linux, macos
- Add hash parser tested on linux, macos
- Add cksum parser tested on linux, macos
- Add wc parser tested on linux, macos
- Add printenv support under env parser
- Add vdir support under ls parser
- Add python 3.9 to github automation tests
20200805 v1.13.4
- Update crontab and crontab-u parsers to tighten up variable detection
- Update ping parser to tighten linux/bsd detection
20200804 v1.13.3
- Updae ping parser for Raspberry Pi compatibility
- Update ping parser for Raspberry Pi compatibility
20200803 v1.13.2
- Add key/value file parser (wrapper for ini parser)

View File

@@ -175,6 +175,29 @@ blkid -o udev -ip /dev/sda2 | jc --blkid -p # or: jc -p blkid -o udev
}
]
```
### cksum
```bash
cksum * | jc --cksum -p # or: jc -p cksum *
```
```json
[
{
"filename": "__init__.py",
"checksum": 4294967295,
"blocks": 0
},
{
"filename": "airport.py",
"checksum": 2208551092,
"blocks": 3745
},
{
"filename": "airport_s.py",
"checksum": 1113817598,
"blocks": 4572
}
]
```
### crontab
```bash
cat /etc/crontab | jc --crontab -p # or: jc -p crontab -l
@@ -843,6 +866,54 @@ cat /etc/gshadow | jc --gshadow -p
}
]
```
### hash
```bash
hash | jc --hash -p
```
```json
[
{
"hits": 2,
"command": "/bin/cat"
},
{
"hits": 1,
"command": "/bin/ls"
}
]
```
### hashsum
```bash
md5sum * | jc --hashsum -p # or: jc -p md5sum *
```
```json
[
{
"filename": "devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm",
"hash": "65fc958c1add637ec23c4b137aecf3d3"
},
{
"filename": "digout",
"hash": "5b9312ee5aff080927753c63a347707d"
},
{
"filename": "dmidecode.out",
"hash": "716fd11c2ac00db109281f7110b8fb9d"
},
{
"filename": "file with spaces in the name",
"hash": "d41d8cd98f00b204e9800998ecf8427e"
},
{
"filename": "id-centos.out",
"hash": "4295be239a14ad77ef3253103de976d2"
},
{
"filename": "ifcfg.json",
"hash": "01fda0d9ba9a75618b072e64ff512b43"
}
]
```
### history
```bash
history | jc --history -p
@@ -2469,6 +2540,32 @@ w | jc --w -p # or: jc -p w
}
]
```
### wc
```bash
wc * | jc --wc -p # or: jc -p wc *
```
```json
[
{
"filename": "airport-I.json",
"lines": 1,
"words": 30,
"characters": 307
},
{
"filename": "airport-I.out",
"lines": 15,
"words": 33,
"characters": 348
},
{
"filename": "airport-s.json",
"lines": 1,
"words": 202,
"characters": 2152
}
]
```
### who
```bash
who | jc --who -p # or: jc -p who

View File

@@ -1,6 +1,10 @@
![Tests](https://github.com/kellyjonbrazil/jc/workflows/Tests/badge.svg?branch=master)
![Pypi](https://img.shields.io/pypi/v/jc.svg)
> Try the new `jc` [web demo](https://jc-web-demo.herokuapp.com/)!
> JC is [now available](https://galaxy.ansible.com/community/general) as an Ansible filter plugin in the `community.general` collection! See this [blog post](https://blog.kellybrazil.com/2020/08/30/parsing-command-output-in-ansible-with-jc/) for an example.
# JC
JSON CLI output utility
@@ -79,7 +83,7 @@ See also:
- [blog: linux apps should have a json flag](https://thomashunter.name/posts/2012-06-06-linux-cli-apps-should-have-a-json-flag)
## Installation
There are several ways to get `jc`. You can install via `pip`; other OS package repositories like `dnf`, `zypper`, `pacman`, `nix-env`, `guix`, `brew`, or `portsnap`; via DEB/RPM packages; or by downloading the correct binary for your architecture and running it anywhere on your filesystem.
There are several ways to get `jc`. You can install via `pip`; other OS package repositories like `apt-get`, `dnf`, `zypper`, `pacman`, `nix-env`, `guix`, `brew`, or `portsnap`; via DEB/RPM packages; or by downloading the correct binary for your architecture and running it anywhere on your filesystem.
### Pip (macOS, linux, unix, Windows)
```bash
@@ -90,6 +94,7 @@ pip3 install jc
| OS | Command |
|-----------------------|-------------------------------------------------------------------------------|
| Debian/Ubuntu linux | `apt-get install jc` |
| Fedora linux | `dnf install jc` |
| openSUSE linux | `zypper install jc` |
| Arch linux | `pacman -S jc` |
@@ -97,6 +102,7 @@ pip3 install jc
| Guix System linux | `guix install jc` |
| MacOS | `brew install jc` |
| FreeBSD | `portsnap fetch update && cd /usr/ports/textproc/py-jc && make install clean` |
| Ansible filter plugin | `ansible-galaxy collection install community.general` |
> For more packages and binaries, see https://kellyjonbrazil.github.io/jc-packaging/.
@@ -116,6 +122,7 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio
- `--airport-s` enables the `airport -s` command parser (OSX)
- `--arp` enables the `arp` command parser
- `--blkid` enables the `blkid` command parser
- `--cksum` enables the `cksum` and `sum` command parser
- `--crontab` enables the `crontab` command and file parser
- `--crontab-u` enables the `crontab` file parser with user support
- `--csv` enables the `CSV` file parser
@@ -124,12 +131,14 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio
- `--dig` enables the `dig` command parser
- `--dmidecode` enables the `dmidecode` command parser
- `--du` enables the `du` command parser
- `--env` enables the `env` command parser
- `--env` enables the `env` and `printenv` command parser
- `--file` enables the `file` command parser
- `--free` enables the `free` command parser
- `--fstab` enables the `/etc/fstab` file parser
- `--group` enables the `/etc/group` file parser
- `--gshadow` enables the `/etc/gshadow` file parser
- `--hash` enables the `hash` command parser
- `--hashsum` enables the `hashsum` command parser (`md5sum`, `shasum`, etc.)
- `--history` enables the `history` command parser
- `--hosts` enables the `/etc/hosts` file parser
- `--id` enables the `id` command parser
@@ -139,7 +148,7 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio
- `--jobs` enables the `jobs` command parser
- `--kv` enables the `Key/Value` file parser
- `--last` enables the `last` and `lastb` command parser
- `--ls` enables the `ls` command parser
- `--ls` enables the `ls` and `vdir` command parser
- `--lsblk` enables the `lsblk` command parser
- `--lsmod` enables the `lsmod` command parser
- `--lsof` enables the `lsof` command parser
@@ -166,6 +175,7 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio
- `--uname` enables the `uname -a` command parser
- `--uptime` enables the `uptime` command parser
- `--w` enables the `w` command parser
- `--wc` enables the `wc` command parser
- `--who` enables the `who` command parser
- `--xml` enables the `XML` file parser
- `--yaml` enables the `YAML` file parser

View File

@@ -9,6 +9,7 @@ pydocmd simple jc.parsers.airport+ > ../docs/parsers/airport.md
pydocmd simple jc.parsers.airport_s+ > ../docs/parsers/airport_s.md
pydocmd simple jc.parsers.arp+ > ../docs/parsers/arp.md
pydocmd simple jc.parsers.blkid+ > ../docs/parsers/blkid.md
pydocmd simple jc.parsers.cksum+ > ../docs/parsers/cksum.md
pydocmd simple jc.parsers.crontab+ > ../docs/parsers/crontab.md
pydocmd simple jc.parsers.crontab_u+ > ../docs/parsers/crontab_u.md
pydocmd simple jc.parsers.csv+ > ../docs/parsers/csv.md
@@ -23,6 +24,8 @@ pydocmd simple jc.parsers.free+ > ../docs/parsers/free.md
pydocmd simple jc.parsers.fstab+ > ../docs/parsers/fstab.md
pydocmd simple jc.parsers.group+ > ../docs/parsers/group.md
pydocmd simple jc.parsers.gshadow+ > ../docs/parsers/gshadow.md
pydocmd simple jc.parsers.hash+ > ../docs/parsers/hash.md
pydocmd simple jc.parsers.hashsum+ > ../docs/parsers/hashsum.md
pydocmd simple jc.parsers.history+ > ../docs/parsers/history.md
pydocmd simple jc.parsers.hosts+ > ../docs/parsers/hosts.md
pydocmd simple jc.parsers.id+ > ../docs/parsers/id.md

View File

@@ -1,13 +1,21 @@
# jc.parsers.airport
jc - JSON CLI output utility airport -I Parser
jc - JSON CLI output utility `airport -I` command output parser
Usage:
The `airport` program can be found at `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport`.
specify --airport as the first argument if the piped input is coming from airport -I (OSX)
Usage (cli):
This program can be found at:
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport
$ airport -I | jc --airport
or
$ jc airport -I
Usage (module):
import jc.parsers.airport
result = jc.parsers.airport.parse(airport_command_output)
Compatibility:

View File

@@ -1,13 +1,21 @@
# jc.parsers.airport_s
jc - JSON CLI output utility airport -s Parser
jc - JSON CLI output utility `airport -s` command output parser
Usage:
The `airport` program can be found at `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport`.
specify --airport as the first argument if the piped input is coming from airport -s (OSX)
Usage (cli):
This program can be found at:
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport
$ airport -s | jc --airport-s
or
$ jc airport -s
Usage (module):
import jc.parsers.airport_s
result = jc.parsers.airport_s.parse(airport_s_command_output)
Compatibility:

View File

@@ -1,14 +1,21 @@
# jc.parsers.arp
jc - JSON CLI output utility arp Parser
jc - JSON CLI output utility `arp` command output parser
Usage:
Supports `arp` and `arp -a` output.
specify --arp as the first argument if the piped input is coming from:
Usage (cli):
arp
or
arp -a
$ arp | jc --arp
or
$ jc arp
Usage (module):
import jc.parsers.arp
result = jc.parsers.arp.parse(arp_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.blkid
jc - JSON CLI output utility blkid Parser
jc - JSON CLI output utility `blkid` command output parser
Usage:
Usage (cli):
specify --blkid as the first argument if the piped input is coming from blkid
$ blkid | jc --blkid
or
$ jc blkid
Usage (module):
import jc.parsers.blkid
result = jc.parsers.blkid.parse(blkid_command_output)
Compatibility:

95
docs/parsers/cksum.md Normal file
View File

@@ -0,0 +1,95 @@
# jc.parsers.cksum
jc - JSON CLI output utility `cksum` command output parser
This parser works with the following checksum calculation utilities:
- `sum`
- `cksum`
Usage (cli):
$ cksum file.txt | jc --cksum
or
$ jc cksum file.txt
Usage (module):
import jc.parsers.cksum
result = jc.parsers.cksum.parse(cksum_command_output)
Compatibility:
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
Examples:
$ cksum * | jc --cksum -p
[
{
"filename": "__init__.py",
"checksum": 4294967295,
"blocks": 0
},
{
"filename": "airport.py",
"checksum": 2208551092,
"blocks": 3745
},
{
"filename": "airport_s.py",
"checksum": 1113817598,
"blocks": 4572
},
...
]
## info
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"filename": string,
"checksum": integer,
"blocks": integer
}
]
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of dictionaries. Raw or processed structured data.

View File

@@ -1,10 +1,21 @@
# jc.parsers.crontab
jc - JSON CLI output utility crontab command and file Parser
jc - JSON CLI output utility `crontab -l` command output and crontab file parser
Usage:
Supports `crontab -l` command output and crontab files.
specify --crontab as the first argument if the piped input is coming from crontab -l or a crontab file
Usage (cli):
$ crontab -l | jc --crontab
or
$ jc crontab -l
Usage (module):
import jc.parsers.crontab
result = jc.parsers.crontab.parse(crontab_output)
Compatibility:

View File

@@ -1,10 +1,17 @@
# jc.parsers.crontab_u
jc - JSON CLI output utility crontab file Parser
jc - JSON CLI output utility `crontab -l` command output and crontab file parser
Usage:
This version of the `crontab -l` parser supports output that contains user information for processes.
specify --crontab-u as the first argument if the piped input is coming from a crontab file with User specified
Usage (cli):
$ crontab -l | jc --crontab-u
Usage (module):
import jc.parsers.crontab_u
result = jc.parsers.crontab_u.parse(crontab_u_output)
Compatibility:

View File

@@ -1,13 +1,17 @@
# jc.parsers.csv
jc - JSON CLI output utility csv Parser
jc - JSON CLI output utility `csv` file parser
Usage:
The `csv` parser will attempt to automatically detect the delimiter character. If the delimiter cannot be detected it will default to comma. The first row of the file must be a header row.
specify --csv as the first argument if the piped input is coming from a csv file.
the csv parser will attempt to automatically detect the delimiter character.
if the delimiter cannot be detected it will default to comma.
the first row of the file must be a header row.
Usage (cli):
$ cat file.csv | jc --csv
Usage (module):
import jc.parsers.csv
result = jc.parsers.csv.parse(csv_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.date
jc - JSON CLI output utility date Parser
jc - JSON CLI output utility `date` command output parser
Usage:
Usage (cli):
specify --date as the first argument if the piped input is coming from date
$ date | jc --date
or
$ jc date
Usage (module):
import jc.parsers.date
result = jc.parsers.date.parse(date_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.df
jc - JSON CLI output utility df Parser
jc - JSON CLI output utility `df` command output parser
Usage:
Usage (cli):
specify --df as the first argument if the piped input is coming from df
$ df | jc --df
or
$ jc df
Usage (module):
import jc.parsers.df
result = jc.parsers.df.parse(df_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.dig
jc - JSON CLI output utility dig Parser
jc - JSON CLI output utility `dig` command output parser
Usage:
Usage (cli):
Specify --dig as the first argument if the piped input is coming from dig
$ dig example.com | jc --dig
or
$ jc dig example.com
Usage (module):
import jc.parsers.dig
result = jc.parsers.dig.parse(dig_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.dmidecode
jc - JSON CLI output utility dmidecode Parser
jc - JSON CLI output utility `dmidecode` command output parser
Usage:
Usage (cli):
specify --dmidecode as the first argument if the piped input is coming from dmidecode
$ dmidecode | jc --dmidecode
or
$ jc dmidecode
Usage (module):
import jc.parsers.dmidecode
result = jc.parsers.dmidecode.parse(dmidecode_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.du
jc - JSON CLI output utility du Parser
jc - JSON CLI output utility `du` command output parser
Usage:
Usage (cli):
specify --du as the first argument if the piped input is coming from du
$ du | jc --du
or
$ jc du
Usage (module):
import jc.parsers.du
result = jc.parsers.du.parse(du_command_output)
Compatibility:

View File

@@ -1,10 +1,21 @@
# jc.parsers.env
jc - JSON CLI output utility env Parser
jc - JSON CLI output utility `env` and `printenv` command output parser
Usage:
This parser will output a list of dictionaries each containing `name` and `value` keys. If you would like a simple dictionary output, then use the `-r` command-line option or the `raw=True` argument in the `parse()` function.
specify --env as the first argument if the piped input is coming from env
Usage (cli):
$ env | jc --env
or
$ jc env
Usage (module):
import jc.parsers.env
result = jc.parsers.env.parse(env_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.file
jc - JSON CLI output utility file command Parser
jc - JSON CLI output utility `file` command output parser
Usage:
Usage (cli):
specify --file as the first argument if the piped input is coming from file.
$ file * | jc --file
or
$ jc file *
Usage (module):
import jc.parsers.file
result = jc.parsers.file.parse(file_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.free
jc - JSON CLI output utility free Parser
jc - JSON CLI output utility `free` command output parser
Usage:
Usage (cli):
specify --free as the first argument if the piped input is coming from free
$ free | jc --free
or
$ jc free
Usage (module):
import jc.parsers.free
result = jc.parsers.free.parse(free_command_output)
Compatibility:

View File

@@ -1,10 +1,15 @@
# jc.parsers.fstab
jc - JSON CLI output utility fstab Parser
jc - JSON CLI output utility `fstab` file parser
Usage:
Usage (cli):
specify --fstab as the first argument if the piped input is coming from a fstab file
$ cat /etc/fstab | jc --fstab
Usage (module):
import jc.parsers.fstab
result = jc.parsers.fstab.parse(fstab_command_output)
Compatibility:

View File

@@ -1,10 +1,15 @@
# jc.parsers.group
jc - JSON CLI output utility /etc/group file Parser
jc - JSON CLI output utility `/etc/group` file parser
Usage:
Usage (cli):
specify --group as the first argument if the piped input is coming from /etc/group
$ cat /etc/group | jc --group
Usage (module):
import jc.parsers.group
result = jc.parsers.group.parse(group_file_output)
Compatibility:

View File

@@ -1,10 +1,15 @@
# jc.parsers.gshadow
jc - JSON CLI output utility /etc/gshadow file Parser
jc - JSON CLI output utility `/etc/gshadow` file parser
Usage:
Usage (cli):
specify --gshadow as the first argument if the piped input is coming from /etc/gshadow
$ cat /etc/gshadow | jc --gshadow
Usage (module):
import jc.parsers.gshadow
result = jc.parsers.gshadow.parse(gshadow_file_output)
Compatibility:

78
docs/parsers/hash.md Normal file
View File

@@ -0,0 +1,78 @@
# jc.parsers.hash
jc - JSON CLI output utility `hash` command output parser
Usage (cli):
$ hash | jc --hash
Usage (module):
import jc.parsers.hash
result = jc.parsers.hash.parse(hash_command_output)
Compatibility:
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
Examples:
$ hash | jc --hash -p
[
{
"hits": 2,
"command": "/bin/cat"
},
{
"hits": 1,
"command": "/bin/ls"
}
]
## info
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"command": string,
"hits": integer
}
]
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of dictionaries. Raw or processed structured data.

109
docs/parsers/hashsum.md Normal file
View File

@@ -0,0 +1,109 @@
# jc.parsers.hashsum
jc - JSON CLI output utility `hash sum` command output parser
This parser works with the following hash calculation utilities:
- `md5`
- `md5sum`
- `shasum`
- `sha1sum`
- `sha224sum`
- `sha256sum`
- `sha384sum`
- `sha512sum`
Usage (cli):
$ md5sum file.txt | jc --hashsum
or
$ jc md5sum file.txt
Usage (module):
import jc.parsers.hashsum
result = jc.parsers.hashsum.parse(md5sum_command_output)
Compatibility:
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
Examples:
$ md5sum * | jc --hashsum -p
[
{
"filename": "devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm",
"hash": "65fc958c1add637ec23c4b137aecf3d3"
},
{
"filename": "digout",
"hash": "5b9312ee5aff080927753c63a347707d"
},
{
"filename": "dmidecode.out",
"hash": "716fd11c2ac00db109281f7110b8fb9d"
},
{
"filename": "file with spaces in the name",
"hash": "d41d8cd98f00b204e9800998ecf8427e"
},
{
"filename": "id-centos.out",
"hash": "4295be239a14ad77ef3253103de976d2"
},
{
"filename": "ifcfg.json",
"hash": "01fda0d9ba9a75618b072e64ff512b43"
},
...
]
## info
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"filename": string,
"hash": string,
}
]
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of dictionaries. Raw or processed structured data.

View File

@@ -1,10 +1,17 @@
# jc.parsers.history
jc - JSON CLI output utility history Parser
jc - JSON CLI output utility `history` command output parser
Usage:
This parser will output a list of dictionaries each containing `line` and `command` keys. If you would like a simple dictionary output, then use the `-r` command-line option or the `raw=True` argument in the `parse()` function.
specify --history as the first argument if the piped input is coming from history
Usage (cli):
$ history | jc --history
Usage (module):
import jc.parsers.history
result = jc.parsers.history.parse(history_command_output)
Compatibility:

View File

@@ -1,10 +1,15 @@
# jc.parsers.hosts
jc - JSON CLI output utility hosts Parser
jc - JSON CLI output utility `/etc/hosts` file parser
Usage:
Usage (cli):
specify --hosts as the first argument if the piped input is coming from a hosts file
$ cat /etc/hosts | jc --hosts
Usage (module):
import jc.parsers.hosts
result = jc.parsers.hosts.parse(hosts_file_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.id
jc - JSON CLI output utility id Parser
jc - JSON CLI output utility `id` command output parser
Usage:
Usage (cli):
specify --id as the first argument if the piped input is coming from id
$ id | jc --id
or
$ jc id
Usage (module):
import jc.parsers.id
result = jc.parsers.id.parse(id_command_output)
Compatibility:

View File

@@ -1,12 +1,21 @@
# jc.parsers.ifconfig
jc - JSON CLI output utility ifconfig Parser
jc - JSON CLI output utility `ifconfig` command output parser
Usage:
Note: No `ifconfig` options are supported.
specify --ifconfig as the first argument if the piped input is coming from ifconfig
Usage (cli):
no ifconfig options are supported.
$ ifconfig | jc --ifconfig
or
$ jc ifconfig
Usage (module):
import jc.parsers.ifconfig
result = jc.parsers.ifconfig.parse(ifconfig_command_output)
Compatibility:

View File

@@ -1,12 +1,19 @@
# jc.parsers.ini
jc - JSON CLI output utility INI Parser
jc - JSON CLI output utility `INI` file parser
Usage:
Parses standard `INI` files and files containing simple key/value pairs. Delimiter can be `=` or `:`. Missing values are supported. Comment prefix can be `#` or `;`. Comments must be on their own line.
Specify --ini as the first argument if the piped input is coming from an INI file or any
simple key/value pair file. Delimiter can be '=' or ':'. Missing values are supported.
Comment prefix can be '#' or ';'. Comments must be on their own line.
Note: Values starting and ending with quotation marks will have the marks removed. If you would like to keep the quotation marks, use the `-r` command-line argument or the `raw=True` argument in `parse()`.
Usage (cli):
$ cat foo.ini | jc --ini
Usage (module):
import jc.parsers.ini
result = jc.parsers.ini.parse(ini_file_output)
Compatibility:

View File

@@ -1,12 +1,21 @@
# jc.parsers.iptables
jc - JSON CLI output utility ipables Parser
jc - JSON CLI output utility `ipables` command output parser
Usage:
Supports `-vLn` and `--line-numbers` for all tables.
Specify --iptables as the first argument if the piped input is coming from iptables
Usage (cli):
Supports -vLn and --line-numbers for all tables
$ sudo iptables -L -t nat | jc --iptables
or
$ jc iptables -L -t nat
Usage (module):
import jc.parsers.iptables
result = jc.parsers.iptables.parse(iptables_command_output)
Compatibility:

View File

@@ -1,12 +1,21 @@
# jc.parsers.jobs
jc - JSON CLI output utility jobs Parser
jc - JSON CLI output utility `jobs` command output parser
Usage:
Also supports the `-l` option.
specify --jobs as the first argument if the piped input is coming from jobs
Usage (cli):
Also supports the -l option
$ jobs | jc --jobs
or
$ jc jobs
Usage (module):
import jc.parsers.jobs
result = jc.parsers.jobs.parse(jobs_command_output)
Compatibility:

View File

@@ -1,12 +1,20 @@
# jc.parsers.kv
jc - JSON CLI output utility Key/Value File Parser
jc - JSON CLI output utility `Key/Value` file parser
Usage:
Supports files containing simple key/value pairs. Delimiter can be `=` or `:`. Missing values are supported. Comment prefix can be `#` or `;`. Comments must be on their own line.
Specify --kv as the first argument if the piped input is coming from a simple
key/value pair file. Delimiter can be '=' or ':'. Missing values are supported.
Comment prefix can be '#' or ';'. Comments must be on their own line.
Note: Values starting and ending with quotation marks will have the marks removed. If you would like to keep the quotation marks, use the `-r` command-line argument or the `raw=True` argument in `parse()`.
Usage (cli):
$ cat foo.txt | jc --kv
Usage (module):
import jc.parsers.kv
result = jc.parsers.kv.parse(kv_file_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.last
jc - JSON CLI output utility last Parser
jc - JSON CLI output utility `last` and `lastb` command output parser
Usage:
Usage (cli):
specify --last as the first argument if the piped input is coming from last or lastb
$ last | jc --last
or
$ jc last
Usage (module):
import jc.parsers.last
result = jc.parsers.last.parse(last_command_output)
Compatibility:

View File

@@ -1,22 +1,26 @@
# jc.parsers.ls
jc - JSON CLI output utility ls Parser
jc - JSON CLI output utility `ls` and `vdir` command output parser
Note: The -l or -b option of ls should be used to correctly parse filenames that include newline characters.
Since ls does not encode newlines in filenames when outputting to a pipe it will cause jc to see
multiple files instead of a single file if -l or -b is not used.
Options supported:
- `lbaR`
- `--time-style=full-iso`
- `-h`: File sizes will be available in text form with `-r` but larger file sizes with human readable suffixes will be converted to `Null` in the default view since the parser attempts to convert this field to an integer.
Usage:
Note: The `-l` or `-b` option of `ls` should be used to correctly parse filenames that include newline characters. Since `ls` does not encode newlines in filenames when outputting to a pipe it will cause `jc` to see multiple files instead of a single file if `-l` or `-b` is not used. Alternatively, `vdir` can be used, which is the same as running `ls -lb`.
specify --ls as the first argument if the piped input is coming from ls
Usage (cli):
ls options supported:
$ ls | jc --ls
-lbaR
--time-style=full-iso
-h file sizes will be available in text form with -r but larger file sizes
with human readable suffixes will be converted to Null in default view
since the parser attempts to convert this field to an integer.
or
$ jc ls
Usage (module):
import jc.parsers.ls
result = jc.parsers.ls.parse(ls_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.lsblk
jc - JSON CLI output utility lsblk Parser
jc - JSON CLI output utility `lsblk` command output parser
Usage:
Usage (cli):
specify --lsblk as the first argument if the piped input is coming from lsblk
$ lsblk | jc --lsblk
or
$ jc lsblk
Usage (module):
import jc.parsers.lsblk
result = jc.parsers.lsblk.parse(lsblk_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.lsmod
jc - JSON CLI output utility lsmod Parser
jc - JSON CLI output utility `lsmod` command output parser
Usage:
Usage (cli):
specify --lsmod as the first argument if the piped input is coming from lsmod
$ lsmod | jc --lsmod
or
$ jc lsmod
Usage (module):
import jc.parsers.lsmod
result = jc.parsers.lsmod.parse(lsmod_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.lsof
jc - JSON CLI output utility lsof Parser
jc - JSON CLI output utility `lsof` command output parser
Usage:
Usage (cli):
specify --lsof as the first argument if the piped input is coming from lsof
$ lsof | jc --lsof
or
$ jc lsof
Usage (module):
import jc.parsers.lsof
result = jc.parsers.lsof.parse(lsof_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.mount
jc - JSON CLI output utility mount Parser
jc - JSON CLI output utility `mount` command output parser
Usage:
Usage (cli):
specify --mount as the first argument if the piped input is coming from mount
$ mount | jc --mount
or
$ jc mount
Usage (module):
import jc.parsers.mount
result = jc.parsers.mount.parse(mount_command_output)
Compatibility:

View File

@@ -1,15 +1,23 @@
# jc.parsers.netstat
jc - JSON CLI output utility netstat Parser
Usage:
Specify --netstat as the first argument if the piped input is coming from netstat
jc - JSON CLI output utility `netstat` command output parser
Caveats:
- Use of multiple `l` options is not supported on OSX (e.g. `netstat -rlll`)
- Use of the `A` option is not supported on OSX when using the `r` option (e.g. `netstat -rA`)
- Use of multiple 'l' options is not supported on OSX (e.g. 'netstat -rlll')
- Use of the 'A' option is not supported on OSX when using the 'r' option (e.g. netstat -rA)
Usage (cli):
$ netstat | jc --netstat
or
$ jc netstat
Usage (module):
import jc.parsers.netstat
result = jc.parsers.netstat.parse(netstat_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.ntpq
jc - JSON CLI output utility ntpq Parser
jc - JSON CLI output utility `ntpq -p` command output parser
Usage:
Usage (cli):
specify --ntpq as the first argument if the piped input is coming from ntpq -p
$ ntpq -p | jc --ntpq
or
$ jc ntpq -p
Usage (module):
import jc.parsers.ntpq
result = jc.parsers.ntpq.parse(ntpq_command_output)
Compatibility:

View File

@@ -1,10 +1,15 @@
# jc.parsers.passwd
jc - JSON CLI output utility /etc/passwd file Parser
jc - JSON CLI output utility `/etc/passwd` file Parser
Usage:
Usage (cli):
specify --passwd as the first argument if the piped input is coming from /etc/passwd
$ cat /etc/passwd | jc --passwd
Usage (module):
import jc.parsers.passwd
result = jc.parsers.passwd.parse(passwd_file_output)
Compatibility:

View File

@@ -1,12 +1,23 @@
# jc.parsers.ping
jc - JSON CLI output utility ping Parser
jc - JSON CLI output utility `ping` command output parser
Usage:
Supports `ping` and `ping6` output.
specify --ping as the first argument if the piped input is coming from ping
Usage (cli):
Note: Use the ping -c (count) option, otherwise data will not be piped to jc.
Note: Use the ping `-c` (count) option, otherwise data will not be piped to `jc`.
$ ping -c 3 1.2.3.4 | jc --ping
or
$ jc ping -c 3 1.2.3.4
Usage (module):
import jc.parsers.ping
result = jc.parsers.ping.parse(ping_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.pip_list
jc - JSON CLI output utility pip-list Parser
jc - JSON CLI output utility `pip-list` command output parser
Usage:
Usage (cli):
specify --pip-list as the first argument if the piped input is coming from pip list
$ pip list | jc --pip-list
or
$ jc pip list
Usage (module):
import jc.parsers.pip_list
result = jc.parsers.pip_list.parse(pip_list_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.pip_show
jc - JSON CLI output utility pip-show Parser
jc - JSON CLI output utility `pip-show` command output parser
Usage:
Usage (cli):
specify --pip-show as the first argument if the piped input is coming from pip show
$ pip show | jc --pip-show
or
$ jc pip show
Usage (module):
import jc.parsers.pip_show
result = jc.parsers.pip_show.parse(pip_show_command_output)
Compatibility:

View File

@@ -1,14 +1,23 @@
# jc.parsers.ps
jc - JSON CLI output utility ps Parser
jc - JSON CLI output utility `ps` command output parser
Usage:
`ps` options supported:
- `ef`
- `axu`
specify --ps as the first argument if the piped input is coming from ps
Usage (cli):
ps options supported:
- ef
- axu
$ ps | jc --ps
or
$ jc ps
Usage (module):
import jc.parsers.ps
result = jc.parsers.ps.parse(ps_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.route
jc - JSON CLI output utility route Parser
jc - JSON CLI output utility `route` command output parser
Usage:
Usage (cli):
specify --route as the first argument if the piped input is coming from route
$ route | jc --route
or
$ jc route
Usage (module):
import jc.parsers.route
result = jc.parsers.route.parse(route_command_output)
Compatibility:

View File

@@ -1,10 +1,15 @@
# jc.parsers.shadow
jc - JSON CLI output utility /etc/shadow file Parser
jc - JSON CLI output utility `/etc/shadow` file parser
Usage:
Usage (cli):
specify --shadow as the first argument if the piped input is coming from /etc/shadow
$ sudo cat /etc/shadow | jc --shadow
Usage (module):
import jc.parsers.shadow
result = jc.parsers.shadow.parse(shadow_file_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.ss
jc - JSON CLI output utility ss Parser
jc - JSON CLI output utility `ss` command output parser
Usage:
Usage (cli):
specify --ss as the first argument if the piped input is coming from ss
$ ss | jc --ss
or
$ jc ss
Usage (module):
import jc.parsers.ss
result = jc.parsers.ss.parse(ss_command_output)
Limitations:

View File

@@ -1,10 +1,19 @@
# jc.parsers.stat
jc - JSON CLI output utility stat Parser
jc - JSON CLI output utility `stat` command output parser
Usage:
Usage (cli):
specify --stat as the first argument if the piped input is coming from stat
$ stat * | jc --stat
or
$ jc stat *
Usage (module):
import jc.parsers.stat
result = jc.parsers.stat.parse(stat_command_output)
Compatibility:

View File

@@ -1,14 +1,21 @@
# jc.parsers.sysctl
jc - JSON CLI output utility sysctl -a Parser
jc - JSON CLI output utility `sysctl -a` command output parser
Usage:
Note: Since `sysctl` output is not easily parsable only a very simple key/value object will be output. An attempt is made to convert obvious integers and floats. If no conversion is desired, use the `-r` command-line argument or the `raw=True` argument in `parse()`.
specify --sysctl as the first argument if the piped input is coming from sysctl -a
Usage (cli):
Note: since sysctl output is not easily parsable only a very simple key/value object
will be output. An attempt is made to convert obvious integers and floats. If no
conversion is desired, use the -r (raw) option.
$ sysctl -a | jc --sysctl
or
$ jc sysctl -a
Usage (module):
import jc.parsers.sysctl
result = jc.parsers.sysctl.parse(sysctl_command_output)
Compatibility:
@@ -16,7 +23,7 @@ Compatibility:
Examples:
$ sysctl | jc --sysctl -p
$ sysctl -a | jc --sysctl -p
{
"user.cs_path": "/usr/bin:/bin:/usr/sbin:/sbin",
"user.bc_base_max": 99,
@@ -28,7 +35,7 @@ Examples:
...
}
$ sysctl | jc --sysctl -p -r
$ sysctl -a | jc --sysctl -p -r
{
"user.cs_path": "/usr/bin:/bin:/usr/sbin:/sbin",
"user.bc_base_max": "99",

View File

@@ -1,10 +1,19 @@
# jc.parsers.systemctl
jc - JSON CLI output utility systemctl Parser
jc - JSON CLI output utility `systemctl` command output parser
Usage:
Usage (cli):
specify --systemctl as the first argument if the piped input is coming from systemctl
$ systemctl | jc --systemctl
or
$ jc systemctl
Usage (module):
import jc.parsers.systemctl
result = jc.parsers.systemctl.parse(systemctl_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.systemctl_lj
jc - JSON CLI output utility systemctl-lj Parser
jc - JSON CLI output utility `systemctl list-jobs` command output parser
Usage:
Usage (cli):
specify --systemctl-lj as the first argument if the piped input is coming from systemctl list-jobs
$ systemctl list-jobs | jc --systemctl-lj
or
$ jc systemctl list-jobs
Usage (module):
import jc.parsers.systemctl_lj
result = jc.parsers.systemctl_lj.parse(systemctl_lj_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.systemctl_ls
jc - JSON CLI output utility systemctl-ls Parser
jc - JSON CLI output utility `systemctl list-sockets` command output parser
Usage:
Usage (cli):
specify --systemctl-ls as the first argument if the piped input is coming from systemctl list-sockets
$ systemctl list-sockets | jc --systemctl-ls
or
$ jc systemctl list-sockets
Usage (module):
import jc.parsers.systemctl_ls
result = jc.parsers.systemctl_ls.parse(systemctl_ls_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.systemctl_luf
jc - JSON CLI output utility systemctl-luf Parser
jc - JSON CLI output utility `systemctl list-unit-files` command output parser
Usage:
Usage (cli):
specify --systemctl-luf as the first argument if the piped input is coming from systemctl list-unit-files
$ systemctl list-unit-files | jc --systemctl-luf
or
$ jc systemctl list-unit-files
Usage (module):
import jc.parsers.systemctl_luf
result = jc.parsers.systemctl_luf.parse(systemctl_luf_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.timedatectl
jc - JSON CLI output utility timedatectl Parser
jc - JSON CLI output utility `timedatectl` command output parser
Usage:
Usage (cli):
specify --timedatectl as the first argument if the piped input is coming from timedatectl or timedatectl status
$ timedatectl | jc --timedatectl
or
$ jc timedatectl
Usage (module):
import jc.parsers.timedatectl
result = jc.parsers.timedatectl.parse(timedatectl_command_output)
Compatibility:

View File

@@ -1,10 +1,21 @@
# jc.parsers.tracepath
jc - JSON CLI output utility tracepath Parser
jc - JSON CLI output utility `tracepath` command output parser
Usage:
Supports `tracepath` and `tracepath6` output.
specify --tracepath as the first argument if the piped input is coming from tracepath
Usage (cli):
$ tracepath 1.2.3.4 | jc --tracepath
or
$ jc tracepath 1.2.3.4
Usage (module):
import jc.parsers.tracepath
result = jc.parsers.tracepath.parse(tracepath_command_output)
Compatibility:

View File

@@ -1,16 +1,25 @@
# jc.parsers.traceroute
jc - JSON CLI output utility traceroute Parser
jc - JSON CLI output utility `traceroute` command output parser
Usage:
Supports `traceroute` and `traceroute6` output.
specify --traceroute as the first argument if the piped input is coming from traceroute
Note: On some operating systems you will need to redirect `STDERR` to `STDOUT` for destination info since the header line is sent to `STDERR`. A warning message will be printed to `STDERR` if the header row is not found.
Note: On some operating systems you will need to redirect STDERR to STDOUT for destination
info since the header line is sent to STDERR. A warning message will be printed to
STDERR if the header row is not found.
e.g. `$ traceroute 8.8.8.8 2>&1 | jc --traceroute`
e.g. $ traceroute 8.8.8.8 2>&1 | jc --traceroute
Usage (cli):
$ traceroute 1.2.3.4 | jc --traceroute
or
$ jc traceroute 1.2.3.4
Usage (module):
import jc.parsers.traceroute
result = jc.parsers.traceroute.parse(traceroute_command_output)
Compatibility:

View File

@@ -1,14 +1,21 @@
# jc.parsers.uname
jc - JSON CLI output utility uname Parser
jc - JSON CLI output utility `uname -a` command output parser
Usage:
Note: Must use `uname -a`
specify --uname as the first argument if the piped input is coming from uname
Usage (cli):
Limitations:
$ uname -a | jc --uname
must use 'uname -a'
or
$ jc uname -a
Usage (module):
import jc.parsers.uname
result = jc.parsers.uname.parse(uname_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.uptime
jc - JSON CLI output utility uptime Parser
jc - JSON CLI output utility `uptime` command output parser
Usage:
Usage (cli):
specify --uptime as the first argument if the piped input is coming from uptime
$ uptime | jc --uptime
or
$ jc uptime
Usage (module):
import jc.parsers.uptime
result = jc.parsers.uptime.parse(uptime_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
# jc.parsers.w
jc - JSON CLI output utility w Parser
jc - JSON CLI output utility `w` command output parser
Usage:
Usage (cli):
specify --w as the first argument if the piped input is coming from w
$ w | jc --w
or
$ jc w
Usage (module):
import jc.parsers.w
result = jc.parsers.w.parse(w_command_output)
Compatibility:

View File

@@ -1,12 +1,21 @@
# jc.parsers.who
jc - JSON CLI output utility who Parser
jc - JSON CLI output utility `who` command output parser
Usage:
Accepts any of the following who options (or no options): `-aTH`
specify --who as the first argument if the piped input is coming from who
Usage (cli):
accepts any of the following who options (or no options): -aTH
$ who | jc --who
or
$ jc who
Usage (module):
import jc.parsers.who
result = jc.parsers.who.parse(who_command_output)
Compatibility:

View File

@@ -1,10 +1,15 @@
# jc.parsers.xml
jc - JSON CLI output utility XML Parser
jc - JSON CLI output utility `XML` file parser
Usage:
Usage (cli):
specify --xml as the first argument if the piped input is coming from an XML file
$ cat foo.xml | jc --xml
Usage (module):
import jc.parsers.xml
result = jc.parsers.xml.parse(xml_file_output)
Compatibility:

View File

@@ -1,10 +1,15 @@
# jc.parsers.yaml
jc - JSON CLI output utility YAML Parser
jc - JSON CLI output utility `YAML` file parser
Usage:
Usage (cli):
specify --yaml as the first argument if the piped input is coming from a YAML file
$ cat foo.yaml | jc --yaml
Usage (module):
import jc.parsers.yaml
result = jc.parsers.yaml.parse(yaml_file_output)
Compatibility:

View File

@@ -6,6 +6,8 @@ JC - JSON CLI output utility
This package serializes the output of many standard unix command line tools to JSON format.
For documentation on each parser, see [docs/parsers](https://github.com/kellyjonbrazil/jc/tree/master/docs/parsers).
CLI Example:
$ ls -l /usr/bin | jc --ls -p

View File

@@ -4,6 +4,8 @@
This package serializes the output of many standard unix command line tools to JSON format.
For documentation on each parser, see [docs/parsers](https://github.com/kellyjonbrazil/jc/tree/master/docs/parsers).
CLI Example:
$ ls -l /usr/bin | jc --ls -p

View File

@@ -21,7 +21,7 @@ import jc.appdirs as appdirs
class info():
version = '1.13.3'
version = '1.14.0'
description = 'JSON CLI output utility'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -34,6 +34,7 @@ parsers = [
'airport-s',
'arp',
'blkid',
'cksum',
'crontab',
'crontab-u',
'csv',
@@ -48,6 +49,8 @@ parsers = [
'fstab',
'group',
'gshadow',
'hash',
'hashsum',
'history',
'hosts',
'id',
@@ -84,6 +87,7 @@ parsers = [
'uname',
'uptime',
'w',
'wc',
'who',
'xml',
'yaml'
@@ -296,7 +300,7 @@ def helptext(message):
-d debug - show traceback (-dd for verbose traceback)
-m monochrome output
-p pretty print output
-q quiet - suppress warnings
-q quiet - suppress parser warnings
-r raw JSON output
Example:

View File

@@ -1,11 +1,19 @@
"""jc - JSON CLI output utility airport -I Parser
"""jc - JSON CLI output utility `airport -I` command output parser
Usage:
The `airport` program can be found at `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport`.
specify --airport as the first argument if the piped input is coming from airport -I (OSX)
Usage (cli):
This program can be found at:
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport
$ airport -I | jc --airport
or
$ jc airport -I
Usage (module):
import jc.parsers.airport
result = jc.parsers.airport.parse(airport_command_output)
Compatibility:

View File

@@ -1,11 +1,19 @@
"""jc - JSON CLI output utility airport -s Parser
"""jc - JSON CLI output utility `airport -s` command output parser
Usage:
The `airport` program can be found at `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport`.
specify --airport as the first argument if the piped input is coming from airport -s (OSX)
Usage (cli):
This program can be found at:
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport
$ airport -s | jc --airport-s
or
$ jc airport -s
Usage (module):
import jc.parsers.airport_s
result = jc.parsers.airport_s.parse(airport_s_command_output)
Compatibility:

View File

@@ -1,12 +1,19 @@
"""jc - JSON CLI output utility arp Parser
"""jc - JSON CLI output utility `arp` command output parser
Usage:
Supports `arp` and `arp -a` output.
specify --arp as the first argument if the piped input is coming from:
Usage (cli):
arp
or
arp -a
$ arp | jc --arp
or
$ jc arp
Usage (module):
import jc.parsers.arp
result = jc.parsers.arp.parse(arp_command_output)
Compatibility:

View File

@@ -1,8 +1,17 @@
"""jc - JSON CLI output utility blkid Parser
"""jc - JSON CLI output utility `blkid` command output parser
Usage:
Usage (cli):
specify --blkid as the first argument if the piped input is coming from blkid
$ blkid | jc --blkid
or
$ jc blkid
Usage (module):
import jc.parsers.blkid
result = jc.parsers.blkid.parse(blkid_command_output)
Compatibility:

128
jc/parsers/cksum.py Normal file
View File

@@ -0,0 +1,128 @@
"""jc - JSON CLI output utility `cksum` command output parser
This parser works with the following checksum calculation utilities:
- `sum`
- `cksum`
Usage (cli):
$ cksum file.txt | jc --cksum
or
$ jc cksum file.txt
Usage (module):
import jc.parsers.cksum
result = jc.parsers.cksum.parse(cksum_command_output)
Compatibility:
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
Examples:
$ cksum * | jc --cksum -p
[
{
"filename": "__init__.py",
"checksum": 4294967295,
"blocks": 0
},
{
"filename": "airport.py",
"checksum": 2208551092,
"blocks": 3745
},
{
"filename": "airport_s.py",
"checksum": 1113817598,
"blocks": 4572
},
...
]
"""
import jc.utils
class info():
version = '1.0'
description = 'cksum command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
details = 'Parses cksum and sum program output'
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
magic_commands = ['cksum', 'sum']
__version__ = info.version
def process(proc_data):
"""
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"filename": string,
"checksum": integer,
"blocks": integer
}
]
"""
for entry in proc_data:
int_list = ['checksum', 'blocks']
for key in int_list:
if key in entry:
try:
entry[key] = int(entry[key])
except (ValueError):
entry[key] = None
return proc_data
def parse(data, raw=False, quiet=False):
"""
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of dictionaries. Raw or processed structured data.
"""
if not quiet:
jc.utils.compatibility(__name__, info.compatible)
raw_output = []
if jc.utils.has_data(data):
for line in filter(None, data.splitlines()):
item = {
'filename': line.split(maxsplit=2)[2],
'checksum': line.split(maxsplit=2)[0],
'blocks': line.split(maxsplit=2)[1]
}
raw_output.append(item)
if raw:
return raw_output
else:
return process(raw_output)

View File

@@ -1,8 +1,19 @@
"""jc - JSON CLI output utility crontab command and file Parser
"""jc - JSON CLI output utility `crontab -l` command output and crontab file parser
Usage:
Supports `crontab -l` command output and crontab files.
specify --crontab as the first argument if the piped input is coming from crontab -l or a crontab file
Usage (cli):
$ crontab -l | jc --crontab
or
$ jc crontab -l
Usage (module):
import jc.parsers.crontab
result = jc.parsers.crontab.parse(crontab_output)
Compatibility:
@@ -235,7 +246,7 @@ def parse(data, raw=False, quiet=False):
# Pop any variable assignment lines
cron_var = []
for i, line in reversed(list(enumerate(cleandata))):
if '=' in line:
if '=' in line and not line.strip()[0].isdigit() and not line.strip()[0] == '@':
var_line = cleandata.pop(i)
var_name = var_line.split('=', maxsplit=1)[0].strip()
var_value = var_line.split('=', maxsplit=1)[1].strip()

View File

@@ -1,8 +1,15 @@
"""jc - JSON CLI output utility crontab file Parser
"""jc - JSON CLI output utility `crontab -l` command output and crontab file parser
Usage:
This version of the `crontab -l` parser supports output that contains user information for processes.
specify --crontab-u as the first argument if the piped input is coming from a crontab file with User specified
Usage (cli):
$ crontab -l | jc --crontab-u
Usage (module):
import jc.parsers.crontab_u
result = jc.parsers.crontab_u.parse(crontab_u_output)
Compatibility:
@@ -133,7 +140,7 @@ import jc.parsers.universal
class info():
version = '1.3'
version = '1.5'
description = 'crontab file parser with user support'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -236,7 +243,7 @@ def parse(data, raw=False, quiet=False):
# Pop any variable assignment lines
cron_var = []
for i, line in reversed(list(enumerate(cleandata))):
if '=' in line:
if '=' in line and not line.strip()[0].isdigit() and not line.strip()[0] == '@':
var_line = cleandata.pop(i)
var_name = var_line.split('=', maxsplit=1)[0].strip()
var_value = var_line.split('=', maxsplit=1)[1].strip()

View File

@@ -1,11 +1,15 @@
"""jc - JSON CLI output utility csv Parser
"""jc - JSON CLI output utility `csv` file parser
Usage:
The `csv` parser will attempt to automatically detect the delimiter character. If the delimiter cannot be detected it will default to comma. The first row of the file must be a header row.
specify --csv as the first argument if the piped input is coming from a csv file.
the csv parser will attempt to automatically detect the delimiter character.
if the delimiter cannot be detected it will default to comma.
the first row of the file must be a header row.
Usage (cli):
$ cat file.csv | jc --csv
Usage (module):
import jc.parsers.csv
result = jc.parsers.csv.parse(csv_output)
Compatibility:

View File

@@ -1,8 +1,17 @@
"""jc - JSON CLI output utility date Parser
"""jc - JSON CLI output utility `date` command output parser
Usage:
Usage (cli):
specify --date as the first argument if the piped input is coming from date
$ date | jc --date
or
$ jc date
Usage (module):
import jc.parsers.date
result = jc.parsers.date.parse(date_command_output)
Compatibility:

View File

@@ -1,8 +1,17 @@
"""jc - JSON CLI output utility df Parser
"""jc - JSON CLI output utility `df` command output parser
Usage:
Usage (cli):
specify --df as the first argument if the piped input is coming from df
$ df | jc --df
or
$ jc df
Usage (module):
import jc.parsers.df
result = jc.parsers.df.parse(df_command_output)
Compatibility:

View File

@@ -1,8 +1,17 @@
"""jc - JSON CLI output utility dig Parser
"""jc - JSON CLI output utility `dig` command output parser
Usage:
Usage (cli):
Specify --dig as the first argument if the piped input is coming from dig
$ dig example.com | jc --dig
or
$ jc dig example.com
Usage (module):
import jc.parsers.dig
result = jc.parsers.dig.parse(dig_command_output)
Compatibility:

View File

@@ -1,8 +1,17 @@
"""jc - JSON CLI output utility dmidecode Parser
"""jc - JSON CLI output utility `dmidecode` command output parser
Usage:
Usage (cli):
specify --dmidecode as the first argument if the piped input is coming from dmidecode
$ dmidecode | jc --dmidecode
or
$ jc dmidecode
Usage (module):
import jc.parsers.dmidecode
result = jc.parsers.dmidecode.parse(dmidecode_command_output)
Compatibility:

View File

@@ -1,8 +1,17 @@
"""jc - JSON CLI output utility du Parser
"""jc - JSON CLI output utility `du` command output parser
Usage:
Usage (cli):
specify --du as the first argument if the piped input is coming from du
$ du | jc --du
or
$ jc du
Usage (module):
import jc.parsers.du
result = jc.parsers.du.parse(du_command_output)
Compatibility:

View File

@@ -1,8 +1,19 @@
"""jc - JSON CLI output utility env Parser
"""jc - JSON CLI output utility `env` and `printenv` command output parser
Usage:
This parser will output a list of dictionaries each containing `name` and `value` keys. If you would like a simple dictionary output, then use the `-r` command-line option or the `raw=True` argument in the `parse()` function.
specify --env as the first argument if the piped input is coming from env
Usage (cli):
$ env | jc --env
or
$ jc env
Usage (module):
import jc.parsers.env
result = jc.parsers.env.parse(env_command_output)
Compatibility:
@@ -59,7 +70,7 @@ class info():
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
magic_commands = ['env']
magic_commands = ['env', 'printenv']
__version__ = info.version

View File

@@ -1,8 +1,17 @@
"""jc - JSON CLI output utility file command Parser
"""jc - JSON CLI output utility `file` command output parser
Usage:
Usage (cli):
specify --file as the first argument if the piped input is coming from file.
$ file * | jc --file
or
$ jc file *
Usage (module):
import jc.parsers.file
result = jc.parsers.file.parse(file_command_output)
Compatibility:

View File

@@ -1,8 +1,19 @@
"""jc - JSON CLI output utility foo Parser
"""jc - JSON CLI output utility `foo` command output parser
Usage:
<<Short foo description and caveats>>
specify --foo as the first argument if the piped input is coming from foo
Usage (cli):
$ foo | jc --foo
or
$ jc foo
Usage (module):
import jc.parsers.foo
result = jc.parsers.foo.parse(foo_command_output)
Compatibility:

View File

@@ -1,8 +1,17 @@
"""jc - JSON CLI output utility free Parser
"""jc - JSON CLI output utility `free` command output parser
Usage:
Usage (cli):
specify --free as the first argument if the piped input is coming from free
$ free | jc --free
or
$ jc free
Usage (module):
import jc.parsers.free
result = jc.parsers.free.parse(free_command_output)
Compatibility:

View File

@@ -1,8 +1,13 @@
"""jc - JSON CLI output utility fstab Parser
"""jc - JSON CLI output utility `fstab` file parser
Usage:
Usage (cli):
specify --fstab as the first argument if the piped input is coming from a fstab file
$ cat /etc/fstab | jc --fstab
Usage (module):
import jc.parsers.fstab
result = jc.parsers.fstab.parse(fstab_command_output)
Compatibility:

View File

@@ -1,8 +1,13 @@
"""jc - JSON CLI output utility /etc/group file Parser
"""jc - JSON CLI output utility `/etc/group` file parser
Usage:
Usage (cli):
specify --group as the first argument if the piped input is coming from /etc/group
$ cat /etc/group | jc --group
Usage (module):
import jc.parsers.group
result = jc.parsers.group.parse(group_file_output)
Compatibility:

View File

@@ -1,8 +1,13 @@
"""jc - JSON CLI output utility /etc/gshadow file Parser
"""jc - JSON CLI output utility `/etc/gshadow` file parser
Usage:
Usage (cli):
specify --gshadow as the first argument if the piped input is coming from /etc/gshadow
$ cat /etc/gshadow | jc --gshadow
Usage (module):
import jc.parsers.gshadow
result = jc.parsers.gshadow.parse(gshadow_file_output)
Compatibility:

108
jc/parsers/hash.py Normal file
View File

@@ -0,0 +1,108 @@
"""jc - JSON CLI output utility `hash` command output parser
Usage (cli):
$ hash | jc --hash
Usage (module):
import jc.parsers.hash
result = jc.parsers.hash.parse(hash_command_output)
Compatibility:
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
Examples:
$ hash | jc --hash -p
[
{
"hits": 2,
"command": "/bin/cat"
},
{
"hits": 1,
"command": "/bin/ls"
}
]
"""
import jc.utils
import jc.parsers.universal
class info():
version = '1.0'
description = 'hash command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
__version__ = info.version
def process(proc_data):
"""
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"command": string,
"hits": integer
}
]
"""
for entry in proc_data:
# change to int
int_list = ['hits']
for key in int_list:
if key in entry:
try:
key_int = int(entry[key])
entry[key] = key_int
except (ValueError):
entry[key] = None
return proc_data
def parse(data, raw=False, quiet=False):
"""
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of dictionaries. Raw or processed structured data.
"""
if not quiet:
jc.utils.compatibility(__name__, info.compatible)
cleandata = data.splitlines()
raw_output = []
if jc.utils.has_data(data):
cleandata[0] = cleandata[0].lower()
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
if raw:
return raw_output
else:
return process(raw_output)

145
jc/parsers/hashsum.py Normal file
View File

@@ -0,0 +1,145 @@
"""jc - JSON CLI output utility `hash sum` command output parser
This parser works with the following hash calculation utilities:
- `md5`
- `md5sum`
- `shasum`
- `sha1sum`
- `sha224sum`
- `sha256sum`
- `sha384sum`
- `sha512sum`
Usage (cli):
$ md5sum file.txt | jc --hashsum
or
$ jc md5sum file.txt
Usage (module):
import jc.parsers.hashsum
result = jc.parsers.hashsum.parse(md5sum_command_output)
Compatibility:
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
Examples:
$ md5sum * | jc --hashsum -p
[
{
"filename": "devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm",
"hash": "65fc958c1add637ec23c4b137aecf3d3"
},
{
"filename": "digout",
"hash": "5b9312ee5aff080927753c63a347707d"
},
{
"filename": "dmidecode.out",
"hash": "716fd11c2ac00db109281f7110b8fb9d"
},
{
"filename": "file with spaces in the name",
"hash": "d41d8cd98f00b204e9800998ecf8427e"
},
{
"filename": "id-centos.out",
"hash": "4295be239a14ad77ef3253103de976d2"
},
{
"filename": "ifcfg.json",
"hash": "01fda0d9ba9a75618b072e64ff512b43"
},
...
]
"""
import jc.utils
class info():
version = '1.0'
description = 'hashsum command parser (md5sum, shasum, etc.)'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
details = 'Parses MD5 and SHA hash program output'
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
magic_commands = ['md5sum', 'md5', 'shasum', 'sha1sum', 'sha224sum', 'sha256sum', 'sha384sum', 'sha512sum']
__version__ = info.version
def process(proc_data):
"""
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"filename": string,
"hash": string,
}
]
"""
# no further processing for this parser
return proc_data
def parse(data, raw=False, quiet=False):
"""
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of dictionaries. Raw or processed structured data.
"""
if not quiet:
jc.utils.compatibility(__name__, info.compatible)
raw_output = []
if jc.utils.has_data(data):
for line in filter(None, data.splitlines()):
# check for legacy md5 command output
if line.startswith('MD5 ('):
file_hash = line.split('=', maxsplit=1)[1].strip()
file_name = line.split('=', maxsplit=1)[0].strip()
file_name = file_name[5:]
file_name = file_name[:-1]
# standard md5sum and shasum command output
else:
file_hash = line.split(maxsplit=1)[0]
file_name = line.split(maxsplit=1)[1]
item = {
'filename': file_name,
'hash': file_hash
}
raw_output.append(item)
if raw:
return raw_output
else:
return process(raw_output)

View File

@@ -1,8 +1,15 @@
"""jc - JSON CLI output utility history Parser
"""jc - JSON CLI output utility `history` command output parser
Usage:
This parser will output a list of dictionaries each containing `line` and `command` keys. If you would like a simple dictionary output, then use the `-r` command-line option or the `raw=True` argument in the `parse()` function.
specify --history as the first argument if the piped input is coming from history
Usage (cli):
$ history | jc --history
Usage (module):
import jc.parsers.history
result = jc.parsers.history.parse(history_command_output)
Compatibility:

View File

@@ -1,8 +1,13 @@
"""jc - JSON CLI output utility hosts Parser
"""jc - JSON CLI output utility `/etc/hosts` file parser
Usage:
Usage (cli):
specify --hosts as the first argument if the piped input is coming from a hosts file
$ cat /etc/hosts | jc --hosts
Usage (module):
import jc.parsers.hosts
result = jc.parsers.hosts.parse(hosts_file_output)
Compatibility:

View File

@@ -1,8 +1,17 @@
"""jc - JSON CLI output utility id Parser
"""jc - JSON CLI output utility `id` command output parser
Usage:
Usage (cli):
specify --id as the first argument if the piped input is coming from id
$ id | jc --id
or
$ jc id
Usage (module):
import jc.parsers.id
result = jc.parsers.id.parse(id_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
"""jc - JSON CLI output utility ifconfig Parser
"""jc - JSON CLI output utility `ifconfig` command output parser
Usage:
Note: No `ifconfig` options are supported.
specify --ifconfig as the first argument if the piped input is coming from ifconfig
Usage (cli):
no ifconfig options are supported.
$ ifconfig | jc --ifconfig
or
$ jc ifconfig
Usage (module):
import jc.parsers.ifconfig
result = jc.parsers.ifconfig.parse(ifconfig_command_output)
Compatibility:

View File

@@ -1,10 +1,17 @@
"""jc - JSON CLI output utility INI Parser
"""jc - JSON CLI output utility `INI` file parser
Usage:
Parses standard `INI` files and files containing simple key/value pairs. Delimiter can be `=` or `:`. Missing values are supported. Comment prefix can be `#` or `;`. Comments must be on their own line.
Specify --ini as the first argument if the piped input is coming from an INI file or any
simple key/value pair file. Delimiter can be '=' or ':'. Missing values are supported.
Comment prefix can be '#' or ';'. Comments must be on their own line.
Note: Values starting and ending with quotation marks will have the marks removed. If you would like to keep the quotation marks, use the `-r` command-line argument or the `raw=True` argument in `parse()`.
Usage (cli):
$ cat foo.ini | jc --ini
Usage (module):
import jc.parsers.ini
result = jc.parsers.ini.parse(ini_file_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
"""jc - JSON CLI output utility ipables Parser
"""jc - JSON CLI output utility `ipables` command output parser
Usage:
Supports `-vLn` and `--line-numbers` for all tables.
Specify --iptables as the first argument if the piped input is coming from iptables
Usage (cli):
Supports -vLn and --line-numbers for all tables
$ sudo iptables -L -t nat | jc --iptables
or
$ jc iptables -L -t nat
Usage (module):
import jc.parsers.iptables
result = jc.parsers.iptables.parse(iptables_command_output)
Compatibility:

View File

@@ -1,10 +1,19 @@
"""jc - JSON CLI output utility jobs Parser
"""jc - JSON CLI output utility `jobs` command output parser
Usage:
Also supports the `-l` option.
specify --jobs as the first argument if the piped input is coming from jobs
Usage (cli):
Also supports the -l option
$ jobs | jc --jobs
or
$ jc jobs
Usage (module):
import jc.parsers.jobs
result = jc.parsers.jobs.parse(jobs_command_output)
Compatibility:

View File

@@ -1,10 +1,18 @@
"""jc - JSON CLI output utility Key/Value File Parser
"""jc - JSON CLI output utility `Key/Value` file parser
Usage:
Supports files containing simple key/value pairs. Delimiter can be `=` or `:`. Missing values are supported. Comment prefix can be `#` or `;`. Comments must be on their own line.
Specify --kv as the first argument if the piped input is coming from a simple
key/value pair file. Delimiter can be '=' or ':'. Missing values are supported.
Comment prefix can be '#' or ';'. Comments must be on their own line.
Note: Values starting and ending with quotation marks will have the marks removed. If you would like to keep the quotation marks, use the `-r` command-line argument or the `raw=True` argument in `parse()`.
Usage (cli):
$ cat foo.txt | jc --kv
Usage (module):
import jc.parsers.kv
result = jc.parsers.kv.parse(kv_file_output)
Compatibility:

View File

@@ -1,8 +1,17 @@
"""jc - JSON CLI output utility last Parser
"""jc - JSON CLI output utility `last` and `lastb` command output parser
Usage:
Usage (cli):
specify --last as the first argument if the piped input is coming from last or lastb
$ last | jc --last
or
$ jc last
Usage (module):
import jc.parsers.last
result = jc.parsers.last.parse(last_command_output)
Compatibility:

View File

@@ -1,20 +1,24 @@
"""jc - JSON CLI output utility ls Parser
"""jc - JSON CLI output utility `ls` and `vdir` command output parser
Note: The -l or -b option of ls should be used to correctly parse filenames that include newline characters.
Since ls does not encode newlines in filenames when outputting to a pipe it will cause jc to see
multiple files instead of a single file if -l or -b is not used.
Options supported:
- `lbaR`
- `--time-style=full-iso`
- `-h`: File sizes will be available in text form with `-r` but larger file sizes with human readable suffixes will be converted to `Null` in the default view since the parser attempts to convert this field to an integer.
Usage:
Note: The `-l` or `-b` option of `ls` should be used to correctly parse filenames that include newline characters. Since `ls` does not encode newlines in filenames when outputting to a pipe it will cause `jc` to see multiple files instead of a single file if `-l` or `-b` is not used. Alternatively, `vdir` can be used, which is the same as running `ls -lb`.
specify --ls as the first argument if the piped input is coming from ls
Usage (cli):
ls options supported:
$ ls | jc --ls
-lbaR
--time-style=full-iso
-h file sizes will be available in text form with -r but larger file sizes
with human readable suffixes will be converted to Null in default view
since the parser attempts to convert this field to an integer.
or
$ jc ls
Usage (module):
import jc.parsers.ls
result = jc.parsers.ls.parse(ls_command_output)
Compatibility:
@@ -156,7 +160,7 @@ class info():
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
magic_commands = ['ls']
magic_commands = ['ls', 'vdir']
__version__ = info.version

Some files were not shown because too many files have changed in this diff Show More