mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2026-04-03 17:44:07 +02:00
Compare commits
265 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2683dbb20a | ||
|
|
8b3228797e | ||
|
|
947b37397f | ||
|
|
f5f0e00e8d | ||
|
|
73ab7da665 | ||
|
|
6f00b6fd61 | ||
|
|
8ada8b79c1 | ||
|
|
cd293d4786 | ||
|
|
b7d59bdd85 | ||
|
|
894f599f79 | ||
|
|
29bb10b8ff | ||
|
|
7224c7183b | ||
|
|
81301357e4 | ||
|
|
ddca18f25a | ||
|
|
d1164290a6 | ||
|
|
3949edc169 | ||
|
|
a296ac2e8f | ||
|
|
551f4b097d | ||
|
|
8d42f747a7 | ||
|
|
163a76dd10 | ||
|
|
7389ed5d0c | ||
|
|
5905058e97 | ||
|
|
2a11fefe45 | ||
|
|
e27ed0743c | ||
|
|
9f6a788a98 | ||
|
|
a15d20b400 | ||
|
|
55ae836a43 | ||
|
|
c4fc5409e3 | ||
|
|
956ad75168 | ||
|
|
71494a53ca | ||
|
|
bc211b7c36 | ||
|
|
2eaef09770 | ||
|
|
641d63604b | ||
|
|
750a3906c7 | ||
|
|
bd8e69ce98 | ||
|
|
16b17dd7aa | ||
|
|
d5a6c22cc6 | ||
|
|
b2271713e1 | ||
|
|
f0b9662c5e | ||
|
|
720c6b5d42 | ||
|
|
c30d44ea13 | ||
|
|
b5788134b6 | ||
|
|
790103fb48 | ||
|
|
e56944dc24 | ||
|
|
ed04951ed7 | ||
|
|
84337fe3d1 | ||
|
|
da631c8b22 | ||
|
|
450d0d5ddf | ||
|
|
0ed47fc7ce | ||
|
|
d57a00e8be | ||
|
|
fa7721c31d | ||
|
|
0f72d46050 | ||
|
|
fe3b5bc2ed | ||
|
|
4f7f8dd82b | ||
|
|
81fb294859 | ||
|
|
c04fd5bbf9 | ||
|
|
d6ed5a0eba | ||
|
|
33b996f6be | ||
|
|
26d4bbe9a4 | ||
|
|
5abea6d0c5 | ||
|
|
afce7cdbd7 | ||
|
|
8c3cff59c6 | ||
|
|
bc15a636f1 | ||
|
|
1564533161 | ||
|
|
27fd6843cc | ||
|
|
8c8d5552c8 | ||
|
|
a7ee414c67 | ||
|
|
6573b355cc | ||
|
|
eaa36a6a31 | ||
|
|
8b1c4f923e | ||
|
|
89c36e4996 | ||
|
|
0ea5c9585a | ||
|
|
5fa2fe3992 | ||
|
|
014437298c | ||
|
|
04d91516e8 | ||
|
|
9b33a50bb0 | ||
|
|
b0e9d9fa9d | ||
|
|
991b612b62 | ||
|
|
855c9363a5 | ||
|
|
625544f53e | ||
|
|
f179da8cd1 | ||
|
|
eeee776555 | ||
|
|
d0bde14a2a | ||
|
|
69b0e407ad | ||
|
|
ad2b9ab76c | ||
|
|
32483de4f2 | ||
|
|
ec713cfa1b | ||
|
|
eac8c1c1a0 | ||
|
|
4e15ab7924 | ||
|
|
5882755e7c | ||
|
|
13388df603 | ||
|
|
430385fa63 | ||
|
|
7bfebdcfeb | ||
|
|
e472c3b140 | ||
|
|
43ac3d951c | ||
|
|
207fa232c3 | ||
|
|
667dc1976a | ||
|
|
7437750de5 | ||
|
|
aab47c9e80 | ||
|
|
f1ed803525 | ||
|
|
093c1703d7 | ||
|
|
1f2e16aeea | ||
|
|
6f89745a58 | ||
|
|
9b710b0b6f | ||
|
|
992120b861 | ||
|
|
229bef5f82 | ||
|
|
c8a4890fc7 | ||
|
|
10a9848ac8 | ||
|
|
95189e37ba | ||
|
|
fe1f09f08d | ||
|
|
6adfa15742 | ||
|
|
edef264f17 | ||
|
|
9911b3fc9d | ||
|
|
1675aa7a59 | ||
|
|
7fd67fda13 | ||
|
|
7583f315ce | ||
|
|
7fd70d2088 | ||
|
|
337ee73844 | ||
|
|
43702a260b | ||
|
|
40208a9f76 | ||
|
|
b958358389 | ||
|
|
c23aacedad | ||
|
|
4f148469d7 | ||
|
|
247c43278c | ||
|
|
45f45e0511 | ||
|
|
c0c469ae9b | ||
|
|
4b86fd8d8a | ||
|
|
8fba47f449 | ||
|
|
f9ae964280 | ||
|
|
ca95615d7f | ||
|
|
747b255e34 | ||
|
|
c0da9ebd6c | ||
|
|
5c40b38a05 | ||
|
|
7bc03dcf06 | ||
|
|
f62e6168fd | ||
|
|
39c1470ea6 | ||
|
|
e48b99f1c1 | ||
|
|
71ae545907 | ||
|
|
b9a5eda187 | ||
|
|
231a2039c2 | ||
|
|
a415bc23fa | ||
|
|
79add35fc1 | ||
|
|
901763fc39 | ||
|
|
1034cb1ea2 | ||
|
|
020093fd67 | ||
|
|
f17b3fbd32 | ||
|
|
15b58e3a6b | ||
|
|
da6c98826b | ||
|
|
26415e2978 | ||
|
|
d849bd3b66 | ||
|
|
5996192455 | ||
|
|
a38b6b5522 | ||
|
|
1d6bc40bff | ||
|
|
437fa62cb1 | ||
|
|
6cde26d9ed | ||
|
|
f6dd5a68cd | ||
|
|
b1507dc576 | ||
|
|
a5d5b1554f | ||
|
|
ec8efebc94 | ||
|
|
f86cbf5527 | ||
|
|
57142d899c | ||
|
|
504a04279e | ||
|
|
3b4ef4a814 | ||
|
|
a7e3d2fc86 | ||
|
|
776ee66bae | ||
|
|
9bf2cd0691 | ||
|
|
fec74cf305 | ||
|
|
d3d7fbca61 | ||
|
|
550862a415 | ||
|
|
1763b530da | ||
|
|
8307150cae | ||
|
|
d2223c45d1 | ||
|
|
472ee5e295 | ||
|
|
1d0aebd836 | ||
|
|
8240626043 | ||
|
|
2cd14235c8 | ||
|
|
f774513554 | ||
|
|
388da9f003 | ||
|
|
fa18243491 | ||
|
|
5df1c1702b | ||
|
|
b6557802f4 | ||
|
|
15e3a511b6 | ||
|
|
08fbde0e8f | ||
|
|
28ebb4e8dd | ||
|
|
04fda57cbe | ||
|
|
b24495136c | ||
|
|
7d3fa55571 | ||
|
|
a76b5db8db | ||
|
|
667dd01ac7 | ||
|
|
559bee962a | ||
|
|
9f977d06e0 | ||
|
|
f67a916940 | ||
|
|
8a1308948f | ||
|
|
4e130d11a3 | ||
|
|
51aa5b268f | ||
|
|
6869133f53 | ||
|
|
ad3d88e47f | ||
|
|
6d29f8ba74 | ||
|
|
c7cb89e91d | ||
|
|
27f5118abd | ||
|
|
ac5a6e516d | ||
|
|
5d5bfbc1d1 | ||
|
|
9f4ba80000 | ||
|
|
c21c334b73 | ||
|
|
14093d9d43 | ||
|
|
176ca2f75d | ||
|
|
cfb71c7dad | ||
|
|
722eab83b1 | ||
|
|
d30edb2dae | ||
|
|
cba461ce8a | ||
|
|
f876505e25 | ||
|
|
5b9fcd5852 | ||
|
|
8a122cd9e1 | ||
|
|
557e68225c | ||
|
|
dc0947b87e | ||
|
|
af2c06cd28 | ||
|
|
67a4c6f797 | ||
|
|
0d1c857410 | ||
|
|
c7684dc94d | ||
|
|
a247572f64 | ||
|
|
306111303a | ||
|
|
c12b48537a | ||
|
|
0bf69713ab | ||
|
|
c05f1475ed | ||
|
|
416c262f02 | ||
|
|
40a5976f11 | ||
|
|
dc582fbec8 | ||
|
|
7047f0a449 | ||
|
|
d7a884a567 | ||
|
|
28de57792c | ||
|
|
a230cdbd21 | ||
|
|
251a261679 | ||
|
|
3baef254fd | ||
|
|
9e69e928b2 | ||
|
|
6eb595d2ca | ||
|
|
acf07a5144 | ||
|
|
7f53c58057 | ||
|
|
a069dc4855 | ||
|
|
febf544202 | ||
|
|
f2dd7b8815 | ||
|
|
d758e37fe3 | ||
|
|
9bc02a5623 | ||
|
|
eb0ec265d0 | ||
|
|
1f236dc02a | ||
|
|
86c279cbb2 | ||
|
|
4a7f1bed3a | ||
|
|
a730ae18c8 | ||
|
|
930bf439c0 | ||
|
|
f5f3133b87 | ||
|
|
cbca96de84 | ||
|
|
4d8ae3f124 | ||
|
|
653127431d | ||
|
|
22acef3765 | ||
|
|
0d5bf11f0d | ||
|
|
a824ccaff3 | ||
|
|
97ac965ba5 | ||
|
|
3e7f284df5 | ||
|
|
5c749fe26f | ||
|
|
aa48b46f48 | ||
|
|
6eaa4ae176 | ||
|
|
60c330b342 | ||
|
|
fdeb994121 | ||
|
|
65ed92fe7b | ||
|
|
9c8730786b | ||
|
|
7608823ea7 |
64
CHANGELOG
64
CHANGELOG
@@ -1,31 +1,73 @@
|
||||
jc changelog
|
||||
|
||||
20220723 v1.20.3
|
||||
- Add URL string parser
|
||||
- Add Email Address string parser
|
||||
- Add JWT string parser
|
||||
- Add ISO 8601 Datetime string parser
|
||||
- Add UNIX Epoch Timestamp string parser
|
||||
- Add M3U/M3U8 file parser
|
||||
- Add pager functionality to help (parser documentation only)
|
||||
- Minor parser performance optimizations
|
||||
|
||||
20220705 v1.20.2
|
||||
- Add `gpg --with-colons` parser tested on linux
|
||||
- Add DER and PEM encoded X.509 Certificate parser
|
||||
- Add Bash and Zsh completion scripts to DEB and RPM packages
|
||||
|
||||
20220615 v1.20.1
|
||||
- Add `postconf -M` parser tested on linux
|
||||
- Update `asciitable` and `asciitable-m` parsers to preserve case in key
|
||||
names when using the `-r` or `raw=True` options.
|
||||
- Add long options (e.g. `--help`, `--about`, `--pretty`, etc.)
|
||||
- Add shell completions for Bash and Zsh
|
||||
- Fix `id` parser for cases where the user or group name is not present
|
||||
|
||||
20220531 v1.20.0
|
||||
- Add YAML output option with `-y`
|
||||
- Add `top -b` standard and streaming parsers tested on linux
|
||||
- Add `plugin_parser_count`, `standard_parser_count`, and `streaming_parser_count`
|
||||
keys to `jc -a` output
|
||||
- Add `is_compatible` function to the `utils` module
|
||||
- Fix `pip-show` parser for packages with a multi-line license field
|
||||
- Fix ASCII Table parser for cases where centered headers cause mis-aligned fields
|
||||
|
||||
20220513 v1.19.0
|
||||
- Add `chage --list` command parser tested on linux
|
||||
- Add `git log` command streaming parser
|
||||
- Fix `git log` standard parser for corner-cases where hash values are in messages
|
||||
- Fix `df` command parser for rare instances when a newline is found at the end
|
||||
- Allow jc to pip install on unsupported python version 3.6
|
||||
- Fix `asciitable-m` parser to skip some rows that contain column separator
|
||||
characters in cell data. A warning message will be printed to STDERR
|
||||
unless `-q` or `quiet=True` is used.
|
||||
|
||||
20220427 v1.18.8
|
||||
- Fix update-alternatives --query parser for cases where `slaves` are not present
|
||||
- Fix `update-alternatives --query` parser for cases where `slaves` are not present
|
||||
- Fix UnicodeEncodeError on some systems where LANG=C is set and unicode
|
||||
characters are in the output
|
||||
- Update history parser: do not drop non-ASCII characters if the system
|
||||
- Update `history` parser: do not drop non-ASCII characters if the system
|
||||
is configured for UTF-8 encoding
|
||||
- Enhance "magic syntax" to always use UTF-8 encoding
|
||||
|
||||
20220425 v1.18.7
|
||||
- Add git log command parser
|
||||
- Add update-alternatives --query parser
|
||||
- Add update-alternatives --get-selections parser
|
||||
- Add `git log` command parser
|
||||
- Add `update-alternatives --query` parser
|
||||
- Add `update-alternatives --get-selections` parser
|
||||
- Fix key/value and ini parsers to allow duplicate keys
|
||||
- Fix yaml file parser for files including timestamp objects
|
||||
- Update xrandr parser: add a 'rotation' field
|
||||
- Update `xrandr` parser: add a 'rotation' field
|
||||
- Fix failing tests by moving template files
|
||||
- Add python interpreter version and path to -v and -a output
|
||||
|
||||
20220325 v1.18.6
|
||||
- Add pidstat command parser tested on linux
|
||||
- Add pidstat command streaming parser tested on linux
|
||||
- Add mpstat command parser tested on linux
|
||||
- Add mpstat command streaming parser tested on linux
|
||||
- Add `pidstat` command parser tested on linux
|
||||
- Add `pidstat` command streaming parser tested on linux
|
||||
- Add `mpstat` command parser tested on linux
|
||||
- Add `mpstat` command streaming parser tested on linux
|
||||
- Add single-line ASCII and Unicode table parser
|
||||
- Add multi-line ASCII and Unicode table parser
|
||||
- Add documentation option to parser_info() and all_parser_info()
|
||||
- Add documentation option to `parser_info()` and `all_parser_info()`
|
||||
|
||||
20220305 v1.18.5
|
||||
- Fix date parser to ensure AM/PM period string is always uppercase
|
||||
|
||||
547
EXAMPLES.md
547
EXAMPLES.md
@@ -265,6 +265,21 @@ blkid -o udev -ip /dev/sda2 | jc --blkid -p # or: jc -p blkid -o udev
|
||||
}
|
||||
]
|
||||
```
|
||||
### chage --list
|
||||
```bash
|
||||
chage --list joeuser | jc --chage -p # or: jc -p chage --list joeuser
|
||||
```
|
||||
```json
|
||||
{
|
||||
"password_last_changed": "never",
|
||||
"password_expires": "never",
|
||||
"password_inactive": "never",
|
||||
"account_expires": "never",
|
||||
"min_days_between_password_change": 0,
|
||||
"max_days_between_password_change": 99999,
|
||||
"warning_days_before_password_expires": 7
|
||||
}
|
||||
```
|
||||
### cksum
|
||||
```bash
|
||||
cksum * | jc --cksum -p # or: jc -p cksum *
|
||||
@@ -907,6 +922,18 @@ du /usr | jc --du -p # or: jc -p du /usr
|
||||
}
|
||||
]
|
||||
```
|
||||
### Email Address string
|
||||
```bash
|
||||
echo 'joe.user@gmail.com' | jc --email-address -p
|
||||
```
|
||||
```json
|
||||
{
|
||||
"username": "joe.user",
|
||||
"domain": "gmail.com",
|
||||
"local": "joe.user",
|
||||
"local_plus_suffix": null
|
||||
}
|
||||
```
|
||||
### env
|
||||
```bash
|
||||
env | jc --env -p # or: jc -p env
|
||||
@@ -1059,6 +1086,84 @@ cat /etc/fstab | jc --fstab -p
|
||||
}
|
||||
]
|
||||
```
|
||||
### git log
|
||||
```bash
|
||||
git log --stat | jc --git-log -p or: jc -p git log --stat
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"commit": "728d882ed007b3c8b785018874a0eb06e1143b66",
|
||||
"author": "Kelly Brazil",
|
||||
"author_email": "kellyjonbrazil@gmail.com",
|
||||
"date": "Wed Apr 20 09:50:19 2022 -0400",
|
||||
"stats": {
|
||||
"files_changed": 2,
|
||||
"insertions": 90,
|
||||
"deletions": 12,
|
||||
"files": [
|
||||
"docs/parsers/git_log.md",
|
||||
"jc/parsers/git_log.py"
|
||||
]
|
||||
},
|
||||
"message": "add timestamp docs and examples",
|
||||
"epoch": 1650462619,
|
||||
"epoch_utc": null
|
||||
},
|
||||
{
|
||||
"commit": "b53e42aca623181aa9bc72194e6eeef1e9a3a237",
|
||||
"author": "Kelly Brazil",
|
||||
"author_email": "kellyjonbrazil@gmail.com",
|
||||
"date": "Wed Apr 20 09:44:42 2022 -0400",
|
||||
"stats": {
|
||||
"files_changed": 5,
|
||||
"insertions": 29,
|
||||
"deletions": 6,
|
||||
"files": [
|
||||
"docs/parsers/git_log.md",
|
||||
"docs/utils.md",
|
||||
"jc/parsers/git_log.py",
|
||||
"jc/utils.py",
|
||||
"man/jc.1"
|
||||
]
|
||||
},
|
||||
"message": "add calculated timestamp",
|
||||
"epoch": 1650462282,
|
||||
"epoch_utc": null
|
||||
}
|
||||
]
|
||||
```
|
||||
### gpg --with-colons
|
||||
```bash
|
||||
gpg --with-colons --show-keys file.gpg | jc --gpg -p # or jc -p gpg --with-colons --show-keys file.gpg
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"type": "pub",
|
||||
"validity": "f",
|
||||
"key_length": "1024",
|
||||
"pub_key_alg": "17",
|
||||
"key_id": "6C7EE1B8621CC013",
|
||||
"creation_date": "899817715",
|
||||
"expiration_date": "1055898235",
|
||||
"certsn_uidhash_trustinfo": null,
|
||||
"owner_trust": "m",
|
||||
"user_id": null,
|
||||
"signature_class": null,
|
||||
"key_capabilities": "scESC",
|
||||
"cert_fingerprint_other": null,
|
||||
"flag": null,
|
||||
"token_sn": null,
|
||||
"hash_alg": null,
|
||||
"curve_name": null,
|
||||
"compliance_flags": null,
|
||||
"last_update_date": null,
|
||||
"origin": null,
|
||||
"comment": null
|
||||
}
|
||||
]
|
||||
```
|
||||
### /etc/group file
|
||||
```bash
|
||||
cat /etc/group | jc --group -p
|
||||
@@ -1622,6 +1727,31 @@ iptables --line-numbers -v -L -t nat | jc --iptables -p # or: jc -p ip
|
||||
}
|
||||
]
|
||||
```
|
||||
### ISO Datetime string
|
||||
```bash
|
||||
echo "2022-07-20T14:52:45Z" | jc --iso-datetime -p
|
||||
```
|
||||
```json
|
||||
{
|
||||
"year": 2022,
|
||||
"month": "Jul",
|
||||
"month_num": 7,
|
||||
"day": 20,
|
||||
"weekday": "Wed",
|
||||
"weekday_num": 3,
|
||||
"hour": 2,
|
||||
"hour_24": 14,
|
||||
"minute": 52,
|
||||
"second": 45,
|
||||
"microsecond": 0,
|
||||
"period": "PM",
|
||||
"utc_offset": "+0000",
|
||||
"day_of_year": 201,
|
||||
"week_of_year": 29,
|
||||
"iso": "2022-07-20T14:52:45+00:00",
|
||||
"timestamp": 1658328765
|
||||
}
|
||||
```
|
||||
### iw dev `device` scan
|
||||
```bash
|
||||
iw dev wlan0 scan | jc --iw-scan -p # or: jc -p iw dev wlan0 scan
|
||||
@@ -1768,6 +1898,24 @@ jobs -l | jc --jobs -p
|
||||
}
|
||||
]
|
||||
```
|
||||
### JWT string
|
||||
```bash
|
||||
echo 'eyJhbGciOiJIUzI1N...' | jc --jwt -p
|
||||
```
|
||||
```json
|
||||
{
|
||||
"header": {
|
||||
"alg": "HS256",
|
||||
"typ": "JWT"
|
||||
},
|
||||
"payload": {
|
||||
"sub": "1234567890",
|
||||
"name": "John Doe",
|
||||
"iat": 1516239022
|
||||
},
|
||||
"signature": "49:f9:4a:c7:04:49:48:c7:8a:28:5d:90:4f:87:f0:a4:c7..."
|
||||
}
|
||||
```
|
||||
### Key/Value files
|
||||
```bash
|
||||
cat keyvalue.txt
|
||||
@@ -2104,6 +2252,24 @@ lsusb -v | jc --lsusb -p # or: jc -p lsusb -v
|
||||
}
|
||||
]
|
||||
```
|
||||
### M3U and M3U8 files
|
||||
```bash
|
||||
cat playlist.m3u | jc --m3u -p
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"runtime": 105,
|
||||
"display": "Example artist - Example title",
|
||||
"path": "C:\\Files\\My Music\\Example.mp3"
|
||||
},
|
||||
{
|
||||
"runtime": 321,
|
||||
"display": "Example Artist2 - Example title2",
|
||||
"path": "C:\\Files\\My Music\\Favorites\\Example2.ogg"
|
||||
}
|
||||
]
|
||||
```
|
||||
### mount
|
||||
```bash
|
||||
mount | jc --mount -p # or: jc -p mount
|
||||
@@ -2416,40 +2582,40 @@ nmcli connection show ens33 | jc --nmcli -p # or jc -p nmcli connection
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"connection_id": "ens33",
|
||||
"connection_uuid": "d92ece08-9e02-47d5-b2d2-92c80e155744",
|
||||
"connection_stable_id": null,
|
||||
"connection_type": "802-3-ethernet",
|
||||
"connection_interface_name": "ens33",
|
||||
"connection_autoconnect": "yes",
|
||||
"ip4_address_1": "192.168.71.180/24",
|
||||
"ip4_gateway": "192.168.71.2",
|
||||
"ip4_route_1": {
|
||||
"dst": "0.0.0.0/0",
|
||||
"nh": "192.168.71.2",
|
||||
"mt": 100
|
||||
},
|
||||
"ip4_route_2": {
|
||||
"dst": "192.168.71.0/24",
|
||||
"nh": "0.0.0.0",
|
||||
"mt": 100
|
||||
},
|
||||
"ip4_dns_1": "192.168.71.2",
|
||||
"ip4_domain_1": "localdomain",
|
||||
"dhcp4_option_1": {
|
||||
"name": "broadcast_address",
|
||||
"value": "192.168.71.255"
|
||||
},
|
||||
"ip6_address_1": "fe80::c1cb:715d:bc3e:b8a0/64",
|
||||
"ip6_gateway": null,
|
||||
"ip6_route_1": {
|
||||
"dst": "fe80::/64",
|
||||
"nh": "::",
|
||||
"mt": 100
|
||||
}
|
||||
}
|
||||
]
|
||||
{
|
||||
"connection_id": "ens33",
|
||||
"connection_uuid": "d92ece08-9e02-47d5-b2d2-92c80e155744",
|
||||
"connection_stable_id": null,
|
||||
"connection_type": "802-3-ethernet",
|
||||
"connection_interface_name": "ens33",
|
||||
"connection_autoconnect": "yes",
|
||||
"ip4_address_1": "192.168.71.180/24",
|
||||
"ip4_gateway": "192.168.71.2",
|
||||
"ip4_route_1": {
|
||||
"dst": "0.0.0.0/0",
|
||||
"nh": "192.168.71.2",
|
||||
"mt": 100
|
||||
},
|
||||
"ip4_route_2": {
|
||||
"dst": "192.168.71.0/24",
|
||||
"nh": "0.0.0.0",
|
||||
"mt": 100
|
||||
},
|
||||
"ip4_dns_1": "192.168.71.2",
|
||||
"ip4_domain_1": "localdomain",
|
||||
"dhcp4_option_1": {
|
||||
"name": "broadcast_address",
|
||||
"value": "192.168.71.255"
|
||||
},
|
||||
"ip6_address_1": "fe80::c1cb:715d:bc3e:b8a0/64",
|
||||
"ip6_gateway": null,
|
||||
"ip6_route_1": {
|
||||
"dst": "fe80::/64",
|
||||
"nh": "::",
|
||||
"mt": 100
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
### ntpq
|
||||
```bash
|
||||
@@ -2666,6 +2832,36 @@ pip show wrapt wheel | jc --pip-show -p # or: jc -p pip show wrapt whe
|
||||
}
|
||||
]
|
||||
```
|
||||
### postconf -M
|
||||
```bash
|
||||
postconf -M | jc --postconf -p # or jc -p postconf -M
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"service_name": "smtp",
|
||||
"service_type": "inet",
|
||||
"private": false,
|
||||
"unprivileged": null,
|
||||
"chroot": true,
|
||||
"wake_up_time": null,
|
||||
"process_limit": null,
|
||||
"command": "smtpd",
|
||||
"no_wake_up_before_first_use": null
|
||||
},
|
||||
{
|
||||
"service_name": "pickup",
|
||||
"service_type": "unix",
|
||||
"private": false,
|
||||
"unprivileged": null,
|
||||
"chroot": true,
|
||||
"wake_up_time": 60,
|
||||
"process_limit": 1,
|
||||
"command": "pickup",
|
||||
"no_wake_up_before_first_use": false
|
||||
}
|
||||
]
|
||||
```
|
||||
### ps
|
||||
```bash
|
||||
ps -ef | jc --ps -p # or: jc -p ps -ef
|
||||
@@ -3403,6 +3599,146 @@ timedatectl | jc --timedatectl -p # or: jc -p timedatectl
|
||||
"epoch_utc": 1583888001
|
||||
}
|
||||
```
|
||||
### Timestamp strings (UNIX Epoch)
|
||||
```bash
|
||||
echo '1658599410' | jc --timestamp -p
|
||||
```
|
||||
```json
|
||||
{
|
||||
"naive": {
|
||||
"year": 2022,
|
||||
"month": "Jul",
|
||||
"month_num": 7,
|
||||
"day": 23,
|
||||
"weekday": "Sat",
|
||||
"weekday_num": 6,
|
||||
"hour": 11,
|
||||
"hour_24": 11,
|
||||
"minute": 3,
|
||||
"second": 30,
|
||||
"period": "AM",
|
||||
"day_of_year": 204,
|
||||
"week_of_year": 29,
|
||||
"iso": "2022-07-23T11:03:30"
|
||||
},
|
||||
"utc": {
|
||||
"year": 2022,
|
||||
"month": "Jul",
|
||||
"month_num": 7,
|
||||
"day": 23,
|
||||
"weekday": "Sat",
|
||||
"weekday_num": 6,
|
||||
"hour": 6,
|
||||
"hour_24": 18,
|
||||
"minute": 3,
|
||||
"second": 30,
|
||||
"period": "PM",
|
||||
"utc_offset": "+0000",
|
||||
"day_of_year": 204,
|
||||
"week_of_year": 29,
|
||||
"iso": "2022-07-23T18:03:30+00:00"
|
||||
}
|
||||
}
|
||||
```
|
||||
### tob -b
|
||||
```bash
|
||||
top -b -n 1 | jc --top -p # or jc -p tob -b -n 1
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"time": "11:20:43",
|
||||
"uptime": 118,
|
||||
"users": 2,
|
||||
"load_1m": 0.0,
|
||||
"load_5m": 0.01,
|
||||
"load_15m": 0.05,
|
||||
"tasks_total": 108,
|
||||
"tasks_running": 2,
|
||||
"tasks_sleeping": 106,
|
||||
"tasks_stopped": 0,
|
||||
"tasks_zombie": 0,
|
||||
"cpu_user": 5.6,
|
||||
"cpu_sys": 11.1,
|
||||
"cpu_nice": 0.0,
|
||||
"cpu_idle": 83.3,
|
||||
"cpu_wait": 0.0,
|
||||
"cpu_hardware": 0.0,
|
||||
"cpu_software": 0.0,
|
||||
"cpu_steal": 0.0,
|
||||
"mem_total": 3.7,
|
||||
"mem_free": 3.3,
|
||||
"mem_used": 0.2,
|
||||
"mem_buff_cache": 0.2,
|
||||
"swap_total": 2.0,
|
||||
"swap_free": 2.0,
|
||||
"swap_used": 0.0,
|
||||
"mem_available": 3.3,
|
||||
"processes": [
|
||||
{
|
||||
"pid": 2225,
|
||||
"user": "kbrazil",
|
||||
"priority": 20,
|
||||
"nice": 0,
|
||||
"virtual_mem": 158.1,
|
||||
"resident_mem": 2.2,
|
||||
"shared_mem": 1.6,
|
||||
"status": "running",
|
||||
"percent_cpu": 12.5,
|
||||
"percent_mem": 0.1,
|
||||
"time_hundredths": "0:00.02",
|
||||
"command": "top",
|
||||
"parent_pid": 1884,
|
||||
"uid": 1000,
|
||||
"real_uid": 1000,
|
||||
"real_user": "kbrazil",
|
||||
"saved_uid": 1000,
|
||||
"saved_user": "kbrazil",
|
||||
"gid": 1000,
|
||||
"group": "kbrazil",
|
||||
"pgrp": 2225,
|
||||
"tty": "pts/0",
|
||||
"tty_process_gid": 2225,
|
||||
"session_id": 1884,
|
||||
"thread_count": 1,
|
||||
"last_used_processor": 0,
|
||||
"time": "0:00",
|
||||
"swap": 0.0,
|
||||
"code": 0.1,
|
||||
"data": 1.0,
|
||||
"major_page_fault_count": 0,
|
||||
"minor_page_fault_count": 736,
|
||||
"dirty_pages_count": 0,
|
||||
"sleeping_in_function": null,
|
||||
"flags": "..4.2...",
|
||||
"cgroups": "1:name=systemd:/user.slice/user-1000.+",
|
||||
"supplementary_gids": [
|
||||
10,
|
||||
1000
|
||||
],
|
||||
"supplementary_groups": [
|
||||
"wheel",
|
||||
"kbrazil"
|
||||
],
|
||||
"thread_gid": 2225,
|
||||
"environment_variables": [
|
||||
"XDG_SESSION_ID=2",
|
||||
"HOSTNAME=localhost"
|
||||
],
|
||||
"major_page_fault_count_delta": 0,
|
||||
"minor_page_fault_count_delta": 4,
|
||||
"used": 2.2,
|
||||
"ipc_namespace_inode": 4026531839,
|
||||
"mount_namespace_inode": 4026531840,
|
||||
"net_namespace_inode": 4026531956,
|
||||
"pid_namespace_inode": 4026531836,
|
||||
"user_namespace_inode": 4026531837,
|
||||
"nts_namespace_inode": 4026531838
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
### tracepath
|
||||
```bash
|
||||
tracepath6 3ffe:2400:0:109::2 | jc --tracepath -p
|
||||
@@ -3792,6 +4128,70 @@ uptime | jc --uptime -p # or: jc -p uptime
|
||||
"uptime_total_seconds": 273780
|
||||
}
|
||||
```
|
||||
### URL string
|
||||
```bash
|
||||
echo "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag" \\
|
||||
| jc --url -p
|
||||
```
|
||||
```json
|
||||
{
|
||||
"url": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag",
|
||||
"scheme": "http",
|
||||
"netloc": "example.com",
|
||||
"path": "/test/path",
|
||||
"path_list": [
|
||||
"test",
|
||||
"path"
|
||||
],
|
||||
"query": "q1=foo&q1=bar&q2=baz",
|
||||
"query_obj": {
|
||||
"q1": [
|
||||
"foo",
|
||||
"bar"
|
||||
],
|
||||
"q2": [
|
||||
"baz"
|
||||
]
|
||||
},
|
||||
"fragment": "frag",
|
||||
"username": null,
|
||||
"password": null,
|
||||
"hostname": "example.com",
|
||||
"port": null,
|
||||
"encoded": {
|
||||
"url": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag",
|
||||
"scheme": "http",
|
||||
"netloc": "example.com",
|
||||
"path": "/test/path",
|
||||
"path_list": [
|
||||
"test",
|
||||
"path"
|
||||
],
|
||||
"query": "q1=foo&q1=bar&q2=baz",
|
||||
"fragment": "frag",
|
||||
"username": null,
|
||||
"password": null,
|
||||
"hostname": "example.com",
|
||||
"port": null
|
||||
},
|
||||
"decoded": {
|
||||
"url": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag",
|
||||
"scheme": "http",
|
||||
"netloc": "example.com",
|
||||
"path": "/test/path",
|
||||
"path_list": [
|
||||
"test",
|
||||
"path"
|
||||
],
|
||||
"query": "q1=foo&q1=bar&q2=baz",
|
||||
"fragment": "frag",
|
||||
"username": null,
|
||||
"password": null,
|
||||
"hostname": "example.com",
|
||||
"port": null
|
||||
}
|
||||
}
|
||||
```
|
||||
### w
|
||||
```bash
|
||||
w | jc --w -p # or: jc -p w
|
||||
@@ -3900,6 +4300,85 @@ who -a | jc --who -p # or: jc -p who -a
|
||||
}
|
||||
]
|
||||
```
|
||||
### X.509 PEM and DER certificate files
|
||||
```bash
|
||||
cat entrust.pem | jc --x509-cert -p
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"tbs_certificate": {
|
||||
"version": "v3",
|
||||
"serial_number": "a6:8b:79:29:00:00:00:00:50:d0:91:f9",
|
||||
"signature": {
|
||||
"algorithm": "sha384_ecdsa",
|
||||
"parameters": null
|
||||
},
|
||||
"issuer": {
|
||||
"country_name": "US",
|
||||
"organization_name": "Entrust, Inc.",
|
||||
"organizational_unit_name": [
|
||||
"See www.entrust.net/legal-terms",
|
||||
"(c) 2012 Entrust, Inc. - for authorized use only"
|
||||
],
|
||||
"common_name": "Entrust Root Certification Authority - EC1"
|
||||
},
|
||||
"validity": {
|
||||
"not_before": 1355844336,
|
||||
"not_after": 2144764536,
|
||||
"not_before_iso": "2012-12-18T15:25:36+00:00",
|
||||
"not_after_iso": "2037-12-18T15:55:36+00:00"
|
||||
},
|
||||
"subject": {
|
||||
"country_name": "US",
|
||||
"organization_name": "Entrust, Inc.",
|
||||
"organizational_unit_name": [
|
||||
"See www.entrust.net/legal-terms",
|
||||
"(c) 2012 Entrust, Inc. - for authorized use only"
|
||||
],
|
||||
"common_name": "Entrust Root Certification Authority - EC1"
|
||||
},
|
||||
"subject_public_key_info": {
|
||||
"algorithm": {
|
||||
"algorithm": "ec",
|
||||
"parameters": "secp384r1"
|
||||
},
|
||||
"public_key": "04:84:13:c9:d0:ba:6d:41:7b:e2:6c:d0:eb:55:5f:66:02:1a:24:f4:5b:89:69:47:e3:b8:c2:7d:f1:f2:02:c5:9f:a0:f6:5b:d5:8b:06:19:86:4f:53:10:6d:07:24:27:a1:a0:f8:d5:47:19:61:4c:7d:ca:93:27:ea:74:0c:ef:6f:96:09:fe:63:ec:70:5d:36:ad:67:77:ae:c9:9d:7c:55:44:3a:a2:63:51:1f:f5:e3:62:d4:a9:47:07:3e:cc:20"
|
||||
},
|
||||
"issuer_unique_id": null,
|
||||
"subject_unique_id": null,
|
||||
"extensions": [
|
||||
{
|
||||
"extn_id": "key_usage",
|
||||
"critical": true,
|
||||
"extn_value": [
|
||||
"key_cert_sign",
|
||||
"crl_sign"
|
||||
]
|
||||
},
|
||||
{
|
||||
"extn_id": "basic_constraints",
|
||||
"critical": true,
|
||||
"extn_value": {
|
||||
"ca": true,
|
||||
"path_len_constraint": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"extn_id": "key_identifier",
|
||||
"critical": false,
|
||||
"extn_value": "b7:63:e7:1a:dd:8d:e9:08:a6:55:83:a4:e0:6a:50:41:65:11:42:49"
|
||||
}
|
||||
]
|
||||
},
|
||||
"signature_algorithm": {
|
||||
"algorithm": "sha384_ecdsa",
|
||||
"parameters": null
|
||||
},
|
||||
"signature_value": "30:64:02:30:61:79:d8:e5:42:47:df:1c:ae:53:99:17:b6:6f:1c:7d:e1:bf:11:94:d1:03:88:75:e4:8d:89:a4:8a:77:46:de:6d:61:ef:02:f5:fb:b5:df:cc:fe:4e:ff:fe:a9:e6:a7:02:30:5b:99:d7:85:37:06:b5:7b:08:fd:eb:27:8b:4a:94:f9:e1:fa:a7:8e:26:08:e8:7c:92:68:6d:73:d8:6f:26:ac:21:02:b8:99:b7:26:41:5b:25:60:ae:d0:48:1a:ee:06"
|
||||
}
|
||||
]
|
||||
```
|
||||
### XML files
|
||||
```bash
|
||||
cat cd_catalog.xml
|
||||
|
||||
296
README.md
296
README.md
@@ -44,8 +44,10 @@ $ jc dig example.com | jq -r '.[].answer[].data'
|
||||
93.184.216.34
|
||||
```
|
||||
|
||||
The `jc` parsers can also be used as python modules. In this case the output
|
||||
will be a python dictionary, or list of dictionaries, instead of JSON:
|
||||
`jc` can also be used as a python library. In this case the output will be
|
||||
a python dictionary, a list of dictionaries, or even a
|
||||
[lazy iterable of dictionaries](#using-streaming-parsers-as-python-modules)
|
||||
instead of JSON:
|
||||
```python
|
||||
>>> import subprocess
|
||||
>>> import jc
|
||||
@@ -111,13 +113,13 @@ pip3 install jc
|
||||
| Debian/Ubuntu linux | `apt-get install jc` |
|
||||
| Fedora linux | `dnf install jc` |
|
||||
| openSUSE linux | `zypper install jc` |
|
||||
| Archlinux User Repositories (AUR) | `paru -S jc` or `aura -A jc` or `yay -S jc` |
|
||||
| Archlinux Community Repository | `paru -S jc` or `aura -S jc` or `yay -S jc` |
|
||||
| NixOS linux | `nix-env -iA nixpkgs.jc` or `nix-env -iA nixos.jc` |
|
||||
| Guix System linux | `guix install jc` |
|
||||
| Gentoo Linux | `emerge dev-python/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` |
|
||||
| Gentoo Linux | `emerge dev-python/jc` |
|
||||
|
||||
> For more OS Packages, see https://repology.org/project/jc/versions.
|
||||
|
||||
@@ -144,121 +146,137 @@ option.
|
||||
|
||||
### Parsers
|
||||
|
||||
- `--acpi` enables the `acpi` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/acpi))
|
||||
- `--airport` enables the `airport -I` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/airport))
|
||||
- `--airport-s` enables the `airport -s` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/airport_s))
|
||||
- `--arp` enables the `arp` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/arp))
|
||||
- `--asciitable` enables the ASCII and Unicode table parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/asciitable))
|
||||
- `--asciitable-m` enables the multi-line ASCII and Unicode table parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/asciitable_m))
|
||||
- `--blkid` enables the `blkid` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/blkid))
|
||||
- `--cksum` enables the `cksum` and `sum` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/cksum))
|
||||
- `--crontab` enables the `crontab` command and file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/crontab))
|
||||
- `--crontab-u` enables the `crontab` file parser with user support ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/crontab_u))
|
||||
- `--csv` enables the CSV file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/csv))
|
||||
- `--csv-s` enables the CSV file streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/csv_s))
|
||||
- `--date` enables the `date` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/date))
|
||||
- `--df` enables the `df` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/df))
|
||||
- `--dig` enables the `dig` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/dig))
|
||||
- `--dir` enables the `dir` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/dir))
|
||||
- `--dmidecode` enables the `dmidecode` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/dmidecode))
|
||||
- `--dpkg-l` enables the `dpkg -l` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/dpkg_l))
|
||||
- `--du` enables the `du` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/du))
|
||||
- `--env` enables the `env` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/env))
|
||||
- `--file` enables the `file` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/file))
|
||||
- `--finger` enables the `finger` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/finger))
|
||||
- `--free` enables the `free` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/free))
|
||||
- `--fstab` enables the `/etc/fstab` file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/fstab))
|
||||
- `--git-log` enables the `git log` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/git_log))
|
||||
- `--group` enables the `/etc/group` file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/group))
|
||||
- `--gshadow` enables the `/etc/gshadow` file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/gshadow))
|
||||
- `--hash` enables the `hash` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/hash))
|
||||
- `--hashsum` enables the hashsum command parser (`md5sum`, `shasum`, etc.) ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/hashsum))
|
||||
- `--hciconfig` enables the `hciconfig` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/hciconfig))
|
||||
- `--history` enables the `history` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/history))
|
||||
- `--hosts` enables the `/etc/hosts` file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/hosts))
|
||||
- `--id` enables the `id` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/id))
|
||||
- `--ifconfig` enables the `ifconfig` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ifconfig))
|
||||
- `--ini` enables the INI file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ini))
|
||||
- `--iostat` enables the `iostat` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat))
|
||||
- `--iostat-s` enables the `iostat` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat_s))
|
||||
- `--iptables` enables the `iptables` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/iptables))
|
||||
- `--iw-scan` enables the `iw dev [device] scan` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/iw_scan))
|
||||
- `--jar-manifest` enables the MANIFEST.MF file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/jar_manifest))
|
||||
- `--jobs` enables the `jobs` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/jobs))
|
||||
- `--kv` enables the Key/Value file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/kv))
|
||||
- `--last` enables the `last` and `lastb` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/last))
|
||||
- `--ls` enables the `ls` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ls))
|
||||
- `--ls-s` enables the `ls` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ls_s))
|
||||
- `--lsblk` enables the `lsblk` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/lsblk))
|
||||
- `--lsmod` enables the `lsmod` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/lsmod))
|
||||
- `--lsof` enables the `lsof` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/lsof))
|
||||
- `--lsusb` enables the `lsusb` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/lsusb))
|
||||
- `--mount` enables the `mount` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/mount))
|
||||
- `--mpstat` enables the `mpstat` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/mpstat))
|
||||
- `--mpstat-s` enables the `mpstat` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/mpstat_s))
|
||||
- `--netstat` enables the `netstat` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/netstat))
|
||||
- `--nmcli` enables the `nmcli` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/nmcli))
|
||||
- `--ntpq` enables the `ntpq -p` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ntpq))
|
||||
- `--passwd` enables the `/etc/passwd` file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/passwd))
|
||||
- `--pidstat` enables the `pidstat` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/pidstat))
|
||||
- `--pidstat-s` enables the `pidstat` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/pidstat_s))
|
||||
- `--ping` enables the `ping` and `ping6` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ping))
|
||||
- `--ping-s` enables the `ping` and `ping6` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ping_s))
|
||||
- `--pip-list` enables the `pip list` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/pip_list))
|
||||
- `--pip-show` enables the `pip show` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/pip_show))
|
||||
- `--ps` enables the `ps` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ps))
|
||||
- `--route` enables the `route` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/route))
|
||||
- `--rpm-qi` enables the `rpm -qi` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/rpm_qi))
|
||||
- `--rsync` enables the `rsync` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/rsync))
|
||||
- `--rsync-s` enables the `rsync` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/rsync_s))
|
||||
- `--sfdisk` enables the `sfdisk` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/sfdisk))
|
||||
- `--shadow` enables the `/etc/shadow` file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/shadow))
|
||||
- `--ss` enables the `ss` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ss))
|
||||
- `--stat` enables the `stat` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/stat))
|
||||
- `--stat-s` enables the `stat` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/stat_s))
|
||||
- `--sysctl` enables the `sysctl` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/sysctl))
|
||||
- `--systemctl` enables the `systemctl` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl))
|
||||
- `--systemctl-lj` enables the `systemctl list-jobs` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl_lj))
|
||||
- `--systemctl-ls` enables the `systemctl list-sockets` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl_ls))
|
||||
- `--systemctl-luf` enables the `systemctl list-unit-files` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl_luf))
|
||||
- `--systeminfo` enables the `systeminfo` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/systeminfo))
|
||||
- `--time` enables the `/usr/bin/time` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/time))
|
||||
- `--timedatectl` enables the `timedatectl status` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/timedatectl))
|
||||
- `--tracepath` enables the `tracepath` and `tracepath6` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/tracepath))
|
||||
- `--traceroute` enables the `traceroute` and `traceroute6` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/traceroute))
|
||||
- `--ufw` enables the `ufw status` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw))
|
||||
- `--ufw-appinfo` enables the `ufw app info [application]` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw_appinfo))
|
||||
- `--uname` enables the `uname -a` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/uname))
|
||||
- `--update-alt-gs` enables the `update-alternatives --get-selections` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/update_alt_gs))
|
||||
- `--update-alt-q` enables the `update-alternatives --query` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/update_alt_q))
|
||||
- `--upower` enables the `upower` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/upower))
|
||||
- `--uptime` enables the `uptime` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/uptime))
|
||||
- `--vmstat` enables the `vmstat` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/vmstat))
|
||||
- `--vmstat-s` enables the `vmstat` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/vmstat_s))
|
||||
- `--w` enables the `w` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/w))
|
||||
- `--wc` enables the `wc` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/wc))
|
||||
- `--who` enables the `who` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/who))
|
||||
- `--xml` enables the XML file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/xml))
|
||||
- `--xrandr` enables the `xrandr` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/xrandr))
|
||||
- `--yaml` enables the YAML file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/yaml))
|
||||
- `--zipinfo` enables the `zipinfo` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/zipinfo))
|
||||
| Argument | Command or Filetype | Documentation |
|
||||
|-------------------|---------------------------------------------------------|----------------------------------------------------------------------------|
|
||||
| ` --acpi` | `acpi` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/acpi) |
|
||||
| ` --airport` | `airport -I` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/airport) |
|
||||
| ` --airport-s` | `airport -s` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/airport_s) |
|
||||
| ` --arp` | `arp` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/arp) |
|
||||
| ` --asciitable` | ASCII and Unicode table parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/asciitable) |
|
||||
| ` --asciitable-m` | multi-line ASCII and Unicode table parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/asciitable_m) |
|
||||
| ` --blkid` | `blkid` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/blkid) |
|
||||
| ` --chage` | `chage --list` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/chage) |
|
||||
| ` --cksum` | `cksum` and `sum` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/cksum) |
|
||||
| ` --crontab` | `crontab` command and file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/crontab) |
|
||||
| ` --crontab-u` | `crontab` file parser with user support | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/crontab_u) |
|
||||
| ` --csv` | CSV file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/csv) |
|
||||
| ` --csv-s` | CSV file streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/csv_s) |
|
||||
| ` --date` | `date` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/date) |
|
||||
| ` --df` | `df` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/df) |
|
||||
| ` --dig` | `dig` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/dig) |
|
||||
| ` --dir` | `dir` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/dir) |
|
||||
| ` --dmidecode` | `dmidecode` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/dmidecode) |
|
||||
| ` --dpkg-l` | `dpkg -l` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/dpkg_l) |
|
||||
| ` --du` | `du` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/du) |
|
||||
| `--email-address` | Email Address string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/email_address) |
|
||||
| ` --env` | `env` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/env) |
|
||||
| ` --file` | `file` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/file) |
|
||||
| ` --finger` | `finger` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/finger) |
|
||||
| ` --free` | `free` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/free) |
|
||||
| ` --fstab` | `/etc/fstab` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/fstab) |
|
||||
| ` --git-log` | `git log` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/git_log) |
|
||||
| ` --git-log-s` | `git log` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/git_log_s) |
|
||||
| ` --gpg` | `gpg --with-colons` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/gpg) |
|
||||
| ` --group` | `/etc/group` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/group) |
|
||||
| ` --gshadow` | `/etc/gshadow` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/gshadow) |
|
||||
| ` --hash` | `hash` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/hash) |
|
||||
| ` --hashsum` | hashsum command parser (`md5sum`, `shasum`, etc.) | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/hashsum) |
|
||||
| ` --hciconfig` | `hciconfig` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/hciconfig) |
|
||||
| ` --history` | `history` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/history) |
|
||||
| ` --hosts` | `/etc/hosts` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/hosts) |
|
||||
| ` --id` | `id` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/id) |
|
||||
| ` --ifconfig` | `ifconfig` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ifconfig) |
|
||||
| ` --ini` | INI file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ini) |
|
||||
| ` --iostat` | `iostat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat) |
|
||||
| ` --iostat-s` | `iostat` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat_s) |
|
||||
| ` --iptables` | `iptables` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iptables) |
|
||||
| ` --iso-datetime` | ISO 8601 Datetime string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iso_datetime) |
|
||||
| ` --iw-scan` | `iw dev [device] scan` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iw_scan) |
|
||||
| ` --jar-manifest` | MANIFEST.MF file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/jar_manifest) |
|
||||
| ` --jobs` | `jobs` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/jobs) |
|
||||
| ` --jwt` | JWT string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/jwt) |
|
||||
| ` --kv` | Key/Value file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/kv) |
|
||||
| ` --last` | `last` and `lastb` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/last) |
|
||||
| ` --ls` | `ls` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ls) |
|
||||
| ` --ls-s` | `ls` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ls_s) |
|
||||
| ` --lsblk` | `lsblk` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsblk) |
|
||||
| ` --lsmod` | `lsmod` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsmod) |
|
||||
| ` --lsof` | `lsof` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsof) |
|
||||
| ` --lsusb` | `lsusb` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsusb) |
|
||||
| ` --m3u` | M3U and M3U8 file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/m3u) |
|
||||
| ` --mount` | `mount` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/mount) |
|
||||
| ` --mpstat` | `mpstat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/mpstat) |
|
||||
| ` --mpstat-s` | `mpstat` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/mpstat_s) |
|
||||
| ` --netstat` | `netstat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/netstat) |
|
||||
| ` --nmcli` | `nmcli` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/nmcli) |
|
||||
| ` --ntpq` | `ntpq -p` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ntpq) |
|
||||
| ` --passwd` | `/etc/passwd` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/passwd) |
|
||||
| ` --pidstat` | `pidstat -h` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pidstat) |
|
||||
| ` --pidstat-s` | `pidstat -h` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pidstat_s) |
|
||||
| ` --ping` | `ping` and `ping6` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ping) |
|
||||
| ` --ping-s` | `ping` and `ping6` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ping_s) |
|
||||
| ` --pip-list` | `pip list` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pip_list) |
|
||||
| ` --pip-show` | `pip show` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pip_show) |
|
||||
| ` --postconf` | `postconf -M` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/postconf) |
|
||||
| ` --ps` | `ps` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ps) |
|
||||
| ` --route` | `route` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/route) |
|
||||
| ` --rpm-qi` | `rpm -qi` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/rpm_qi) |
|
||||
| ` --rsync` | `rsync` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/rsync) |
|
||||
| ` --rsync-s` | `rsync` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/rsync_s) |
|
||||
| ` --sfdisk` | `sfdisk` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/sfdisk) |
|
||||
| ` --shadow` | `/etc/shadow` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/shadow) |
|
||||
| ` --ss` | `ss` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ss) |
|
||||
| ` --stat` | `stat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/stat) |
|
||||
| ` --stat-s` | `stat` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/stat_s) |
|
||||
| ` --sysctl` | `sysctl` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/sysctl) |
|
||||
| ` --systemctl` | `systemctl` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl) |
|
||||
| ` --systemctl-lj` | `systemctl list-jobs` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl_lj) |
|
||||
| ` --systemctl-ls` | `systemctl list-sockets` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl_ls) |
|
||||
| `--systemctl-luf` | `systemctl list-unit-files` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl_luf) |
|
||||
| ` --systeminfo` | `systeminfo` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/systeminfo) |
|
||||
| ` --time` | `/usr/bin/time` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/time) |
|
||||
| ` --timedatectl` | `timedatectl status` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/timedatectl) |
|
||||
| ` --timestamp` | UNIX Epoch Timestamp string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/timestamp) |
|
||||
| ` --top` | `top -b` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/top) |
|
||||
| ` --top-s` | `top -b` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/top_s) |
|
||||
| ` --tracepath` | `tracepath` and `tracepath6` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/tracepath) |
|
||||
| ` --traceroute` | `traceroute` and `traceroute6` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/traceroute) |
|
||||
| ` --ufw` | `ufw status` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw) |
|
||||
| ` --ufw-appinfo` | `ufw app info [application]` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw_appinfo) |
|
||||
| ` --uname` | `uname -a` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/uname) |
|
||||
| `--update-alt-gs` | `update-alternatives --get-selections` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/update_alt_gs) |
|
||||
| ` --update-alt-q` | `update-alternatives --query` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/update_alt_q) |
|
||||
| ` --upower` | `upower` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/upower) |
|
||||
| ` --uptime` | `uptime` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/uptime) |
|
||||
| ` --url` | URL string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/url) |
|
||||
| ` --vmstat` | `vmstat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/vmstat) |
|
||||
| ` --vmstat-s` | `vmstat` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/vmstat_s) |
|
||||
| ` --w` | `w` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/w) |
|
||||
| ` --wc` | `wc` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/wc) |
|
||||
| ` --who` | `who` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/who) |
|
||||
| ` --x509-cert` | X.509 PEM and DER certificate file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/x509_cert) |
|
||||
| ` --xml` | XML file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/xml) |
|
||||
| ` --xrandr` | `xrandr` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/xrandr) |
|
||||
| ` --yaml` | YAML file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/yaml) |
|
||||
| ` --zipinfo` | `zipinfo` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/zipinfo) |
|
||||
|
||||
### Options
|
||||
- `-a` about `jc`. Prints information about `jc` and the parsers (in JSON, of
|
||||
course!)
|
||||
- `-C` force color output even when using pipes (overrides `-m` and the
|
||||
`NO_COLOR` env variable)
|
||||
- `-d` debug mode. Prints trace messages if parsing issues are encountered (use
|
||||
`-dd` for verbose debugging)
|
||||
- `-h` help. Use `jc -h --parser_name` for parser documentation
|
||||
- `-m` monochrome JSON output
|
||||
- `-p` pretty format the JSON output
|
||||
- `-q` quiet mode. Suppresses parser warning messages (use `-qq` to ignore
|
||||
streaming parser errors)
|
||||
- `-r` raw output. Provides a more literal JSON output, typically with string
|
||||
values and no additional semantic processing
|
||||
- `-u` unbuffer output
|
||||
- `-v` version information
|
||||
|
||||
| Short | Long | Description |
|
||||
|-------|-----------------|---------------------------------------------------------------------------------------------------------------------|
|
||||
| `-a` | `--about` | About `jc`. Prints information about `jc` and the parsers (in JSON or YAML, of course!) |
|
||||
| `-C` | `--force-color` | Force color output even when using pipes (overrides `-m` and the `NO_COLOR` env variable) |
|
||||
| `-d` | `--debug` | Debug mode. Prints trace messages if parsing issues are encountered (use`-dd` for verbose debugging) |
|
||||
| `-h` | `--help` | Help. Use `jc -h --parser_name` for parser documentation |
|
||||
| `-m` | `--monochrome` | Monochrome output |
|
||||
| `-p` | `--pretty` | Pretty format the JSON output |
|
||||
| `-q` | `--quiet` | Quiet mode. Suppresses parser warning messages (use `-qq` to ignore streaming parser errors) |
|
||||
| `-r` | `--raw` | Raw output. Provides more literal output, typically with string values and no additional semantic processing |
|
||||
| `-u` | `--unbuffer` | Unbuffer output |
|
||||
| `-v` | `--version` | Version information |
|
||||
| `-y` | `--yaml-out` | YAML output |
|
||||
| `-B` | `--bash-comp` | Generate Bash shell completion script ([more info](https://github.com/kellyjonbrazil/jc/wiki/Shell-Completions)) |
|
||||
| `-Z` | `--zsh-comp` | Generate Zsh shell completion script ([more info](https://github.com/kellyjonbrazil/jc/wiki/Shell-Completions)) |
|
||||
|
||||
### Exit Codes
|
||||
Any fatal errors within `jc` will generate an exit code of `100`, otherwise the
|
||||
@@ -305,11 +323,11 @@ color output will override both the `NO_COLOR` environment variable and the `-m`
|
||||
option.
|
||||
|
||||
### Streaming Parsers
|
||||
Most parsers load all of the data from STDIN, parse it, then output the entire
|
||||
Most parsers load all of the data from `STDIN`, parse it, then output the entire
|
||||
JSON document serially. There are some streaming parsers (e.g. `ls-s` and
|
||||
`ping-s`) that immediately start processing and outputing the data line-by-line
|
||||
as [JSON Lines](https://jsonlines.org/) (aka [NDJSON](http://ndjson.org/)) while
|
||||
it is being received from STDIN. This can significantly reduce the amount of
|
||||
it is being received from `STDIN`. This can significantly reduce the amount of
|
||||
memory required to parse large amounts of command output (e.g. `ls -lR /`) and
|
||||
can sometimes process the data more quickly. Streaming parsers have slightly
|
||||
different behavior than standard parsers as outlined below.
|
||||
@@ -374,14 +392,14 @@ $ ping 1.1.1.1 | jc --ping-s -u | jq
|
||||
|
||||
#### Using Streaming Parsers as Python Modules
|
||||
|
||||
Streaming parsers accept any iterable object and return an iterator object
|
||||
(generator) allowing lazy processing of the data. The input data should
|
||||
iterate on lines of string data. Examples of good input data are `sys.stdin` or
|
||||
Streaming parsers accept any iterable object and return an iterable object
|
||||
allowing lazy processing of the data. The input data should iterate on lines
|
||||
of string data. Examples of good input data are `sys.stdin` or
|
||||
`str.splitlines()`.
|
||||
|
||||
To use the generator object in your code, simply loop through it or use the
|
||||
[next()](https://docs.python.org/3/library/functions.html#next) builtin
|
||||
function:
|
||||
To use the returned iterable object in your code, simply loop through it or
|
||||
use the [next()](https://docs.python.org/3/library/functions.html#next)
|
||||
builtin function:
|
||||
```python
|
||||
import jc
|
||||
|
||||
@@ -404,8 +422,8 @@ or [`jc/parsers/foo_s.py (streaming)`](https://github.com/kellyjonbrazil/jc/blob
|
||||
parser as a template and simply place a `.py` file in the `jcparsers` subfolder.
|
||||
|
||||
Local plugin filenames must be valid python module names and therefore must
|
||||
start with a letter and consist entirely of alphanumerics. Local plugins
|
||||
may override default parsers.
|
||||
start with a letter and consist entirely of alphanumerics and underscores.
|
||||
Local plugins may override default parsers.
|
||||
|
||||
> Note: The application data directory follows the
|
||||
[XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)
|
||||
@@ -438,15 +456,30 @@ If a UTC timezone can be detected in the text of the command output, the
|
||||
timestamp will be timezone aware and have a `_utc` suffix on the key name.
|
||||
(e.g. `epoch_utc`) No other timezones are supported for aware timestamps.
|
||||
|
||||
## Use In Other Shells
|
||||
`jc` can be used in most any shell. Some modern shells have JSON deserialization
|
||||
and filtering capabilities built-in which makes using `jc` even more convenient.
|
||||
|
||||
For example, the following is possible in [NGS](https://ngs-lang.org/)
|
||||
(Next Generation Shell):
|
||||
```bash
|
||||
myvar = ``jc dig www.google.com``[0].answer[0].data
|
||||
```
|
||||
This runs `jc`, parses the output JSON, and assigs the resulting data structure
|
||||
to a variable in a single line of code.
|
||||
|
||||
For more examples of how to use `jc` in other shells, see this
|
||||
[wiki page](https://github.com/kellyjonbrazil/jc/wiki/Using-jc-With-Different-Shells).
|
||||
|
||||
## Compatibility
|
||||
Some parsers like `dig`, `xml`, `csv`, etc. will work on any platform. Other
|
||||
parsers that convert platform-specific output will generate a warning message if
|
||||
they are run on an unsupported platform. To see all parser information,
|
||||
including compatibility, run `jc -ap`.
|
||||
|
||||
You may still use a parser on an unsupported platform - for example, you may want
|
||||
to parse a file with linux `lsof` output on an macOS or Windows laptop. In that
|
||||
case you can suppress the warning message with the `-q` cli option or the
|
||||
You may still use a parser on an unsupported platform - for example, you may
|
||||
want to parse a file with linux `lsof` output on an macOS or Windows laptop. In
|
||||
that case you can suppress the warning message with the `-q` cli option or the
|
||||
`quiet=True` function parameter in `parse()`:
|
||||
|
||||
macOS:
|
||||
@@ -475,7 +508,8 @@ Tested on:
|
||||
## Contributions
|
||||
Feel free to add/improve code or parsers! You can use the
|
||||
[`jc/parsers/foo.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo.py)
|
||||
or [`jc/parsers/foo_s.py (streaming)`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo_s.py) parsers as a template and submit your parser with a pull request.
|
||||
or [`jc/parsers/foo_s.py (streaming)`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo_s.py) parsers as a template and submit your parser with a pull
|
||||
request.
|
||||
|
||||
Please see the [Contributing Guidelines](https://github.com/kellyjonbrazil/jc/blob/master/CONTRIBUTING.md) for more information.
|
||||
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
theme: jekyll-theme-cayman
|
||||
theme: jekyll-theme-cayman
|
||||
markdown: GFM
|
||||
|
||||
9
build-completions.py
Executable file
9
build-completions.py
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
# build Bash and Zsh completion scripts and add to the completions folder
|
||||
from jc.shell_completions import bash_completion, zsh_completion
|
||||
|
||||
with open('completions/jc_bash_completion.sh', 'w') as f:
|
||||
print(bash_completion(), file=f)
|
||||
|
||||
with open('completions/jc_zsh_completion.sh', 'w') as f:
|
||||
print(zsh_completion(), file=f)
|
||||
84
completions/jc_bash_completion.sh
Normal file
84
completions/jc_bash_completion.sh
Normal file
@@ -0,0 +1,84 @@
|
||||
_jc()
|
||||
{
|
||||
local cur prev words cword jc_commands jc_parsers jc_options \
|
||||
jc_about_options jc_about_mod_options jc_help_options jc_special_options
|
||||
|
||||
jc_commands=(acpi airport arp blkid chage cksum crontab date df dig dmidecode dpkg du env file finger free git gpg hciconfig id ifconfig iostat iptables iw jobs last lastb ls lsblk lsmod lsof lsusb md5 md5sum mount mpstat netstat nmcli ntpq pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss stat sum sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 ufw uname update-alternatives upower uptime vdir vmstat w wc who xrandr zipinfo)
|
||||
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --chage --cksum --crontab --crontab-u --csv --csv-s --date --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --finger --free --fstab --git-log --git-log-s --gpg --group --gshadow --hash --hashsum --hciconfig --history --hosts --id --ifconfig --ini --iostat --iostat-s --iptables --iso-datetime --iw-scan --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsblk --lsmod --lsof --lsusb --m3u --mount --mpstat --mpstat-s --netstat --nmcli --ntpq --passwd --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --postconf --ps --route --rpm-qi --rsync --rsync-s --sfdisk --shadow --ss --stat --stat-s --sysctl --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --top --top-s --tracepath --traceroute --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --vmstat --vmstat-s --w --wc --who --x509-cert --xml --xrandr --yaml --zipinfo)
|
||||
jc_options=(--force-color -C --debug -d --monochrome -m --pretty -p --quiet -q --raw -r --unbuffer -u --yaml-out -y)
|
||||
jc_about_options=(--about -a)
|
||||
jc_about_mod_options=(--pretty -p --yaml-out -y --monochrome -m --force-color -C)
|
||||
jc_help_options=(--help -h)
|
||||
jc_special_options=(--version -v --bash-comp -B --zsh-comp -Z)
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev words cword
|
||||
|
||||
# if jc_about_options are found anywhere in the line, then only complete from jc_about_mod_options
|
||||
for i in "${words[@]::${#words[@]}-1}"; do
|
||||
if [[ " ${jc_about_options[*]} " =~ " ${i} " ]]; then
|
||||
COMPREPLY=( $( compgen -W "${jc_about_mod_options[*]}" \
|
||||
-- "${cur}" ) )
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# if jc_help_options and a parser are found anywhere in the line, then no more completions
|
||||
if
|
||||
(
|
||||
for i in "${words[@]::${#words[@]}-1}"; do
|
||||
if [[ " ${jc_help_options[*]} " =~ " ${i} " ]]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
) && (
|
||||
for i in "${words[@]::${#words[@]}-1}"; do
|
||||
if [[ " ${jc_parsers[*]} " =~ " ${i} " ]]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
); then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# if jc_help_options are found anywhere in the line, then only complete with parsers
|
||||
for i in "${words[@]::${#words[@]}-1}"; do
|
||||
if [[ " ${jc_help_options[*]} " =~ " ${i} " ]]; then
|
||||
COMPREPLY=( $( compgen -W "${jc_parsers[*]}" \
|
||||
-- "${cur}" ) )
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# if special options are found anywhere in the line, then no more completions
|
||||
for i in "${words[@]::${#words[@]}-1}"; do
|
||||
if [[ " ${jc_special_options[*]} " =~ " ${i} " ]]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# if magic command is found anywhere in the line, use called command's autocompletion
|
||||
for i in "${words[@]::${#words[@]}-1}"; do
|
||||
if [[ " ${jc_commands[*]} " =~ " ${i} " ]]; then
|
||||
_command
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# if a parser arg is found anywhere in the line, only show options and help options
|
||||
for i in "${words[@]::${#words[@]}-1}"; do
|
||||
if [[ " ${jc_parsers[*]} " =~ " ${i} " ]]; then
|
||||
COMPREPLY=( $( compgen -W "${jc_options[*]} ${jc_help_options[*]}" \
|
||||
-- "${cur}" ) )
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# default completion
|
||||
COMPREPLY=( $( compgen -W "${jc_options[*]} ${jc_about_options[*]} ${jc_help_options[*]} ${jc_special_options[*]} ${jc_parsers[*]} ${jc_commands[*]}" \
|
||||
-- "${cur}" ) )
|
||||
} &&
|
||||
complete -F _jc jc
|
||||
|
||||
331
completions/jc_zsh_completion.sh
Normal file
331
completions/jc_zsh_completion.sh
Normal file
@@ -0,0 +1,331 @@
|
||||
#compdef jc
|
||||
|
||||
_jc() {
|
||||
local -a jc_commands jc_commands_describe \
|
||||
jc_parsers jc_parsers_describe \
|
||||
jc_options jc_options_describe \
|
||||
jc_about_options jc_about_options_describe \
|
||||
jc_about_mod_options jc_about_mod_options_describe \
|
||||
jc_help_options jc_help_options_describe \
|
||||
jc_special_options jc_special_options_describe
|
||||
|
||||
jc_commands=(acpi airport arp blkid chage cksum crontab date df dig dmidecode dpkg du env file finger free git gpg hciconfig id ifconfig iostat iptables iw jobs last lastb ls lsblk lsmod lsof lsusb md5 md5sum mount mpstat netstat nmcli ntpq pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss stat sum sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 ufw uname update-alternatives upower uptime vdir vmstat w wc who xrandr zipinfo)
|
||||
jc_commands_describe=(
|
||||
'acpi:run "acpi" command with magic syntax.'
|
||||
'airport:run "airport" command with magic syntax.'
|
||||
'arp:run "arp" command with magic syntax.'
|
||||
'blkid:run "blkid" command with magic syntax.'
|
||||
'chage:run "chage" command with magic syntax.'
|
||||
'cksum:run "cksum" command with magic syntax.'
|
||||
'crontab:run "crontab" command with magic syntax.'
|
||||
'date:run "date" command with magic syntax.'
|
||||
'df:run "df" command with magic syntax.'
|
||||
'dig:run "dig" command with magic syntax.'
|
||||
'dmidecode:run "dmidecode" command with magic syntax.'
|
||||
'dpkg:run "dpkg" command with magic syntax.'
|
||||
'du:run "du" command with magic syntax.'
|
||||
'env:run "env" command with magic syntax.'
|
||||
'file:run "file" command with magic syntax.'
|
||||
'finger:run "finger" command with magic syntax.'
|
||||
'free:run "free" command with magic syntax.'
|
||||
'git:run "git" command with magic syntax.'
|
||||
'gpg:run "gpg" command with magic syntax.'
|
||||
'hciconfig:run "hciconfig" command with magic syntax.'
|
||||
'id:run "id" command with magic syntax.'
|
||||
'ifconfig:run "ifconfig" command with magic syntax.'
|
||||
'iostat:run "iostat" command with magic syntax.'
|
||||
'iptables:run "iptables" command with magic syntax.'
|
||||
'iw:run "iw" command with magic syntax.'
|
||||
'jobs:run "jobs" command with magic syntax.'
|
||||
'last:run "last" command with magic syntax.'
|
||||
'lastb:run "lastb" command with magic syntax.'
|
||||
'ls:run "ls" command with magic syntax.'
|
||||
'lsblk:run "lsblk" command with magic syntax.'
|
||||
'lsmod:run "lsmod" command with magic syntax.'
|
||||
'lsof:run "lsof" command with magic syntax.'
|
||||
'lsusb:run "lsusb" command with magic syntax.'
|
||||
'md5:run "md5" command with magic syntax.'
|
||||
'md5sum:run "md5sum" command with magic syntax.'
|
||||
'mount:run "mount" command with magic syntax.'
|
||||
'mpstat:run "mpstat" command with magic syntax.'
|
||||
'netstat:run "netstat" command with magic syntax.'
|
||||
'nmcli:run "nmcli" command with magic syntax.'
|
||||
'ntpq:run "ntpq" command with magic syntax.'
|
||||
'pidstat:run "pidstat" command with magic syntax.'
|
||||
'ping:run "ping" command with magic syntax.'
|
||||
'ping6:run "ping6" command with magic syntax.'
|
||||
'pip:run "pip" command with magic syntax.'
|
||||
'pip3:run "pip3" command with magic syntax.'
|
||||
'postconf:run "postconf" command with magic syntax.'
|
||||
'printenv:run "printenv" command with magic syntax.'
|
||||
'ps:run "ps" command with magic syntax.'
|
||||
'route:run "route" command with magic syntax.'
|
||||
'rpm:run "rpm" command with magic syntax.'
|
||||
'rsync:run "rsync" command with magic syntax.'
|
||||
'sfdisk:run "sfdisk" command with magic syntax.'
|
||||
'sha1sum:run "sha1sum" command with magic syntax.'
|
||||
'sha224sum:run "sha224sum" command with magic syntax.'
|
||||
'sha256sum:run "sha256sum" command with magic syntax.'
|
||||
'sha384sum:run "sha384sum" command with magic syntax.'
|
||||
'sha512sum:run "sha512sum" command with magic syntax.'
|
||||
'shasum:run "shasum" command with magic syntax.'
|
||||
'ss:run "ss" command with magic syntax.'
|
||||
'stat:run "stat" command with magic syntax.'
|
||||
'sum:run "sum" command with magic syntax.'
|
||||
'sysctl:run "sysctl" command with magic syntax.'
|
||||
'systemctl:run "systemctl" command with magic syntax.'
|
||||
'systeminfo:run "systeminfo" command with magic syntax.'
|
||||
'timedatectl:run "timedatectl" command with magic syntax.'
|
||||
'top:run "top" command with magic syntax.'
|
||||
'tracepath:run "tracepath" command with magic syntax.'
|
||||
'tracepath6:run "tracepath6" command with magic syntax.'
|
||||
'traceroute:run "traceroute" command with magic syntax.'
|
||||
'traceroute6:run "traceroute6" command with magic syntax.'
|
||||
'ufw:run "ufw" command with magic syntax.'
|
||||
'uname:run "uname" command with magic syntax.'
|
||||
'update-alternatives:run "update-alternatives" command with magic syntax.'
|
||||
'upower:run "upower" command with magic syntax.'
|
||||
'uptime:run "uptime" command with magic syntax.'
|
||||
'vdir:run "vdir" command with magic syntax.'
|
||||
'vmstat:run "vmstat" command with magic syntax.'
|
||||
'w:run "w" command with magic syntax.'
|
||||
'wc:run "wc" command with magic syntax.'
|
||||
'who:run "who" command with magic syntax.'
|
||||
'xrandr:run "xrandr" command with magic syntax.'
|
||||
'zipinfo:run "zipinfo" command with magic syntax.'
|
||||
)
|
||||
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --chage --cksum --crontab --crontab-u --csv --csv-s --date --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --finger --free --fstab --git-log --git-log-s --gpg --group --gshadow --hash --hashsum --hciconfig --history --hosts --id --ifconfig --ini --iostat --iostat-s --iptables --iso-datetime --iw-scan --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsblk --lsmod --lsof --lsusb --m3u --mount --mpstat --mpstat-s --netstat --nmcli --ntpq --passwd --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --postconf --ps --route --rpm-qi --rsync --rsync-s --sfdisk --shadow --ss --stat --stat-s --sysctl --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --top --top-s --tracepath --traceroute --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --vmstat --vmstat-s --w --wc --who --x509-cert --xml --xrandr --yaml --zipinfo)
|
||||
jc_parsers_describe=(
|
||||
'--acpi:`acpi` command parser'
|
||||
'--airport:`airport -I` command parser'
|
||||
'--airport-s:`airport -s` command parser'
|
||||
'--arp:`arp` command parser'
|
||||
'--asciitable:ASCII and Unicode table parser'
|
||||
'--asciitable-m:multi-line ASCII and Unicode table parser'
|
||||
'--blkid:`blkid` command parser'
|
||||
'--chage:`chage --list` command parser'
|
||||
'--cksum:`cksum` and `sum` command parser'
|
||||
'--crontab:`crontab` command and file parser'
|
||||
'--crontab-u:`crontab` file parser with user support'
|
||||
'--csv:CSV file parser'
|
||||
'--csv-s:CSV file streaming parser'
|
||||
'--date:`date` command parser'
|
||||
'--df:`df` command parser'
|
||||
'--dig:`dig` command parser'
|
||||
'--dir:`dir` command parser'
|
||||
'--dmidecode:`dmidecode` command parser'
|
||||
'--dpkg-l:`dpkg -l` command parser'
|
||||
'--du:`du` command parser'
|
||||
'--email-address:Email Address string parser'
|
||||
'--env:`env` command parser'
|
||||
'--file:`file` command parser'
|
||||
'--finger:`finger` command parser'
|
||||
'--free:`free` command parser'
|
||||
'--fstab:`/etc/fstab` file parser'
|
||||
'--git-log:`git log` command parser'
|
||||
'--git-log-s:`git log` command streaming parser'
|
||||
'--gpg:`gpg --with-colons` command parser'
|
||||
'--group:`/etc/group` file parser'
|
||||
'--gshadow:`/etc/gshadow` file parser'
|
||||
'--hash:`hash` command parser'
|
||||
'--hashsum:hashsum command parser (`md5sum`, `shasum`, etc.)'
|
||||
'--hciconfig:`hciconfig` command parser'
|
||||
'--history:`history` command parser'
|
||||
'--hosts:`/etc/hosts` file parser'
|
||||
'--id:`id` command parser'
|
||||
'--ifconfig:`ifconfig` command parser'
|
||||
'--ini:INI file parser'
|
||||
'--iostat:`iostat` command parser'
|
||||
'--iostat-s:`iostat` command streaming parser'
|
||||
'--iptables:`iptables` command parser'
|
||||
'--iso-datetime:ISO 8601 Datetime string parser'
|
||||
'--iw-scan:`iw dev [device] scan` command parser'
|
||||
'--jar-manifest:MANIFEST.MF file parser'
|
||||
'--jobs:`jobs` command parser'
|
||||
'--jwt:JWT string parser'
|
||||
'--kv:Key/Value file parser'
|
||||
'--last:`last` and `lastb` command parser'
|
||||
'--ls:`ls` command parser'
|
||||
'--ls-s:`ls` command streaming parser'
|
||||
'--lsblk:`lsblk` command parser'
|
||||
'--lsmod:`lsmod` command parser'
|
||||
'--lsof:`lsof` command parser'
|
||||
'--lsusb:`lsusb` command parser'
|
||||
'--m3u:M3U and M3U8 file parser'
|
||||
'--mount:`mount` command parser'
|
||||
'--mpstat:`mpstat` command parser'
|
||||
'--mpstat-s:`mpstat` command streaming parser'
|
||||
'--netstat:`netstat` command parser'
|
||||
'--nmcli:`nmcli` command parser'
|
||||
'--ntpq:`ntpq -p` command parser'
|
||||
'--passwd:`/etc/passwd` file parser'
|
||||
'--pidstat:`pidstat -h` command parser'
|
||||
'--pidstat-s:`pidstat -h` command streaming parser'
|
||||
'--ping:`ping` and `ping6` command parser'
|
||||
'--ping-s:`ping` and `ping6` command streaming parser'
|
||||
'--pip-list:`pip list` command parser'
|
||||
'--pip-show:`pip show` command parser'
|
||||
'--postconf:`postconf -M` command parser'
|
||||
'--ps:`ps` command parser'
|
||||
'--route:`route` command parser'
|
||||
'--rpm-qi:`rpm -qi` command parser'
|
||||
'--rsync:`rsync` command parser'
|
||||
'--rsync-s:`rsync` command streaming parser'
|
||||
'--sfdisk:`sfdisk` command parser'
|
||||
'--shadow:`/etc/shadow` file parser'
|
||||
'--ss:`ss` command parser'
|
||||
'--stat:`stat` command parser'
|
||||
'--stat-s:`stat` command streaming parser'
|
||||
'--sysctl:`sysctl` command parser'
|
||||
'--systemctl:`systemctl` command parser'
|
||||
'--systemctl-lj:`systemctl list-jobs` command parser'
|
||||
'--systemctl-ls:`systemctl list-sockets` command parser'
|
||||
'--systemctl-luf:`systemctl list-unit-files` command parser'
|
||||
'--systeminfo:`systeminfo` command parser'
|
||||
'--time:`/usr/bin/time` command parser'
|
||||
'--timedatectl:`timedatectl status` command parser'
|
||||
'--timestamp:UNIX Epoch Timestamp string parser'
|
||||
'--top:`top -b` command parser'
|
||||
'--top-s:`top -b` command streaming parser'
|
||||
'--tracepath:`tracepath` and `tracepath6` command parser'
|
||||
'--traceroute:`traceroute` and `traceroute6` command parser'
|
||||
'--ufw:`ufw status` command parser'
|
||||
'--ufw-appinfo:`ufw app info [application]` command parser'
|
||||
'--uname:`uname -a` command parser'
|
||||
'--update-alt-gs:`update-alternatives --get-selections` command parser'
|
||||
'--update-alt-q:`update-alternatives --query` command parser'
|
||||
'--upower:`upower` command parser'
|
||||
'--uptime:`uptime` command parser'
|
||||
'--url:URL string parser'
|
||||
'--vmstat:`vmstat` command parser'
|
||||
'--vmstat-s:`vmstat` command streaming parser'
|
||||
'--w:`w` command parser'
|
||||
'--wc:`wc` command parser'
|
||||
'--who:`who` command parser'
|
||||
'--x509-cert:X.509 PEM and DER certificate file parser'
|
||||
'--xml:XML file parser'
|
||||
'--xrandr:`xrandr` command parser'
|
||||
'--yaml:YAML file parser'
|
||||
'--zipinfo:`zipinfo` command parser'
|
||||
)
|
||||
jc_options=(--force-color -C --debug -d --monochrome -m --pretty -p --quiet -q --raw -r --unbuffer -u --yaml-out -y)
|
||||
jc_options_describe=(
|
||||
'--force-color:force color output even when using pipes (overrides -m)'
|
||||
'-C:force color output even when using pipes (overrides -m)'
|
||||
'--debug:debug (double for verbose debug)'
|
||||
'-d:debug (double for verbose debug)'
|
||||
'--monochrome:monochrome output'
|
||||
'-m:monochrome output'
|
||||
'--pretty:pretty print output'
|
||||
'-p:pretty print output'
|
||||
'--quiet:suppress warnings (double to ignore streaming errors)'
|
||||
'-q:suppress warnings (double to ignore streaming errors)'
|
||||
'--raw:raw output'
|
||||
'-r:raw output'
|
||||
'--unbuffer:unbuffer output'
|
||||
'-u:unbuffer output'
|
||||
'--yaml-out:YAML output'
|
||||
'-y:YAML output'
|
||||
)
|
||||
jc_about_options=(--about -a)
|
||||
jc_about_options_describe=(
|
||||
'--about:about jc'
|
||||
'-a:about jc'
|
||||
)
|
||||
jc_about_mod_options=(--pretty -p --yaml-out -y --monochrome -m --force-color -C)
|
||||
jc_about_mod_options_describe=(
|
||||
'--pretty:pretty print output'
|
||||
'-p:pretty print output'
|
||||
'--yaml-out:YAML output'
|
||||
'-y:YAML output'
|
||||
'--monochrome:monochrome output'
|
||||
'-m:monochrome output'
|
||||
'--force-color:force color output even when using pipes (overrides -m)'
|
||||
'-C:force color output even when using pipes (overrides -m)'
|
||||
)
|
||||
jc_help_options=(--help -h)
|
||||
jc_help_options_describe=(
|
||||
'--help:help (--help --parser_name for parser documentation)'
|
||||
'-h:help (--help --parser_name for parser documentation)'
|
||||
)
|
||||
jc_special_options=(--version -v --bash-comp -B --zsh-comp -Z)
|
||||
jc_special_options_describe=(
|
||||
'--version:version info'
|
||||
'-v:version info'
|
||||
'--bash-comp:gen Bash completion: jc -B > /etc/bash_completion.d/jc'
|
||||
'-B:gen Bash completion: jc -B > /etc/bash_completion.d/jc'
|
||||
'--zsh-comp:gen Zsh completion: jc -Z > "${fpath[1]}/_jc"'
|
||||
'-Z:gen Zsh completion: jc -Z > "${fpath[1]}/_jc"'
|
||||
)
|
||||
|
||||
# if jc_about_options are found anywhere in the line, then only complete from jc_about_mod_options
|
||||
for i in ${words:0:-1}; do
|
||||
if (( $jc_about_options[(Ie)${i}] )); then
|
||||
_describe 'commands' jc_about_mod_options_describe
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# if jc_help_options and a parser are found anywhere in the line, then no more completions
|
||||
if
|
||||
(
|
||||
for i in ${words:0:-1}; do
|
||||
if (( $jc_help_options[(Ie)${i}] )); then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
) && (
|
||||
for i in ${words:0:-1}; do
|
||||
if (( $jc_parsers[(Ie)${i}] )); then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
); then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# if jc_help_options are found anywhere in the line, then only complete with parsers
|
||||
for i in ${words:0:-1}; do
|
||||
if (( $jc_help_options[(Ie)${i}] )); then
|
||||
_describe 'commands' jc_parsers_describe
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# if special options are found anywhere in the line, then no more completions
|
||||
for i in ${words:0:-1}; do
|
||||
if (( $jc_special_options[(Ie)${i}] )); then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# if magic command is found anywhere in the line, use called command's autocompletion
|
||||
for i in ${words:0:-1}; do
|
||||
if (( $jc_commands[(Ie)${i}] )); then
|
||||
# hack to remove options between jc and the magic command
|
||||
shift $(( ${#words} - 2 )) words
|
||||
words[1,0]=(jc)
|
||||
CURRENT=${#words}
|
||||
|
||||
# run the magic command's completions
|
||||
_arguments '*::arguments:_normal'
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# if a parser arg is found anywhere in the line, only show options and help options
|
||||
for i in ${words:0:-1}; do
|
||||
if (( $jc_parsers[(Ie)${i}] )); then
|
||||
_describe 'commands' jc_options_describe -- jc_help_options_describe
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# default completion
|
||||
_describe 'commands' jc_options_describe -- jc_about_options_describe -- jc_help_options_describe -- jc_special_options_describe -- jc_parsers_describe -- jc_commands_describe
|
||||
}
|
||||
|
||||
_jc
|
||||
|
||||
@@ -22,7 +22,7 @@ jc - JSON Convert lib module
|
||||
|
||||
```python
|
||||
def parse(parser_mod_name: str,
|
||||
data: Union[str, Iterable[str]],
|
||||
data: Union[str, bytes, Iterable[str]],
|
||||
quiet: bool = False,
|
||||
raw: bool = False,
|
||||
ignore_exceptions: bool = None,
|
||||
@@ -67,9 +67,9 @@ Parameters:
|
||||
cli-name, and --argument-name
|
||||
variants of the module name.
|
||||
|
||||
data: (string or data to parse (string for normal
|
||||
iterable) parsers, iterable of strings for
|
||||
streaming parsers)
|
||||
data: (string or data to parse (string or bytes for
|
||||
bytes or standard parsers, iterable of
|
||||
iterable) strings for streaming parsers)
|
||||
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
|
||||
|
||||
@@ -250,4 +250,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -103,4 +103,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: darwin
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -131,4 +131,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: darwin
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -140,4 +140,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, aix, freebsd, darwin
|
||||
|
||||
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.10 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -8,7 +8,12 @@ jc - JSON Convert `asciitable` parser
|
||||
This parser converts ASCII and Unicode text tables with single-line rows.
|
||||
|
||||
Column headers must be at least two spaces apart from each other and must
|
||||
be unique.
|
||||
be unique. For best results, column headers should be left-justified. If
|
||||
column separators are present, then non-left-justified headers will be fixed
|
||||
automatically.
|
||||
|
||||
Row separators are optional and are ignored. Each non-row-separator line is
|
||||
considered a separate row in the table.
|
||||
|
||||
For example:
|
||||
|
||||
@@ -54,6 +59,9 @@ etc...
|
||||
Headers (keys) are converted to snake-case. All values are returned as
|
||||
strings, except empty strings, which are converted to None/null.
|
||||
|
||||
> Note: To preserve the case of the keys use the `-r` cli option or
|
||||
> `raw=True` argument in `parse()`.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat table.txt | jc --asciitable
|
||||
@@ -136,4 +144,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -29,6 +29,15 @@ Headers (keys) are converted to snake-case and newlines between multi-line
|
||||
headers are joined with an underscore. All values are returned as strings,
|
||||
except empty strings, which are converted to None/null.
|
||||
|
||||
> Note: To preserve the case of the keys use the `-r` cli option or
|
||||
> `raw=True` argument in `parse()`.
|
||||
|
||||
> Note: table column separator characters (e.g. `|`) cannot be present
|
||||
> inside the cell data. If detected, a warning message will be printed to
|
||||
> `STDERR` and the line will be skipped. The warning message can be
|
||||
> suppressed by using the `-q` command option or by setting `quiet=True` in
|
||||
> `parse()`.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat table.txt | jc --asciitable-m
|
||||
@@ -120,4 +129,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -143,4 +143,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
82
docs/parsers/chage.md
Normal file
82
docs/parsers/chage.md
Normal file
@@ -0,0 +1,82 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.chage"></a>
|
||||
|
||||
# jc.parsers.chage
|
||||
|
||||
jc - JSON Convert `chage --list` command output parser
|
||||
|
||||
Supports `chage -l <username>` or `chage --list <username>`
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ chage -l johndoe | jc --chage
|
||||
|
||||
or
|
||||
|
||||
$ jc chage -l johndoe
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('chage', chage_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"password_last_changed": string,
|
||||
"password_expires": string,
|
||||
"password_inactive": string,
|
||||
"account_expires": string,
|
||||
"min_days_between_password_change": integer,
|
||||
"max_days_between_password_change": integer,
|
||||
"warning_days_before_password_expires": integer
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ chage --list joeuser | jc --chage -p
|
||||
{
|
||||
"password_last_changed": "never",
|
||||
"password_expires": "never",
|
||||
"password_inactive": "never",
|
||||
"account_expires": "never",
|
||||
"min_days_between_password_change": 0,
|
||||
"max_days_between_password_change": 99999,
|
||||
"warning_days_before_password_expires": 7
|
||||
}
|
||||
|
||||
$ chage --list joeuser | jc --chage -p -r
|
||||
{
|
||||
"password_last_changed": "never",
|
||||
"password_expires": "never",
|
||||
"password_inactive": "never",
|
||||
"account_expires": "never",
|
||||
"min_days_between_password_change": "0",
|
||||
"max_days_between_password_change": "99999",
|
||||
"warning_days_before_password_expires": "7"
|
||||
}
|
||||
|
||||
<a id="jc.parsers.chage.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> Dict
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -77,4 +77,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -20,8 +20,8 @@ Usage (module):
|
||||
|
||||
Schema:
|
||||
|
||||
csv file converted to a Dictionary:
|
||||
https://docs.python.org/3/library/csv.html
|
||||
CSV file converted to a Dictionary:
|
||||
https://docs.python.org/3/library/csv.html
|
||||
|
||||
[
|
||||
{
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
|
||||
jc - JSON Convert `csv` file streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines (cli) or returns a Generator
|
||||
iterator of Dictionaries (module)
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
The `csv` streaming 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.
|
||||
|
||||
Note: The first 100 rows are read into memory to enable delimiter detection,
|
||||
then the rest of the rows are loaded lazily.
|
||||
> Note: The first 100 rows are read into memory to enable delimiter
|
||||
> detection, then the rest of the rows are loaded lazily.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -29,8 +29,8 @@ Usage (module):
|
||||
|
||||
Schema:
|
||||
|
||||
csv file converted to a Dictionary:
|
||||
https://docs.python.org/3/library/csv.html
|
||||
CSV file converted to a Dictionary:
|
||||
https://docs.python.org/3/library/csv.html
|
||||
|
||||
{
|
||||
"column_name1": string,
|
||||
@@ -68,7 +68,7 @@ Examples:
|
||||
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterator object.
|
||||
Main text parsing generator function. Returns an iterable object.
|
||||
|
||||
Parameters:
|
||||
|
||||
@@ -79,13 +79,9 @@ Parameters:
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||
|
||||
Yields:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
Returns:
|
||||
|
||||
Iterator object (generator)
|
||||
Iterable of Dictionaries
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
@@ -100,4 +100,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 2.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 2.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -120,4 +120,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.11 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -345,4 +345,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, aix, freebsd, darwin, win32, cygwin
|
||||
|
||||
Version 2.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 2.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -19,7 +19,7 @@ time of the system the parser is run on)
|
||||
|
||||
Usage (cli):
|
||||
|
||||
C:> dir | jc --dir
|
||||
C:\> dir | jc --dir
|
||||
|
||||
Usage (module):
|
||||
|
||||
@@ -42,7 +42,7 @@ Schema:
|
||||
|
||||
Examples:
|
||||
|
||||
C:> dir | jc --dir -p
|
||||
C:\> dir | jc --dir -p
|
||||
[
|
||||
{
|
||||
"date": "03/24/2021",
|
||||
@@ -83,7 +83,7 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
C:> dir | jc --dir -p -r
|
||||
C:\> dir | jc --dir -p -r
|
||||
[
|
||||
{
|
||||
"date": "03/24/2021",
|
||||
@@ -143,4 +143,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: win32
|
||||
|
||||
Version 1.5 by Rasheed Elsaleh (rasheed@rebelliondefense.com)
|
||||
Version 1.6 by Rasheed Elsaleh (rasheed@rebelliondefense.com)
|
||||
|
||||
@@ -148,4 +148,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -154,4 +154,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -110,4 +110,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, aix, freebsd
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
67
docs/parsers/email_address.md
Normal file
67
docs/parsers/email_address.md
Normal file
@@ -0,0 +1,67 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.email_address"></a>
|
||||
|
||||
# jc.parsers.email\_address
|
||||
|
||||
jc - JSON Convert Email Address string parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ echo "username@example.com" | jc --email-address
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('email_address', email_address_string)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"username": string,
|
||||
"domain": string,
|
||||
"local": string,
|
||||
"local_plus_suffix": string or null
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ echo 'joe.user@gmail.com' | jc --email-address -p
|
||||
{
|
||||
"username": "joe.user",
|
||||
"domain": "gmail.com",
|
||||
"local": "joe.user",
|
||||
"local_plus_suffix": null
|
||||
}
|
||||
|
||||
$ echo 'joe.user+spam@gmail.com' | jc --email-address -p
|
||||
{
|
||||
"username": "joe.user",
|
||||
"domain": "gmail.com",
|
||||
"local": "joe.user+spam",
|
||||
"local_plus_suffix": "spam"
|
||||
}
|
||||
|
||||
<a id="jc.parsers.email_address.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> Dict
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -95,4 +95,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -108,4 +108,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, freebsd
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -43,8 +43,8 @@ Schema:
|
||||
"author": string,
|
||||
"author_email": string,
|
||||
"date": string,
|
||||
"epoch": integer, [0]
|
||||
"epoch_utc": integer, [1]
|
||||
"epoch": integer, # [0]
|
||||
"epoch_utc": integer, # [1]
|
||||
"commit_by": string,
|
||||
"commit_by_email": string,
|
||||
"commit_by_date": string,
|
||||
@@ -172,4 +172,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
111
docs/parsers/git_log_s.md
Normal file
111
docs/parsers/git_log_s.md
Normal file
@@ -0,0 +1,111 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.git_log_s"></a>
|
||||
|
||||
# jc.parsers.git\_log\_s
|
||||
|
||||
jc - JSON Convert `git log` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
Can be used with the following format options:
|
||||
- `oneline`
|
||||
- `short`
|
||||
- `medium`
|
||||
- `full`
|
||||
- `fuller`
|
||||
|
||||
Additional options supported:
|
||||
- `--stat`
|
||||
- `--shortstat`
|
||||
|
||||
The `epoch` calculated timestamp field is naive. (i.e. based on the
|
||||
local time of the system the parser is run on)
|
||||
|
||||
The `epoch_utc` calculated timestamp field is timezone-aware and is
|
||||
only available if the timezone field is UTC.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ git log | jc --git-log-s
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
|
||||
result = jc.parse('git_log_s', git_log_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"commit": string,
|
||||
"author": string,
|
||||
"author_email": string,
|
||||
"date": string,
|
||||
"epoch": integer, # [0]
|
||||
"epoch_utc": integer, # [1]
|
||||
"commit_by": string,
|
||||
"commit_by_email": string,
|
||||
"commit_by_date": string,
|
||||
"message": string,
|
||||
"stats" : {
|
||||
"files_changed": integer,
|
||||
"insertions": integer,
|
||||
"deletions": integer,
|
||||
"files": [
|
||||
string
|
||||
]
|
||||
}
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # false if error parsing
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
}
|
||||
|
||||
[0] naive timestamp if "date" field is parsable, else null
|
||||
[1] timezone aware timestamp availabe for UTC, else null
|
||||
|
||||
Examples:
|
||||
|
||||
$ git log | jc --git-log-s
|
||||
{"commit":"a730ae18c8e81c5261db132df73cd74f272a0a26","author":"Kelly...}
|
||||
{"commit":"930bf439c06c48a952baec05a9896c8d92b7693e","author":"Kelly...}
|
||||
...
|
||||
|
||||
<a id="jc.parsers.git_log_s.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
@add_jc_meta
|
||||
def parse(data: Iterable[str],
|
||||
raw: bool = False,
|
||||
quiet: bool = False,
|
||||
ignore_exceptions: bool = False) -> Union[Iterable[Dict], tuple]
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterable object.
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (iterable) line-based text data to parse
|
||||
(e.g. sys.stdin or str.splitlines())
|
||||
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||
|
||||
|
||||
Returns:
|
||||
|
||||
Iterable of Dictionaries
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
145
docs/parsers/gpg.md
Normal file
145
docs/parsers/gpg.md
Normal file
@@ -0,0 +1,145 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.gpg"></a>
|
||||
|
||||
# jc.parsers.gpg
|
||||
|
||||
jc - JSON Convert `gpg --with-colons` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ gpg --with-colons --show-keys file.gpg | jc --gpg
|
||||
|
||||
or
|
||||
|
||||
$ jc gpg --with-colons --show-keys file.gpg
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('gpg', gpg_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
Field definitions from https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob_plain;f=doc/DETAILS
|
||||
|
||||
> Note: Number values are not converted to integers because many field
|
||||
> specifications are overloaded and future augmentations are implied in the
|
||||
> documentation.
|
||||
|
||||
[
|
||||
{
|
||||
"type": string,
|
||||
"validity": string,
|
||||
"key_length": string,
|
||||
"pub_key_alg": string,
|
||||
"key_id": string,
|
||||
"creation_date": string,
|
||||
"expiration_date": string,
|
||||
"certsn_uidhash_trustinfo": string,
|
||||
"owner_trust": string,
|
||||
"user_id": string,
|
||||
"signature_class": string,
|
||||
"key_capabilities": string,
|
||||
"cert_fingerprint_other": string,
|
||||
"flag": string,
|
||||
"token_sn": string,
|
||||
"hash_alg": string,
|
||||
"curve_name": string,
|
||||
"compliance_flags": string,
|
||||
"last_update_date": string,
|
||||
"origin": string,
|
||||
"comment": string,
|
||||
"index": string, # [0]
|
||||
"bits": string, # [0]
|
||||
"value": string, # [0]
|
||||
"version": string, # [1], [4]
|
||||
"signature_count": string, # [1]
|
||||
"encryption_count": string, # [1]
|
||||
"policy": string, # [1]
|
||||
"signature_first_seen": string, # [1]
|
||||
"signature_most_recent_seen": string, # [1]
|
||||
"encryption_first_done": string, # [1]
|
||||
"encryption_most_recent_done": string, # [1]
|
||||
"staleness_reason": string, # [2]
|
||||
"trust_model": string, # [2]
|
||||
"trust_db_created": string, # [2]
|
||||
"trust_db_expires": string, # [2]
|
||||
"marginally_trusted_users": string, # [2]
|
||||
"completely_trusted_users": string, # [2]
|
||||
"cert_chain_max_depth": string, # [2]
|
||||
"subpacket_number": string, # [3]
|
||||
"hex_flags": string, # [3]
|
||||
"subpacket_length": string, # [3]
|
||||
"subpacket_data": string, # [3]
|
||||
"pubkey": string, # [4]
|
||||
"cipher": string, # [4]
|
||||
"digest": string, # [4]
|
||||
"compress": string, # [4]
|
||||
"group": string, # [4]
|
||||
"members": string, # [4]
|
||||
"curve_names": string, # [4]
|
||||
}
|
||||
]
|
||||
|
||||
All blank values are converted to null/None.
|
||||
|
||||
[0] for 'pkd' type
|
||||
[1] for 'tfs' type
|
||||
[2] for 'tru' type
|
||||
[3] for 'skp' type
|
||||
[4] for 'cfg' type
|
||||
|
||||
Examples:
|
||||
|
||||
$ gpg --with-colons --show-keys file.gpg | jc --gpg -p
|
||||
[
|
||||
{
|
||||
"type": "pub",
|
||||
"validity": "f",
|
||||
"key_length": "1024",
|
||||
"pub_key_alg": "17",
|
||||
"key_id": "6C7EE1B8621CC013",
|
||||
"creation_date": "899817715",
|
||||
"expiration_date": "1055898235",
|
||||
"certsn_uidhash_trustinfo": null,
|
||||
"owner_trust": "m",
|
||||
"user_id": null,
|
||||
"signature_class": null,
|
||||
"key_capabilities": "scESC",
|
||||
"cert_fingerprint_other": null,
|
||||
"flag": null,
|
||||
"token_sn": null,
|
||||
"hash_alg": null,
|
||||
"curve_name": null,
|
||||
"compliance_flags": null,
|
||||
"last_update_date": null,
|
||||
"origin": null,
|
||||
"comment": null
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.gpg.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -132,4 +132,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, aix, freebsd
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -60,4 +60,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -340,4 +340,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -128,4 +128,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, aix, freebsd
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
jc - JSON Convert `ifconfig` command output parser
|
||||
|
||||
Note: No `ifconfig` options are supported.
|
||||
> Note: No `ifconfig` options are supported.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -209,4 +209,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, aix, freebsd, darwin
|
||||
|
||||
Version 1.11 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.12 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -11,9 +11,10 @@ Parses standard `INI` files and files containing simple key/value pairs.
|
||||
- Comment prefix can be `#` or `;`. Comments must be on their own line.
|
||||
- If duplicate keys are found, only the last value will be used.
|
||||
|
||||
> 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()`.
|
||||
> Note: Values starting and ending with double or single 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):
|
||||
|
||||
@@ -26,8 +27,8 @@ Usage (module):
|
||||
|
||||
Schema:
|
||||
|
||||
ini or key/value document converted to a dictionary - see the
|
||||
configparser standard library documentation for more details.
|
||||
ini or key/value document converted to a dictionary - see the configparser
|
||||
standard library documentation for more details.
|
||||
|
||||
{
|
||||
"key1": string,
|
||||
@@ -91,4 +92,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
jc - JSON Convert `iostat` command output parser
|
||||
|
||||
Note: `iostat` version 11 and higher include a JSON output option
|
||||
> Note: `iostat` version 11 and higher include a JSON output option
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -182,4 +182,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -5,21 +5,21 @@
|
||||
|
||||
jc - JSON Convert `iostat` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines (cli) or returns a Generator
|
||||
iterator of Dictionaries (module)
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
Note: `iostat` version 11 and higher include a JSON output option
|
||||
> Note: `iostat` version 11 and higher include a JSON output option
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ iostat | jc --iostat-s
|
||||
|
||||
> Note: When piping `jc` converted `iostat` output to other processes it may
|
||||
appear the output is hanging due to the OS pipe buffers. This is because
|
||||
`iostat` output is too small to quickly fill up the buffer. Use the `-u`
|
||||
option to unbuffer the `jc` output if you would like immediate output. See
|
||||
the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
|
||||
for more information.
|
||||
> appear the output is hanging due to the OS pipe buffers. This is because
|
||||
> `iostat` output is too small to quickly fill up the buffer. Use the `-u`
|
||||
> option to unbuffer the `jc` output if you would like immediate output. See
|
||||
> the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
|
||||
> for more information.
|
||||
|
||||
Usage (module):
|
||||
|
||||
@@ -112,7 +112,7 @@ Examples:
|
||||
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterator object.
|
||||
Main text parsing generator function. Returns an iterable object.
|
||||
|
||||
Parameters:
|
||||
|
||||
@@ -123,15 +123,11 @@ Parameters:
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||
|
||||
Yields:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
Returns:
|
||||
|
||||
Iterator object (generator)
|
||||
Iterable of Dictionaries
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -186,4 +186,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
91
docs/parsers/iso_datetime.md
Normal file
91
docs/parsers/iso_datetime.md
Normal file
@@ -0,0 +1,91 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.iso_datetime"></a>
|
||||
|
||||
# jc.parsers.iso\_datetime
|
||||
|
||||
jc - JSON Convert ISO 8601 Datetime string parser
|
||||
|
||||
This parser supports standard ISO 8601 strings that include both date and
|
||||
time. If no timezone or offset information is available in the sring, then
|
||||
UTC timezone is used.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ echo "2022-07-20T14:52:45Z" | jc --iso-datetime
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('iso_datetime', iso_8601_string)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"year": integer,
|
||||
"month": string,
|
||||
"month_num": integer,
|
||||
"day": integer,
|
||||
"weekday": string,
|
||||
"weekday_num": integer,
|
||||
"hour": integer,
|
||||
"hour_24": integer,
|
||||
"minute": integer,
|
||||
"second": integer,
|
||||
"microsecond": integer,
|
||||
"period": string,
|
||||
"utc_offset": string,
|
||||
"day_of_year": integer,
|
||||
"week_of_year": integer,
|
||||
"iso": string,
|
||||
"timestamp": integer # [0]
|
||||
}
|
||||
|
||||
[0] timezone aware UNIX timestamp expressed in UTC
|
||||
|
||||
Examples:
|
||||
|
||||
$ echo "2022-07-20T14:52:45Z" | jc --iso-datetime -p
|
||||
{
|
||||
"year": 2022,
|
||||
"month": "Jul",
|
||||
"month_num": 7,
|
||||
"day": 20,
|
||||
"weekday": "Wed",
|
||||
"weekday_num": 3,
|
||||
"hour": 2,
|
||||
"hour_24": 14,
|
||||
"minute": 52,
|
||||
"second": 45,
|
||||
"microsecond": 0,
|
||||
"period": "PM",
|
||||
"utc_offset": "+0000",
|
||||
"day_of_year": 201,
|
||||
"week_of_year": 29,
|
||||
"iso": "2022-07-20T14:52:45+00:00",
|
||||
"timestamp": 1658328765
|
||||
}
|
||||
|
||||
<a id="jc.parsers.iso_datetime.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, aix, freebsd, darwin, win32, cygwin
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -116,4 +116,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
73
docs/parsers/jwt.md
Normal file
73
docs/parsers/jwt.md
Normal file
@@ -0,0 +1,73 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.jwt"></a>
|
||||
|
||||
# jc.parsers.jwt
|
||||
|
||||
jc - JSON Convert JWT string parser
|
||||
|
||||
> Note: `jc` will not check the integrity of the JWT payload.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ echo "eyJhbGciOiJIUzI1N..." | jc --jwt
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('jwt', jwt_string)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"header": {
|
||||
"alg": string,
|
||||
"typ": string
|
||||
},
|
||||
"payload": {
|
||||
<key name>: string/integer/float/boolean/null
|
||||
},
|
||||
"signature": string # [0]
|
||||
}
|
||||
|
||||
[0] in colon-delimited hex notation
|
||||
|
||||
Examples:
|
||||
|
||||
% echo 'eyJhbGciOiJIUzI1N...' | jc --jwt -p
|
||||
{
|
||||
"header": {
|
||||
"alg": "HS256",
|
||||
"typ": "JWT"
|
||||
},
|
||||
"payload": {
|
||||
"sub": "1234567890",
|
||||
"name": "John Doe",
|
||||
"iat": 1516239022
|
||||
},
|
||||
"signature": "49:f9:4a:c7:04:49:48:c7:8a:28:5d:90:4f:87:f0:a4:c7..."
|
||||
}
|
||||
|
||||
<a id="jc.parsers.jwt.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> Dict
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -12,8 +12,8 @@ Supports files containing simple key/value pairs.
|
||||
- If duplicate keys are found, only the last value will be used.
|
||||
|
||||
> 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()`.
|
||||
> 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):
|
||||
|
||||
@@ -26,8 +26,8 @@ Usage (module):
|
||||
|
||||
Schema:
|
||||
|
||||
key/value document converted to a dictionary - see the
|
||||
configparser standard library documentation for more details.
|
||||
key/value document converted to a dictionary - see the configparser standard
|
||||
library documentation for more details.
|
||||
|
||||
{
|
||||
"key1": string,
|
||||
|
||||
@@ -9,11 +9,12 @@ Options supported:
|
||||
- `lbaR1`
|
||||
- `--time-style=full-iso`
|
||||
|
||||
Note: The `-1`, `-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 `-1`, `-l`, or `-b` is not used.
|
||||
Alternatively, `vdir` can be used, which is the same as running `ls -lb`.
|
||||
> Note: The `-1`, `-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 `-1`, `-l`, or `-b` is
|
||||
> not used. Alternatively, `vdir` can be used, which is the same as running
|
||||
> `ls -lb`.
|
||||
|
||||
The `epoch` calculated timestamp field is naive. (i.e. based on the local
|
||||
time of the system the parser is run on)
|
||||
@@ -139,4 +140,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.11 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.12 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
jc - JSON Convert `ls` and `vdir` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines (cli) or returns a Generator
|
||||
iterator of Dictionaries (module)
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
Requires the `-l` option to be used on `ls`. If there are newline characters
|
||||
in the filename, then make sure to use the `-b` option on `ls`.
|
||||
@@ -81,7 +81,7 @@ Examples:
|
||||
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterator object.
|
||||
Main text parsing generator function. Returns an iterable object.
|
||||
|
||||
Parameters:
|
||||
|
||||
@@ -92,15 +92,11 @@ Parameters:
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||
|
||||
Yields:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
Returns:
|
||||
|
||||
Iterator object (generator)
|
||||
Iterable of Dictionaries
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -297,4 +297,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -148,4 +148,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -142,4 +142,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -22,9 +22,9 @@ Usage (module):
|
||||
|
||||
Schema:
|
||||
|
||||
Note: <item> object keynames are assigned directly from the lsusb
|
||||
output. If there are duplicate <item> names in a section, only the
|
||||
last one is converted.
|
||||
> Note: <item> object keynames are assigned directly from the lsusb
|
||||
> output. If there are duplicate <item> names in a section, only the
|
||||
> last one is converted.
|
||||
|
||||
[
|
||||
{
|
||||
|
||||
90
docs/parsers/m3u.md
Normal file
90
docs/parsers/m3u.md
Normal file
@@ -0,0 +1,90 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.m3u"></a>
|
||||
|
||||
# jc.parsers.m3u
|
||||
|
||||
jc - JSON Convert M3U and M3U8 file parser
|
||||
|
||||
This parser will make a best-effort to parse extended field information. If
|
||||
the extended fields cannot be successfully parsed, then an `unparsed_info`
|
||||
field will be added to the object. If not using `--quiet`, then a warning
|
||||
message also will be printed to `STDERR`.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat playlist.m3u | jc --m3u
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('m3u', m3u_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"runtime": integer,
|
||||
"display": string,
|
||||
"path": string,
|
||||
<extended fields>: string, # [0]
|
||||
"unparsed_info": string, # [1]
|
||||
}
|
||||
]
|
||||
|
||||
[0] Field names are pulled directly from the #EXTINF: line
|
||||
[1] Only added if the extended information cannot be parsed
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat playlist.m3u | jc --m3u -p
|
||||
[
|
||||
{
|
||||
"runtime": 105,
|
||||
"display": "Example artist - Example title",
|
||||
"path": "C:\\Files\\My Music\\Example.mp3"
|
||||
},
|
||||
{
|
||||
"runtime": 321,
|
||||
"display": "Example Artist2 - Example title2",
|
||||
"path": "C:\\Files\\My Music\\Favorites\\Example2.ogg"
|
||||
}
|
||||
]
|
||||
|
||||
$ cat playlist.m3u | jc --m3u -p -r
|
||||
[
|
||||
{
|
||||
"runtime": "105",
|
||||
"display": "Example artist - Example title",
|
||||
"path": "C:\\Files\\My Music\\Example.mp3"
|
||||
},
|
||||
{
|
||||
"runtime": "321",
|
||||
"display": "Example Artist2 - Example title2",
|
||||
"path": "C:\\Files\\My Music\\Favorites\\Example2.ogg"
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.m3u.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
jc - JSON Convert `mpstat` command output parser
|
||||
|
||||
Note: Latest versions of `mpstat` support JSON output (v11.5.1+)
|
||||
> Note: Latest versions of `mpstat` support JSON output (v11.5.1+)
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -137,4 +137,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
|
||||
jc - JSON Convert `mpstat` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines (cli) or returns a Generator
|
||||
iterator of Dictionaries (module)
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
Note: Latest versions of `mpstat` support JSON output (v11.5.1+)
|
||||
> Note: Latest versions of `mpstat` support JSON output (v11.5.1+)
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -101,15 +101,13 @@ Examples:
|
||||
|
||||
```python
|
||||
@add_jc_meta
|
||||
def parse(
|
||||
data: Iterable[str],
|
||||
raw: bool = False,
|
||||
quiet: bool = False,
|
||||
ignore_exceptions: bool = False
|
||||
) -> Union[Generator[Dict, None, None], tuple]
|
||||
def parse(data: Iterable[str],
|
||||
raw: bool = False,
|
||||
quiet: bool = False,
|
||||
ignore_exceptions: bool = False) -> Union[Iterable[Dict], tuple]
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterator object.
|
||||
Main text parsing generator function. Returns an iterable object.
|
||||
|
||||
Parameters:
|
||||
|
||||
@@ -120,15 +118,11 @@ Parameters:
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||
|
||||
Yields:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
Returns:
|
||||
|
||||
Iterator object (generator)
|
||||
Iterable of Dictionaries
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -378,4 +378,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.12 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.13 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -29,18 +29,18 @@ Usage (module):
|
||||
|
||||
Schema:
|
||||
|
||||
Because there are so many options, the schema is not strictly defined.
|
||||
Integer and Float value conversions are attempted and the original
|
||||
values are kept if they fail. If you don't want automatic conversion,
|
||||
then use the -r or raw=True option to disable it.
|
||||
Because there are so many options, the schema is not strictly defined.
|
||||
Integer and Float value conversions are attempted and the original
|
||||
values are kept if they fail. If you don't want automatic conversion,
|
||||
then use the `-r` or `raw=True` option to disable it.
|
||||
|
||||
The structure is flat, for the most part, but there are a couple of
|
||||
"well-known" keys that are further parsed into objects for convenience.
|
||||
These are documented below.
|
||||
The structure is flat, for the most part, but there are a couple of
|
||||
"well-known" keys that are further parsed into objects for convenience.
|
||||
These are documented below.
|
||||
|
||||
[
|
||||
{
|
||||
"<key>": string/integer/float, [0]
|
||||
"<key>": string/integer/float, # [0]
|
||||
"dhcp4_option_x": {
|
||||
"name": string,
|
||||
"value": string/integer/float,
|
||||
|
||||
@@ -229,4 +229,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, freebsd
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
# jc.parsers.pidstat
|
||||
|
||||
jc - JSON Convert `pidstat` command output parser
|
||||
jc - JSON Convert `pidstat -h` command output parser
|
||||
|
||||
Must use the `-h` option in `pidstat`. All other `pidstat` options are
|
||||
supported in combination with `-h`.
|
||||
@@ -148,4 +148,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
|
||||
# jc.parsers.pidstat\_s
|
||||
|
||||
jc - JSON Convert `pidstat` command output streaming parser
|
||||
jc - JSON Convert `pidstat -h` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines (cli) or returns a Generator
|
||||
iterator of Dictionaries (module)
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
Must use the `-h` option in `pidstat`. All other `pidstat` options are
|
||||
supported in combination with `-h`.
|
||||
@@ -16,11 +16,11 @@ Usage (cli):
|
||||
$ pidstat | jc --pidstat-s
|
||||
|
||||
> Note: When piping `jc` converted `pidstat` output to other processes it
|
||||
may appear the output is hanging due to the OS pipe buffers. This is
|
||||
because `pidstat` output is too small to quickly fill up the buffer. Use
|
||||
the `-u` option to unbuffer the `jc` output if you would like immediate
|
||||
output. See the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
|
||||
for more information.
|
||||
> may appear the output is hanging due to the OS pipe buffers. This is
|
||||
> because `pidstat` output is too small to quickly fill up the buffer. Use
|
||||
> the `-u` option to unbuffer the `jc` output if you would like immediate
|
||||
> output. See the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
|
||||
> for more information.
|
||||
|
||||
Usage (module):
|
||||
|
||||
@@ -83,15 +83,13 @@ Examples:
|
||||
|
||||
```python
|
||||
@add_jc_meta
|
||||
def parse(
|
||||
data: Iterable[str],
|
||||
raw: bool = False,
|
||||
quiet: bool = False,
|
||||
ignore_exceptions: bool = False
|
||||
) -> Union[Generator[Dict, None, None], tuple]
|
||||
def parse(data: Iterable[str],
|
||||
raw: bool = False,
|
||||
quiet: bool = False,
|
||||
ignore_exceptions: bool = False) -> Union[Iterable[Dict], tuple]
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterator object.
|
||||
Main text parsing generator function. Returns an iterable object.
|
||||
|
||||
Parameters:
|
||||
|
||||
@@ -102,15 +100,11 @@ Parameters:
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||
|
||||
Yields:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
Returns:
|
||||
|
||||
Iterator object (generator)
|
||||
Iterable of Dictionaries
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -9,8 +9,8 @@ Supports `ping` and `ping6` output.
|
||||
|
||||
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
|
||||
|
||||
@@ -185,4 +185,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -5,21 +5,21 @@
|
||||
|
||||
jc - JSON Convert `ping` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines (cli) or returns a Generator
|
||||
iterator of Dictionaries (module)
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
Supports `ping` and `ping6` output.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ ping | jc --ping-s
|
||||
$ ping 1.2.3.4 | jc --ping-s
|
||||
|
||||
> Note: When piping `jc` converted `ping` output to other processes it may
|
||||
appear the output is hanging due to the OS pipe buffers. This is because
|
||||
`ping` output is too small to quickly fill up the buffer. Use the `-u`
|
||||
option to unbuffer the `jc` output if you would like immediate output.
|
||||
See the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
|
||||
for more information.
|
||||
> appear the output is hanging due to the OS pipe buffers. This is because
|
||||
> `ping` output is too small to quickly fill up the buffer. Use the `-u`
|
||||
> option to unbuffer the `jc` output if you would like immediate output.
|
||||
> See the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
|
||||
> for more information.
|
||||
|
||||
Usage (module):
|
||||
|
||||
@@ -88,7 +88,7 @@ Examples:
|
||||
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterator object.
|
||||
Main text parsing generator function. Returns an iterable object.
|
||||
|
||||
Parameters:
|
||||
|
||||
@@ -99,15 +99,11 @@ Parameters:
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||
|
||||
Yields:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
Returns:
|
||||
|
||||
Iterator object (generator)
|
||||
Iterable of Dictionaries
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -70,7 +70,7 @@ Examples:
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data, raw=False, quiet=False)
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -88,4 +88,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
115
docs/parsers/postconf.md
Normal file
115
docs/parsers/postconf.md
Normal file
@@ -0,0 +1,115 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.postconf"></a>
|
||||
|
||||
# jc.parsers.postconf
|
||||
|
||||
jc - JSON Convert `postconf -M` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ postconf -M | jc --postconf
|
||||
|
||||
or
|
||||
|
||||
$ jc postconf -M
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('postconf', postconf_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"service_name": string,
|
||||
"service_type": string,
|
||||
"private": boolean/null, # [0]
|
||||
"unprivileged": boolean/null, # [0]
|
||||
"chroot": boolean/null, # [0]
|
||||
"wake_up_time": integer/null, # [0]
|
||||
"no_wake_up_before_first_use": boolean/null, # [1]
|
||||
"process_limit": integer/null, # [0]
|
||||
"command": string
|
||||
}
|
||||
]
|
||||
|
||||
[0] '-' converted to null/None
|
||||
[1] null/None if `wake_up_time` is null/None
|
||||
|
||||
Examples:
|
||||
|
||||
$ postconf -M | jc --postconf -p
|
||||
[
|
||||
{
|
||||
"service_name": "smtp",
|
||||
"service_type": "inet",
|
||||
"private": false,
|
||||
"unprivileged": null,
|
||||
"chroot": true,
|
||||
"wake_up_time": null,
|
||||
"process_limit": null,
|
||||
"command": "smtpd",
|
||||
"no_wake_up_before_first_use": null
|
||||
},
|
||||
{
|
||||
"service_name": "pickup",
|
||||
"service_type": "unix",
|
||||
"private": false,
|
||||
"unprivileged": null,
|
||||
"chroot": true,
|
||||
"wake_up_time": 60,
|
||||
"process_limit": 1,
|
||||
"command": "pickup",
|
||||
"no_wake_up_before_first_use": false
|
||||
}
|
||||
]
|
||||
|
||||
$ postconf -M | jc --postconf -p -r
|
||||
[
|
||||
{
|
||||
"service_name": "smtp",
|
||||
"service_type": "inet",
|
||||
"private": "n",
|
||||
"unprivileged": "-",
|
||||
"chroot": "y",
|
||||
"wake_up_time": "-",
|
||||
"process_limit": "-",
|
||||
"command": "smtpd"
|
||||
},
|
||||
{
|
||||
"service_name": "pickup",
|
||||
"service_type": "unix",
|
||||
"private": "n",
|
||||
"unprivileged": "-",
|
||||
"chroot": "y",
|
||||
"wake_up_time": "60",
|
||||
"process_limit": "1",
|
||||
"command": "pickup"
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.postconf.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -229,4 +229,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -22,20 +22,20 @@ Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"destination": string,
|
||||
"gateway": string,
|
||||
"genmask": string,
|
||||
"flags": string,
|
||||
"destination": string,
|
||||
"gateway": string,
|
||||
"genmask": string,
|
||||
"flags": string,
|
||||
"flags_pretty": [
|
||||
string
|
||||
string
|
||||
]
|
||||
"metric": integer,
|
||||
"ref": integer,
|
||||
"use": integer,
|
||||
"mss": integer,
|
||||
"window": integer,
|
||||
"irtt": integer,
|
||||
"iface": string
|
||||
"metric": integer,
|
||||
"ref": integer,
|
||||
"use": integer,
|
||||
"mss": integer,
|
||||
"window": integer,
|
||||
"irtt": integer,
|
||||
"iface": string
|
||||
}
|
||||
]
|
||||
|
||||
@@ -131,4 +131,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -10,7 +10,7 @@ Works with `rpm -qi [package]` or `rpm -qia`.
|
||||
The `..._epoch` calculated timestamp fields are naive. (i.e. based on the
|
||||
local time of the system the parser is run on)
|
||||
|
||||
The `..._epoch_utc` calculated timestamp fields are timezone-aware and is
|
||||
The `..._epoch_utc` calculated timestamp fields are timezone-aware and are
|
||||
only available if the timezone field is UTC.
|
||||
|
||||
Usage (cli):
|
||||
@@ -184,4 +184,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
jc - JSON Convert `rsync` command output parser
|
||||
|
||||
Supports the `-i` or `--itemize-changes` options with all levels of
|
||||
verbosity. This parser will process the STDOUT output or a log file
|
||||
verbosity. This parser will process the `STDOUT` output or a log file
|
||||
generated with the `--log-file` option.
|
||||
|
||||
Usage (cli):
|
||||
@@ -51,8 +51,8 @@ Schema:
|
||||
"time": string,
|
||||
"process": integer,
|
||||
"metadata": string,
|
||||
"update_type": string/null, [0]
|
||||
"file_type": string/null, [1]
|
||||
"update_type": string/null, # [0]
|
||||
"file_type": string/null, # [1]
|
||||
"checksum_or_value_different": bool/null,
|
||||
"size_different": bool/null,
|
||||
"modification_time_different": bool/null,
|
||||
@@ -61,7 +61,7 @@ Schema:
|
||||
"group_different": bool/null,
|
||||
"acl_different": bool/null,
|
||||
"extended_attribute_different": bool/null,
|
||||
"epoch": integer, [2]
|
||||
"epoch": integer, # [2]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -157,4 +157,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
|
||||
jc - JSON Convert `rsync` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines (cli) or returns a Generator
|
||||
iterator of Dictionaries (module)
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
Supports the `-i` or `--itemize-changes` options with all levels of
|
||||
verbosity. This parser will process the STDOUT output or a log file
|
||||
verbosity. This parser will process the `STDOUT` output or a log file
|
||||
generated with the `--log-file` option.
|
||||
|
||||
Usage (cli):
|
||||
@@ -49,8 +49,8 @@ Schema:
|
||||
"time": string,
|
||||
"process": integer,
|
||||
"metadata": string,
|
||||
"update_type": string/null, [0]
|
||||
"file_type": string/null, [1]
|
||||
"update_type": string/null, # [0]
|
||||
"file_type": string/null, # [1]
|
||||
"checksum_or_value_different": bool/null,
|
||||
"size_different": bool/null,
|
||||
"modification_time_different": bool/null,
|
||||
@@ -59,7 +59,7 @@ Schema:
|
||||
"group_different": bool/null,
|
||||
"acl_different": bool/null,
|
||||
"extended_attribute_different": bool/null,
|
||||
"epoch": integer, [2]
|
||||
"epoch": integer, # [2]
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
@@ -90,15 +90,13 @@ Examples:
|
||||
|
||||
```python
|
||||
@add_jc_meta
|
||||
def parse(
|
||||
data: Iterable[str],
|
||||
raw: bool = False,
|
||||
quiet: bool = False,
|
||||
ignore_exceptions: bool = False
|
||||
) -> Union[Generator[Dict, None, None], tuple]
|
||||
def parse(data: Iterable[str],
|
||||
raw: bool = False,
|
||||
quiet: bool = False,
|
||||
ignore_exceptions: bool = False) -> Union[Iterable[Dict], tuple]
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterator object.
|
||||
Main text parsing generator function. Returns an iterable object.
|
||||
|
||||
Parameters:
|
||||
|
||||
@@ -109,15 +107,11 @@ Parameters:
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||
|
||||
Yields:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
Returns:
|
||||
|
||||
Iterator object (generator)
|
||||
Iterable of Dictionaries
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -225,4 +225,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -124,4 +124,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, aix, freebsd
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
jc - JSON Convert `ss` command output parser
|
||||
|
||||
Extended information options like -e and -p are not supported and may cause
|
||||
parsing irregularities.
|
||||
Extended information options like `-e` and `-p` are not supported and may
|
||||
cause parsing irregularities.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -23,8 +23,8 @@ Usage (module):
|
||||
|
||||
Schema:
|
||||
|
||||
Information from https://www.cyberciti.biz/files/ss.html used to define
|
||||
field names
|
||||
Information from https://www.cyberciti.biz/files/ss.html used to define
|
||||
field names
|
||||
|
||||
[
|
||||
{
|
||||
@@ -303,4 +303,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -193,4 +193,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.11 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.12 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
jc - JSON Convert `stat` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines (cli) or returns a Generator
|
||||
iterator of Dictionaries (module)
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
The `xxx_epoch` calculated timestamp fields are naive. (i.e. based on the
|
||||
local time of the system the parser is run on).
|
||||
@@ -86,7 +86,7 @@ Examples:
|
||||
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterator object.
|
||||
Main text parsing generator function. Returns an iterable object.
|
||||
|
||||
Parameters:
|
||||
|
||||
@@ -97,15 +97,11 @@ Parameters:
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||
|
||||
Yields:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
Returns:
|
||||
|
||||
Iterator object (generator)
|
||||
Iterable of Dictionaries
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
|
||||
jc - JSON Convert `sysctl -a` command output parser
|
||||
|
||||
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()`.
|
||||
> 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()`.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
|
||||
@@ -98,4 +98,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -234,4 +234,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: win32
|
||||
|
||||
Version 1.2 by Jon Smith (jon@rebelliondefense.com)
|
||||
Version 1.3 by Jon Smith (jon@rebelliondefense.com)
|
||||
|
||||
@@ -11,8 +11,8 @@ used to redirect the output to a file that can be read by `jc`.
|
||||
Alternatively, the output from `/usr/bin/time` can be redirected to `STDOUT`
|
||||
so `jc` can receive it.
|
||||
|
||||
Note: `/usr/bin/time` is similar but different from the Bash builtin
|
||||
`time` command.
|
||||
> Note: `/usr/bin/time` is similar but different from the Bash builtin
|
||||
> `time` command.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -26,8 +26,8 @@ Usage (module):
|
||||
|
||||
Schema:
|
||||
|
||||
Source: https://www.freebsd.org/cgi/man.cgi?query=getrusage
|
||||
https://man7.org/linux/man-pages/man1/time.1.html
|
||||
Source: https://www.freebsd.org/cgi/man.cgi?query=getrusage,
|
||||
https://man7.org/linux/man-pages/man1/time.1.html
|
||||
|
||||
{
|
||||
"real_time": float,
|
||||
@@ -155,4 +155,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -87,4 +87,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
122
docs/parsers/timestamp.md
Normal file
122
docs/parsers/timestamp.md
Normal file
@@ -0,0 +1,122 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.timestamp"></a>
|
||||
|
||||
# jc.parsers.timestamp
|
||||
|
||||
jc - JSON Convert UNIX Epoch Timestamp string parser
|
||||
|
||||
The naive fields are based on the local time of the system the parser is
|
||||
run on.
|
||||
|
||||
The utc fields are timezone-aware, based on the UTC timezone.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ echo "2022-07-20T14:52:45Z" | jc --timestamp
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('timestamp', timestamp_string)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"naive": {
|
||||
"year": integer,
|
||||
"month": string,
|
||||
"month_num": integer,
|
||||
"day": integer,
|
||||
"weekday": string,
|
||||
"weekday_num": integer,
|
||||
"hour": integer,
|
||||
"hour_24": integer,
|
||||
"minute": integer,
|
||||
"second": integer,
|
||||
"period": string,
|
||||
"day_of_year": integer,
|
||||
"week_of_year": integer,
|
||||
"iso": string
|
||||
},
|
||||
"utc": {
|
||||
"year": integer,
|
||||
"month": string,
|
||||
"month_num": integer,
|
||||
"day": integer,
|
||||
"weekday": string,
|
||||
"weekday_num": integer,
|
||||
"hour": integer,
|
||||
"hour_24": integer,
|
||||
"minute": integer,
|
||||
"second": integer,
|
||||
"period": string,
|
||||
"utc_offset": string,
|
||||
"day_of_year": integer,
|
||||
"week_of_year": integer,
|
||||
"iso": string
|
||||
}
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ echo '1658599410' | jc --timestamp -p
|
||||
{
|
||||
"naive": {
|
||||
"year": 2022,
|
||||
"month": "Jul",
|
||||
"month_num": 7,
|
||||
"day": 23,
|
||||
"weekday": "Sat",
|
||||
"weekday_num": 6,
|
||||
"hour": 11,
|
||||
"hour_24": 11,
|
||||
"minute": 3,
|
||||
"second": 30,
|
||||
"period": "AM",
|
||||
"day_of_year": 204,
|
||||
"week_of_year": 29,
|
||||
"iso": "2022-07-23T11:03:30"
|
||||
},
|
||||
"utc": {
|
||||
"year": 2022,
|
||||
"month": "Jul",
|
||||
"month_num": 7,
|
||||
"day": 23,
|
||||
"weekday": "Sat",
|
||||
"weekday_num": 6,
|
||||
"hour": 6,
|
||||
"hour_24": 18,
|
||||
"minute": 3,
|
||||
"second": 30,
|
||||
"period": "PM",
|
||||
"utc_offset": "+0000",
|
||||
"day_of_year": 204,
|
||||
"week_of_year": 29,
|
||||
"iso": "2022-07-23T18:03:30+00:00"
|
||||
}
|
||||
}
|
||||
|
||||
<a id="jc.parsers.timestamp.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, aix, freebsd, darwin, win32, cygwin
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
339
docs/parsers/top.md
Normal file
339
docs/parsers/top.md
Normal file
@@ -0,0 +1,339 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.top"></a>
|
||||
|
||||
# jc.parsers.top
|
||||
|
||||
jc - JSON Convert `top -b` command output parser
|
||||
|
||||
Requires batch mode (`-b`). The `-n` option must also be used to limit
|
||||
the number of times `top` is run.
|
||||
|
||||
Warning messages will be printed to `STDERR` if truncated fields are
|
||||
detected. These warnings can be suppressed with the `-q` or `quiet=True`
|
||||
option.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ top -b -n 3 | jc --top
|
||||
|
||||
or
|
||||
|
||||
$ jc top -b -n 3
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('top', top_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
All `-` values are converted to `null`
|
||||
|
||||
[
|
||||
{
|
||||
"time": string,
|
||||
"uptime": integer,
|
||||
"users": integer,
|
||||
"load_1m": float,
|
||||
"load_5m": float,
|
||||
"load_15m": float,
|
||||
"tasks_total": integer,
|
||||
"tasks_running": integer,
|
||||
"tasks_sleeping": integer,
|
||||
"tasks_stopped": integer,
|
||||
"tasks_zombie": integer,
|
||||
"cpu_user": float,
|
||||
"cpu_sys": float,
|
||||
"cpu_nice": float,
|
||||
"cpu_idle": float,
|
||||
"cpu_wait": float,
|
||||
"cpu_hardware": float,
|
||||
"cpu_software": float,
|
||||
"cpu_steal": float,
|
||||
"mem_total": float, # [0]
|
||||
"mem_free": float, # [0]
|
||||
"mem_used": float, # [0]
|
||||
"mem_buff_cache": float, # [0]
|
||||
"swap_total": float, # [0]
|
||||
"swap_free": float, # [0]
|
||||
"swap_used": float, # [0]
|
||||
"mem_available": float, # [0]
|
||||
"processes": [
|
||||
{
|
||||
"pid": integer,
|
||||
"user": string,
|
||||
"priority": integer,
|
||||
"nice": integer,
|
||||
"virtual_mem": float, # [1]
|
||||
"resident_mem": float, # [1]
|
||||
"shared_mem": float, # [1]
|
||||
"status": string,
|
||||
"percent_cpu": float,
|
||||
"percent_mem": float,
|
||||
"time_hundredths": string,
|
||||
"command": string,
|
||||
"parent_pid": integer,
|
||||
"uid": integer,
|
||||
"real_uid": integer,
|
||||
"real_user": string,
|
||||
"saved_uid": integer,
|
||||
"saved_user": string,
|
||||
"gid": integer,
|
||||
"group": string,
|
||||
"pgrp": integer,
|
||||
"tty": string,
|
||||
"tty_process_gid": integer,
|
||||
"session_id": integer,
|
||||
"thread_count": integer,
|
||||
"last_used_processor": integer,
|
||||
"time": string,
|
||||
"swap": float, # [1]
|
||||
"code": float, # [1]
|
||||
"data": float, # [1]
|
||||
"major_page_fault_count": integer,
|
||||
"minor_page_fault_count": integer,
|
||||
"dirty_pages_count": integer,
|
||||
"sleeping_in_function": string,
|
||||
"flags": string,
|
||||
"cgroups": string,
|
||||
"supplementary_gids": [
|
||||
integer
|
||||
],
|
||||
"supplementary_groups": [
|
||||
string
|
||||
],
|
||||
"thread_gid": integer,
|
||||
"environment_variables": [
|
||||
string
|
||||
]
|
||||
"major_page_fault_count_delta": integer,
|
||||
"minor_page_fault_count_delta": integer,
|
||||
"used": float, # [1]
|
||||
"ipc_namespace_inode": integer,
|
||||
"mount_namespace_inode": integer,
|
||||
"net_namespace_inode": integer,
|
||||
"pid_namespace_inode": integer,
|
||||
"user_namespace_inode": integer,
|
||||
"nts_namespace_inode": integer,
|
||||
"control_group_name": string,
|
||||
"lxc_container_name": string,
|
||||
"numa_node": integer,
|
||||
"out_of_mem_adjustment": integer,
|
||||
"out_of_mem_score": integer,
|
||||
"resident_anon_mem": integer,
|
||||
"resident_file_backed_mem": integer,
|
||||
"resident_locked_mem": integer,
|
||||
"resident_shared_mem": integer
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
[0] Values are in the units output by `top`
|
||||
[1] Unit suffix stripped during float conversion
|
||||
|
||||
Examples:
|
||||
|
||||
$ top -b -n 3 | jc --top -p
|
||||
[
|
||||
{
|
||||
"time": "11:20:43",
|
||||
"uptime": 118,
|
||||
"users": 2,
|
||||
"load_1m": 0.0,
|
||||
"load_5m": 0.01,
|
||||
"load_15m": 0.05,
|
||||
"tasks_total": 108,
|
||||
"tasks_running": 2,
|
||||
"tasks_sleeping": 106,
|
||||
"tasks_stopped": 0,
|
||||
"tasks_zombie": 0,
|
||||
"cpu_user": 5.6,
|
||||
"cpu_sys": 11.1,
|
||||
"cpu_nice": 0.0,
|
||||
"cpu_idle": 83.3,
|
||||
"cpu_wait": 0.0,
|
||||
"cpu_hardware": 0.0,
|
||||
"cpu_software": 0.0,
|
||||
"cpu_steal": 0.0,
|
||||
"mem_total": 3.7,
|
||||
"mem_free": 3.3,
|
||||
"mem_used": 0.2,
|
||||
"mem_buff_cache": 0.2,
|
||||
"swap_total": 2.0,
|
||||
"swap_free": 2.0,
|
||||
"swap_used": 0.0,
|
||||
"mem_available": 3.3,
|
||||
"processes": [
|
||||
{
|
||||
"pid": 2225,
|
||||
"user": "kbrazil",
|
||||
"priority": 20,
|
||||
"nice": 0,
|
||||
"virtual_mem": 158.1,
|
||||
"resident_mem": 2.2,
|
||||
"shared_mem": 1.6,
|
||||
"status": "running",
|
||||
"percent_cpu": 12.5,
|
||||
"percent_mem": 0.1,
|
||||
"time_hundredths": "0:00.02",
|
||||
"command": "top",
|
||||
"parent_pid": 1884,
|
||||
"uid": 1000,
|
||||
"real_uid": 1000,
|
||||
"real_user": "kbrazil",
|
||||
"saved_uid": 1000,
|
||||
"saved_user": "kbrazil",
|
||||
"gid": 1000,
|
||||
"group": "kbrazil",
|
||||
"pgrp": 2225,
|
||||
"tty": "pts/0",
|
||||
"tty_process_gid": 2225,
|
||||
"session_id": 1884,
|
||||
"thread_count": 1,
|
||||
"last_used_processor": 0,
|
||||
"time": "0:00",
|
||||
"swap": 0.0,
|
||||
"code": 0.1,
|
||||
"data": 1.0,
|
||||
"major_page_fault_count": 0,
|
||||
"minor_page_fault_count": 736,
|
||||
"dirty_pages_count": 0,
|
||||
"sleeping_in_function": null,
|
||||
"flags": "..4.2...",
|
||||
"cgroups": "1:name=systemd:/user.slice/user-1000.+",
|
||||
"supplementary_gids": [
|
||||
10,
|
||||
1000
|
||||
],
|
||||
"supplementary_groups": [
|
||||
"wheel",
|
||||
"kbrazil"
|
||||
],
|
||||
"thread_gid": 2225,
|
||||
"environment_variables": [
|
||||
"XDG_SESSION_ID=2",
|
||||
"HOSTNAME=localhost"
|
||||
],
|
||||
"major_page_fault_count_delta": 0,
|
||||
"minor_page_fault_count_delta": 4,
|
||||
"used": 2.2,
|
||||
"ipc_namespace_inode": 4026531839,
|
||||
"mount_namespace_inode": 4026531840,
|
||||
"net_namespace_inode": 4026531956,
|
||||
"pid_namespace_inode": 4026531836,
|
||||
"user_namespace_inode": 4026531837,
|
||||
"nts_namespace_inode": 4026531838
|
||||
},
|
||||
...
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
$ top -b -n 3 | jc --top -p -r
|
||||
[
|
||||
{
|
||||
"time": "11:20:43",
|
||||
"uptime": "1:18",
|
||||
"users": "2",
|
||||
"load_1m": "0.00",
|
||||
"load_5m": "0.01",
|
||||
"load_15m": "0.05",
|
||||
"tasks_total": "108",
|
||||
"tasks_running": "2",
|
||||
"tasks_sleeping": "106",
|
||||
"tasks_stopped": "0",
|
||||
"tasks_zombie": "0",
|
||||
"cpu_user": "5.6",
|
||||
"cpu_sys": "11.1",
|
||||
"cpu_nice": "0.0",
|
||||
"cpu_idle": "83.3",
|
||||
"cpu_wait": "0.0",
|
||||
"cpu_hardware": "0.0",
|
||||
"cpu_software": "0.0",
|
||||
"cpu_steal": "0.0",
|
||||
"swap_total": "2.0",
|
||||
"swap_free": "2.0",
|
||||
"swap_used": "0.0",
|
||||
"mem_available": "3.3",
|
||||
"processes": [
|
||||
{
|
||||
"PID": "2225",
|
||||
"USER": "kbrazil",
|
||||
"PR": "20",
|
||||
"NI": "0",
|
||||
"VIRT": "158.1m",
|
||||
"RES": "2.2m",
|
||||
"SHR": "1.6m",
|
||||
"S": "R",
|
||||
"%CPU": "12.5",
|
||||
"%MEM": "0.1",
|
||||
"TIME+": "0:00.02",
|
||||
"COMMAND": "top",
|
||||
"PPID": "1884",
|
||||
"UID": "1000",
|
||||
"RUID": "1000",
|
||||
"RUSER": "kbrazil",
|
||||
"SUID": "1000",
|
||||
"SUSER": "kbrazil",
|
||||
"GID": "1000",
|
||||
"GROUP": "kbrazil",
|
||||
"PGRP": "2225",
|
||||
"TTY": "pts/0",
|
||||
"TPGID": "2225",
|
||||
"SID": "1884",
|
||||
"nTH": "1",
|
||||
"P": "0",
|
||||
"TIME": "0:00",
|
||||
"SWAP": "0.0m",
|
||||
"CODE": "0.1m",
|
||||
"DATA": "1.0m",
|
||||
"nMaj": "0",
|
||||
"nMin": "736",
|
||||
"nDRT": "0",
|
||||
"WCHAN": "-",
|
||||
"Flags": "..4.2...",
|
||||
"CGROUPS": "1:name=systemd:/user.slice/user-1000.+",
|
||||
"SUPGIDS": "10,1000",
|
||||
"SUPGRPS": "wheel,kbrazil",
|
||||
"TGID": "2225",
|
||||
"ENVIRON": "XDG_SESSION_ID=2 HOSTNAME=localhost S+",
|
||||
"vMj": "0",
|
||||
"vMn": "4",
|
||||
"USED": "2.2m",
|
||||
"nsIPC": "4026531839",
|
||||
"nsMNT": "4026531840",
|
||||
"nsNET": "4026531956",
|
||||
"nsPID": "4026531836",
|
||||
"nsUSER": "4026531837",
|
||||
"nsUTS": "4026531838"
|
||||
},
|
||||
...
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.top.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
180
docs/parsers/top_s.md
Normal file
180
docs/parsers/top_s.md
Normal file
@@ -0,0 +1,180 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.top_s"></a>
|
||||
|
||||
# jc.parsers.top\_s
|
||||
|
||||
jc - JSON Convert `top -b` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
Requires batch mode (`-b`).
|
||||
|
||||
Warning messages will be printed to `STDERR` if truncated fields are
|
||||
detected. These warnings can be suppressed with the `-q` or `quiet=True`
|
||||
option.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ top -b | jc --top-s
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
|
||||
result = jc.parse('top_s', top_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"time": string,
|
||||
"uptime": integer,
|
||||
"users": integer,
|
||||
"load_1m": float,
|
||||
"load_5m": float,
|
||||
"load_15m": float,
|
||||
"tasks_total": integer,
|
||||
"tasks_running": integer,
|
||||
"tasks_sleeping": integer,
|
||||
"tasks_stopped": integer,
|
||||
"tasks_zombie": integer,
|
||||
"cpu_user": float,
|
||||
"cpu_sys": float,
|
||||
"cpu_nice": float,
|
||||
"cpu_idle": float,
|
||||
"cpu_wait": float,
|
||||
"cpu_hardware": float,
|
||||
"cpu_software": float,
|
||||
"cpu_steal": float,
|
||||
"mem_total": float, # [0]
|
||||
"mem_free": float, # [0]
|
||||
"mem_used": float, # [0]
|
||||
"mem_buff_cache": float, # [0]
|
||||
"swap_total": float, # [0]
|
||||
"swap_free": float, # [0]
|
||||
"swap_used": float, # [0]
|
||||
"mem_available": float, # [0]
|
||||
"processes": [
|
||||
{
|
||||
"pid": integer,
|
||||
"user": string,
|
||||
"priority": integer,
|
||||
"nice": integer,
|
||||
"virtual_mem": float, # [1]
|
||||
"resident_mem": float, # [1]
|
||||
"shared_mem": float, # [1]
|
||||
"status": string,
|
||||
"percent_cpu": float,
|
||||
"percent_mem": float,
|
||||
"time_hundredths": string,
|
||||
"command": string,
|
||||
"parent_pid": integer,
|
||||
"uid": integer,
|
||||
"real_uid": integer,
|
||||
"real_user": string,
|
||||
"saved_uid": integer,
|
||||
"saved_user": string,
|
||||
"gid": integer,
|
||||
"group": string,
|
||||
"pgrp": integer,
|
||||
"tty": string,
|
||||
"tty_process_gid": integer,
|
||||
"session_id": integer,
|
||||
"thread_count": integer,
|
||||
"last_used_processor": integer,
|
||||
"time": string,
|
||||
"swap": float, # [1]
|
||||
"code": float, # [1]
|
||||
"data": float, # [1]
|
||||
"major_page_fault_count": integer,
|
||||
"minor_page_fault_count": integer,
|
||||
"dirty_pages_count": integer,
|
||||
"sleeping_in_function": string,
|
||||
"flags": string,
|
||||
"cgroups": string,
|
||||
"supplementary_gids": [
|
||||
integer
|
||||
],
|
||||
"supplementary_groups": [
|
||||
string
|
||||
],
|
||||
"thread_gid": integer,
|
||||
"environment_variables": [
|
||||
string
|
||||
]
|
||||
"major_page_fault_count_delta": integer,
|
||||
"minor_page_fault_count_delta": integer,
|
||||
"used": float, # [1]
|
||||
"ipc_namespace_inode": integer,
|
||||
"mount_namespace_inode": integer,
|
||||
"net_namespace_inode": integer,
|
||||
"pid_namespace_inode": integer,
|
||||
"user_namespace_inode": integer,
|
||||
"nts_namespace_inode": integer,
|
||||
"control_group_name": string,
|
||||
"lxc_container_name": string,
|
||||
"numa_node": integer,
|
||||
"out_of_mem_adjustment": integer,
|
||||
"out_of_mem_score": integer,
|
||||
"resident_anon_mem": integer,
|
||||
"resident_file_backed_mem": integer,
|
||||
"resident_locked_mem": integer,
|
||||
"resident_shared_mem": integer
|
||||
}
|
||||
],
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # false if error parsing
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
}
|
||||
|
||||
[0] Values are in the units output by `top`
|
||||
[1] Unit suffix stripped during float conversion
|
||||
|
||||
Examples:
|
||||
|
||||
$ top -b | jc --top-s
|
||||
{"time":"11:24:50","uptime":2,"users":2,"load_1m":0.23,"load_5m":...}
|
||||
...
|
||||
|
||||
$ top -b | jc --top-s -r
|
||||
{"time":"11:24:50","uptime":"2 min","users":"2","load_1m":"0.23","lo...}
|
||||
...
|
||||
|
||||
<a id="jc.parsers.top_s.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
@add_jc_meta
|
||||
def parse(data: Iterable[str],
|
||||
raw: bool = False,
|
||||
quiet: bool = False,
|
||||
ignore_exceptions: bool = False) -> Union[Iterable[Dict], tuple]
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterable object.
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (iterable) line-based text data to parse
|
||||
(e.g. sys.stdin or str.splitlines())
|
||||
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||
|
||||
|
||||
Returns:
|
||||
|
||||
Iterable of Dictionaries
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -154,4 +154,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -7,12 +7,12 @@ jc - JSON Convert `traceroute` command output parser
|
||||
|
||||
Supports `traceroute` and `traceroute6` output.
|
||||
|
||||
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`
|
||||
> 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`
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -143,4 +143,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -223,4 +223,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -161,4 +161,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
jc - JSON Convert `uname -a` command output parser
|
||||
|
||||
Note: Must use `uname -a`
|
||||
> Note: Must use `uname -a`
|
||||
|
||||
Usage (cli):
|
||||
|
||||
|
||||
@@ -154,4 +154,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -88,4 +88,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
223
docs/parsers/url.md
Normal file
223
docs/parsers/url.md
Normal file
@@ -0,0 +1,223 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.url"></a>
|
||||
|
||||
# jc.parsers.url
|
||||
|
||||
jc - JSON Convert URL string parser
|
||||
|
||||
Normalized, Encoded, and Decoded versions of the original URL and URL parts
|
||||
are included in the output. Encoding and Decoding is best effort.
|
||||
|
||||
> Note: Do not use the Encoded fields for a URL that has already been
|
||||
> Encoded. Similarly, do not use the Decoded fields for a URL that has
|
||||
> already been Decoded.
|
||||
|
||||
This parser will work with naked and wrapped URL strings:
|
||||
|
||||
- `scheme://host/path`
|
||||
- `URL:scheme://host/path`
|
||||
- `<scheme://host/path>`
|
||||
- `<URL:scheme://host/path>`
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ echo "http://example.com/test/path?q1=foo&q2=bar#frag" | jc --url
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('url', url_string)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"url": string,
|
||||
"scheme": string or null,
|
||||
"netloc": string or null,
|
||||
"path": string or null,
|
||||
"path_list": [ array or null
|
||||
string
|
||||
],
|
||||
"query": string or null,
|
||||
"query_obj": { object or null
|
||||
<query-key>: [ array or null
|
||||
<query-value> string # [0]
|
||||
]
|
||||
},
|
||||
"fragment": string or null,
|
||||
"username": string or null,
|
||||
"password": string or null,
|
||||
"hostname": string or null,
|
||||
"port": integer or null, # [1]
|
||||
"encoded": {
|
||||
"url": string,
|
||||
"scheme": string or null,
|
||||
"netloc": string or null,
|
||||
"path": string or null,
|
||||
"path_list": [ array or null
|
||||
string
|
||||
],
|
||||
"query": string or null,
|
||||
"fragment": string or null,
|
||||
"username": string or null,
|
||||
"password": string or null,
|
||||
"hostname": string or null,
|
||||
"port": integer or null, # [1]
|
||||
},
|
||||
"decoded": {
|
||||
"url": string,
|
||||
"scheme": string or null,
|
||||
"netloc": string or null,
|
||||
"path": string or null,
|
||||
"path_list": [ array or null
|
||||
string
|
||||
],
|
||||
"query": string or null,
|
||||
"fragment": string or null,
|
||||
"username": string or null,
|
||||
"password": string or null,
|
||||
"hostname": string or null,
|
||||
"port": integer or null, # [1]
|
||||
}
|
||||
}
|
||||
|
||||
[0] Duplicate query-keys will have their values consolidated into the
|
||||
array of query-values
|
||||
|
||||
[1] Invalid port values will be converted to null/None and a warning
|
||||
message will be printed to `STDERR` if quiet=False
|
||||
|
||||
Examples:
|
||||
|
||||
$ echo "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag" \\
|
||||
| jc --url -p
|
||||
{
|
||||
"url": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag",
|
||||
"scheme": "http",
|
||||
"netloc": "example.com",
|
||||
"path": "/test/path",
|
||||
"path_list": [
|
||||
"test",
|
||||
"path"
|
||||
],
|
||||
"query": "q1=foo&q1=bar&q2=baz",
|
||||
"query_obj": {
|
||||
"q1": [
|
||||
"foo",
|
||||
"bar"
|
||||
],
|
||||
"q2": [
|
||||
"baz"
|
||||
]
|
||||
},
|
||||
"fragment": "frag",
|
||||
"username": null,
|
||||
"password": null,
|
||||
"hostname": "example.com",
|
||||
"port": null,
|
||||
"encoded": {
|
||||
"url": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag",
|
||||
"scheme": "http",
|
||||
"netloc": "example.com",
|
||||
"path": "/test/path",
|
||||
"path_list": [
|
||||
"test",
|
||||
"path"
|
||||
],
|
||||
"query": "q1=foo&q1=bar&q2=baz",
|
||||
"fragment": "frag",
|
||||
"username": null,
|
||||
"password": null,
|
||||
"hostname": "example.com",
|
||||
"port": null
|
||||
},
|
||||
"decoded": {
|
||||
"url": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag",
|
||||
"scheme": "http",
|
||||
"netloc": "example.com",
|
||||
"path": "/test/path",
|
||||
"path_list": [
|
||||
"test",
|
||||
"path"
|
||||
],
|
||||
"query": "q1=foo&q1=bar&q2=baz",
|
||||
"fragment": "frag",
|
||||
"username": null,
|
||||
"password": null,
|
||||
"hostname": "example.com",
|
||||
"port": null
|
||||
}
|
||||
}
|
||||
|
||||
$ echo "ftp://localhost/filepath" | jc --url -p
|
||||
{
|
||||
"url": "ftp://localhost/filepath",
|
||||
"scheme": "ftp",
|
||||
"netloc": "localhost",
|
||||
"path": "/filepath",
|
||||
"path_list": [
|
||||
"filepath"
|
||||
],
|
||||
"query": null,
|
||||
"query_obj": null,
|
||||
"fragment": null,
|
||||
"username": null,
|
||||
"password": null,
|
||||
"hostname": "localhost",
|
||||
"port": null,
|
||||
"encoded": {
|
||||
"url": "ftp://localhost/filepath",
|
||||
"scheme": "ftp",
|
||||
"netloc": "localhost",
|
||||
"path": "/filepath",
|
||||
"path_list": [
|
||||
"filepath"
|
||||
],
|
||||
"query": null,
|
||||
"fragment": null,
|
||||
"username": null,
|
||||
"password": null,
|
||||
"hostname": "localhost",
|
||||
"port": null
|
||||
},
|
||||
"decoded": {
|
||||
"url": "ftp://localhost/filepath",
|
||||
"scheme": "ftp",
|
||||
"netloc": "localhost",
|
||||
"path": "/filepath",
|
||||
"path_list": [
|
||||
"filepath"
|
||||
],
|
||||
"query": null,
|
||||
"fragment": null,
|
||||
"username": null,
|
||||
"password": null,
|
||||
"hostname": "localhost",
|
||||
"port": null
|
||||
}
|
||||
}
|
||||
|
||||
<a id="jc.parsers.url.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> Dict
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -149,4 +149,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
jc - JSON Convert `vmstat` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines (cli) or returns a Generator
|
||||
iterator of Dictionaries (module)
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
Options supported: `-a`, `-w`, `-d`, `-t`
|
||||
|
||||
@@ -21,11 +21,11 @@ Usage (cli):
|
||||
$ vmstat | jc --vmstat-s
|
||||
|
||||
> Note: When piping `jc` converted `vmstat` output to other processes it may
|
||||
appear the output is hanging due to the OS pipe buffers. This is because
|
||||
`vmstat` output is too small to quickly fill up the buffer. Use the `-u`
|
||||
option to unbuffer the `jc` output if you would like immediate output. See
|
||||
the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
|
||||
for more information.
|
||||
> appear the output is hanging due to the OS pipe buffers. This is because
|
||||
> `vmstat` output is too small to quickly fill up the buffer. Use the `-u`
|
||||
> option to unbuffer the `jc` output if you would like immediate output. See
|
||||
> the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
|
||||
> for more information.
|
||||
|
||||
Usage (module):
|
||||
|
||||
@@ -75,9 +75,9 @@ Schema:
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # [2]
|
||||
"error": string, # [3]
|
||||
"line": string # [3]
|
||||
"success": boolean, # [2]
|
||||
"error": string, # [3]
|
||||
"line": string # [3]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ Examples:
|
||||
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterator object.
|
||||
Main text parsing generator function. Returns an iterable object.
|
||||
|
||||
Parameters:
|
||||
|
||||
@@ -116,15 +116,11 @@ Parameters:
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||
|
||||
Yields:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
Returns:
|
||||
|
||||
Iterator object (generator)
|
||||
Iterable of Dictionaries
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -126,4 +126,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -77,4 +77,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -158,4 +158,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
431
docs/parsers/x509_cert.md
Normal file
431
docs/parsers/x509_cert.md
Normal file
@@ -0,0 +1,431 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.x509_cert"></a>
|
||||
|
||||
# jc.parsers.x509\_cert
|
||||
|
||||
jc - JSON Convert X.509 Certificate format file parser
|
||||
|
||||
This parser will convert DER and PEM encoded X.509 certificate files.
|
||||
|
||||
You can convert other certificate formats (e.g. PKCS #7, PKCS #12, etc.) by
|
||||
processing them through a program like `openssl` and sending the output to
|
||||
`jc`. (See examples below)
|
||||
|
||||
> Note: `jc` does not verify the integrity of the certificate, which
|
||||
> requires calculating the hash of the certificate body and comparing it to
|
||||
> the the hash in the certificate's signature after it is decrypted with the
|
||||
> issuer certificate's public key.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat certificate.pem | jc --x509-cert
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('x509_cert', x509_cert_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"tbs_certificate": {
|
||||
"version": string,
|
||||
"serial_number": string, # [0]
|
||||
"signature": {
|
||||
"algorithm": string,
|
||||
"parameters": string/null,
|
||||
},
|
||||
"issuer": {
|
||||
"country_name": string,
|
||||
"state_or_province_name" string,
|
||||
"locality_name": string,
|
||||
"organization_name": array/string,
|
||||
"organizational_unit_name": array/string,
|
||||
"common_name": string,
|
||||
"email_address": string
|
||||
},
|
||||
"validity": {
|
||||
"not_before": integer, # [1]
|
||||
"not_after": integer, # [1]
|
||||
"not_before_iso": string,
|
||||
"not_after_iso": string
|
||||
},
|
||||
"subject": {
|
||||
"country_name": string,
|
||||
"state_or_province_name": string,
|
||||
"locality_name": string,
|
||||
"organization_name": array/string,
|
||||
"organizational_unit_name": array/string,
|
||||
"common_name": string,
|
||||
"email_address": string
|
||||
},
|
||||
"subject_public_key_info": {
|
||||
"algorithm": {
|
||||
"algorithm": string,
|
||||
"parameters": string/null,
|
||||
},
|
||||
"public_key": {
|
||||
"modulus": string, # [0]
|
||||
"public_exponent": integer
|
||||
}
|
||||
},
|
||||
"issuer_unique_id": string/null,
|
||||
"subject_unique_id": string/null,
|
||||
"extensions": [
|
||||
{
|
||||
"extn_id": string,
|
||||
"critical": boolean,
|
||||
"extn_value": array/object/string/integer # [2]
|
||||
}
|
||||
]
|
||||
},
|
||||
"signature_algorithm": {
|
||||
"algorithm": string,
|
||||
"parameters": string/null
|
||||
},
|
||||
"signature_value": string # [0]
|
||||
}
|
||||
]
|
||||
|
||||
[0] in colon-delimited hex notation
|
||||
[1] time-zone-aware (UTC) epoch timestamp
|
||||
[2] See below for well-known Extension schemas:
|
||||
|
||||
Basic Constraints:
|
||||
{
|
||||
"extn_id": "basic_constraints",
|
||||
"critical": boolean,
|
||||
"extn_value": {
|
||||
"ca": boolean,
|
||||
"path_len_constraint": string/null
|
||||
}
|
||||
}
|
||||
|
||||
Key Usage:
|
||||
{
|
||||
"extn_id": "key_usage",
|
||||
"critical": boolean,
|
||||
"extn_value": [
|
||||
string
|
||||
]
|
||||
}
|
||||
|
||||
Key Identifier:
|
||||
{
|
||||
"extn_id": "key_identifier",
|
||||
"critical": boolean,
|
||||
"extn_value": string # [0]
|
||||
}
|
||||
|
||||
Authority Key Identifier:
|
||||
{
|
||||
"extn_id": "authority_key_identifier",
|
||||
"critical": boolean,
|
||||
"extn_value": {
|
||||
"key_identifier": string, # [0]
|
||||
"authority_cert_issuer": string/null,
|
||||
"authority_cert_serial_number": string/null
|
||||
}
|
||||
}
|
||||
|
||||
Subject Alternative Name:
|
||||
{
|
||||
"extn_id": "subject_alt_name",
|
||||
"critical": boolean,
|
||||
"extn_value": [
|
||||
string
|
||||
]
|
||||
}
|
||||
|
||||
Certificate Policies:
|
||||
{
|
||||
"extn_id": "certificate_policies",
|
||||
"critical": boolean,
|
||||
"extn_value": [
|
||||
{
|
||||
"policy_identifier": string,
|
||||
"policy_qualifiers": [ array or null
|
||||
{
|
||||
"policy_qualifier_id": string,
|
||||
"qualifier": string
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Signed Certificate Timestamp List
|
||||
{
|
||||
"extn_id": "signed_certificate_timestamp_list",
|
||||
"critical": boolean,
|
||||
"extn_value": string # [0]
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat entrust-ec1.pem | jc --x509-cert -p
|
||||
[
|
||||
{
|
||||
"tbs_certificate": {
|
||||
"version": "v3",
|
||||
"serial_number": "a6:8b:79:29:00:00:00:00:50:d0:91:f9",
|
||||
"signature": {
|
||||
"algorithm": "sha384_ecdsa",
|
||||
"parameters": null
|
||||
},
|
||||
"issuer": {
|
||||
"country_name": "US",
|
||||
"organization_name": "Entrust, Inc.",
|
||||
"organizational_unit_name": [
|
||||
"See www.entrust.net/legal-terms",
|
||||
"(c) 2012 Entrust, Inc. - for authorized use only"
|
||||
],
|
||||
"common_name": "Entrust Root Certification Authority - EC1"
|
||||
},
|
||||
"validity": {
|
||||
"not_before": 1355844336,
|
||||
"not_after": 2144764536,
|
||||
"not_before_iso": "2012-12-18T15:25:36+00:00",
|
||||
"not_after_iso": "2037-12-18T15:55:36+00:00"
|
||||
},
|
||||
"subject": {
|
||||
"country_name": "US",
|
||||
"organization_name": "Entrust, Inc.",
|
||||
"organizational_unit_name": [
|
||||
"See www.entrust.net/legal-terms",
|
||||
"(c) 2012 Entrust, Inc. - for authorized use only"
|
||||
],
|
||||
"common_name": "Entrust Root Certification Authority - EC1"
|
||||
},
|
||||
"subject_public_key_info": {
|
||||
"algorithm": {
|
||||
"algorithm": "ec",
|
||||
"parameters": "secp384r1"
|
||||
},
|
||||
"public_key": "04:84:13:c9:d0:ba:6d:41:7b:e2:6c:d0:eb:55:..."
|
||||
},
|
||||
"issuer_unique_id": null,
|
||||
"subject_unique_id": null,
|
||||
"extensions": [
|
||||
{
|
||||
"extn_id": "key_usage",
|
||||
"critical": true,
|
||||
"extn_value": [
|
||||
"crl_sign",
|
||||
"key_cert_sign"
|
||||
]
|
||||
},
|
||||
{
|
||||
"extn_id": "basic_constraints",
|
||||
"critical": true,
|
||||
"extn_value": {
|
||||
"ca": true,
|
||||
"path_len_constraint": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"extn_id": "key_identifier",
|
||||
"critical": false,
|
||||
"extn_value": "b7:63:e7:1a:dd:8d:e9:08:a6:55:83:a4:e0:6a:..."
|
||||
}
|
||||
]
|
||||
},
|
||||
"signature_algorithm": {
|
||||
"algorithm": "sha384_ecdsa",
|
||||
"parameters": null
|
||||
},
|
||||
"signature_value": "30:64:02:30:61:79:d8:e5:42:47:df:1c:ae:53:..."
|
||||
}
|
||||
]
|
||||
|
||||
$ openssl pkcs7 -in thawte.p7b -inform der -print_certs | \\
|
||||
jc --x509-cert -p
|
||||
[
|
||||
{
|
||||
"tbs_certificate": {
|
||||
"version": "v3",
|
||||
"serial_number": "34:4e:d5:57:20:d5:ed:ec:49:f4:2f:ce:37:db...",
|
||||
"signature": {
|
||||
"algorithm": "sha1_rsa",
|
||||
"parameters": null
|
||||
},
|
||||
"issuer": {
|
||||
"country_name": "US",
|
||||
"organization_name": "thawte, Inc.",
|
||||
"organizational_unit_name": [
|
||||
"Certification Services Division",
|
||||
"(c) 2006 thawte, Inc. - For authorized use only"
|
||||
],
|
||||
"common_name": "thawte Primary Root CA"
|
||||
},
|
||||
"validity": {
|
||||
"not_before": 1163721600,
|
||||
"not_after": 2099865599,
|
||||
"not_before_iso": "2006-11-17T00:00:00+00:00",
|
||||
"not_after_iso": "2036-07-16T23:59:59+00:00"
|
||||
},
|
||||
"subject": {
|
||||
"country_name": "US",
|
||||
"organization_name": "thawte, Inc.",
|
||||
"organizational_unit_name": [
|
||||
"Certification Services Division",
|
||||
"(c) 2006 thawte, Inc. - For authorized use only"
|
||||
],
|
||||
"common_name": "thawte Primary Root CA"
|
||||
},
|
||||
"subject_public_key_info": {
|
||||
"algorithm": {
|
||||
"algorithm": "rsa",
|
||||
"parameters": null
|
||||
},
|
||||
"public_key": {
|
||||
"modulus": "ac:a0:f0:fb:80:59:d4:9c:c7:a4:cf:9d:a1:59:73...",
|
||||
"public_exponent": 65537
|
||||
}
|
||||
},
|
||||
"issuer_unique_id": null,
|
||||
"subject_unique_id": null,
|
||||
"extensions": [
|
||||
{
|
||||
"extn_id": "basic_constraints",
|
||||
"critical": true,
|
||||
"extn_value": {
|
||||
"ca": true,
|
||||
"path_len_constraint": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"extn_id": "key_usage",
|
||||
"critical": true,
|
||||
"extn_value": [
|
||||
"crl_sign",
|
||||
"key_cert_sign"
|
||||
]
|
||||
},
|
||||
{
|
||||
"extn_id": "key_identifier",
|
||||
"critical": false,
|
||||
"extn_value": "7b:5b:45:cf:af:ce:cb:7a:fd:31:92:1a:6a:b6:..."
|
||||
}
|
||||
]
|
||||
},
|
||||
"signature_algorithm": {
|
||||
"algorithm": "sha1_rsa",
|
||||
"parameters": null
|
||||
},
|
||||
"signature_value": "79:11:c0:4b:b3:91:b6:fc:f0:e9:67:d4:0d:6e..."
|
||||
}
|
||||
]
|
||||
|
||||
$ openssl pkcs12 -info -in certificate.pfx \\
|
||||
-passin pass: -passout pass: | \\
|
||||
jc --x509-cert -p
|
||||
[
|
||||
{
|
||||
"tbs_certificate": {
|
||||
"version": "v3",
|
||||
"serial_number": "01",
|
||||
"signature": {
|
||||
"algorithm": "sha1_rsa",
|
||||
"parameters": null
|
||||
},
|
||||
"issuer": {
|
||||
"country_name": "FR",
|
||||
"state_or_province_name": "Alsace",
|
||||
"locality_name": "Strasbourg",
|
||||
"organization_name": "www.freelan.org",
|
||||
"organizational_unit_name": "freelan",
|
||||
"common_name": "Freelan Sample Certificate Authority",
|
||||
"email_address": "contact@freelan.org"
|
||||
},
|
||||
"validity": {
|
||||
"not_before": 1335522678,
|
||||
"not_after": 1650882678,
|
||||
"not_before_iso": "2012-04-27T10:31:18+00:00",
|
||||
"not_after_iso": "2022-04-25T10:31:18+00:00"
|
||||
},
|
||||
"subject": {
|
||||
"country_name": "FR",
|
||||
"state_or_province_name": "Alsace",
|
||||
"organization_name": "www.freelan.org",
|
||||
"organizational_unit_name": "freelan",
|
||||
"common_name": "alice",
|
||||
"email_address": "contact@freelan.org"
|
||||
},
|
||||
"subject_public_key_info": {
|
||||
"algorithm": {
|
||||
"algorithm": "rsa",
|
||||
"parameters": null
|
||||
},
|
||||
"public_key": {
|
||||
"modulus": "dd:6d:bd:f8:80:fa:d7:de:1b:1f:a7:a3:2e:b2:02...",
|
||||
"public_exponent": 65537
|
||||
}
|
||||
},
|
||||
"issuer_unique_id": null,
|
||||
"subject_unique_id": null,
|
||||
"extensions": [
|
||||
{
|
||||
"extn_id": "basic_constraints",
|
||||
"critical": false,
|
||||
"extn_value": {
|
||||
"ca": false,
|
||||
"path_len_constraint": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"extn_id": "2.16.840.1.113730.1.13",
|
||||
"critical": false,
|
||||
"extn_value": "16:1d:4f:70:65:6e:53:53:4c:20:47:65:6e:65..."
|
||||
},
|
||||
{
|
||||
"extn_id": "key_identifier",
|
||||
"critical": false,
|
||||
"extn_value": "59:5f:c9:13:ba:1b:cc:b9:a8:41:4a:8a:49:79..."
|
||||
},
|
||||
{
|
||||
"extn_id": "authority_key_identifier",
|
||||
"critical": false,
|
||||
"extn_value": {
|
||||
"key_identifier": "23:6c:2d:3d:3e:29:5d:78:b8:6c:3e:aa...",
|
||||
"authority_cert_issuer": null,
|
||||
"authority_cert_serial_number": null
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"signature_algorithm": {
|
||||
"algorithm": "sha1_rsa",
|
||||
"parameters": null
|
||||
},
|
||||
"signature_value": "13:e7:02:45:3e:a7:ab:bd:b8:da:e7:ef:74:88..."
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.x509_cert.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: Union[str, bytes],
|
||||
raw: bool = False,
|
||||
quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string or bytes) text or binary data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -16,8 +16,8 @@ Usage (module):
|
||||
|
||||
Schema:
|
||||
|
||||
XML Document converted to a Dictionary
|
||||
See https://github.com/martinblech/xmltodict for details
|
||||
XML Document converted to a Dictionary. See https://github.com/martinblech/xmltodict
|
||||
for details.
|
||||
|
||||
{
|
||||
"key1": string/object,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
jc - JSON Convert `YAML` file parser
|
||||
|
||||
Note: datetime objects will be converted to strings.
|
||||
> Note: `datetime` objects will be converted to strings.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
|
||||
@@ -5,10 +5,7 @@
|
||||
|
||||
jc - JSON Convert `zipinfo` command output parser
|
||||
|
||||
Options supported:
|
||||
- none
|
||||
|
||||
Note: The default listing format.
|
||||
> Note: No `zipinfo` options are supported.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -102,4 +99,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin
|
||||
|
||||
Version 1.0 by Matt J (https://github.com/listuser)
|
||||
Version 1.1 by Matt J (https://github.com/listuser)
|
||||
|
||||
@@ -26,11 +26,12 @@ https://github.com/kellyjonbrazil/jc/tree/master/docs
|
||||
|
||||
### Specific Version
|
||||
|
||||
Replace `<full_version_number>` - e.g. `1.17.7`:
|
||||
|
||||
`https://github.com/kellyjonbrazil/jc/tree/v<full_version_number>/docs`
|
||||
|
||||
Specific versions can also be selected by tag in the branch dropdown menu.
|
||||
> Replace `<full_version_number>` - e.g. `1.18.0`:
|
||||
|
||||
Specific versions can also be selected by tag in the Github branch dropdown
|
||||
menu.
|
||||
|
||||
## Usage Example
|
||||
|
||||
@@ -63,7 +64,7 @@ Use `help(jc.lib)` for details.
|
||||
|
||||
parse(
|
||||
parser_module_name: str,
|
||||
data: str | Iterable
|
||||
data: str | bytes | Iterable
|
||||
) -> dict | list[dict] | Iterable[dict]
|
||||
|
||||
High-level API to easily access the parser. This API will find both
|
||||
@@ -93,14 +94,14 @@ its module name.
|
||||
|
||||
### parser_mod_list
|
||||
|
||||
parser_mod_list() -> list
|
||||
parser_mod_list() -> list[str]
|
||||
|
||||
Get a list of all available parser module names to be used in
|
||||
`parse()`, `parser_info()`, and `get_help()`.
|
||||
|
||||
### plugin_parser_mod_list
|
||||
|
||||
plugin_parser_mod_list() -> list
|
||||
plugin_parser_mod_list() -> list[str]
|
||||
|
||||
Get a list of plugin parser module names to be used in
|
||||
`parse()`, `parser_info()`, and `get_help()`. This list is a subset of
|
||||
@@ -108,7 +109,7 @@ Get a list of plugin parser module names to be used in
|
||||
|
||||
### standard_parser_mod_list
|
||||
|
||||
standard_parser_mod_list() -> list
|
||||
standard_parser_mod_list() -> list[str]
|
||||
|
||||
Get a list of standard parser module names to be used in
|
||||
`parse()`, `parser_info()`, and `get_help()`. This list is a subset of
|
||||
@@ -116,7 +117,7 @@ Get a list of standard parser module names to be used in
|
||||
|
||||
### streaming_parser_mod_list
|
||||
|
||||
streaming_parser_mod_list() -> list
|
||||
streaming_parser_mod_list() -> list[str]
|
||||
|
||||
Get a list of streaming parser module names to be used in
|
||||
`parse()`, `parser_info()`, and `get_help()`. This list is a subset of
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* [jc.utils](#jc.utils)
|
||||
* [warning\_message](#jc.utils.warning_message)
|
||||
* [error\_message](#jc.utils.error_message)
|
||||
* [is\_compatible](#jc.utils.is_compatible)
|
||||
* [compatibility](#jc.utils.compatibility)
|
||||
* [has\_data](#jc.utils.has_data)
|
||||
* [convert\_to\_int](#jc.utils.convert_to_int)
|
||||
@@ -26,8 +27,8 @@ jc - JSON Convert utils
|
||||
def warning_message(message_lines: List[str]) -> None
|
||||
```
|
||||
|
||||
Prints warning message for non-fatal issues. The first line is
|
||||
prepended with 'jc: Warning - ' and subsequent lines are indented.
|
||||
Prints warning message to `STDERR` for non-fatal issues. The first line
|
||||
is prepended with 'jc: Warning - ' and subsequent lines are indented.
|
||||
Wraps text as needed based on the terminal width.
|
||||
|
||||
Parameters:
|
||||
@@ -46,7 +47,7 @@ Returns:
|
||||
def error_message(message_lines: List[str]) -> None
|
||||
```
|
||||
|
||||
Prints an error message for fatal issues. The first line is
|
||||
Prints an error message to `STDERR` for fatal issues. The first line is
|
||||
prepended with 'jc: Error - ' and subsequent lines are indented.
|
||||
Wraps text as needed based on the terminal width.
|
||||
|
||||
@@ -58,6 +59,16 @@ Returns:
|
||||
|
||||
None - just prints output to STDERR
|
||||
|
||||
<a id="jc.utils.is_compatible"></a>
|
||||
|
||||
### is\_compatible
|
||||
|
||||
```python
|
||||
def is_compatible(compatible: List) -> bool
|
||||
```
|
||||
|
||||
Returns True if the parser is compatible with the running OS platform.
|
||||
|
||||
<a id="jc.utils.compatibility"></a>
|
||||
|
||||
### compatibility
|
||||
@@ -68,8 +79,9 @@ def compatibility(mod_name: str,
|
||||
quiet: bool = False) -> None
|
||||
```
|
||||
|
||||
Checks for the parser's compatibility with the running OS
|
||||
platform.
|
||||
Checks for the parser's compatibility with the running OS platform and
|
||||
prints a warning message to `STDERR` if not compatible and
|
||||
`quiet=False.`
|
||||
|
||||
Parameters:
|
||||
|
||||
@@ -90,20 +102,23 @@ Returns:
|
||||
### has\_data
|
||||
|
||||
```python
|
||||
def has_data(data: str) -> bool
|
||||
def has_data(data: Union[str, bytes]) -> bool
|
||||
```
|
||||
|
||||
Checks if the input contains data. If there are any non-whitespace
|
||||
characters then return True, else return False.
|
||||
Checks if the string input contains data. If there are any
|
||||
non-whitespace characters then return `True`, else return `False`.
|
||||
|
||||
For bytes, returns True if there is any data.
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) input to check whether it contains data
|
||||
data: (string, bytes) input to check whether it contains data
|
||||
|
||||
Returns:
|
||||
|
||||
Boolean True if input string (data) contains non-whitespace
|
||||
characters, otherwise False
|
||||
characters, otherwise False. For bytes data, returns
|
||||
True if there is any data, otherwise False.
|
||||
|
||||
<a id="jc.utils.convert_to_int"></a>
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user