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

Compare commits

...

456 Commits

Author SHA1 Message Date
Kelly Brazil
9fd13e6987 Merge pull request #671 from kellyjonbrazil/dev
Dev v1.25.6
2025-10-12 18:52:52 -07:00
Kelly Brazil
1feb000231 doc update 2025-10-12 18:09:31 -07:00
Kelly Brazil
d270ddc6ce fixup traceroute and traceroute-s parsers 2025-10-12 17:58:37 -07:00
Shintaro Kojima
07ef285b06 Add traceroute streaming parser - traceroute-s (#669)
* test: split out test fixtures for long ipv6 traceroute for consistency

* refactor(jc/parsers/traceroute): remove duplicate ParseError class

* refactor(jc/parsers/traceroute): pre-process data in _loads() for easy-to-reuse

* refactor(jc/parsers/traceroute): split hop serialization into separate function to reuse

* refactor(jc/parsers/traceroute): simplify numeric conversion and make it reusable for traceroute_s

* fix(jc/parsers/traceroute): stricter regex to match traceroute headers only

* feat(jc/parsers/traceroute_s): v1.0 implementation

* fix(jc/parsers/traceroute): revert "_" prefix in function and class names

* fixup! fix(jc/parsers/traceroute): revert "_" prefix in function and class names

* chore(jc/parsers/traceroute): update the author information
2025-10-12 10:21:16 -07:00
Kelly Brazil
467ad60e20 Fix for who output containing process name #663 2025-09-08 17:14:37 -07:00
Kelly Brazil
91b3572ead parser version bump 2025-09-08 15:04:48 -07:00
Brian Wo
60caa17eb9 add yay as magic command for pacman (#657)
yay is a popular pacman wrapper that adds extra functionality to
standard pacman. It has the same output format as pacman.

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2025-09-08 14:59:55 -07:00
Kelly Brazil
eea31ddbe4 add .DS_Store to gitignore 2025-09-08 14:56:43 -07:00
Kelly Brazil
61793bba31 fix net_localgroup tests 2025-09-08 14:54:45 -07:00
Kelly Brazil
51e4a476ba fixup net_localgroup parser 2025-09-08 14:44:13 -07:00
Kelly Brazil
883f0c9cf7 net-user parser fixup 2025-09-08 14:25:44 -07:00
Kelly Brazil
ffaf455d43 doc updates 2025-09-04 16:59:21 -07:00
Kelly Brazil
b520532578 fixup route-print parser 2025-09-04 16:43:18 -07:00
Jose E. Rodriguez
3b1af1a9b6 Feat: Introduce net-localgroup net-user and route-print parsers (#602)
* feat(patch): introduce net localgroup, net user, and route print parsers

* fix: fix net user parsing error

* fix: address PR findings

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2025-09-04 14:47:28 -07:00
Kelly Brazil
0fa5f7f67f add test 2025-08-03 17:19:21 -07:00
Kelly Brazil
a77298e560 add cable_pairing field to fix #662 2025-08-01 07:41:45 -07:00
Kelly Brazil
5f75df2e4b remove force test comment 2025-07-24 13:13:21 -07:00
Kelly Brazil
38d169f4d0 force tests 2025-07-24 13:09:44 -07:00
Kelly Brazil
e737dde9e0 windows 2019 runner deprecated - move to windows 2022 2025-07-24 13:08:15 -07:00
Kelly Brazil
6e49c87575 update tests 2025-07-24 13:02:37 -07:00
Kelly Brazil
6afa6b449e add unit and byte conversion fields 2025-07-08 12:30:41 -07:00
Kelly Brazil
424d9c1347 add unit string fields and topline bytes fields 2025-07-08 11:45:47 -07:00
Kelly Brazil
10d1ab1c74 add bytes fields 2025-07-08 08:50:12 -07:00
Kelly Brazil
5db256c3e7 add x509-crl parser tests 2025-06-06 15:23:42 -07:00
Kelly Brazil
7f7dcc35ec help screen update 2025-05-28 14:54:29 -07:00
Kelly Brazil
edcde58cb9 remove unused Dict type import 2025-05-28 13:18:00 -07:00
Kelly Brazil
3a7ca118ff doc updates 2025-05-27 09:06:26 -07:00
Kelly Brazil
f36c713110 doc fix 2025-05-20 17:58:04 -07:00
Kelly Brazil
0db2ad2f5e doc fix 2025-05-20 17:56:15 -07:00
Kelly Brazil
816c38e1fe now returns only a single object, not an array of CRL objects 2025-05-20 17:47:05 -07:00
Kelly Brazil
e4cf7b502e doc update 2025-05-18 20:16:58 -07:00
Kelly Brazil
4ca7179481 add x509-crl parser 2025-05-18 20:09:05 -07:00
Kelly Brazil
bebd6a60fb add team-port.config and fix for blank values 2025-05-18 19:24:54 -07:00
Kelly Brazil
5d7940a89b version bump 2025-05-18 19:24:19 -07:00
Kelly Brazil
ac8120e1fe Merge pull request #655 from kellyjonbrazil/dev
Dev v1.25.5
2025-05-10 11:38:04 -07:00
Kelly Brazil
a854f1d6b0 doc update 2025-05-10 11:25:41 -07:00
Kelly Brazil
7c9e92e284 add test for team.config with JSON 2025-05-05 14:48:12 -07:00
Kelly Brazil
4c2775970d change team_config to object instead of list 2025-05-05 11:34:30 -07:00
Kelly Brazil
ba0fc5dad9 doc update 2025-05-03 13:42:34 -07:00
Kelly Brazil
222d1b7255 support json value in team.config field 2025-05-03 13:39:32 -07:00
Kelly Brazil
34fda0905f force test run 2025-04-15 08:56:36 -07:00
Kelly Brazil
ccbe36e712 Create very_old, old, and latest python runs
needed due to loss of python 3.6 support on some runners
2025-04-15 08:55:41 -07:00
Kelly Brazil
bb1136c33c Merge branch 'dev' of https://github.com/kellyjonbrazil/jc into dev 2025-04-15 08:51:39 -07:00
Kelly Brazil
c6a13aa4d8 force test run 2025-04-15 08:51:35 -07:00
Kelly Brazil
d04a175d36 Update to ubuntu-22.04 on old version run 2025-04-15 08:50:30 -07:00
Kelly Brazil
966df71566 add default policy stats to iptables parser 2025-04-15 08:41:30 -07:00
Kelly Brazil
c8599253fb formatting 2025-04-14 15:30:35 -07:00
Kelly Brazil
65d9cc718f version bump 2025-04-13 18:14:15 -07:00
Kelly Brazil
9b4190f1e6 fix mount on macOS when filesystem contains parenthesis 2025-04-13 18:13:31 -07:00
Kelly Brazil
c519657d85 allow IDNA2008 encoded email addresses with warning 2025-04-12 10:50:26 -07:00
Kelly Brazil
d5cceb77e9 remove extraneous file 2025-04-04 16:16:47 -07:00
Kelly Brazil
5cde110afb set bytes conversion to posix mode 2025-04-04 16:14:20 -07:00
Kelly Brazil
65aa6c1a9a update copyright date 2025-04-02 12:06:59 -07:00
Kelly Brazil
5394d7f62d doc update 2025-04-02 11:37:24 -07:00
Jake Ob
ebbd4e9320 Fix broken controller parser schema to include power state prop (#652)
This commit fixes issue #627

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2025-04-02 11:32:19 -07:00
Kelly Brazil
834acfb2d6 update lsblk tests 2025-03-31 17:06:41 -07:00
Kelly Brazil
1182c9f263 fix for missing dB value 2025-03-31 16:50:46 -07:00
Kelly Brazil
ed3046bb1b remove type annotations since they are not used 2025-03-31 16:34:38 -07:00
Kelly Brazil
ca73076b56 make empty mountpoints list instead of null 2025-03-31 14:29:27 -07:00
Kelly Brazil
9efc014dce doc update 2025-03-31 14:17:51 -07:00
Kelly Brazil
dbe1757a48 add mountpoints array field and convert sizes to bytes 2025-03-31 14:16:17 -07:00
Kelly Brazil
1c09289d95 fix time parser for missing centiseconds 2025-03-31 12:16:45 -07:00
Kelly Brazil
e9ccedf0d7 doc update 2025-03-30 12:38:41 -07:00
Michel Lind
fb4b4eeb58 Adjust for removal of typing.ByteString in Python 3.14 (#639)
`typing.ByteString` has been removed:

https://docs.python.org/3.14/whatsnew/3.14.html

The modernizing guide suggests `collections.abc.ByteString` which has
also been removed; the recommendation is to use either:

- just `bytes`
- `collections.abc.Buffer`
- a union of `bytes`, `bytesarray`, etc.

https://typing.readthedocs.io/en/latest/guides/modernizing.html#modernizing-byte-string

Per discussion, using `bytes` should suffice

Signed-off-by: Michel Lind <salimma@fedoraproject.org>
2025-03-30 12:34:54 -07:00
pettai
896891ad9e Switch TZ to a generic name (#635)
Switch TZ to a more generic name that works under minimal chrooted builds. (America/Los_Angeles, Pacific, PST, PST8PDT)
This fixes pbuilder builds on Ubuntu

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2025-03-30 12:33:45 -07:00
Kelly Brazil
7fda79d841 allow parser to deal with null input 2024-12-20 16:31:38 -08:00
Kelly Brazil
8995ac686a doc update 2024-12-20 15:30:41 -08:00
Kelly Brazil
006047553d version bump to v1.25.5 2024-12-20 15:29:07 -08:00
Kelly Brazil
c56e38c66c Merge pull request #625 from kellyjonbrazil/master
Merge pull request #618 sync dev
2024-12-20 23:26:25 +00:00
Kelly Brazil
ee3b873ef4 Merge branch 'dev' into master 2024-12-20 23:24:53 +00:00
Eden Refael
a39cb05228 created the amixer sget command parser - READY FOR REVIEW (#616)
* created the amixer first skeleton

* push testing and integrate this commit and branch with issue: #591

* #591 checks the input data with jc utils

* created the data parser of the sget control of the amixer sget <controller> command.

* test commit - just for tests

* another test commit

* another test commit

* created a dedicated pseudo algorithm for the amixer sget and tried various of strings.

* orginized the docstring with general explanation about the tool and the amixer tool output and algorithm of the input parsing and input examples.

* created raw implementation, but it's raw either or either.

* orginized the content inside the amixer parser

* removed endpoint name

* added amixer to the jc parser in lib

* more explanations

* added tests for the amixer sget

* added tests for the amixer sget

* fine versioning fix

* created docstring+another explanations seperated.

* created the amixer parser docu

* added the amixer in alphabet order to the json convert lib

* Fix PEP 8: E302 violation as part of boy scout principle

* deleted not necessary file

* fixed the spaces between sections in the amixer description

* resolved commits such as amixer module docstring and preperations for  parser for raw=False.

* Revert "Fix PEP 8: E302 violation as part of boy scout principle"

This reverts commit 241d1a1c63.

* created the dedicated _process for raw=False

* created the dedicated _process for raw=False

* added tests for the _process raw=False.

* changed keys to be lowercase snake-case - Change 'dB' to 'db'

* added more dB -> db changes and used int convertor of the jc utils

---------

Co-authored-by: EdenRafael <eden.refael@kazuar.com>
Co-authored-by: Eden Refael <edeenraf@hotmail.com>
Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-12-20 15:06:38 -08:00
Kelly Brazil
f54ceaa793 Merge pull request #619 from Luigi31415/add-tz-to-tests
Timezone Testing with TZ Env Variable
2024-11-29 01:02:31 +00:00
Hamza Saht
99cce72244 fix: Add TZ for runtests.sh 2024-11-27 20:31:47 +03:00
Kelly Brazil
0c40e3a3c9 Merge pull request #618 from kellyjonbrazil/dev
Dev v1.25.4
2024-11-25 20:39:34 -08:00
Kelly Brazil
025d00ecd2 Merge branch 'master' into dev 2024-11-25 20:33:20 -08:00
Kelly Brazil
a2b5d41308 minor fix to iw-scan to parse more fields 2024-11-25 20:19:40 -08:00
Kelly Brazil
366589268e update calculated fields 2024-11-25 17:16:30 -08:00
Kelly Brazil
53dd28b65e doc update 2024-11-24 18:59:30 -08:00
Kelly Brazil
0be6528aff convert size fields and fix issue for optional_deps without a description 2024-11-24 18:13:08 -08:00
Kelly Brazil
6ceaa7749e doc update 2024-11-24 17:30:49 -08:00
Kelly Brazil
6ae2e17ea1 add examples and tests 2024-11-24 17:30:03 -08:00
Kelly Brazil
ef9ca9322e Some processing completed 2024-11-24 16:02:59 -08:00
Kelly Brazil
95cba21d73 initial pacman parser 2024-11-24 14:57:55 -08:00
Kelly Brazil
be1dd031f1 doc update 2024-11-24 13:38:10 -08:00
Hamza Saht
7fbe1e9f21 Add WireGuard (wg) Command Output Parser (#606)
* feat: add parser to parse the output of wg

* fixup! feat: add parser to parse the output of wg

* feat: Add tests for windows 10

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-11-24 13:34:58 -08:00
Hamza Saht
7d33850d43 fix: Edit pythonapp.yml workflow to run on non-draft PRs (#617) 2024-11-24 13:24:04 -08:00
Kelly Brazil
7887789d0d coerce non-json-serializable objects to strings 2024-11-20 13:49:27 -08:00
Kelly Brazil
7ddd2a4ce2 fix yaml parser to support values starting with an equal sign 2024-11-19 14:12:21 -08:00
Kelly Brazil
34ab34cc66 doc update 2024-11-19 12:15:18 -08:00
pettai
a8b231da81 nsd-control parser update, zone transfer status (#607)
* add more parsing functionality for transfering state

* add additional/conditional fields into the schema

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-11-19 12:12:43 -08:00
Kelly Brazil
2278c7ecab doc update 2024-11-19 10:51:16 -08:00
Kelly Brazil
4cb88977cc add long ipv6 test 2024-11-19 10:51:10 -08:00
Aleksey Lobanov
0af4a3a5d7 fix: New RE_PROBE_IPV6_ONLY with better complexity in worst case (#609)
Example ':'*100

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-11-19 10:43:24 -08:00
Kelly Brazil
c0f9b705c6 doc update 2024-11-19 10:33:19 -08:00
Hamza Saht
fa416083f2 Fix/spaces in program name (#608)
* fix: enforce word boundaries while checking state presence

* fix: add tests for the special netstat case with space in process name

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-11-19 10:28:32 -08:00
Kelly Brazil
e858faa746 fix for contiguous packages with the same name 2024-11-18 16:21:40 -08:00
Kelly Brazil
a8f769eea3 doc update 2024-10-20 09:50:36 -07:00
Kelly Brazil
26133261f9 use jc.utils.timestamp() for datetime conversions 2024-10-20 09:45:08 -07:00
Kelly Brazil
6072ea0ec7 doc update 2024-10-18 14:34:29 -07:00
Kelly Brazil
95672c23b7 doc update 2024-10-18 14:30:04 -07:00
Jose E. Rodriguez
a2e0e6d549 feat: Add Windows ipconfig parser to jc (#596)
* feat: Introduce ipconfig parser

* fix: add parsing support for "connection_specific_dns_suffix_search_list" and windows XP ipv4 addresses, remove dateutil dependency

* fix: introduce unit tests, correct import of datetime

* fix: changed preferred to status to account for other ip statuses, and parsed link local ipv6 prefix length

* fix: compress _parse_header_line and _parse_adapter_line + fix casing in unit test file

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-10-18 14:17:14 -07:00
Kelly Brazil
2df5e79295 doc update 2024-10-18 09:56:32 -07:00
Jake Ob
c5e0642b0b Fix broken controller regexp scheme in the bluetoothctl parser (#599)
This commit fixes the controller parser scheme in order to take care
and extract some extra attributes, the manufacturer and version.
The order of the attributes appearing in the regexp scheme must follow
the order they appear in the `bluetoothctl show` outputs.

A new test has been added to test outputs with these extra attrs.

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-10-18 09:50:51 -07:00
Kelly Brazil
78150ded70 doc update 2024-10-17 14:05:06 -07:00
Kelly Brazil
05f3e4ea8a fixup tests 2024-10-17 13:53:20 -07:00
Kelly Brazil
b7cf0ca8d4 flip is_reserved to false for python ipv6 backports 2024-10-17 13:13:31 -07:00
Kelly Brazil
ba6e1e694e fix for python backports for ipv6 output 2024-10-17 13:06:17 -07:00
Kelly Brazil
aec3e3cd13 force github test 2024-10-17 09:15:29 -07:00
Kelly Brazil
d9363ae473 doc update 2024-09-26 09:49:06 -07:00
Kelly Brazil
0f367a435a formatting 2024-09-23 06:58:33 -07:00
Kelly Brazil
0955598b49 formatting 2024-09-23 06:55:17 -07:00
Kelly Brazil
f2a8e0087b add tests and doc update 2024-09-22 20:01:40 -07:00
Kelly Brazil
97e9798cef add posix_mode to utils/convert_size_to_int and use in df 2024-09-22 19:34:23 -07:00
Leonard Crestez
413519e02c #592: Handle df size suffixes as binary (#593)
* df: convert_size_to_int as binary

* tests: Update df -h expected output

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-09-22 19:28:45 -07:00
Kelly Brazil
5c855e40c6 fix 6to4 test for python backports 2024-09-17 09:52:38 -07:00
Kelly Brazil
b66c5dbf55 doc update 2024-09-12 19:38:31 -07:00
Kelly Brazil
b054b1b782 doc update 2024-09-07 19:50:08 -07:00
Mabuchin
1593d0bf79 Add error type support for Linux Ping (#575)
* feat: add icmp error handle into linux_parse

* refactor: fixed timestamp offset logic(including error-response-type condition)
2024-09-07 19:46:43 -07:00
Kelly Brazil
8a22f8a468 add support for Link partner advertised link modes to ethtool parser 2024-09-07 18:43:41 -07:00
Kelly Brazil
c26f0641ff enhance ifconfig parser to support utun interfaces with assigned ipv4 addresses on macOS 2024-09-07 18:11:25 -07:00
Kelly Brazil
40eb2b7ef6 fix uptime for "user" instead of "users" 2024-09-07 17:24:21 -07:00
Kelly Brazil
71af0c5555 fix for IPv4 mapped IPv6 address changes in Python 3.13 2024-09-06 10:26:34 -07:00
Kelly Brazil
9f5532d91f formatting 2024-06-18 17:43:16 -07:00
Kelly Brazil
c68c919024 add mount test 2024-06-18 17:34:17 -07:00
Michał Górny
9eb4df34b1 adjust expected test_ip_address_ipv6_6to4 output for Python 3.12.4 (#573)
Adjust the expected output in `test_ip_address_ipv6_6to4` to account
for `is_global`/`is_private` changes for 6to4 addresses in Python 3.12.4
and Python 3.13.0.

Fixes #572

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-06-18 08:53:19 -07:00
Kelly Brazil
921133f3ac version bump 2024-06-18 08:47:24 -07:00
Kelly Brazil
0350607359 fix for space if filesystem name 2024-06-18 08:47:02 -07:00
Kelly Brazil
5f8c65cf5b Merge branch 'dev' 2024-06-09 19:00:37 -07:00
Kelly Brazil
ed048c7b2b doc update 2024-06-09 18:48:25 -07:00
Kelly Brazil
18dabd4b9f update var names 2024-06-09 10:35:42 -07:00
Kelly Brazil
0005945383 doc update 2024-06-09 10:31:06 -07:00
Kelly Brazil
e13605a6a9 add ss tests 2024-06-08 09:17:57 -07:00
Kelly Brazil
a92e318319 doc update 2024-06-07 17:42:30 -07:00
Kelly Brazil
7d8166326a fix for when recv-q is too close to state field 2024-06-07 17:06:40 -07:00
Kelly Brazil
d21e5f4f28 doc update 2024-05-14 18:20:14 -07:00
Kelly Brazil
f1bab336ee fix file_stats in git-log parsers 2024-05-14 17:38:39 -07:00
konstantin-shatalov
0faacb6d0d Added support for number of lines changed for git logs (#557)
Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
Co-authored-by: kshatalov <kshatalov@citco.com>
2024-05-14 15:05:22 -07:00
Kelly Brazil
6af82fb9ae doc update 2024-05-10 11:11:31 -07:00
Kelly Brazil
517137889c fix zpool-status parser when there are no columnar values 2024-05-10 11:06:05 -07:00
Kelly Brazil
8a3997cd0e fix for pip-show parser with multi-line fields starting with a blank line 2024-05-02 15:09:06 -07:00
Kelly Brazil
4f66faad0d do not convert physlot to int 2024-04-29 14:20:15 -07:00
Kelly Brazil
846f4fb691 doc update 2024-04-29 14:09:14 -07:00
Kelly Brazil
5bec53b3f8 feat: get correct probe IP when mutliple probe on hop (#562)
Co-authored-by: Pierre-Olivier Côté <pierre-olivier.cote@polymtl.ca>
2024-04-29 13:58:11 -07:00
Kelly Brazil
dfc942776b doc update 2024-04-28 13:10:38 -07:00
Kelly Brazil
18a00bc57a doc update 2024-04-28 13:01:07 -07:00
Sam SIU
e2b2406931 [Fix issue #558] Add a condition check before subvendor dict creation (#559)
- Updated jc/parsers/pci_ids.py adding a check to see if the subvendor dict is already created
- Updated test fixture

Signed-off-by: Sam SIU <23556929+ssiuhk@users.noreply.github.com>
Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-04-28 12:58:22 -07:00
Kelly Brazil
a9cfb4b13a force test 2024-04-28 12:49:27 -07:00
Kelly Brazil
3e57ecf6df remove verbose testing 2024-04-28 12:48:03 -07:00
Kelly Brazil
2ddf67ad0c make xrander test quiet 2024-04-28 12:44:40 -07:00
Kelly Brazil
137c59cea1 add quiet=True to uptime parsing 2024-04-28 12:40:52 -07:00
Kelly Brazil
8b2f57e8e7 force test 2024-04-28 12:14:10 -07:00
Kelly Brazil
01f5aa05b3 Update pythonapp.yml
fix unittest command
2024-04-28 12:13:30 -07:00
Kelly Brazil
6ae626ef9f Merge branch 'dev' of https://github.com/kellyjonbrazil/jc into dev 2024-04-28 12:10:27 -07:00
Kelly Brazil
dea7099183 doc update 2024-04-28 12:08:13 -07:00
Kelly Brazil
9c3e4f349c verbose tests
make tests verbose to troubleshoot uptime compatibility messages in tests
2024-04-28 12:07:21 -07:00
Kelly Brazil
d5398c7089 remove timezone updates within tests - should be done by tester before running tests 2024-04-28 12:01:50 -07:00
Kelly Brazil
2dcf0e2d1b test remove timezone setting within test for windows 2024-04-28 11:48:32 -07:00
Kelly Brazil
f45295eee4 doc update 2024-04-28 11:30:33 -07:00
Nicolas Mattelaer
4ef34f7849 feat: Add battery_percentage property to --bluetoothctl output (#564)
* Adds battery_percentage property to bluetoothctl output

* remove ending comma

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-04-28 11:27:31 -07:00
Kelly Brazil
a69e55cb1c version bump 2024-04-27 11:17:37 -07:00
Kelly Brazil
6563b9f073 split jobs for old python and latest python 2024-04-27 11:15:44 -07:00
Kelly Brazil
6e17ed6f62 version bump 2024-04-22 10:11:26 -07:00
Kelly Brazil
abda8735be Merge pull request #551 from kellyjonbrazil/dev
Dev v1.25.2
2024-03-23 11:11:00 -07:00
Kelly Brazil
79cb156441 doc update 2024-03-23 10:58:36 -07:00
Kelly Brazil
1da080dc52 fix for unhandled lines in xrandr output 2024-03-23 10:57:46 -07:00
Kelly Brazil
3ca8e1ef11 iptables -x support for larger numbers and doc update 2024-03-19 14:38:20 -07:00
Kelly Brazil
1d31d3570a add -x support to iptables parser 2024-03-18 10:52:26 -07:00
Kelly Brazil
b84123a09b doc update 2024-03-18 10:26:00 -07:00
Kelly Brazil
475eedb142 Merge pull request #547 from lyterk/xrandr_fix_schema
[xrandr] Add props schema
2024-03-18 10:15:34 -07:00
Kelly Brazil
ebd0432b82 Merge branch 'dev' into xrandr_fix_schema 2024-03-18 10:05:29 -07:00
Kelly Brazil
ee1135003b add space after bullets 2024-03-16 18:28:52 -07:00
Kelly Brazil
aaee394e51 formatting 2024-03-16 18:25:45 -07:00
Kelly Brazil
ad91a71488 doc update 2024-03-15 12:19:14 -07:00
Kelly Brazil
c2adc46db4 make all summary docstrings raw 2024-03-15 12:17:39 -07:00
Kelly Brazil
3e9afca803 formatting 2024-03-15 11:39:27 -07:00
Kelly Brazil
ee2a7ddc2e remove python path update since the script will be run from the correct directory 2024-03-15 11:37:56 -07:00
Kelly Brazil
4fc7232d44 update all docs with new script 2024-03-14 22:46:52 -07:00
Kelly Brazil
a0dff721b1 reduce TOC level 2024-03-14 21:58:43 -07:00
Kelly Brazil
37061227d9 New doc generation script 2024-03-14 21:44:37 -07:00
Kelly Brazil
401b7b31b8 remove sys.path print 2024-03-14 17:31:38 -07:00
Kelly Brazil
86a4bd12b5 fix for tests run inside vscode 2024-03-14 17:29:31 -07:00
Kelly Brazil
50638cc11e fix escape warnings 2024-03-14 12:06:34 -07:00
Kelly Brazil
36de08a6f8 change existing_src to existing_pkg_ver 2024-03-13 19:01:09 -07:00
Kelly Brazil
83fa32f615 ethtool - convert units 2024-03-08 16:39:23 -08:00
Kevin Lyter
a3ca2814b3 Add props schema 2024-03-02 17:46:13 -08:00
Kevin Lyter
5c06712fba [xrandr] Fix schema 2024-03-02 17:46:13 -08:00
Kevin Lyter
fdadba226f [xrandr] Update schema 2024-03-02 17:46:13 -08:00
Kelly Brazil
5ac36befe2 add apt-get-sqq parser tests 2024-03-01 14:25:33 -08:00
Kelly Brazil
527b5ab5c5 doc update 2024-03-01 13:57:21 -08:00
Kelly Brazil
495c353c5d clean up template 2024-03-01 13:53:02 -08:00
Kelly Brazil
abbd4820fd add ethtool parser tests 2024-03-01 13:52:45 -08:00
Kelly Brazil
5e88eb0c8b add --module-info support to ethtool parser 2024-03-01 11:43:19 -08:00
Kelly Brazil
b0c98a56ce add operation value updates to _process 2024-02-29 14:32:46 -08:00
Kelly Brazil
07e9b46535 add new parsers 2024-02-29 14:00:33 -08:00
Kelly Brazil
87419750fc add apt-get-sqq command parser 2024-02-29 13:59:32 -08:00
Kelly Brazil
412a772b42 fix for multiple list items on a line 2024-02-29 10:09:24 -08:00
Kelly Brazil
52a816cc45 add ethtool command parser 2024-02-28 18:03:00 -08:00
Kelly Brazil
48deacf875 doc update 2024-02-28 13:33:56 -08:00
Kelly Brazil
7a377f7b8d add needrestart command parser 2024-02-28 13:28:03 -08:00
Kelly Brazil
e2f97d7d8e add simple summary support to rsync and rsync-s parsers 2024-02-27 10:26:07 -08:00
Kelly Brazil
f9bf889654 add apt_cache_show tests and fix parser name in warning messeages for parser aliases 2024-02-26 20:18:57 -08:00
Kelly Brazil
026846650a add apt_cache_show parser. Split list values into an array. fix tests. 2024-02-26 19:56:07 -08:00
Kelly Brazil
850917ada0 remove extra fields from df parser. All size values are now normalized to bytes. Size field is now an integer. 2024-02-26 11:17:42 -08:00
Kelly Brazil
bce4eb536a add human readable output support to the free parser 2024-02-26 10:42:26 -08:00
Kelly Brazil
ef2a2121b5 add human-readable support to the df parser 2024-02-26 10:00:42 -08:00
Kelly Brazil
4bed8392b8 update release notes section 2024-02-20 08:56:53 -08:00
Kelly Brazil
8e2bcba352 use get_parser instead of importlib 2024-02-14 15:45:18 -08:00
Kelly Brazil
588e5c2653 add Idle support to state_map 2024-02-14 15:31:10 -08:00
Kelly Brazil
25085c3412 doc update 2024-02-14 15:25:22 -08:00
Kelly Brazil
bfa99d99af Merge pull request #544 from viktory683/iwconfig-fix
Iwconfig fix
2024-02-14 23:19:31 +00:00
Kelly Brazil
b8f7ddcfc8 Merge branch 'dev' into iwconfig-fix 2024-02-14 22:46:49 +00:00
bzglve
413ea4bc68 added some more symbols following "SSID Naming Conventions"
from https://www.cisco.com/assets/sol/sb/WAP321_Emulators/WAP321_Emulator_v1.0.0.3/help/Wireless05.html
2024-02-14 15:36:04 +06:00
bzglve
13948fff26 #541 fix 2024-02-14 15:19:13 +06:00
Kelly Brazil
6275591ef1 version bump and doc updates 2024-02-12 21:31:10 -08:00
Kelly Brazil
2cdbebb7fd Merge pull request #542 from kellyjonbrazil/dev
Dev v1.25.1
2024-02-13 00:35:00 +00:00
Kelly Brazil
412f11276a fix sys.path update 2024-02-12 16:18:52 -08:00
Kelly Brazil
f3dd51f517 hard-code disabled parser path 2024-02-12 15:53:21 -08:00
Kelly Brazil
f66f1aadaa use shlex to correctly split the /proc files in magic_run_command_str 2024-02-12 15:32:38 -08:00
Kelly Brazil
8ead7e4835 rename List class to _List for documentation purposes 2024-02-12 15:05:44 -08:00
Kelly Brazil
f1177a2606 add more coverage for --quiet cli option 2024-02-12 11:00:27 -08:00
Kelly Brazil
44dc2a74c1 add test for jc -h 2024-02-12 11:00:02 -08:00
Kevin Lyter
d50bd96ce6 [xrandr] Allow props command (#540)
* [xrandr] Allow props command

Responding to issue #525
Somewhat substantial rewriting here to make the parser more resilient
- Change parser to not mutate the incoming data list, instead index
- Create `Line` class and `categorize` classmethod
  - Every line is categorized and regexed, so it gets dispatched to the
  right level of responsibility

* Bump version

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-02-12 09:03:25 -08:00
Kelly Brazil
5cde127a04 raise ParseError instead of output empty object for disabled parser 2024-02-10 14:58:15 -08:00
Kelly Brazil
63d1cead90 enhance uptime parser for busybox output with no user info 2024-02-10 11:55:19 -08:00
Kelly Brazil
d3e7f09ca3 fix for more graceful handling of missing optional libraries 2024-02-10 11:16:38 -08:00
Kelly Brazil
e6bdbb42d3 add more ini tests 2024-02-09 19:32:19 -08:00
Kelly Brazil
3cfc5e3e3c fix ini parser for edge cases with non-value keys 2024-02-09 17:13:19 -08:00
Kelly Brazil
082d4a3f80 doc update 2024-02-07 11:53:13 -08:00
Kelly Brazil
158c28455b version bump 2024-02-05 18:30:26 -08:00
Kelly Brazil
efb02493b8 remove extra $ from slicing example 2024-02-05 18:22:05 -08:00
Kelly Brazil
a319ec85ca doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
e754e88f2d doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
cfa7f267fc update schema 2024-02-06 01:54:31 +00:00
Kelly Brazil
c581e959fa formatting 2024-02-06 01:54:31 +00:00
Kelly Brazil
9eb56543be add verbosity check for printing 2024-02-06 01:54:31 +00:00
Kelly Brazil
67643906b1 formatting 2024-02-06 01:54:31 +00:00
Kelly Brazil
14d257225c doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
0411940f75 add full path to error messages 2024-02-06 01:54:31 +00:00
Kelly Brazil
7d60df67f3 check for missing fixtures 2024-02-06 01:54:31 +00:00
Kelly Brazil
70a971a2f1 formatting 2024-02-06 01:54:31 +00:00
Kelly Brazil
3fbdffd028 efibootmgr updates 2024-02-06 01:54:31 +00:00
yaofei zheng
539fe72d16 add "sudo efibootmgr" (without -v) output test case (#534) 2024-02-06 01:54:31 +00:00
Kelly Brazil
bd6611aaba doc updates 2024-02-06 01:54:31 +00:00
Kelly Brazil
cf77ddc396 cleanup 2024-02-06 01:54:31 +00:00
Kelly Brazil
77bcd616cd add tests for curl-head and http-headers parsers 2024-02-06 01:54:31 +00:00
yaofei zheng
5ee2eda83e add efibootmgr parser (#528)
* More nsd fixes (#523)

* Update nsd_control.py

support catz output

* Update nsd_control.py

fix parsing of catz zones

* add testdata

add corresponding catz testdata

* Revert "More nsd fixes" (#526)

* add efibootmgr parser

* add efibootmgr completions

* Multiple fixes on jc/parsers/efibootmgr.py

1. Update schema in comments.
1. Add an example.
1. Use clean and clear sub string finding sytax.
1. Wrap schema in an object.
1. Make variable scope as small as possible.

* add tests for efibootmgr

* Update jc/parsers/efibootmgr.py

Update example using `--pretty` for output.

Co-authored-by: Muescha <184316+muescha@users.noreply.github.com>

* jc/parsers/efibootmgr multiple changes

1. convert all keys to "snake_case"
2. add "mirrored_percentage_above_4g" and "mirror_memory_below_4gb"
3. move conversion (from string to other types) to "_process"

---------

Co-authored-by: pettai <pettai@sunet.se>
Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
Co-authored-by: Muescha <184316+muescha@users.noreply.github.com>
2024-02-06 01:54:31 +00:00
Kelly Brazil
5b849b0275 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
3e5d206f0c test utils cleanup 2024-02-06 01:54:31 +00:00
Kelly Brazil
f50f96381d doc update 2024-02-06 01:54:31 +00:00
Muescha
962632ac1f Feature: generic fixtures tests (#529)
* add generic test runners

* extract generic test runners

* beautify messages, remove unused return value

* add template and info do CONTRIBUTING

* typo

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-02-06 01:54:31 +00:00
Kelly Brazil
d209780a9d only add timestamp field if datetime string is parsable 2024-02-06 01:54:31 +00:00
Kelly Brazil
8e5451a7c1 fix for datetime or integer fields 2024-02-06 01:54:31 +00:00
Kelly Brazil
86a09c17cf remove unused _process function 2024-02-06 01:54:31 +00:00
Kelly Brazil
4bb85195e2 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
39f43aad63 add http_headers and curl_head parsers 2024-02-06 01:54:31 +00:00
Kelly Brazil
29689f7603 formatting 2024-02-06 01:54:31 +00:00
Muescha
78d7ab1308 add info about documentation and completions (#531) 2024-02-06 01:54:31 +00:00
Kelly Brazil
303cd12de3 version bump to v1.25.0 2024-02-06 01:54:31 +00:00
Kelly Brazil
b65f37e075 add normalize_key() function and tests 2024-02-06 01:54:31 +00:00
Kelly Brazil
c05fa7e9cd add remove_quotes() to utils and use in ini parsers 2024-02-06 01:54:31 +00:00
Kelly Brazil
264272a8b8 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
7fadb23fea use convert_size_to_int() 2024-02-06 01:54:31 +00:00
Kelly Brazil
c419e460db doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
6434ff61bf add HTTP header datetime format 2024-02-06 01:54:31 +00:00
Kelly Brazil
45a1be11e2 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
7659fe470a formatting 2024-02-06 01:54:31 +00:00
Muescha
c332c4febf draft for path and path_list (#513)
* draft for path_list

* updaate doc

* add input check

* fix types

* fix schema: add missing properties

* add _process

* fix _process docs

* refactor: extract path.py parser

* swap order of names alphabetically

* documentation and comments

* path parser: add early return for nodata

* path and path-list parser: add test and fixtures

* typo in file name

* add early return for nodata

* add test and fixtures

* typo in file name

* rename fixtures

* rename fixtures

* refactor to pathlib.Path

* failing on windows - use PurePosixPath

* changed the way to strip dot from suffix

* add POSIX to path

* test commit to see results on windows is failing

* test commit to see results on windows is failing

* add windows path detection

* somehow Path not like the newline from input line

* add test with more items

* remove debug print

* wrap test loops into into subTest

* remove print statements

* add path and path-list to CHANGELOG

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-02-06 01:54:31 +00:00
Kelly Brazil
2cc212bfab use convert_size_to_int() from utils 2024-02-06 01:54:31 +00:00
Kelly Brazil
b836ffc583 add tests for convert_size_to_int() 2024-02-06 01:54:31 +00:00
Kelly Brazil
29f1a1d425 fix proc doc - output is dict or list of dicts 2024-02-06 01:54:31 +00:00
Kelly Brazil
9f78dc6afa proc parser doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
74c7e11948 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
6ba6dc0374 version bump 2024-02-06 01:54:31 +00:00
pettai
ec0f2569e5 More nsd fixes (#523)
* Update nsd_control.py

support catz output

* Update nsd_control.py

fix parsing of catz zones

* add testdata

add corresponding catz testdata
2024-02-06 01:54:31 +00:00
Kelly Brazil
65e30c4440 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
8d9ebf5dfa doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
c3746454ff doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
ea0f6493a2 update contributing guide 2024-02-06 01:54:31 +00:00
Kelly Brazil
afbc46076e add ping tests 2024-02-06 01:54:31 +00:00
Mabuchin
2b9b6550a7 Fix data_bytes is null in ping -I option (#520)
* fixed header parsing when specifying ping interface

* add source_ip parsing test for ping/ping-s

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-02-06 01:54:31 +00:00
Kelly Brazil
6fb3c0a409 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
1b8911ad36 add slurp docs 2024-02-06 01:54:31 +00:00
Kelly Brazil
cc61b57dd1 add blank line tests to slicer 2024-02-06 01:54:31 +00:00
Kelly Brazil
6d679b2895 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
1e1fc08a47 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
b5c3a03d56 implement slurp by wrapping in a list, adding "_file" for /proc, and further wrapping in {"result": data} when --meta-out is used. 2024-02-06 01:54:31 +00:00
Kelly Brazil
9e269f070f update slice help doc 2024-02-06 01:54:31 +00:00
Kelly Brazil
f863cfdef4 fix for slicing blank lines 2024-02-06 01:54:31 +00:00
Kelly Brazil
2cd58d75e7 make parser_shortname more robust 2024-02-06 01:54:31 +00:00
Kelly Brazil
03b70eebb7 make /proc slurpable with magic syntax 2024-02-06 01:54:31 +00:00
Kelly Brazil
1e76ce2aea doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
d9fc1b4242 doc update 2024-02-06 01:54:31 +00:00
Muescha
36a3d2e96d crontab remove double entry in doc (#518) 2024-02-06 01:54:31 +00:00
Kelly Brazil
bf05de1d63 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
cae41df1d8 add get_parser tests 2024-02-06 01:54:31 +00:00
Kelly Brazil
8e9ff7fa9f refactor to use get_parser() 2024-02-06 01:54:31 +00:00
Muescha
973c535c72 extract to public jc.get_parser(parser_name) (#516)
* remove unused imports and RegEx

* extract to public jc.get_parser(parser_name)

* changed order of exports

* add doc

* add doc.md

* remove data_dir from doc.md

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-02-06 01:54:31 +00:00
Muescha
8614d3dde9 remove unused imports and RegEx (#515) 2024-02-06 01:54:31 +00:00
Kelly Brazil
a73ee47bcf move slurp error message so it will work for all parser types 2024-02-06 01:54:31 +00:00
Kelly Brazil
d54a81831f update slicer to use utils.line_slice() 2024-02-06 01:54:31 +00:00
Kelly Brazil
73ae1396b9 enhance slurp error message 2024-02-06 01:54:31 +00:00
Kelly Brazil
3399e8551e add slurpable_parser_mod_list test 2024-02-06 01:54:31 +00:00
Kelly Brazil
b9656c2fae add line_slice tests 2024-02-06 01:54:31 +00:00
Kelly Brazil
e08ccb7942 add slurp test. fix cli_json_out_pretty test 2024-02-06 01:54:31 +00:00
Kelly Brazil
9b648e8560 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
c97a8fb48f add line_slice function 2024-02-06 01:54:31 +00:00
Kelly Brazil
3a95407161 back out slurp array flattening code 2024-02-06 01:54:31 +00:00
Kelly Brazil
7609af28b3 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
c2b2e81a2b add more slurpable parsers 2024-02-06 01:54:31 +00:00
Kelly Brazil
3b0594a4a6 flatten slurp output if parser outputs a list 2024-02-06 01:54:31 +00:00
Kelly Brazil
2b0b9dd7ba doc update 2024-02-06 01:54:31 +00:00
don Rumata
f159dd6b9d Add plugins support 4 snapcraft (#512)
* Added `snap` support.

* Added plugins support.

* Add README 4 snap.

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2024-02-06 01:54:31 +00:00
Kelly Brazil
2d5d87c73d version bump and doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
a260ceba1c add slurp functionality 2024-02-06 01:54:31 +00:00
Kelly Brazil
6c30b8106c use PurePosixPath to fix tests running on Windows 2024-02-06 01:54:31 +00:00
Kelly Brazil
a23921c879 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
3999276d17 add parent, filename, stem, and extension to schema 2024-02-06 01:54:31 +00:00
Kelly Brazil
65bd4850f2 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
d71c2d2b20 add kv_dup tests 2024-02-06 01:54:31 +00:00
Kelly Brazil
6dd5b29998 fix to make None values always a blank string 2024-02-06 01:54:31 +00:00
Kelly Brazil
1868b28f74 doc fix 2024-02-06 01:54:31 +00:00
Kelly Brazil
e8c0bef6ca doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
2c09a06b5a add kv_dup parser 2024-02-06 01:54:31 +00:00
Kelly Brazil
fc75ce90d1 refactor alias parsers 2024-02-06 01:54:31 +00:00
Kelly Brazil
45a6cfc9cf add source info to docs 2024-02-06 01:54:31 +00:00
Kelly Brazil
69a0922410 doc update 2024-02-06 01:54:31 +00:00
Kelly Brazil
2bb201a706 fix parser source path 2024-02-06 01:54:31 +00:00
Kelly Brazil
50d5d3a3ba add opposite endian ipv6 addresses for s390x and other Big Endian architecture support 2024-02-06 01:54:31 +00:00
Kelly Brazil
b14a8980b8 add more info for unit tests 2024-02-06 01:54:31 +00:00
muescha
de6aa1cc92 change \n to echo to create new lines 2024-02-06 01:54:31 +00:00
Muescha
c4dcedb269 Update docgen.sh: add link to source 2024-02-06 01:54:31 +00:00
Kelly Brazil
140a61702b Revert "More nsd fixes" (#526) 2024-01-26 14:22:13 -08:00
pettai
4d3fc07e3b More nsd fixes (#523)
* Update nsd_control.py

support catz output

* Update nsd_control.py

fix parsing of catz zones

* add testdata

add corresponding catz testdata
2024-01-26 14:20:33 -08:00
Kelly Brazil
dcc4d35d55 Merge branch 'dev' into master 2023-12-21 22:02:56 +00:00
Muescha
cfb30b32f3 Update CONTRIBUTING.md (#509)
* Update CONTRIBUTING.md

fix:
- bullet points
- fix link to custom plugins
- add info about appending to `jc/lib.py`

* Update CONTRIBUTING.md

fix numbering

* typo: lowercase
2023-12-21 07:42:04 -08:00
Kelly Brazil
26f2738471 Merge pull request #502 from kellyjonbrazil/master
sync to dev
2023-12-18 20:13:45 +00:00
Kelly Brazil
2bccd14c5d Merge pull request #499 from kellyjonbrazil/dev
v1.24.0
2023-12-17 18:08:02 +00:00
Kelly Brazil
0d4823c9de doc update 2023-12-17 09:44:18 -08:00
Kelly Brazil
2a14f56b72 add proc-cmdline tests 2023-12-16 13:18:14 -08:00
Kelly Brazil
fe49759598 doc update 2023-12-16 12:59:35 -08:00
Kelly Brazil
ee737a59eb doc update 2023-12-16 12:55:29 -08:00
Kelly Brazil
517ab10930 add proc-cmdline parser 2023-12-16 12:09:37 -08:00
Kelly Brazil
604fb574be doc update 2023-12-16 11:44:11 -08:00
Kelly Brazil
a254ee8d88 add test for issue 490 2023-12-16 11:39:40 -08:00
Kelly Brazil
f784a7a76d doc update 2023-12-10 13:13:57 -08:00
Kelly Brazil
2e33afbe18 doc cleanup 2023-12-10 10:53:28 -08:00
Kelly Brazil
103bb174fc rename pkg-index-alpine to pkg-index-apk 2023-12-10 10:49:05 -08:00
Kelly Brazil
2a76a64fa1 schema update 2023-12-10 10:41:20 -08:00
Kelly Brazil
c8fb56c601 formatting 2023-12-10 10:41:09 -08:00
Kelly Brazil
e835227027 doc update 2023-12-10 10:30:05 -08:00
Kelly Brazil
88ffcaee56 update schema. fix no-data output to match other parsers. 2023-12-10 10:29:58 -08:00
Kelly Brazil
a9ba98847c update _device_pattern regex for Freezing with 100% CPU when parsing Xrandr output - 1.23.6 #490 2023-12-09 17:01:03 -08:00
Kelly Brazil
2630049ab7 possible fix for infinite loop issue 2023-12-09 16:14:27 -08:00
Kelly Brazil
47c7e081f3 doc update 2023-12-09 11:45:26 -08:00
Kelly Brazil
ef7f755614 doc update 2023-12-09 11:41:45 -08:00
Kelly Brazil
32bd7ffbf6 formatting updates 2023-12-09 11:41:22 -08:00
Kelly Brazil
347097a294 add convert_size_to_int function 2023-12-09 11:41:06 -08:00
Kelly Brazil
356857f5d6 rename deb-packages-index to pkg-index-deb 2023-12-09 10:17:48 -08:00
Kelly Brazil
ee12c52291 rename apkindex parser to pkg-index-alpine 2023-12-09 10:03:33 -08:00
Ron Green
0e7ebf4dc1 feat(iftop): add iftop-scanning (#484)
* feat(iftop): add iftop-scanning

this is not even an MVP, but I would like it to exist to allow per client json aggregation

also, a future use is a stream response

* fix typos and test first regex

* add more iftop fun

* Update iftop.py

* add tests and json

Signed-off-by: Ron Green <11993626+georgettica@users.noreply.github.com>

* feat: make work and add tests

Signed-off-by: Ron Green <11993626+georgettica@users.noreply.github.com>

* add completion

* change schema for query looping

* fix: tests

* fix review comments

* feat: add byte parsing

* add no-port to options

* remove completion and format dep

Signed-off-by: Ron Green <11993626+georgettica@users.noreply.github.com>

* Update setup.py

* Update iftop.py

---------

Signed-off-by: Ron Green <11993626+georgettica@users.noreply.github.com>
Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2023-12-07 18:22:53 -08:00
Kelly Brazil
f1e0cec9d6 add apkindex parser 2023-12-04 14:01:30 -08:00
Roey Darwish Dror
d96a2a8623 APKINDEX parser (#487) (#491)
* APKINDEX parser (#487)

* Missing space in doc
2023-12-04 13:35:04 -08:00
Hugo van Kemenade
1b1bc46222 Remove redundant Python 2 code (#493)
Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2023-12-04 13:03:15 -08:00
Kelly Brazil
d5a8b4eed2 remove deprecated iso-datetime parser 2023-12-04 11:35:37 -08:00
Kelly Brazil
5ddd4f0e86 version bump to 1.24.0 2023-12-04 11:33:04 -08:00
Kelly Brazil
8b94c326de add no data test 2023-12-04 09:59:28 -08:00
Hugo van Kemenade
29b012e66d Add support for Python 3.12 (#492)
Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2023-12-04 09:55:07 -08:00
Kelly Brazil
572a3207cd doc update 2023-11-28 11:23:47 -08:00
Kelly Brazil
2a88f2be6b fix mypy issues 2023-11-28 11:21:13 -08:00
Roey Darwish Dror
3de6eac1ad swapon parser (#383) (#489)
* swapon parser

* revert lib

* fix lib

* Added tests

* Fix tests

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2023-11-28 11:15:40 -08:00
Kelly Brazil
f44260603e doc update 2023-11-24 10:38:33 -08:00
Kelly Brazil
1c60f5355e convert one more field to integer 2023-11-24 09:45:56 -08:00
Kelly Brazil
40fa78a966 version bump 2023-11-24 09:44:03 -08:00
Himadri Bhattacharjee
71db67ef49 refactor: acpi parser: adhere code to the happy path to avoid nested branches (#488)
* refactor: acpi parser: keep working code in happy path to avoid nested branches

* fix: use elif for branches marked charging and discharging

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2023-11-24 09:38:10 -08:00
Kelly Brazil
1cd723b48f add tests 2023-11-23 15:19:14 -08:00
Kelly Brazil
82ee4d7b30 add debconf-show parser 2023-11-23 14:52:06 -08:00
Kelly Brazil
dfd19f38f3 doc update 2023-11-23 12:12:05 -08:00
Kelly Brazil
2358c883d0 remove unused type annotation import 2023-11-23 12:07:54 -08:00
Kelly Brazil
79e4f3a761 doc update 2023-11-23 12:05:03 -08:00
Kelly Brazil
5be45622cc Merge branch 'dev' of https://github.com/kellyjonbrazil/jc into dev 2023-11-23 12:01:54 -08:00
Kelly Brazil
5f4136b943 run tests 2023-11-23 12:00:58 -08:00
Kelly Brazil
941bfe2724 update szenius/set-timezone to v1.2 2023-11-23 11:59:12 -08:00
Kelly Brazil
3ed44a26d9 doc update 2023-11-23 11:51:04 -08:00
Kelly Brazil
b7270517bd add tune2fs parser 2023-11-23 11:49:04 -08:00
Kelly Brazil
bf63ac93c6 add Photon linux 2023-11-21 15:01:04 -08:00
Kelly Brazil
1cb80f15c2 add tests 2023-11-21 14:51:37 -08:00
Kelly Brazil
b5c22c6e53 add deb-packages-index parser 2023-11-21 14:40:43 -08:00
Kelly Brazil
7951366117 remove old unused line 2023-11-17 12:06:43 -08:00
Kelly Brazil
c78a4bb655 mount fix for spaces in mountpoint name 2023-11-14 15:17:31 -08:00
Kelly Brazil
8aceda18b9 Merge pull request #483 from wolkenarchitekt/master
#482 Quickfix to parse mount output
2023-11-14 23:07:52 +00:00
Ingo Weinmann
e0c75a9b6b #482 Quickfix to parse mount output 2023-11-14 22:47:56 +01:00
Kelly Brazil
fd283f6cf7 doc update 2023-11-04 16:02:02 -07:00
Kelly Brazil
b881ad4ec0 make blank target null 2023-11-04 15:58:12 -07:00
Kelly Brazil
2fcb32e26f add debian/ubuntu package index support 2023-11-04 15:19:12 -07:00
Kelly Brazil
13a802225b add tests 2023-10-25 16:53:24 -07:00
Kelly Brazil
88649a4e8d doc update 2023-10-25 13:42:19 -07:00
Kelly Brazil
5c6fa5bff6 better header row detection 2023-10-25 13:37:59 -07:00
Kelly Brazil
b70025d6d6 fix for blank target in rule 2023-10-24 16:17:53 -07:00
Kelly Brazil
59b89ecbd4 version bump 2023-10-24 15:24:33 -07:00
Kelly Brazil
8f7502ff0f Merge pull request #479 from kellyjonbrazil/master
sync to dev
2023-10-24 22:22:31 +00:00
Kelly Brazil
249d93f15c Merge pull request #477 from kellyjonbrazil/dev
v1.23.6
2023-10-24 00:57:57 +00:00
Kelly Brazil
b0cf2e2d78 clean up final return 2023-10-23 17:37:53 -07:00
Kelly Brazil
264fcd40ad clear linedata if 'from' found 2023-10-23 17:36:25 -07:00
Kelly Brazil
54def8ef49 doc update 2023-10-23 15:41:11 -07:00
Kelly Brazil
63c271b837 add tests 2023-10-23 15:39:13 -07:00
Kelly Brazil
741b2d1c1d version bump 2023-10-23 15:15:07 -07:00
Kelly Brazil
47d4335890 fix for multi-word remote 2023-10-23 15:14:28 -07:00
Kelly Brazil
81f721f1ab doc update 2023-10-23 14:33:40 -07:00
Kelly Brazil
c4e1068895 move print statements 2023-10-23 14:06:04 -07:00
Kelly Brazil
a77bb4165a fix tests for different xmltodict versions 2023-10-23 12:49:06 -07:00
Kelly Brazil
3cd2dce496 formatting 2023-10-23 08:01:50 -07:00
Kelly Brazil
46a8978740 doc update 2023-10-23 07:54:14 -07:00
Kelly Brazil
3161c48939 fix for older xmltodict library versions 2023-10-23 07:53:39 -07:00
Kelly Brazil
a89a9187f8 version bump 2023-10-23 07:53:16 -07:00
Kelly Brazil
d9e0aa5b93 Merge pull request #475 from kellyjonbrazil/master
Merge pull request #473 from kellyjonbrazil/dev
2023-10-23 14:48:55 +00:00
Kelly Brazil
d298e101e9 Merge pull request #473 from kellyjonbrazil/dev
Dev v1.23.5
2023-10-21 12:23:25 -07:00
Kelly Brazil
cea975d7f1 doc update 2023-10-21 12:12:43 -07:00
Kelly Brazil
1ed69f9e6a doc update and fix tests 2023-10-21 12:09:18 -07:00
Kelly Brazil
ab0e05ec82 only set colors if pygments is installed 2023-10-21 12:01:09 -07:00
Kelly Brazil
c16cce4bf0 add tests 2023-10-13 08:52:14 -07:00
Kelly Brazil
d3489536a1 add "7" as a netstat raw state 2023-10-12 17:25:40 -07:00
Sebastian Uhlik
041050ce28 Fix bug in split when program running on UDP contains space in name (#447)
* Add condition before split.

* Safe detection of 'state' presence.

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2023-10-12 17:21:06 -07:00
pettai
7de1a8a5d6 add more tests (#468)
add all test-cases
2023-10-05 17:09:35 -07:00
Kelly Brazil
d4604743d1 add multiline value support to env parser 2023-10-02 16:30:56 -07:00
Kelly Brazil
0b8fb31298 doc update 2023-10-02 08:35:36 -07:00
Kelly Brazil
dcdd79e28c doc update 2023-10-02 08:34:14 -07:00
Kelly Brazil
5291baeb8e fixup variable names 2023-10-02 08:32:41 -07:00
Kelly Brazil
6867102c66 doc update 2023-10-01 18:13:27 -07:00
Kelly Brazil
36ed2c7e2e add lsb_release parser 2023-10-01 18:12:22 -07:00
Kelly Brazil
4ab0aba9d3 doc update 2023-10-01 17:42:42 -07:00
Kelly Brazil
e643badaf7 add os-release parser 2023-10-01 17:42:00 -07:00
Kelly Brazil
d96e96219e add comment support to xml parser 2023-10-01 11:49:50 -07:00
Kelly Brazil
e42af3353e fix pidstat parsers for -T ALL option 2023-10-01 11:25:56 -07:00
Kelly Brazil
4ec2b16f42 doc fix 2023-09-30 16:18:32 -07:00
Kelly Brazil
0a028456bf add nsd-control parser 2023-09-30 15:45:29 -07:00
pettai
a1f10928e1 Add nsd-control (#454)
* Create nsd_control.py

Init nsd_control.py

* cleanup nsd-control + add test data

- Cleanup nsd-control parser
- Add test data

* add test script

add test script + fix test data

* Update test_nsd_control.py

fix a default test

* Update test_nsd_control.py

nit
2023-09-30 15:36:52 -07:00
Kelly Brazil
eae1d4b89a doc update 2023-09-30 15:34:29 -07:00
Kelly Brazil
d3c7cec333 add host parser 2023-09-30 15:32:27 -07:00
pettai
36fa08d711 Add ISC 'host' support (#450)
* Add ISC 'host' support

Add ISC 'host' command support

* Update host.py

remove leading tab from string

* Add integer conversion

Per request, fix integer conversion

* Cleanup

Cleanup strip()'s

* Add tests

Add two tests for the 'host' parser

* Update test_host.py

nit

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2023-09-30 15:26:03 -07:00
Kelly Brazil
a9958841e4 doc update 2023-09-30 15:23:29 -07:00
Kelly Brazil
504ad81a01 version bump 2023-09-30 15:21:29 -07:00
Kevin Lyter
8bf2f4f4d0 [xrandr] Fix 453 devices issue (#455)
* [xrandr] Fix bug 453, clean up data model

* Fix: 'devices' was originally not a list, just assigned each time it
was parsed. Made that a list and appended to it.
* Removed distinction between unassociated/associated devices
* Added test for @marcin-koziol's problem
* Put tests into separate test methods

* Formatting cleanup

* Backwards compatible type syntax

---------

Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2023-09-30 15:19:14 -07:00
Kelly Brazil
805397ea18 doc update 2023-09-30 15:15:29 -07:00
Samson Umezulike
1b3985c2d7 Adds graceful handling of superfluous bits in bit strings (#459)
Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2023-09-30 15:12:18 -07:00
Kelly Brazil
f602043642 fix for negative serial numbers 2023-09-30 15:06:28 -07:00
Samson Umezulike
1a1aa8fda3 Adds graceful handling of negative serial numbers in x509 certificates (#445)
Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2023-09-30 15:02:55 -07:00
Kelly Brazil
3249a017ae add dest-unreachable test 2023-09-15 12:09:38 -07:00
Kelly Brazil
84f0246b2d move int/float conversions to _process 2023-09-14 18:15:28 -07:00
Kelly Brazil
1c795982b0 add error and corrupted fields to ping-s 2023-09-14 13:03:45 -07:00
Kelly Brazil
c5164b4108 doc update 2023-09-10 15:20:11 -07:00
Kelly Brazil
dc3716ecb3 add errors and corrupted support 2023-09-10 15:18:32 -07:00
Kelly Brazil
c5165ccc21 version bump 2023-09-10 15:18:23 -07:00
José Miguel Guzmán
5b2035e0e6 Add support for corrupted and errors in linux ping. (#442)
* Add support for corrupted and errors in linux ping.

* Fix regular expressions

* Workaround to keep compatibility with current tests

---------

Co-authored-by: Jose Miguel Guzman <jmguzman@whitestack.com>
Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
2023-08-25 10:31:17 -07:00
Kelly Brazil
5205154aaf add percent_wait to float conversion 2023-08-21 17:18:07 -07:00
Kelly Brazil
f500de3af6 version bump 2023-08-21 17:17:34 -07:00
Kian-Meng Ang
4b028b5080 Fix typos (#440)
Found via `codespell -S ./tests/fixtures -L chage,respons,astroid,unx,ist,technik,ans,buildd`
2023-07-31 08:45:03 -07:00
1032 changed files with 66249 additions and 4176 deletions

View File

@@ -9,17 +9,74 @@ on:
- "**/*.py"
jobs:
build:
very_old_python:
if: github.event.pull_request.draft == false
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-20.04, windows-latest]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
os: [macos-13, windows-2022]
python-version: ["3.6"]
steps:
- uses: actions/checkout@v3
- name: "Set up timezone to America/Los_Angeles"
uses: szenius/set-timezone@v1.0
uses: szenius/set-timezone@v1.2
with:
timezoneLinux: "America/Los_Angeles"
timezoneMacos: "America/Los_Angeles"
timezoneWindows: "Pacific Standard Time"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Test with unittest
run: |
python -m unittest discover tests
old_python:
if: github.event.pull_request.draft == false
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-13, ubuntu-22.04, windows-2022]
python-version: ["3.7", "3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v3
- name: "Set up timezone to America/Los_Angeles"
uses: szenius/set-timezone@v1.2
with:
timezoneLinux: "America/Los_Angeles"
timezoneMacos: "America/Los_Angeles"
timezoneWindows: "Pacific Standard Time"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Test with unittest
run: |
python -m unittest discover tests
latest_python:
if: github.event.pull_request.draft == false
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: ["3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: "Set up timezone to America/Los_Angeles"
uses: szenius/set-timezone@v1.2
with:
timezoneLinux: "America/Los_Angeles"
timezoneMacos: "America/Los_Angeles"

2
.gitignore vendored
View File

@@ -6,3 +6,5 @@ build/
.github/
.vscode/
_config.yml
.venv
.DS_Store

156
CHANGELOG
View File

@@ -1,5 +1,161 @@
jc changelog
202501012 v1.25.6
- Add `net-localgroup` Windows command parser
- Add `net-user` Windows command parser
- Add `route-print` Windows command parser
- Add `traceroute-s` streaming command parser
- Add `max_hops` and `data_bytes` fields to `traceroute` command parser
- Add `x509-crl` file parser to support Certificate Revocation List PEM and DER files
- Add `yay` as a magic command for the `pacman` command parser
- Fix `bluetoothctl` command parser to support output with the `cable_pairing` attribute
- Fix `nmcli` command parser to support blank `team.config` JSON value and `team-port.config` JSON value
- Fix `top` command parsers to correct memory size field parsing. Several new unit
and byte conversion fields have been added
- Fix `who` command parser to support the `process` field on Debian13
20250503 v1.25.5
- Add `amixer` command parser
- Enhance `iptables` command parser to add default policy statistics fields
- Fix `bluetoothctl` parser failing to parse controllers with power state prop
- Fix `lsblk` command parser to support multiple mountpoints. Also, added
byte conversions for size fields.
- Fix `nmcli` command parser to support `team.config` JSON field
- Fix `time` command parser for output that does not contain centiseconds
- Fix `x509-cert` parser to handle IDNA2008 encoded email addresses with a warning
- Fix typing for upcoming python v3.14
- Fix timezone setting for tests to support minimal chrooted builds
20241125 v1.25.4
- Add `ipconfig` command parser (`ipconfig` for Windows)
- Add `pacman` command parser
- Add `wg show` command parser
- Enhance `ethtool` parser to support `link_partner_advertised_link_modes`
- Enhance `ifconfig` parser to support `utun` interfaces with assigned IPv4 addresses on macOS
- Enhance `nsd-control` parser with additional state fields
- Enhance `ping-s` streaming parser to support error replies
- Fix `bluetoothctl` parser when extra attributes like `manufacturer` and `version` exist
- Fix `df` parser to correctly output binary vs. decimal size outputs
- Fix `ip-address` parser for Python 3.13 changes to IPv4 mapped IPv6 addresses
- Fix `iw-scan` parser to output more fields (still beta quality)
- Fix `mount` parser for cases where there are spaces in the filesystem name
- Fix `netstat` parser for cases where there are spaces in the program name
- Fix `pkg-index-deb`, `apt-cache-show`, and `rpm-qi` parsers to correctly convert contiguous packages with the same name
- Fix `traceroute` parser to support extreme IPv6 cases
- Fix `uptime` parser for data that contains `user` instead of `users`
- Fix `yaml` parser to support values that start with an equal sign
- Enhance `jc.utils.convert_size_to_int()` to add `posix_mode` and `decimal_bias` parameters
- Enhance cli to coerce any non-JSON-serializable objects to a string
20240609 v1.25.3
- Enhance `bluetoothctl` parser with added `battery_percentage` field
- Enhance `git-log` standard and streaming parsers with added `lines_changed` field under `file_stats`
- Fix `lspci` parser to handle `physlot` fields with a range value
- Fix `pci-ids` parser to correctly handle multiple subdevices
- Fix `pip-show` parser to handle multi-line fields with a beginning blank line
- Fix `ss` parser to correctly handle the `Recv-Q` field being too close to the `Status` field
- Fix `top` parsers to quiet uptime info parsing
- Fix `traceroute` parser to correctly handle hops with multiple IPs
- Fix `zpool-status` parser for config items lacking data values
- Optimize some tests by removing timezone settings and using quiet=True
- Documentation updates
20240323 v1.25.2
- Add `apt-cache-show` command parser
- Add `apt-get-sqq` command parser
- Add `ethtool` command parser
- Add `needrestart` command parser
- Enhance `df` parser to add human readable output support. Note: the `size`
field has been changed to an integer and all size values have been normalized
to bytes.
- Enhance `free` parser to add human readable output support. All size values
have been normalizd to bytes.
- Enhance `iptables` parser to handle -x output
- Enhance `/proc/pid/stat` parser to support "Idle" state
- Enhance `rpm_qi` and `pkg_index_deb` parsers to split list fields into arrays
- Fix `iwconfig` parser to handle more special characters in the SSID name
- Fix `xrandr` parser to ignore extra horizontal and vertical stats lines
- Add aarch64 binaries to Releases for macOS and Linux
- Documentation and doc build updates
20240212 v1.25.1
- Fix for crash when optional libraries are not installed (e.g. xmltodict)
- Fix for `ini` parser crashing with some keys with no values
- Fix `xrandr` parser to extract more EDID data
- Enhance `uptime` parser to support output with no user information
- Enhance `--quiet` CLI option to cover more warning messages
- Add tests for missing optional libraries
- Documentation updates
20240204 v1.25.0
- Add `--slurp` functionality to wrap output from multiple lines into a single array.
Note, this only works with single-line input parsers. (e.g. `date`, `ip-address`, `url`, etc.)
Streaming parsers are not supported. Use `jc -hhh` to find parsers compatible with the slurp option.
- Enhance `/proc` file magic syntax to allow slurping when multiple files are selected
and to include the `_file` metadata field in the data
- Enhance `--meta-out` functionality to include a list of the input data when using `--slurp`
or `/proc` file magic syntax. For slurpable parsers, this is a list of string inputs in order.
For `/proc` file magic syntax, this is a list of `/proc` filenames in order. This can help with
identifying which input matches to which output when using `--slurp` or when converting multiple
files via `/proc` file magic syntax.
- Add `curl-head` command parser for `curl --head` or `curl -I` with verbose support
- Add `efibootmgr` command parser
- Add `http-headers` parser for plain HTTP header output
- Add `kv-dup` parser for Key/Value files with duplicate keys
- Add `path` string parser to parse posix path
- Add `path-list` string parser to parse path list strings found in env variables
- Add source link to online parser documentation
- Add snap package build scripts
- Add `remove_quotes` function to `utils.py`
- Add `normalize_key` function to `utils.py`
- Add `line_slice` function to `utils.py`
- Add `get_parser` function to `lib.py`
- Enhance `nsd-control` parser to support more zone information
- Enhance `ping` and `ping-s` parsers to support the `-I` command option
- Enhance `proc-net-tcp` parser to add opposite endian support for architectures
like the s390x
- Enhance `url` parser to add `parent`, `filename`, `stem`, and `extension` fields
- Fix `ini` and `ini-dup` parsers to consistently handle null values as empty strings
- Fix line slicer to not skip blank lines
- Refactor parser aliases for `kv`, `pkg_index_deb`, `lsb_release`, and `os-release`
- Update copyright date
20231216 v1.24.0
- Add `debconf-show` command parser
- Add `iftop` command parser
- Add `pkg-index-apk` parser for Alpine Linux Package Index files
- Add `pkg-index-deb` parser for Debian/Ubuntu Package Index files
- Add `proc-cmdline` parser for `/proc/cmdline` file
- Add `swapon` command parser
- Add `tune2fs` command parser
- Remove `iso-datetime` parser deprecated since v1.22.1. (use `datetime-iso` instead)
- Update timezone change in Github Actions for node v16 requirement
- Add Python 3.12 tests to Github Actions
- Refactor `acpi` command parser for code cleanup
- Refactor vendored libraries to remove Python 2 support
- Fix `iptables` parser for cases where the `target` field is blank in a rule
- Fix `vmstat` parsers for some cases where wide output is used
- Fix `mount` parser for cases with spaces in the mount point name
- Fix `xrandr` parser for infinite loop issues
20231023 v1.23.6
- Fix XML parser for xmltodict library versions < 0.13.0
- Fix `who` command parser for cases when the from field contains spaces
20231021 v1.23.5
- Add `host` command parser
- Add `nsd-control` command parser
- Add `lsb_release` command parser
- Add `/etc/os-release` file parser
- Enhance `env` command parser to support multi-line values
- Enhance `ping` and `ping-s` parsers to add error and corrupted support
- Enhance `xml` parser to include comments in the JSON output
- Fix `pidstat` command parser when using `-T ALL`
- Fix `x509-cert` parser to allow negative serial numbers
- Fix `x509-cert` parser for cases when bitstrings are larger than standard
- Fix `xrandr` command parser for associated device issues
- Fix error when pygments library is not installed
20230730 v1.23.4
- Add `/etc/resolve.conf` file parser
- Add `/proc/net/tcp` and `/proc/net/tcp6` file parser

View File

@@ -1,5 +1,6 @@
# Contributing to jc
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
We love your input! We want to make contributing to this project as easy and
transparent as possible, whether it's:
- Reporting a bug
- Discussing the current state of the code
@@ -8,26 +9,65 @@ We love your input! We want to make contributing to this project as easy and tra
- Proposing a new parser
## We Develop with Github
We use github to host code, to track issues and feature requests, as well as accept pull requests.
We use github to host code, to track issues and feature requests, as well as
accept pull requests.
## We Use Github Flow, So All Code Changes Happen Through Pull Requests
Pull requests are the best way to propose changes to the codebase (we use [Github Flow](https://guides.github.com/introduction/flow/index.html)). We actively welcome your pull requests:
Pull requests are the best way to propose changes to the codebase (we use
[Github Flow](https://guides.github.com/introduction/flow/index.html)). We
actively welcome your pull requests:
1. Open an issue to discuss the new feature, bug fix, or parser before opening a pull request. For new parsers, it is important to agree upon a schema before developing the parser.
2. Fork the repo and create your branch from `dev`, if available, otherwise `master`.
3. For new parsers: 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 to get started. You can even place a new parser python module file in the [parser plugin directory](https://github.com/kellyjonbrazil/jc#custom-parsers) to get started right away with just a standard `jc` installation.
4. If you've added code that should be tested, add tests. All new parsers should have several sample outputs and tests.
5. Documentation is auto-generated from docstrings, so ensure they are clear and accurate.
6. Ensure the test suite passes. (Note: "**America/Los_Angeles**" timezone should be configured on the test system)
1. Open an issue to discuss the new feature, bug fix, or parser before opening
a pull request. For new parsers, it is important to agree upon a schema
before developing the parser.
2. Fork the repo and create your branch from `dev`, if available, otherwise
`master`.
3. For new parsers:
- Templates: 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 to get started.
- Local development: You can even place a new parser python module file in
the [parser plugin directory](https://github.com/kellyjonbrazil/jc#parser-plugins)
to get started right away with just a standard `jc` installation.
- Parser registry: Add the parser name to the [jc/lib.py](https://github.com/kellyjonbrazil/jc/blob/master/jc/lib.py)
file.
4. If you've added code that should be tested, add tests. All new parsers should
have several sample outputs and tests.
- Templates:
- **Recommended:** [tests/templates/_test_foo_simple.py](https://github.com/kellyjonbrazil/jc/tree/master/tests/templates/_test_foo_simple.py) as a template if you only have test with fixtures.
Execute these steps for standard tests:
- Save this file as `test_{parser_name}.py` since the helper methods extract parser names from the filename. Use underscores instead of dashes for the parser name.
- Organize fixtures in `tests/fixtures` for optimal structure.
- Format fixtures as follows (using double dashes):
- `{parser_name}--{some_test_description}.out` for command output. (no dots in the filename except for the `.out` suffix)
- `{parser_name}--{some_test_description}.json` for expected JSON after parsing. (no dots in the filename except for the `.json` suffix)
- Custom: [tests/templates/_test_foo.py](https://github.com/kellyjonbrazil/jc/blob/master/tests/templates/_test_foo.py) as a template for tests.
- Custom: [tests/templates/_test_foo_s.py](https://github.com/kellyjonbrazil/jc/tree/master/tests/templates/_test_foo_s.py) as a template for **streaming parser** tests.
- Fixtures: Tests typically consist of an input file and an expected output
JSON file. Add the data files to the appropriate folder under [tests/fixtures](https://github.com/kellyjonbrazil/jc/tree/master/tests/fixtures)
5. Documentation is auto-generated from docstrings, so ensure they are clear and
accurate.
6. Ensure the test suite passes. (Note: "**America/Los_Angeles**" timezone
should be configured on the test system)
7. Make sure your code lints.
8. Issue that pull request!
## Parser Schema Guidelines
- Try to keep the schema as flat as possible - typically a list of flat dictionaries
- Keys should be lowercase, contain no special characters, and spaces should be converted to underscores
- Keys should be static, if possible. If they have to be dynamic, then they should not contain lists or dictionaries
## Documentation And Completions
This will make it easier to use tools like `jq` without requiring escaping of special characters, encapsulating key names in [""], keeps paths predictable, and makes iterating and searching for values easier.
No need to worry about documentation and completions as those are auto generated
via the python doc strings.
## Parser Schema Guidelines
- Try to keep the schema as flat as possible - typically a list of flat
dictionaries
- Keys should be lowercase, contain no special characters, and spaces should be
converted to underscores
- Keys should be static, if possible. If they have to be dynamic, then they
should not contain lists or dictionaries
This will make it easier to use tools like `jq` without requiring escaping of
special characters, encapsulating key names in `[""]`, keeps paths predictable,
and makes iterating and searching for values easier.
**Examples**
@@ -62,18 +102,61 @@ Good:
]
```
## Tests
It is essential to have good command output sample coverage and tests to keep the `jc` parser quality high.
## Development Environment
Use the following steps to set up the development environment.
Many parsers include calculated timestamp fields using the `jc.utils.timestamp` class. Naive timestamps created with this class should be generated on a system configured with the "**America/Los_Angeles**" timezone on linux/macOS/unix and "**Pacific Standard Time**" timezone on Windows for tests to pass on the Github Actions CI tests. This timezone should be configured on your local system before running the tests locally, as well.
### Virtual Environment
Set up a Python virtual environment for `jc` development so you won't have to
worry about library conflicts. This can be done with something like
[pyenv](https://github.com/pyenv/pyenv) and/or
[venv](https://docs.python.org/3/library/venv.html)
### Clone the repo
Once the virtual environment is set up, clone the `jc` repository inside:
```bash
git clone https://github.com/kellyjonbrazil/jc.git
```
### Install In Developer Mode
Next, use the `./install.sh` script to install `jc` and the requirements in
developer mode (code chages take effect immediately). This will install the
console-script entry point to `$HOME/.local/bin` so you may need to add this
to your path.
## Tests
It is essential to have good command output sample coverage and tests to keep
the `jc` parser quality high.
Many parsers include calculated timestamp fields using the `jc.utils.timestamp`
class. Naive timestamps created with this class should be generated on a system
configured with the "**America/Los_Angeles**" timezone on linux/macOS/unix and
"**Pacific Standard Time**" timezone on Windows for tests to pass on the Github
Actions CI tests. This timezone should be configured on your local system before
running the tests locally, as well.
You can run all tests by running the `./runtests.sh` script.
## Debug Messages
Use `--debug` or `-d` to see debug error messages (double to see more):
```shell
echo 'abc' | jc --parser-with-error -dd
```
## Any contributions you make will be under the MIT Software License
In short, when you submit code changes, your submissions are understood to be under the same [MIT License](http://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern.
In short, when you submit code changes, your submissions are understood to be
under the same [MIT License](http://choosealicense.com/licenses/mit/) that
covers the project. Feel free to contact the maintainers if that's a concern.
## Report bugs using Github's Issues
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/kellyjonbrazil/jc/issues); it's that easy!
We use GitHub issues to track public bugs. Report a bug by
[opening a new issue](https://github.com/kellyjonbrazil/jc/issues); it's that
easy!
## Write bug reports with detail, background, and sample code
**Great Bug Reports** tend to have:
- A quick summary and/or background
@@ -82,8 +165,10 @@ We use GitHub issues to track public bugs. Report a bug by [opening a new issue]
- Give sample code if you can.
- What you expected would happen
- What actually happens
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)
- Notes (possibly including why you think this might be happening, or stuff you
tried that didn't work)
## Use a Consistent Coding Style
* 4 spaces for indentation rather than tabs
* Use a Python linter that will enforce PEP 8 and other best practices

75
README-snap.md Normal file
View File

@@ -0,0 +1,75 @@
# How to use `jc` with `snap`
## How to build `snap` package
- Install `snapd`. [One](https://snapcraft.io/docs/installing-snapd) or [two](https://github.com/don-rumata/ansible-role-install-snap).
- Install `snapcraft`:
```bash
$ sudo snap install snapcraft --classic
```
- Update snapd:
```bash
$ sudo snap refresh snapcraft --edge
```
- Clone the repo:
```bash
$ git clone https://github.com/kellyjonbrazil/jc
```
- Change the directory:
```bash
$ cd ./jc
```
- Select branch:
```bash
$ git checkout snap-support
```
- Initialize LXD:
```bash
$ lxd init --auto
```
- Build `.snap` file:
```bash
$ snapcraft
```
## How to install local snap file
```bash
$ snap install --dangerous ./jc_*_amd64.snap
```
## How to use `jc` with plugins
- Put your plugin in the `"$HOME/.local/share/jc"` directory.
- To connect the directory, run:
```bash
snap connect jc:dot-jc-plugins snapd
```
## Urls
- <https://snapcraft.io/docs/supported-interfaces>
- <https://snapcraft.io/docs/interface-management>
- <https://snapcraft.io/docs/personal-files-interface>
- <https://snapcraft.io/docs/python-apps>
- <https://documentation.ubuntu.com/lxd/en/latest/getting_started/>

126
README.md
View File

@@ -1,17 +1,15 @@
[![Tests](https://github.com/kellyjonbrazil/jc/workflows/Tests/badge.svg?branch=master)](https://github.com/kellyjonbrazil/jc/actions)
[![Pypi](https://img.shields.io/pypi/v/jc.svg)](https://pypi.org/project/jc/)
> Check out the `jc` Python [package documentation](https://github.com/kellyjonbrazil/jc/tree/master/docs) for developers
> Try the `jc` [web demo](https://jc-web.onrender.com/) and [REST API](https://github.com/kellyjonbrazil/jc-restapi)
> `jc` is [now available](https://galaxy.ansible.com/community/general) as an
Ansible filter plugin in the `community.general` collection. See this
> `jc` is available as an
[Ansible filter plugin](https://docs.ansible.com/ansible/latest/collections/community/general/jc_filter.html#ansible-collections-community-general-jc-filter)
in the `community.general` collection. See this
[blog post](https://blog.kellybrazil.com/2020/08/30/parsing-command-output-in-ansible-with-jc/)
for an example.
> Looking for something like `jc` but lower-level? Check out [regex2json](https://gitlab.com/tozd/regex2json).
# JC
JSON Convert
@@ -77,7 +75,7 @@ function parameter in `parse()` when using `jc` as a python library.
Schemas for each parser can be found at the documentation link beside each
[**Parser**](#parsers) below.
Release notes can be found [here](https://blog.kellybrazil.com/category/jc-news/).
Release notes can be found in the [Releases section](https://github.com/kellyjonbrazil/jc/releases) on Github.
## Why Would Anyone Do This!?
For more information on the motivations for this project, please see my blog
@@ -120,6 +118,7 @@ pip3 install 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` |
| Photon linux | `tdnf install jc` |
| macOS | `brew install jc` |
| FreeBSD | `portsnap fetch update && cd /usr/ports/textproc/py-jc && make install clean` |
| Ansible filter plugin | `ansible-galaxy collection install community.general` |
@@ -159,6 +158,9 @@ option.
| `--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) |
| `--amixer` | `amixer` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/amixer) |
| `--apt-cache-show` | `apt-cache show` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/apt_cache_show) |
| `--apt-get-sqq` | `apt-get -sqq` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/apt_get_sqq) |
| `--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) |
@@ -176,16 +178,20 @@ option.
| `--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) |
| `--curl-head` | `curl --head` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/curl_head) |
| `--date` | `date` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/date) |
| `--datetime-iso` | ISO 8601 Datetime string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/datetime_iso) |
| `--debconf-show` | `debconf-show` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/debconf_show) |
| `--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) |
| `--efibootmgr` | `efibootmgr` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/efibootmgr) |
| `--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) |
| `--ethtool` | `ethtool` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ethtool) |
| `--file` | `file` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/file) |
| `--find` | `find` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/find) |
| `--findmnt` | `findmnt` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/findmnt) |
@@ -202,7 +208,9 @@ option.
| `--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) |
| `--host` | `host` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/host) |
| `--hosts` | `/etc/hosts` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/hosts) |
| `--http-headers` | HTTP headers parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/http_headers) |
| `--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) |
@@ -210,6 +218,7 @@ option.
| `--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) |
| `--ip-address` | IPv4 and IPv6 Address string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ip_address) |
| `--ipconfig` | `ipconfig` Windows command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ipconfig) |
| `--iptables` | `iptables` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iptables) |
| `--ip-route` | `ip route` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ip_route) |
| `--iw-scan` | `iw dev [device] scan` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iw_scan) |
@@ -218,10 +227,12 @@ option.
| `--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 and string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/kv) |
| `--kv-dup` | Key/Value with duplicate key file and string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/kv_dup) |
| `--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) |
| `--lsattr` | `lsattr` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsattr) |
| `--lsb-release` | `lsb_release` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsb_release) |
| `--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) |
@@ -232,12 +243,20 @@ option.
| `--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) |
| `--needrestart` | `needrestart -b` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/needrestart) |
| `--netstat` | `netstat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/netstat) |
| `--net-localgroup` | `net localgroup` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/net_localgroup) |
| `--net-user` | `net user` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/net_user) |
| `--nmcli` | `nmcli` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/nmcli) |
| `--nsd-control` | `nsd-control` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/nsd_control) |
| `--ntpq` | `ntpq -p` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ntpq) |
| `--openvpn` | openvpn-status.log file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/openvpn) |
| `--os-prober` | `os-prober` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/os_prober) |
| `--os-release` | `/etc/os-release` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/os_release) |
| `--pacman` | `pacman` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pacman) |
| `--passwd` | `/etc/passwd` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/passwd) |
| `--path` | POSIX path string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/path) |
| `--path-list` | POSIX path list string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/path_list) |
| `--pci-ids` | `pci.ids` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pci_ids) |
| `--pgpass` | PostgreSQL password file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pgpass) |
| `--pidstat` | `pidstat -H` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pidstat) |
@@ -246,12 +265,15 @@ option.
| `--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) |
| `--pkg-index-apk` | Alpine Linux Package Index file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pkg_index_apk) |
| `--pkg-index-deb` | Debian Package Index file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pkg_index_deb) |
| `--plist` | PLIST file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/plist) |
| `--postconf` | `postconf -M` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/postconf) |
| `--proc` | `/proc/` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/proc) |
| `--ps` | `ps` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ps) |
| `--resolve-conf` | `/etc/resolve.conf` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/resolve_conf) |
| `--route` | `route` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/route) |
| `--route-print` | `route print` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/route_print) |
| `--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) |
@@ -264,6 +286,7 @@ option.
| `--sshd-conf` | `sshd` config file and `sshd -T` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/sshd_conf) |
| `--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) |
| `--swapon` | `swapon` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/swapon) |
| `--sysctl` | `sysctl` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/sysctl) |
| `--syslog` | Syslog RFC 5424 string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/syslog) |
| `--syslog-s` | Syslog RFC 5424 string streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/syslog_s) |
@@ -282,6 +305,8 @@ option.
| `--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) |
| `--traceroute-s` | `traceroute` and `traceroute6` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/traceroute_s) |
| `--tune2fs` | `tune2fs -l` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/tune2fs) |
| `--udevadm` | `udevadm info` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/udevadm) |
| `--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) |
@@ -297,8 +322,10 @@ option.
| `--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) |
| `--wg-show` | `wg show` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/wg_show) |
| `--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) |
| `--x509-crl` | X.509 PEM and DER certificate revocation list file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/x509_crl) |
| `--x509-csr` | X.509 PEM and DER certificate request file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/x509_csr) |
| `--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) |
@@ -309,22 +336,23 @@ option.
### Options
| 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. Use twice to show hidden parsers (e.g. `-hh`) |
| `-m` | `--monochrome` | Monochrome output |
| `-M` | `--meta-out` | Add metadata to output including timestamp, parser name, magic command, magic command exit code, etc. | |
| `-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)) |
| 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. Use twice to show hidden parsers (e.g. `-hh`). Use thrice to show parser categories (e.g. `-hhh`). |
| `-m` | `--monochrome` | Monochrome output |
| `-M` | `--meta-out` | Add metadata to output including timestamp, parser name, magic command, magic command exit code, etc. | |
| `-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 |
| `-s` | `--slurp` | Slurp multiple lines into an array. (use `-hhh` to find compatible parsers) |
| `-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)) |
### Slice
Line slicing is supported using the `START:STOP` syntax similar to Python
@@ -374,6 +402,58 @@ Here is a breakdown of line slice options:
| `:-STOP` | lines from the beginning through `STOP` lines from the end |
| `:` | all lines |
### Slurp
Some parsers support multi-item input and can output an array of results in a
single pass. Slurping works for string parsers that accept a single line of
input. (e.g. `url` and `ip-address`) To see a list of parsers that support
the `--slurp` option, use `jc -hhh`.
For example, you can send a file with multiple IP addresses (one per line) to
`jc` with the `--slurp` option and an array of results will output:
```bash
$ cat ip-addresses.txt | jc --slurp --ip-address
[<multiple output objects>]
```
The magic syntax for `/proc` files automatically supports slurping of multiple
files (no need to use the `--slurp` option). For example, you can convert many
PID files at once:
```bash
$ jc /proc/*/status
[<multiple output objects>]
```
When the `/proc` magic syntax is used and multiple files are selected, an
additional `_file` field is inserted in the output so it is easier to tell what
file each output object refers to.
Finally, the `--meta-out` option can be used in conjunction with slurped output.
In this case, the slurped output is wrapped in an object with the following
structure:
```json
{
"result": [<multiple output objects>],
"_jc_meta": {
"parser": "url",
"timestamp": 1706235558.654576,
"slice_start": null,
"slice_end": null,
"input_list": [
"http://www.google.com",
"https://www.apple.com",
"https://www.microsoft.com"
]
}
}
```
With `--meta-out`, `input_list` contains a list of inputs (actual input strings
or `/proc` filenames) so you can identify which output object relates to each
input string or `/proc` filename.
### Exit Codes
Any fatal errors within `jc` will generate an exit code of `100`, otherwise the
exit code will be `0`.
@@ -1303,4 +1383,4 @@ cat istio.yaml | jc -p --yaml
]
```
© 2019-2023 Kelly Brazil
© 2019-2025 Kelly Brazil

View File

@@ -3,9 +3,9 @@ _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 bluetoothctl cbt certbot chage cksum crontab date df dig dmidecode dpkg du env file findmnt finger free git gpg hciconfig id ifconfig iostat ip iptables iw iwconfig jobs last lastb ls lsattr lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat netstat nmcli ntpq os-prober pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss ssh sshd stat sum sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 udevadm ufw uname update-alternatives upower uptime vdir veracrypt vmstat w wc who xrandr zipinfo zpool)
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --date --datetime-iso --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --hosts --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsattr --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --ntpq --openvpn --os-prober --passwd --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --plist --postconf --proc --proc-buddyinfo --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --who --x509-cert --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status)
jc_options=(--force-color -C --debug -d --monochrome -m --meta-out -M --pretty -p --quiet -q --raw -r --unbuffer -u --yaml-out -y)
jc_commands=(acpi airport amixer apt-cache apt-get arp blkid bluetoothctl cbt certbot chage cksum crontab curl date debconf-show df dig dmidecode dpkg du efibootmgr env ethtool file findmnt finger free git gpg hciconfig host id ifconfig iostat ip ipconfig iptables iw iwconfig jobs last lastb ls lsattr lsb_release lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat needrestart net netstat nmcli nsd-control ntpq os-prober pacman pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss ssh sshd stat sum swapon sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 tune2fs udevadm ufw uname update-alternatives upower uptime vdir veracrypt vmstat w wc wg who xrandr yay zipinfo zpool)
jc_parsers=(--acpi --airport --airport-s --amixer --apt-cache-show --apt-get-sqq --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --curl-head --date --datetime-iso --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --efibootmgr --email-address --env --ethtool --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --http-headers --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --ipconfig --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --kv-dup --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --needrestart --netstat --net-localgroup --net-user --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --pacman --passwd --path --path-list --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --pkg-index-apk --pkg-index-deb --plist --postconf --proc --proc-buddyinfo --proc-cmdline --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --route-print --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --swapon --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --traceroute-s --tune2fs --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --wg-show --who --x509-cert --x509-crl --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status)
jc_options=(--force-color -C --debug -d --monochrome -m --meta-out -M --pretty -p --quiet -q --raw -r --slurp -s --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)

View File

@@ -9,10 +9,13 @@ _jc() {
jc_help_options jc_help_options_describe \
jc_special_options jc_special_options_describe
jc_commands=(acpi airport arp blkid bluetoothctl cbt certbot chage cksum crontab date df dig dmidecode dpkg du env file findmnt finger free git gpg hciconfig id ifconfig iostat ip iptables iw iwconfig jobs last lastb ls lsattr lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat netstat nmcli ntpq os-prober pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss ssh sshd stat sum sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 udevadm ufw uname update-alternatives upower uptime vdir veracrypt vmstat w wc who xrandr zipinfo zpool)
jc_commands=(acpi airport amixer apt-cache apt-get arp blkid bluetoothctl cbt certbot chage cksum crontab curl date debconf-show df dig dmidecode dpkg du efibootmgr env ethtool file findmnt finger free git gpg hciconfig host id ifconfig iostat ip ipconfig iptables iw iwconfig jobs last lastb ls lsattr lsb_release lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat needrestart net netstat nmcli nsd-control ntpq os-prober pacman pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss ssh sshd stat sum swapon sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 tune2fs udevadm ufw uname update-alternatives upower uptime vdir veracrypt vmstat w wc wg who xrandr yay zipinfo zpool)
jc_commands_describe=(
'acpi:run "acpi" command with magic syntax.'
'airport:run "airport" command with magic syntax.'
'amixer:run "amixer" command with magic syntax.'
'apt-cache:run "apt-cache" command with magic syntax.'
'apt-get:run "apt-get" command with magic syntax.'
'arp:run "arp" command with magic syntax.'
'blkid:run "blkid" command with magic syntax.'
'bluetoothctl:run "bluetoothctl" command with magic syntax.'
@@ -21,13 +24,17 @@ _jc() {
'chage:run "chage" command with magic syntax.'
'cksum:run "cksum" command with magic syntax.'
'crontab:run "crontab" command with magic syntax.'
'curl:run "curl" command with magic syntax.'
'date:run "date" command with magic syntax.'
'debconf-show:run "debconf-show" 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.'
'efibootmgr:run "efibootmgr" command with magic syntax.'
'env:run "env" command with magic syntax.'
'ethtool:run "ethtool" command with magic syntax.'
'file:run "file" command with magic syntax.'
'findmnt:run "findmnt" command with magic syntax.'
'finger:run "finger" command with magic syntax.'
@@ -35,10 +42,12 @@ _jc() {
'git:run "git" command with magic syntax.'
'gpg:run "gpg" command with magic syntax.'
'hciconfig:run "hciconfig" command with magic syntax.'
'host:run "host" 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.'
'ip:run "ip" command with magic syntax.'
'ipconfig:run "ipconfig" command with magic syntax.'
'iptables:run "iptables" command with magic syntax.'
'iw:run "iw" command with magic syntax.'
'iwconfig:run "iwconfig" command with magic syntax.'
@@ -47,6 +56,7 @@ _jc() {
'lastb:run "lastb" command with magic syntax.'
'ls:run "ls" command with magic syntax.'
'lsattr:run "lsattr" command with magic syntax.'
'lsb_release:run "lsb_release" 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.'
@@ -57,10 +67,14 @@ _jc() {
'mdadm:run "mdadm" command with magic syntax.'
'mount:run "mount" command with magic syntax.'
'mpstat:run "mpstat" command with magic syntax.'
'needrestart:run "needrestart" command with magic syntax.'
'net:run "net" command with magic syntax.'
'netstat:run "netstat" command with magic syntax.'
'nmcli:run "nmcli" command with magic syntax.'
'nsd-control:run "nsd-control" command with magic syntax.'
'ntpq:run "ntpq" command with magic syntax.'
'os-prober:run "os-prober" command with magic syntax.'
'pacman:run "pacman" 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.'
@@ -84,6 +98,7 @@ _jc() {
'sshd:run "sshd" command with magic syntax.'
'stat:run "stat" command with magic syntax.'
'sum:run "sum" command with magic syntax.'
'swapon:run "swapon" 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.'
@@ -93,6 +108,7 @@ _jc() {
'tracepath6:run "tracepath6" command with magic syntax.'
'traceroute:run "traceroute" command with magic syntax.'
'traceroute6:run "traceroute6" command with magic syntax.'
'tune2fs:run "tune2fs" command with magic syntax.'
'udevadm:run "udevadm" command with magic syntax.'
'ufw:run "ufw" command with magic syntax.'
'uname:run "uname" command with magic syntax.'
@@ -104,16 +120,21 @@ _jc() {
'vmstat:run "vmstat" command with magic syntax.'
'w:run "w" command with magic syntax.'
'wc:run "wc" command with magic syntax.'
'wg:run "wg" command with magic syntax.'
'who:run "who" command with magic syntax.'
'xrandr:run "xrandr" command with magic syntax.'
'yay:run "yay" command with magic syntax.'
'zipinfo:run "zipinfo" command with magic syntax.'
'zpool:run "zpool" command with magic syntax.'
)
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --date --datetime-iso --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --hosts --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsattr --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --ntpq --openvpn --os-prober --passwd --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --plist --postconf --proc --proc-buddyinfo --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --who --x509-cert --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status)
jc_parsers=(--acpi --airport --airport-s --amixer --apt-cache-show --apt-get-sqq --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --curl-head --date --datetime-iso --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --efibootmgr --email-address --env --ethtool --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --http-headers --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --ipconfig --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --kv-dup --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --needrestart --netstat --net-localgroup --net-user --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --pacman --passwd --path --path-list --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --pkg-index-apk --pkg-index-deb --plist --postconf --proc --proc-buddyinfo --proc-cmdline --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --route-print --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --swapon --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --traceroute-s --tune2fs --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --wg-show --who --x509-cert --x509-crl --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status)
jc_parsers_describe=(
'--acpi:`acpi` command parser'
'--airport:`airport -I` command parser'
'--airport-s:`airport -s` command parser'
'--amixer:`amixer` command parser'
'--apt-cache-show:`apt-cache show` command parser'
'--apt-get-sqq:`apt-get -sqq` command parser'
'--arp:`arp` command parser'
'--asciitable:ASCII and Unicode table parser'
'--asciitable-m:multi-line ASCII and Unicode table parser'
@@ -131,16 +152,20 @@ _jc() {
'--crontab-u:`crontab` file parser with user support'
'--csv:CSV file parser'
'--csv-s:CSV file streaming parser'
'--curl-head:`curl --head` command parser'
'--date:`date` command parser'
'--datetime-iso:ISO 8601 Datetime string parser'
'--debconf-show:`debconf-show` 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'
'--efibootmgr:`efibootmgr` command parser'
'--email-address:Email Address string parser'
'--env:`env` command parser'
'--ethtool:`ethtool` command parser'
'--file:`file` command parser'
'--find:`find` command parser'
'--findmnt:`findmnt` command parser'
@@ -157,7 +182,9 @@ _jc() {
'--hashsum:hashsum command parser (`md5sum`, `shasum`, etc.)'
'--hciconfig:`hciconfig` command parser'
'--history:`history` command parser'
'--host:`host` command parser'
'--hosts:`/etc/hosts` file parser'
'--http-headers:HTTP headers parser'
'--id:`id` command parser'
'--ifconfig:`ifconfig` command parser'
'--ini:INI file parser'
@@ -165,6 +192,7 @@ _jc() {
'--iostat:`iostat` command parser'
'--iostat-s:`iostat` command streaming parser'
'--ip-address:IPv4 and IPv6 Address string parser'
'--ipconfig:`ipconfig` Windows command parser'
'--iptables:`iptables` command parser'
'--ip-route:`ip route` command parser'
'--iw-scan:`iw dev [device] scan` command parser'
@@ -173,10 +201,12 @@ _jc() {
'--jobs:`jobs` command parser'
'--jwt:JWT string parser'
'--kv:Key/Value file and string parser'
'--kv-dup:Key/Value with duplicate key file and string parser'
'--last:`last` and `lastb` command parser'
'--ls:`ls` command parser'
'--ls-s:`ls` command streaming parser'
'--lsattr:`lsattr` command parser'
'--lsb-release:`lsb_release` command parser'
'--lsblk:`lsblk` command parser'
'--lsmod:`lsmod` command parser'
'--lsof:`lsof` command parser'
@@ -187,12 +217,20 @@ _jc() {
'--mount:`mount` command parser'
'--mpstat:`mpstat` command parser'
'--mpstat-s:`mpstat` command streaming parser'
'--needrestart:`needrestart -b` command parser'
'--netstat:`netstat` command parser'
'--net-localgroup:`net localgroup` command parser'
'--net-user:`net user` command parser'
'--nmcli:`nmcli` command parser'
'--nsd-control:`nsd-control` command parser'
'--ntpq:`ntpq -p` command parser'
'--openvpn:openvpn-status.log file parser'
'--os-prober:`os-prober` command parser'
'--os-release:`/etc/os-release` file parser'
'--pacman:`pacman` command parser'
'--passwd:`/etc/passwd` file parser'
'--path:POSIX path string parser'
'--path-list:POSIX path list string parser'
'--pci-ids:`pci.ids` file parser'
'--pgpass:PostgreSQL password file parser'
'--pidstat:`pidstat -H` command parser'
@@ -201,10 +239,13 @@ _jc() {
'--ping-s:`ping` and `ping6` command streaming parser'
'--pip-list:`pip list` command parser'
'--pip-show:`pip show` command parser'
'--pkg-index-apk:Alpine Linux Package Index file parser'
'--pkg-index-deb:Debian Package Index file parser'
'--plist:PLIST file parser'
'--postconf:`postconf -M` command parser'
'--proc:`/proc/` file parser'
'--proc-buddyinfo:`/proc/buddyinfo` file parser'
'--proc-cmdline:`/proc/cmdline` file parser'
'--proc-consoles:`/proc/consoles` file parser'
'--proc-cpuinfo:`/proc/cpuinfo` file parser'
'--proc-crypto:`/proc/crypto` file parser'
@@ -257,6 +298,7 @@ _jc() {
'--ps:`ps` command parser'
'--resolve-conf:`/etc/resolve.conf` file parser'
'--route:`route` command parser'
'--route-print:`route print` command parser'
'--rpm-qi:`rpm -qi` command parser'
'--rsync:`rsync` command parser'
'--rsync-s:`rsync` command streaming parser'
@@ -269,6 +311,7 @@ _jc() {
'--sshd-conf:`sshd` config file and `sshd -T` command parser'
'--stat:`stat` command parser'
'--stat-s:`stat` command streaming parser'
'--swapon:`swapon` command parser'
'--sysctl:`sysctl` command parser'
'--syslog:Syslog RFC 5424 string parser'
'--syslog-s:Syslog RFC 5424 string streaming parser'
@@ -287,6 +330,8 @@ _jc() {
'--top-s:`top -b` command streaming parser'
'--tracepath:`tracepath` and `tracepath6` command parser'
'--traceroute:`traceroute` and `traceroute6` command parser'
'--traceroute-s:`traceroute` and `traceroute6` command streaming parser'
'--tune2fs:`tune2fs -l` command parser'
'--udevadm:`udevadm info` command parser'
'--ufw:`ufw status` command parser'
'--ufw-appinfo:`ufw app info [application]` command parser'
@@ -302,8 +347,10 @@ _jc() {
'--vmstat-s:`vmstat` command streaming parser'
'--w:`w` command parser'
'--wc:`wc` command parser'
'--wg-show:`wg show` command parser'
'--who:`who` command parser'
'--x509-cert:X.509 PEM and DER certificate file parser'
'--x509-crl:X.509 PEM and DER certificate revocation list file parser'
'--x509-csr:X.509 PEM and DER certificate request file parser'
'--xml:XML file parser'
'--xrandr:`xrandr` command parser'
@@ -312,7 +359,7 @@ _jc() {
'--zpool-iostat:`zpool iostat` command parser'
'--zpool-status:`zpool status` command parser'
)
jc_options=(--force-color -C --debug -d --monochrome -m --meta-out -M --pretty -p --quiet -q --raw -r --unbuffer -u --yaml-out -y)
jc_options=(--force-color -C --debug -d --monochrome -m --meta-out -M --pretty -p --quiet -q --raw -r --slurp -s --unbuffer -u --yaml-out -y)
jc_options_describe=(
'--force-color:force color output (overrides -m)'
'-C:force color output (overrides -m)'
@@ -328,6 +375,8 @@ _jc() {
'-q:suppress warnings (double to ignore streaming errors)'
'--raw:raw output'
'-r:raw output'
'--slurp:slurp multiple lines into an array'
'-s:slurp multiple lines into an array'
'--unbuffer:unbuffer output'
'-u:unbuffer output'
'--yaml-out:YAML output'

86
doc2md.py Executable file
View File

@@ -0,0 +1,86 @@
#!/usr/bin/env python3
"""
Convert parser doc string to markdown
"""
import sys
import importlib
from inspect import isfunction, signature, cleandoc
import yapf # type: ignore
ignore_lib_functions = [
'cast',
'wraps',
'lru_cache',
'namedtuple'
]
mod_path = sys.argv[1]
mod_name = mod_path.split('.')[-1]
module = importlib.import_module(f'{mod_path}')
######## HEADER ########
header = f'''[Home](https://kellyjonbrazil.github.io/jc/)
<a id="{mod_path}"></a>
# {mod_path}
'''
summary = module.__doc__ or ''
functions = []
for attribute in dir(module):
if isfunction(getattr(module, attribute)) \
and not getattr(module, attribute).__name__.startswith('_'):
if 'jc.parsers.' in mod_path and not 'universal' in mod_path:
if attribute == 'parse':
functions.append(attribute)
else:
if not attribute in ignore_lib_functions:
functions.append(attribute)
######## TABLE OF CONTENTS ########
toc = f'## Table of Contents\n\n* [{mod_path}](#{mod_path})\n'
for api in functions:
toc = f'{toc} * [{api}](#{mod_path}.{api})\n'
######## API DOCS ########
api_docs = ''
for api in functions:
api_function = getattr(module, api)
this_header = f'<a id="{mod_path}.{api}"></a>\n\n### {api}\n'
this_sig = str(signature(api_function))
formatted_sig = yapf.yapf_api.FormatCode(f'def {api_function.__name__}{this_sig}:\n pass' )
formatted_sig = formatted_sig[0].split(':\n pass')[0]
this_name_and_sig = f'{this_header}\n```python\n{formatted_sig}\n```'
this_doc = cleandoc(api_function.__doc__)
api_docs = api_docs + this_name_and_sig + '\n\n' + this_doc + '\n\n'
######## FOOTER ########
footer = ''
if 'jc.parsers.' in mod_path and not 'universal' in mod_path:
footer = '### Parser Information\n'
comp = ', '.join(module.info.compatible)
ver = module.info.version
author = module.info.author
author_email = module.info.author_email
slurpable = 'slurpable' in module.info.tags
footer = footer + f'Compatibility: {comp}\n\n'
footer = footer + f'Source: [`jc/parsers/{mod_name}.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/{mod_name}.py)\n\n'
if slurpable:
footer = footer + 'This parser can be used with the `--slurp` command-line option.\n\n'
footer = footer + f'Version {ver} by {author} ({author_email})'
final_doc = ''
if 'jc.parsers.' in mod_path and not 'universal' in mod_path:
final_doc = header + '\n' + summary + '\n' + api_docs + footer
elif mod_path == 'jc':
final_doc = header + '\n' + summary
else:
final_doc = header + '\n' + toc + '\n' + summary + '\n\n' + api_docs
print(final_doc)

102
docgen.sh
View File

@@ -1,107 +1,32 @@
#!/bin/bash
# Generate docs.md
# requires pydoc-markdown 4.6.1
# Generate markdown document files (*.md)
# Requires the yapf python library
# use ./docgen all to generate all docs
readme_config=$(cat <<'EOF'
{
"processors": [
{
"type": "filter"
},
{
"type": "pydocmd"
}
],
"renderer": {
"type": "markdown",
"header_level_by_type": {
"Module": 1,
"Class": 3,
"Method": 3,
"Function": 3,
"Variable": 3
}
}
}
EOF
)
toc_config=$(cat <<'EOF'
{
"processors": [
{
"type": "filter"
},
{
"type": "pydocmd"
}
],
"renderer": {
"type": "markdown",
"render_toc": true,
"header_level_by_type": {
"Module": 1,
"Class": 3,
"Method": 3,
"Function": 3,
"Variable": 3
}
}
}
EOF
)
parser_config=$(cat <<'EOF'
{
"processors": [
{
"type": "filter",
"expression": "not name == \"info\" and not name.startswith(\"_\") and default()"
},
{
"type": "pydocmd"
}
],
"renderer": {
"type": "markdown",
"header_level_by_type": {
"Module": 1,
"Class": 3,
"Method": 3,
"Function": 3,
"Variable": 3
}
}
}
EOF
)
cd jc
(
echo Building docs for: package
pydoc-markdown -m jc "${readme_config}" > ../docs/readme.md; echo "+++ package docs complete"
../doc2md.py jc > ../docs/readme.md && echo "+++ package docs complete" || echo "*** PACKAGE DOCS FAILED ***"
) &
(
echo Building docs for: lib
pydoc-markdown -m jc.lib "${toc_config}" > ../docs/lib.md; echo "+++ lib docs complete"
../doc2md.py jc.lib > ../docs/lib.md && echo "+++ lib docs complete" || echo "*** LIB DOCS FAILED ***"
) &
(
echo Building docs for: utils
pydoc-markdown -m jc.utils "${toc_config}" > ../docs/utils.md; echo "+++ utils docs complete"
../doc2md.py jc.utils > ../docs/utils.md && echo "+++ utils docs complete" || echo "*** UTILS DOCS FAILED ***"
) &
(
echo Building docs for: streaming
pydoc-markdown -m jc.streaming "${toc_config}" > ../docs/streaming.md; echo "+++ streaming docs complete"
../doc2md.py jc.streaming > ../docs/streaming.md && echo "+++ streaming docs complete" || echo "*** STREAMING DOCS FAILED ***"
) &
(
echo Building docs for: universal parser
pydoc-markdown -m jc.parsers.universal "${toc_config}" > ../docs/parsers/universal.md; echo "+++ universal parser docs complete"
../doc2md.py jc.parsers.universal > ../docs/parsers/universal.md && echo "+++ universal parser docs complete" || echo "*** UNIVERSAL PARSER DOCS FAILED ***"
) &
# a bit of inception here... jc is being used to help
@@ -119,19 +44,8 @@ for parser in "${parsers[@]}"; do
parser_name=$(jq -r '.name' <<< "$parser")
{
if [[ $1 == "all" ]] || ! git diff --quiet --exit-code HEAD~5 -- "parsers/${parser_name}.py"; then
compatible=$(jq -r '.compatible | join(", ")' <<< "$parser")
version=$(jq -r '.version' <<< "$parser")
author=$(jq -r '.author' <<< "$parser")
author_email=$(jq -r '.author_email' <<< "$parser")
echo "Building docs for: ${parser_name}"
echo "[Home](https://kellyjonbrazil.github.io/jc/)" > ../docs/parsers/"${parser_name}".md
pydoc-markdown -m jc.parsers."${parser_name}" "${parser_config}" >> ../docs/parsers/"${parser_name}".md
echo "### Parser Information" >> ../docs/parsers/"${parser_name}".md
echo "Compatibility: ${compatible}" >> ../docs/parsers/"${parser_name}".md
echo >> ../docs/parsers/"${parser_name}".md
echo "Version ${version} by ${author} (${author_email})" >> ../docs/parsers/"${parser_name}".md
echo "+++ ${parser_name} docs complete"
../doc2md.py jc.parsers."${parser_name}" > ../docs/parsers/"${parser_name}".md && echo "+++ ${parser_name} docs complete" || echo "*** ${parser_name} DOCS FAILED ***"
fi
} &
done

View File

@@ -1,34 +1,106 @@
# Table of Contents
* [jc.lib](#jc.lib)
* [parse](#jc.lib.parse)
* [parser\_mod\_list](#jc.lib.parser_mod_list)
* [plugin\_parser\_mod\_list](#jc.lib.plugin_parser_mod_list)
* [standard\_parser\_mod\_list](#jc.lib.standard_parser_mod_list)
* [streaming\_parser\_mod\_list](#jc.lib.streaming_parser_mod_list)
* [parser\_info](#jc.lib.parser_info)
* [all\_parser\_info](#jc.lib.all_parser_info)
* [get\_help](#jc.lib.get_help)
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.lib"></a>
# jc.lib
## Table of Contents
* [jc.lib](#jc.lib)
* [all_parser_info](#jc.lib.all_parser_info)
* [get_help](#jc.lib.get_help)
* [get_parser](#jc.lib.get_parser)
* [parse](#jc.lib.parse)
* [parser_info](#jc.lib.parser_info)
* [parser_mod_list](#jc.lib.parser_mod_list)
* [plugin_parser_mod_list](#jc.lib.plugin_parser_mod_list)
* [slurpable_parser_mod_list](#jc.lib.slurpable_parser_mod_list)
* [standard_parser_mod_list](#jc.lib.standard_parser_mod_list)
* [streaming_parser_mod_list](#jc.lib.streaming_parser_mod_list)
jc - JSON Convert lib module
<a id="jc.lib.all_parser_info"></a>
### all_parser_info
```python
def all_parser_info(
documentation: bool = False,
show_hidden: bool = False,
show_deprecated: bool = False) -> List[jc.jc_types.ParserInfoType]
```
Returns a list of dictionaries that includes metadata for all parser
modules. By default only non-hidden, non-deprecated parsers are
returned.
Parameters:
documentation: (boolean) include parser docstrings if `True`
show_hidden: (boolean) also show parsers marked as hidden
in their info metadata.
show_deprecated: (boolean) also show parsers marked as
deprecated in their info metadata.
<a id="jc.lib.get_help"></a>
### get_help
```python
def get_help(parser_mod_name: Union[str, module]) -> None
```
Show help screen for the selected parser.
This function will accept **module_name**, **cli-name**, and
**--argument-name** variants of the module name string as well as a
parser module object.
<a id="jc.lib.get_parser"></a>
### get_parser
```python
def get_parser(parser_mod_name: Union[str, module]) -> module
```
Return the parser module object and check that the module is a valid
parser module.
Parameters:
parser_mod_name: (string or Name of the parser module. This
Module) function will accept module_name,
cli-name, and --argument-name
variants of the module name.
If a Module is given and the Module
is a valid parser Module, then the
same Module is returned.
Returns:
Module: the parser Module object
Raises:
ModuleNotFoundError: If the Module is not found or is not a valid
parser Module, then a ModuleNotFoundError
exception is raised.
<a id="jc.lib.parse"></a>
### parse
```python
def parse(
parser_mod_name: Union[str, ModuleType],
parser_mod_name: Union[str, module],
data: Union[str, bytes, Iterable[str]],
quiet: bool = False,
raw: bool = False,
ignore_exceptions: Optional[bool] = None,
**kwargs
) -> Union[JSONDictType, List[JSONDictType], Iterator[JSONDictType]]
) -> Union[Dict[str, Any], List[Dict[str, Any]], Iterator[Dict[str, Any]]]
```
Parse the data (string or bytes) using the supplied parser (string or
@@ -59,15 +131,25 @@ To get a list of available parser module names, use `parser_mod_list()`.
Alternatively, a parser module object can be supplied:
>>> import jc
>>> import jc.parsers.date as jc_date
>>> jc_date = jc.get_parser('date')
>>> date_obj = jc.parse(jc_date, 'Tue Jan 18 10:23:07 PST 2022')
>>> print(f'The year is: {date_obj["year"]}')
The year is: 2022
You can also use the lower-level parser modules directly:
You can also use the parser modules directly via `get_parser()`:
>>> import jc
>>> jc_date = jc.get_parser('date')
>>> date_obj = jc_date.parse('Tue Jan 18 10:23:07 PST 2022')
>>> print(f'The year is: {date_obj["year"]}')
The year is: 2022
Finally, you can access the low-level parser modules manually:
>>> import jc.parsers.date
>>> jc.parsers.date.parse('Tue Jan 18 10:23:07 PST 2022')
>>> date_obj = jc.parsers.date.parse('Tue Jan 18 10:23:07 PST 2022')
>>> print(f'The year is: {date_obj["year"]}')
The year is: 2022
Though, accessing plugin parsers directly is a bit more cumbersome, so
this higher-level API is recommended. Here is how you can access plugin
@@ -90,17 +172,17 @@ Parameters:
variants of the module name.
A Module object can also be passed
directly or via _get_parser()
directly or via `get_parser()`
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
raw: (boolean) output preprocessed JSON if `True`
quiet: (boolean) suppress warning messages if True
quiet: (boolean) suppress warning messages if `True`
ignore_exceptions: (boolean) ignore parsing exceptions if True
ignore_exceptions: (boolean) ignore parsing exceptions if `True`
(streaming parsers only)
Returns:
@@ -108,61 +190,13 @@ Returns:
Standard Parsers: Dictionary or List of Dictionaries
Streaming Parsers: Generator Object containing Dictionaries
<a id="jc.lib.parser_mod_list"></a>
### parser\_mod\_list
```python
def parser_mod_list(show_hidden: bool = False,
show_deprecated: bool = False) -> List[str]
```
Returns a list of all available parser module names.
<a id="jc.lib.plugin_parser_mod_list"></a>
### plugin\_parser\_mod\_list
```python
def plugin_parser_mod_list(show_hidden: bool = False,
show_deprecated: bool = False) -> List[str]
```
Returns a list of plugin parser module names. This function is a
subset of `parser_mod_list()`.
<a id="jc.lib.standard_parser_mod_list"></a>
### standard\_parser\_mod\_list
```python
def standard_parser_mod_list(show_hidden: bool = False,
show_deprecated: bool = False) -> List[str]
```
Returns a list of standard parser module names. This function is a
subset of `parser_mod_list()` and does not contain any streaming
parsers.
<a id="jc.lib.streaming_parser_mod_list"></a>
### streaming\_parser\_mod\_list
```python
def streaming_parser_mod_list(show_hidden: bool = False,
show_deprecated: bool = False) -> List[str]
```
Returns a list of streaming parser module names. This function is a
subset of `parser_mod_list()`.
<a id="jc.lib.parser_info"></a>
### parser\_info
### parser_info
```python
def parser_info(parser_mod_name: Union[str, ModuleType],
documentation: bool = False) -> ParserInfoType
def parser_info(parser_mod_name: Union[str, module],
documentation: bool = False) -> jc.jc_types.ParserInfoType
```
Returns a dictionary that includes the parser module metadata.
@@ -175,41 +209,66 @@ Parameters:
variants of the module name as well
as a parser module object.
documentation: (boolean) include parser docstring if True
documentation: (boolean) include parser docstring if `True`
<a id="jc.lib.all_parser_info"></a>
<a id="jc.lib.parser_mod_list"></a>
### all\_parser\_info
### parser_mod_list
```python
def all_parser_info(documentation: bool = False,
show_hidden: bool = False,
show_deprecated: bool = False) -> List[ParserInfoType]
def parser_mod_list(show_hidden: bool = False,
show_deprecated: bool = False) -> List[str]
```
Returns a list of dictionaries that includes metadata for all parser
modules. By default only non-hidden, non-deprecated parsers are
returned.
Returns a list of all available parser module names.
Parameters:
<a id="jc.lib.plugin_parser_mod_list"></a>
documentation: (boolean) include parser docstrings if True
show_hidden: (boolean) also show parsers marked as hidden
in their info metadata.
show_deprecated: (boolean) also show parsers marked as
deprecated in their info metadata.
<a id="jc.lib.get_help"></a>
### get\_help
### plugin_parser_mod_list
```python
def get_help(parser_mod_name: Union[str, ModuleType]) -> None
def plugin_parser_mod_list(show_hidden: bool = False,
show_deprecated: bool = False) -> List[str]
```
Show help screen for the selected parser.
Returns a list of plugin parser module names. This function is a
subset of `parser_mod_list()`.
<a id="jc.lib.slurpable_parser_mod_list"></a>
### slurpable_parser_mod_list
```python
def slurpable_parser_mod_list(show_hidden: bool = False,
show_deprecated: bool = False) -> List[str]
```
Returns a list of slurpable parser module names. This function is a
subset of `parser_mod_list()`.
<a id="jc.lib.standard_parser_mod_list"></a>
### standard_parser_mod_list
```python
def standard_parser_mod_list(show_hidden: bool = False,
show_deprecated: bool = False) -> List[str]
```
Returns a list of standard parser module names. This function is a
subset of `parser_mod_list()` and does not contain any streaming
parsers.
<a id="jc.lib.streaming_parser_mod_list"></a>
### streaming_parser_mod_list
```python
def streaming_parser_mod_list(show_hidden: bool = False,
show_deprecated: bool = False) -> List[str]
```
Returns a list of streaming parser module names. This function is a
subset of `parser_mod_list()`.
This function will accept **module_name**, **cli-name**, and
**--argument-name** variants of the module name string as well as a
parser module object.

View File

@@ -250,4 +250,6 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/acpi.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/acpi.py)
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -103,4 +103,6 @@ Returns:
### Parser Information
Compatibility: darwin
Source: [`jc/parsers/airport.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/airport.py)
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,7 +1,7 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.airport_s"></a>
# jc.parsers.airport\_s
# jc.parsers.airport_s
jc - JSON Convert `airport -s` command output parser
@@ -131,4 +131,6 @@ Returns:
### Parser Information
Compatibility: darwin
Source: [`jc/parsers/airport_s.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/airport_s.py)
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)

117
docs/parsers/amixer.md Normal file
View File

@@ -0,0 +1,117 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.amixer"></a>
# jc.parsers.amixer
jc - JSON Convert `amixer sget` command output parser
Usage (cli):
$ amixer sget <control_name> | jc --amixer
$ amixer sget Master | jc --amixer
$ amixer sget Capture | jc --amixer
$ amixer sget Speakers | jc --amixer
Usage (module):
import jc
result = jc.parse('amixer', <amixer_sget_command_output>)
Schema:
{
"control_name": string,
"capabilities": [
string
],
"playback_channels": [
string
],
"limits": {
"playback_min": integer,
"playback_max": integer
},
"mono": {
"playback_value": integer,
"percentage": integer,
"db": float,
"status": boolean
}
}
Examples:
$ amixer sget Master | jc --amixer -p
{
"control_name": "Capture",
"capabilities": [
"cvolume",
"cswitch"
],
"playback_channels": [],
"limits": {
"playback_min": 0,
"playback_max": 63
},
"front_left": {
"playback_value": 63,
"percentage": 100,
"db": 30.0,
"status": true
},
"front_right": {
"playback_value": 63,
"percentage": 100,
"db": 30.0,
"status": true
}
}
$ amixer sget Master | jc --amixer -p -r
{
"control_name": "Master",
"capabilities": [
"pvolume",
"pvolume-joined",
"pswitch",
"pswitch-joined"
],
"playback_channels": [
"Mono"
],
"limits": {
"playback_min": "0",
"playback_max": "87"
},
"mono": {
"playback_value": "87",
"percentage": "100%",
"db": "0.00db",
"status": "on"
}
}
<a id="jc.parsers.amixer.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
Source: [`jc/parsers/amixer.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/amixer.py)
Version 1.0 by Eden Refael (edenraf@hotmail.com)

View File

@@ -0,0 +1,180 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.apt_cache_show"></a>
# jc.parsers.apt_cache_show
jc - JSON Convert `apt-cache show` command parser
Usage (cli):
$ apt-cache show | jc --apt-cache-show
Usage (module):
import jc
result = jc.parse('apt_cache_show', apt_cache_show_output)
Schema:
[
{
"package": string,
"version": string,
"installed_size": integer,
"maintainer": string,
"architecture": string,
"depends": [
string
],
"pre_depends": [
string
],
"recommends": [
string
],
"suggests": [
string
],
"conflicts": [
string
],
"breaks": [
string
],
"description_md5": string,
"multi_arch": string,
"homepage": string,
"section": string,
"priority": string,
"filename": string,
"size": integer,
"sha256": string,
"description": string
}
]
Examples:
$ apt-cache show | jc --apt-cache-show -p
[
{
"package": "systemd",
"version": "247.3-6~bpo10+1",
"installed_size": 16121,
"maintainer": "Debian systemd Maintainers <pkg-systemd-maintaine..",
"architecture": "amd64",
"depends": [
"libacl1 (>= 2.2.23)",
"libapparmor1 (>= 2.13)",
"libaudit1 (>= 1:2.2.1)",
"libcap2 (>= 1:2.10)",
"libcryptsetup12 (>= 2:2.0.1)",
"libgnutls30 (>= 3.6.6)",
"libgpg-error0 (>= 1.14)",
"libip4tc0 (>= 1.6.0+snapshot20161117)",
"libkmod2 (>= 5~)",
"liblz4-1 (>= 0.0~r130)",
"libmount1 (>= 2.30)",
"libpam0g (>= 0.99.7.1)",
"libseccomp2 (>= 2.3.1)",
"libsystemd0 (= 247.3-6~bpo10+1)",
"systemd-timesyncd | time-daemon",
"util-linux (>= 2.27.1)",
"mount (>= 2.26)",
"adduser"
],
"pre_depends": [
"libblkid1 (>= 2.24)",
"libc6 (>= 2.28)",
"libgcrypt20 (>= 1.8.0)",
"liblz4-1 (>= 0.0~r122)",
"liblzma5 (>= 5.1.1alpha+20120614)",
"libselinux1 (>= 2.1.9)",
"libzstd1 (>= 1.4.0)"
],
"recommends": [
"dbus"
],
"suggests": [
"systemd-container",
"policykit-1"
],
"conflicts": [
"consolekit",
"libpam-ck-connector"
],
"breaks": [
"python-dbusmock (<< 0.18)",
"python3-dbusmock (<< 0.18)",
"resolvconf (<< 1.83~)",
"systemd-shim (<< 10-4~)",
"udev (<< 247~)"
],
"description_md5": "19399579cbc0c47a303288bf15eadcd4",
"multi_arch": "foreign",
"homepage": "https://www.freedesktop.org/wiki/Software/systemd",
"section": "admin",
"priority": "important",
"filename": "pool/main/s/systemd/systemd_247.3-6~bpo10+1_amd64.deb",
"size": 4382056,
"sha256": "2035450655ad02faa0f75dc952128b503e51df5795c67273c0f6...",
"description": "system and service manager systemd is a system..."
},
...
]
$ apt-cache show | jc --apt-cache-show -p -r
[
{
"package": "systemd",
"version": "247.3-6~bpo10+1",
"installed_size": "16121",
"maintainer": "Debian systemd Maintainers <pkg-systemd-maintain...",
"architecture": "amd64",
"depends": "libacl1 (>= 2.2.23), libapparmor1 (>= 2.13), libaud...",
"pre_depends": "libblkid1 (>= 2.24), libc6 (>= 2.28), libgcrypt...",
"recommends": "dbus",
"suggests": "systemd-container, policykit-1",
"conflicts": "consolekit, libpam-ck-connector",
"breaks": "python-dbusmock (<< 0.18), python3-dbusmock (<< 0.18...",
"description_md5": "19399579cbc0c47a303288bf15eadcd4",
"multi_arch": "foreign",
"homepage": "https://www.freedesktop.org/wiki/Software/systemd",
"section": "admin",
"priority": "important",
"filename": "pool/main/s/systemd/systemd_247.3-6~bpo10+1_amd64.deb",
"size": "4382056",
"sha256": "2035450655ad02faa0f75dc952128b503e51df5795c67273c0f6...",
"description": "system and service manager systemd is a system..."
},
...
]
<a id="jc.parsers.apt_cache_show.parse"></a>
### parse
```python
def parse(data: str,
raw: bool = False,
quiet: bool = False) -> List[Dict[str, Any]]
```
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
Source: [`jc/parsers/apt_cache_show.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/apt_cache_show.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

201
docs/parsers/apt_get_sqq.md Normal file
View File

@@ -0,0 +1,201 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.apt_get_sqq"></a>
# jc.parsers.apt_get_sqq
jc - JSON Convert `apt-get -sqq` command output parser
Requires the `-sqq` options in `apt-get`.
Usage (cli):
$ apt-get -sqq upgrade | jc --apt-get-sqq
or
$ jc apt-get -sqq full-upgrade
Usage (module):
import jc
result = jc.parse('apt_get_sqq', apt_get_sqq_command_output)
Schema:
[
{
"operation": string, # configure, remove, or unpack
"package": string,
"broken": string/null,
"proposed_pkg_ver": string,
"existing_pkg_ver": string/null,
"architecture": string
}
]
Examples:
$ apt-get -sqq upgrade | jc --apt-get-sqq -p
[
{
"operation": "unpack",
"package": "dpkg",
"broken": "1.19.7",
"proposed_pkg_ver": "1.19.8 Debian:10.13/oldstable",
"existing_pkg_ver": "Debian-Security:10/oldstable",
"architecture": "amd64"
},
{
"operation": "unpack",
"package": "dpkg",
"broken": null,
"proposed_pkg_ver": "1.19.8 Debian:10.13/oldstable",
"existing_pkg_ver": "Debian-Security:10/oldstable",
"architecture": "amd64"
},
{
"operation": "configure",
"package": "dpkg",
"broken": "1.19.7",
"proposed_pkg_ver": "1.19.8 Debian:10.13/oldstable",
"existing_pkg_ver": "Debian-Security:10/oldstable",
"architecture": "amd64"
},
{
"operation": "remove",
"package": "dpkg",
"broken": "1.19.7",
"proposed_pkg_ver": "1.19.8 Debian:10.13/oldstable",
"existing_pkg_ver": "Debian-Security:10/oldstable",
"architecture": "amd64"
},
{
"operation": "unpack",
"package": "base-files",
"broken": "10.3+deb10u4",
"proposed_pkg_ver": "10.3+deb10u13 Debian:10.13/oldstable",
"existing_pkg_ver": null,
"architecture": "amd64"
},
{
"operation": "configure",
"package": "base-files",
"broken": null,
"proposed_pkg_ver": "10.3+deb10u13 Debian:10.13/oldstable",
"existing_pkg_ver": null,
"architecture": "amd64"
},
{
"operation": "unpack",
"package": "dpkg",
"broken": "1.19.7",
"proposed_pkg_ver": "1.19.8 Debian:10.13/oldstable",
"existing_pkg_ver": "Debian-Security:10/oldstable",
"architecture": "amd64"
},
{
"operation": "configure",
"package": "dpkg",
"broken": null,
"proposed_pkg_ver": "1.19.8 Debian:10.13/oldstable",
"existing_pkg_ver": "Debian-Security:10/oldstable",
"architecture": "amd64"
}
]
$ apt-get -sqq upgrade | jc --apt-get-sqq -p -r
[
{
"operation": "Inst",
"package": "dpkg",
"broken": "1.19.7",
"proposed_pkg_ver": "1.19.8 Debian:10.13/oldstable",
"existing_pkg_ver": "Debian-Security:10/oldstable",
"architecture": "amd64"
},
{
"operation": "Inst",
"package": "dpkg",
"broken": null,
"proposed_pkg_ver": "1.19.8 Debian:10.13/oldstable",
"existing_pkg_ver": "Debian-Security:10/oldstable",
"architecture": "amd64"
},
{
"operation": "Conf",
"package": "dpkg",
"broken": "1.19.7",
"proposed_pkg_ver": "1.19.8 Debian:10.13/oldstable",
"existing_pkg_ver": "Debian-Security:10/oldstable",
"architecture": "amd64"
},
{
"operation": "Remv",
"package": "dpkg",
"broken": "1.19.7",
"proposed_pkg_ver": "1.19.8 Debian:10.13/oldstable",
"existing_pkg_ver": "Debian-Security:10/oldstable",
"architecture": "amd64"
},
{
"operation": "Inst",
"package": "base-files",
"broken": "10.3+deb10u4",
"proposed_pkg_ver": "10.3+deb10u13 Debian:10.13/oldstable",
"existing_pkg_ver": null,
"architecture": "amd64"
},
{
"operation": "Conf",
"package": "base-files",
"broken": null,
"proposed_pkg_ver": "10.3+deb10u13 Debian:10.13/oldstable",
"existing_pkg_ver": null,
"architecture": "amd64"
},
{
"operation": "Inst",
"package": "dpkg",
"broken": "1.19.7",
"proposed_pkg_ver": "1.19.8 Debian:10.13/oldstable",
"existing_pkg_ver": "Debian-Security:10/oldstable",
"architecture": "amd64"
},
{
"operation": "Conf",
"package": "dpkg",
"broken": null,
"proposed_pkg_ver": "1.19.8 Debian:10.13/oldstable",
"existing_pkg_ver": "Debian-Security:10/oldstable",
"architecture": "amd64"
}
]
<a id="jc.parsers.apt_get_sqq.parse"></a>
### parse
```python
def parse(data: str,
raw: bool = False,
quiet: bool = False) -> List[Dict[str, Any]]
```
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
Source: [`jc/parsers/apt_get_sqq.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/apt_get_sqq.py)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -140,4 +140,6 @@ Returns:
### Parser Information
Compatibility: linux, aix, freebsd, darwin
Source: [`jc/parsers/arp.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/arp.py)
Version 1.12 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -144,4 +144,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/asciitable.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/asciitable.py)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,7 +1,7 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.asciitable_m"></a>
# jc.parsers.asciitable\_m
# jc.parsers.asciitable_m
jc - JSON Convert `asciitable-m` parser
@@ -129,4 +129,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/asciitable_m.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/asciitable_m.py)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -143,4 +143,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/blkid.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/blkid.py)
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -33,6 +33,8 @@ a controller and a device but there might be fields corresponding to one entity.
Controller:
[
{
"manufacturer": string,
"version": string,
"name": string,
"is_default": boolean,
"is_public": boolean,
@@ -67,10 +69,12 @@ a controller and a device but there might be fields corresponding to one entity.
"blocked": string,
"connected": string,
"legacy_pairing": string,
"cable_pairing": string,
"rssi": int,
"txpower": int,
"uuids": array,
"modalias": string
"modalias": string,
"battery_percentage": int
}
]
@@ -101,7 +105,8 @@ Examples:
"Headset HS (00001831-0000-1000-8000-00805f9b34fb)"
],
"rssi": -52,
"txpower": 4
"txpower": 4,
"battery_percentage": 70
}
]
@@ -112,7 +117,7 @@ Examples:
```python
def parse(data: str,
raw: bool = False,
quiet: bool = False) -> List[JSONDictType]
quiet: bool = False) -> List[Dict[str, Any]]
```
Main text parsing function
@@ -130,4 +135,6 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.1 by Jake Ob (iakopap at gmail.com)
Source: [`jc/parsers/bluetoothctl.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/bluetoothctl.py)
Version 1.5 by Jake Ob (iakopap at gmail.com)

View File

@@ -104,7 +104,7 @@ Examples:
```python
def parse(data: str,
raw: bool = False,
quiet: bool = False) -> List[JSONDictType]
quiet: bool = False) -> List[Dict[str, Any]]
```
Main text parsing function
@@ -122,4 +122,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/cbt.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/cbt.py)
Version 1.0 by Andreas Weiden (andreas.weiden@gmail.com)

View File

@@ -143,4 +143,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/cef.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/cef.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,7 +1,7 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.cef_s"></a>
# jc.parsers.cef\_s
# jc.parsers.cef_s
jc - JSON Convert CEF string output streaming parser
@@ -95,7 +95,6 @@ Examples:
### parse
```python
@add_jc_meta
def parse(data: Iterable[str],
raw: bool = False,
quiet: bool = False,
@@ -121,4 +120,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/cef_s.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/cef_s.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -140,7 +140,7 @@ Examples:
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False) -> JSONDictType
def parse(data: str, raw: bool = False, quiet: bool = False) -> Dict[str, Any]
```
Main text parsing function
@@ -158,4 +158,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/certbot.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/certbot.py)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -79,4 +79,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/chage.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/chage.py)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -77,4 +77,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Source: [`jc/parsers/cksum.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/cksum.py)
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -178,7 +178,7 @@ Examples:
```python
def parse(data: str,
raw: bool = False,
quiet: bool = False) -> List[JSONDictType]
quiet: bool = False) -> List[Dict[str, Any]]
```
Main text parsing function
@@ -196,4 +196,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/clf.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/clf.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,7 +1,7 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.clf_s"></a>
# jc.parsers.clf\_s
# jc.parsers.clf_s
jc - JSON Convert Common Log Format file streaming parser
@@ -88,11 +88,12 @@ Examples:
### parse
```python
@add_jc_meta
def parse(data: Iterable[str],
raw: bool = False,
quiet: bool = False,
ignore_exceptions: bool = False) -> StreamingOutputType
def parse(
data: Iterable[str],
raw: bool = False,
quiet: bool = False,
ignore_exceptions: bool = False
) -> Iterator[Union[Dict[str, Any], Tuple[BaseException, str]]]
```
Main text parsing generator function. Returns an iterable object.
@@ -114,4 +115,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/clf_s.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/clf_s.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -32,7 +32,6 @@ Schema:
],
"schedule": [
{
"occurrence" string,
"minute": [
string
],
@@ -196,4 +195,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, aix, freebsd
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/crontab.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/crontab.py)
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,7 +1,7 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.crontab_u"></a>
# jc.parsers.crontab\_u
# jc.parsers.crontab_u
jc - JSON Convert `crontab -l` command output and crontab
file parser
@@ -29,7 +29,6 @@ Schema:
],
"schedule": [
{
"occurrence" string,
"minute": [
string
],
@@ -193,4 +192,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, aix, freebsd
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/crontab_u.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/crontab_u.py)
Version 1.10 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -84,7 +84,7 @@ Examples:
```python
def parse(data: Union[str, bytes],
raw: bool = False,
quiet: bool = False) -> List[JSONDictType]
quiet: bool = False) -> List[Dict[str, Any]]
```
Main text parsing function
@@ -102,4 +102,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/csv.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/csv.py)
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,7 +1,7 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.csv_s"></a>
# jc.parsers.csv\_s
# jc.parsers.csv_s
jc - JSON Convert `csv` file streaming parser
@@ -64,7 +64,6 @@ Examples:
### parse
```python
@add_jc_meta
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
```
@@ -86,4 +85,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/csv_s.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/csv_s.py)
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

309
docs/parsers/curl_head.md Normal file
View File

@@ -0,0 +1,309 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.curl_head"></a>
# jc.parsers.curl_head
jc - JSON Convert `curl --head` command output parser
This parser converts standard and verbose `curl --head` output.
When converting verbose output from `curl` (to gather request headers, for
example) you will need to redirect STDERR to STDOUT with `2>&1`. The magic
syntax will not work in this case.
Usage (cli):
$ curl --head www.example.com | jc --curl-head
$ curl -Ivs www.example.com 2>&1 | jc --curl-head
or
$ jc curl --head www.example.com
Usage (module):
import jc
result = jc.parse('curl_head', curl_head_command_output)
Schema:
[
{
"_type": string, # request or response
"_request_method": string,
"_request_uri": string,
"_request_version": string,
"_response_version": string,
"_response_status": integer,
"_response_reason": string or null,
"<header>": string,
# well-known headers:
"accept": [
string
],
"accept-ch": [
string
],
"accept-ch-lifetime": integer,
"accept-encoding": [
string
],
"accept-language": [
string
],
"accept-patch": [
string
],
"accept-post": [
string
],
"accept-ranges": [
string
],
"access-control-allow-headers": [
string
],
"access-control-allow-methods": [
string
],
"access-control-expose-headers": [
string
],
"access-control-max-age": integer,
"access-control-request-headers": [
string
],
"age": integer,
"allow": [
string
],
"alt-svc": [
string
],
"cache-control": [
string
],
"clear-site-data": [
string
],
"connection": [
string
],
"content-encoding": [
string
],
"content-dpr": integer,
"content-language": [
string
],
"content-length": integer,
"content-security-policy": [
string
],
"content-security-policy-report-only": [
string
],
"cookie": [
string
],
"critical-ch": [
string
],
"date": string,
"date_epoch_utc": integer,
"expect-ct": [
string
],
"expires": string,
"expires_epoch_utc": integer,
"device-memory": integer,
"downlink": integer,
"dpr": integer,
"forwarded": [
string
],
"if-match": [
string
],
"if-modified-since": string,
"if-modified-since_epoch_utc": integer,
"if-none-match": [
string
],
"if-range": string,
"if-range_epoch_utc": integer,
"if-unmodified-since": string,
"if-unmodified-since_epoch_utc": integer,
"im": [
string
],
"keep-alive": [
string
],
"large-allocation": integer,
"last-modified": string,
"last-modified_epoch_utc": integer,
"link": [
string
],
"max-forwards": integer,
"memento-datetime": string,
"memento-datetime_epoch_utc": integer,
"permissions-policy": [
string
],
"permissions-policy-report-only": [
string
],
"pragma": [
string
],
"proxy-authenticate": [
string
],
"reporting-endpoints": [
string
],
"retry-after": string,
"retry-after_epoch_utc": integer,
"rtt": integer,
"sec-ch-ua": [
string
],
"sec-ch-ua-full-version-list": [
string
],
"server": [
string
],
"server-timing": [
string
],
"set-cookie": [
string
],
"timing-allow-origin": [
string
],
"trailer": [
string
],
"transfer-encoding": [
string
],
"upgrade": [
string
],
"upgrade-insecure-requests": integer,
"vary": [
string
],
"via": [
string
],
"warning": [
string
],
"www-authenticate": [
string
],
"x-cache-hits": [
integer
],
"x-content-duration": float
}
]
Examples:
$ curl --head www.example.com | jc --curl-head -p
[
{
"_type": "response",
"_response_version": "HTTP/1.1",
"_response_status": 200,
"_response_reason": [
"OK"
],
"accept-ranges": [
"bytes"
],
"age": 241144,
"cache-control": [
"max-age=604800"
],
"content-type": "text/html; charset=UTF-8",
"date": "Sun, 04 Feb 2024 23:26:29 GMT",
"etag": "\"3147526947\"",
"expires": "Sun, 11 Feb 2024 23:26:29 GMT",
"last-modified": "Thu, 17 Oct 2019 07:18:26 GMT",
"server": [
"ECS (sac/2508)"
],
"x-cache": "HIT",
"content-length": 1256,
"date_epoch_utc": 1707089189,
"expires_epoch_utc": 1707693989,
"last-modified_epoch_utc": 1571296706
}
]
$ curl --head www.example.com | jc --curl-head -p -r
[
{
"_type": "response",
"_response_version": "HTTP/1.1",
"_response_status": 200,
"_response_reason": [
"OK"
],
"accept-ranges": [
"bytes"
],
"age": "225102",
"cache-control": [
"max-age=604800"
],
"content-type": "text/html; charset=UTF-8",
"date": "Sun, 04 Feb 2024 23:28:17 GMT",
"etag": "\"3147526947\"",
"expires": "Sun, 11 Feb 2024 23:28:17 GMT",
"last-modified": "Thu, 17 Oct 2019 07:18:26 GMT",
"server": [
"ECS (sac/2575)"
],
"x-cache": "HIT",
"content-length": "1256"
}
]
<a id="jc.parsers.curl_head.parse"></a>
### parse
```python
def parse(data: str,
raw: bool = False,
quiet: bool = False) -> List[Dict[str, Any]]
```
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
Source: [`jc/parsers/curl_head.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/curl_head.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -100,4 +100,8 @@ Returns:
### Parser Information
Compatibility: linux, darwin, freebsd
Version 2.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/date.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/date.py)
This parser can be used with the `--slurp` command-line option.
Version 2.6 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,7 +1,7 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.datetime_iso"></a>
# jc.parsers.datetime\_iso
# jc.parsers.datetime_iso
jc - JSON Convert ISO 8601 Datetime string parser
@@ -88,4 +88,8 @@ Returns:
### Parser Information
Compatibility: linux, aix, freebsd, darwin, win32, cygwin
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/datetime_iso.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/datetime_iso.py)
This parser can be used with the `--slurp` command-line option.
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -0,0 +1,107 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.debconf_show"></a>
# jc.parsers.debconf_show
jc - JSON Convert `debconf-show` command output parser
Usage (cli):
$ debconf-show onlyoffice-documentserver | jc --debconf-show
or
$ jc debconf-show onlyoffice-documentserver
Usage (module):
import jc
result = jc.parse('debconf_show', debconf_show_command_output)
Schema:
[
{
"asked": boolean,
"packagename": string,
"name": string,
"value": string
}
]
Examples:
$ debconf-show onlyoffice-documentserver | jc --debconf-show -p
[
{
"asked": true,
"packagename": "onlyoffice",
"name": "jwt_secret",
"value": "aL8ei2iereuzee7cuJ6Cahjah1ixee2ah"
},
{
"asked": false,
"packagename": "onlyoffice",
"name": "db_pwd",
"value": "(password omitted)"
},
{
"asked": true,
"packagename": "onlyoffice",
"name": "rabbitmq_pwd",
"value": "(password omitted)"
},
{
"asked": true,
"packagename": "onlyoffice",
"name": "db_port",
"value": "5432"
},
{
"asked": true,
"packagename": "onlyoffice",
"name": "db_user",
"value": "onlyoffice"
},
{
"asked": true,
"packagename": "onlyoffice",
"name": "rabbitmq_proto",
"value": "amqp"
},
{
"asked": true,
"packagename": "onlyoffice",
"name": "cluster_mode",
"value": "false"
}
]
<a id="jc.parsers.debconf_show.parse"></a>
### parse
```python
def parse(data: str,
raw: bool = False,
quiet: bool = False) -> List[Dict[str, Any]]
```
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
Source: [`jc/parsers/debconf_show.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/debconf_show.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -5,6 +5,8 @@
jc - JSON Convert `df` command output parser
Values are normalized to bytes when using `df -h`.
Usage (cli):
$ df | jc --df
@@ -23,7 +25,7 @@ Schema:
[
{
"filesystem": string,
"size": string,
"size": integer,
"1k_blocks": integer,
"512_blocks": integer,
"used": integer,
@@ -120,4 +122,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, freebsd
Version 1.11 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/df.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/df.py)
Version 2.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -346,4 +346,6 @@ Returns:
### Parser Information
Compatibility: linux, aix, freebsd, darwin, win32, cygwin
Source: [`jc/parsers/dig.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/dig.py)
Version 2.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -143,4 +143,6 @@ Returns:
### Parser Information
Compatibility: win32
Source: [`jc/parsers/dir.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/dir.py)
Version 1.6 by Rasheed Elsaleh (rasheed@rebelliondefense.com)

View File

@@ -148,4 +148,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/dmidecode.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/dmidecode.py)
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,7 +1,7 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.dpkg_l"></a>
# jc.parsers.dpkg\_l
# jc.parsers.dpkg_l
jc - JSON Convert `dpkg -l` command output parser
@@ -154,4 +154,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/dpkg_l.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/dpkg_l.py)
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -114,4 +114,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, aix, freebsd
Source: [`jc/parsers/du.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/du.py)
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)

104
docs/parsers/efibootmgr.md Normal file
View File

@@ -0,0 +1,104 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.efibootmgr"></a>
# jc.parsers.efibootmgr
jc - JSON Convert `efibootmgr` command output parser
The `-v` option is also supported.
Usage (cli):
$ sudo efibootmgr | jc --efibootmgr
$ sudo efibootmgr -v | jc --efibootmgr
or
$ sudo jc efibootmgr
Usage (module):
import jc
result = jc.parse('efibootmgr', efibootmgr_command_output)
Schema:
{
"boot_current": string,
"timeout_seconds": integer,
"boot_order": [
string
],
mirrored_percentage_above_4g: float,
mirror_memory_below_4gb: boolean,
"boot_options": [
{
"boot_option_reference": string,
"display_name": string,
"uefi_device_path": string,
"boot_option_enabled": boolean
}
]
}
Examples:
$ sudo efibootmgr -v | jc --efibootmgr --p
{
"boot_current": "0002",
"timeout_seconds": 0,
"boot_order": [
"0002",
"0000",
"0001"
],
"mirrored_percentage_above_4g": 0.0,
"mirror_memory_below_4gb": false,
"boot_options": [
{
"boot_option_reference": "Boot0000",
"display_name": "WARNADO",
"uefi_device_path": "HD(1,GPT,05b9944c-1c60-492b-a510-7bbedccdc...",
"boot_option_enabled": true
},
{
"boot_option_reference": "Boot0001",
"display_name": "Embedded NIC 1 Port 1 Partition 1",
"uefi_device_path": "VenHw(3a191845-5f86-4e78-8fce-c4cff59f9daa)",
"boot_option_enabled": true
},
{
"boot_option_reference": "Boot0002",
"display_name": "opensuse-secureboot",
"uefi_device_path": "HD(1,GPT,c5d4f69d-6fc2-48c7-acee-af3f30336...",
"boot_option_enabled": true
}
]
}
<a id="jc.parsers.efibootmgr.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False) -> Dict[str, Any]
```
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
Source: [`jc/parsers/efibootmgr.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/efibootmgr.py)
Version 1.0 by Yaofei Zheng (zyf26256@gmail.com, Yaofei.Zheng@dell.com)

View File

@@ -1,7 +1,7 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.email_address"></a>
# jc.parsers.email\_address
# jc.parsers.email_address
jc - JSON Convert Email Address string parser
@@ -64,4 +64,8 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/email_address.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/email_address.py)
This parser can be used with the `--slurp` command-line option.
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -90,10 +90,12 @@ Parameters:
Returns:
Dictionary of raw structured data or
List of Dictionaries of processed structured data
Dictionary of raw structured data or (default)
List of Dictionaries of processed structured data (raw)
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/env.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/env.py)
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

197
docs/parsers/ethtool.md Normal file
View File

@@ -0,0 +1,197 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.ethtool"></a>
# jc.parsers.ethtool
jc - JSON Convert `ethtool` command output parser
Supports standard `ethtool` output and the `--module-info` option.
Usage (cli):
$ ethtool <interface> | jc --ethtool
$ ethtool --module-info <interface> | jc --ethtool
or
$ jc ethtool <interface>
$ jc ethtool --module-info <interface>
Usage (module):
import jc
result = jc.parse('ethtool', ethtool_command_output)
Schema:
Note: many units fields are converted to integers and floats
when detected. Use raw output for the original string values.
{
"name": string,
"supported_ports": [
string
],
"supported_link_modes": [
string
],
"supported_pause_frame_use": string,
"supports_auto_negotiation": boolean,
"supported_fec_modes": [
string
],
"advertised_link_modes": [
string
],
"advertised_pause_frame_use": boolean,
"advertised_auto_negotiation": boolean,
"advertised_fec_modes": [
string
],
"speed": string,
"speed_bps": integer,
"duplex": string,
"auto_negotiation": boolean,
"port": string,
"phyad": string,
"mdi_x": string,
"transceiver": string,
"supports_wake_on": string,
"wake_on": string,
"current_message_level": [
string
],
"link_detected": boolean,
"identifier": string,
"extended_identifier": string,
"connector": string,
"transceiver_codes": string,
"transceiver_type": [
string
],
"encoding": string,
"br_nominal": string,
"rate_identifier": string,
"length_smf_km": string,
"length_smf": string,
"length_50um": string,
"length_62_5um": string,
"length_copper": string,
"length_om3": string,
"passive_cu_cmplnce": string,
"vendor_name": string,
"vendor_oui": string,
"vendor_pn": string,
"vendor_rev": string,
"option_values": string,
"br_margin_max": string,
"br_margin_min": string
}
Examples:
$ ethtool enp0s3 | jc --ethtool -p
{
"name": "enp0s3",
"supported_pause_frame_use": "No",
"supports_auto_negotiation": true,
"supported_fec_modes": "Not reported",
"advertised_pause_frame_use": false,
"advertised_auto_negotiation": true,
"advertised_fec_modes": "Not reported",
"speed": "1000Mb/s",
"duplex": "Full",
"port": "Twisted Pair",
"phyad": "0",
"transceiver": "internal",
"auto_negotiation": false,
"mdi_x": "off (auto)",
"supports_wake_on": "umbg",
"wake_on": "d",
"link_detected": true,
"supported_ports": [
"TP"
],
"supported_link_modes": [
"10baseT/Half",
"10baseT/Full",
"100baseT/Half",
"100baseT/Full",
"1000baseT/Full"
],
"advertised_link_modes": [
"10baseT/Half",
"10baseT/Full",
"100baseT/Half",
"100baseT/Full",
"1000baseT/Full"
],
"current_message_level": [
"0x00000007 (7)",
"drv probe link"
],
"speed_bps": 1000000000
}
$ ethtool --module-info enp0s3 | jc --ethtool -p
{
"identifier": "0x03 (SFP)",
"extended_identifier": "0x04 (GBIC/SFP defined by 2-wire interface ID)",
"connector": "0x21 (Copper pigtail)",
"transceiver_codes": "0x01 0x00 0x00 0x04 0x00 0x04 0x80 0xd5 0x00",
"transceiver_type": [
"Infiniband: 1X Copper Passive",
"Ethernet: 1000BASE-CX",
"Passive Cable",
"FC: Twin Axial Pair (TW)",
"FC: 1200 MBytes/sec",
"FC: 800 MBytes/sec",
"FC: 400 MBytes/sec",
"FC: 200 MBytes/sec",
"FC: 100 MBytes/sec"
],
"encoding": "0x00 (unspecified)",
"br_nominal": "10300MBd",
"rate_identifier": "0x00 (unspecified)",
"length_smf_km": "0km",
"length_smf": "0m",
"length_50um": "0m",
"length_62_5um": "0m",
"length_copper": "2m",
"length_om3": "0m",
"passive_cu_cmplnce": "0x01 (SFF-8431 appendix E) [SFF-8472 rev10.4 only]",
"vendor_name": "UbiquitiNetworks",
"vendor_oui": "00:40:20",
"vendor_pn": "UDC-2",
"vendor_rev": "",
"option_values": "0x00 0x00",
"br_margin_max": "0%",
"br_margin_min": "0%"
}
<a id="jc.parsers.ethtool.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False) -> Dict[str, Any]
```
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
Source: [`jc/parsers/ethtool.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ethtool.py)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -85,4 +85,6 @@ Returns:
### Parser Information
Compatibility: linux, aix, freebsd, darwin
Source: [`jc/parsers/file.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/file.py)
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -79,4 +79,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/find.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/find.py)
Version 1.0 by Solomon Leang (solomonleang@gmail.com)

View File

@@ -96,7 +96,7 @@ Examples:
```python
def parse(data: str,
raw: bool = False,
quiet: bool = False) -> List[JSONDictType]
quiet: bool = False) -> List[Dict[str, Any]]
```
Main text parsing function
@@ -114,4 +114,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/findmnt.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/findmnt.py)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -113,4 +113,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, freebsd
Source: [`jc/parsers/finger.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/finger.py)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -5,6 +5,8 @@
jc - JSON Convert `free` command output parser
Values are normalized to bytes when using `free -h`.
Usage (cli):
$ free | jc --free
@@ -22,13 +24,13 @@ Schema:
[
{
"type": string,
"total": integer,
"used": integer,
"free": integer,
"shared": integer,
"buff_cache": integer,
"available": integer
"type": string,
"total": integer,
"used": integer,
"free": integer,
"shared": integer,
"buff_cache": integer,
"available": integer
}
]
@@ -95,4 +97,6 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/free.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/free.py)
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -108,4 +108,6 @@ Returns:
### Parser Information
Compatibility: linux, freebsd
Source: [`jc/parsers/fstab.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/fstab.py)
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,7 +1,7 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.git_log"></a>
# jc.parsers.git\_log
# jc.parsers.git_log
jc - JSON Convert `git log` command output parser
@@ -55,6 +55,12 @@ Schema:
"deletions": integer,
"files": [
string
],
"file_stats": [
{
"name": string,
"lines_changed": integer
}
]
}
}
@@ -79,6 +85,16 @@ Examples:
"files": [
"docs/parsers/git_log.md",
"jc/parsers/git_log.py"
],
"file_stats": [
{
"name": "docs/parsers/git_log.md",
"lines_changed": 3
},
{
"name": "jc/parsers/git_log.py",
"lines_changed": 7
}
]
},
"message": "add timestamp docs and examples",
@@ -100,6 +116,28 @@ Examples:
"jc/parsers/git_log.py",
"jc/utils.py",
"man/jc.1"
],
"file_stats": [
{
"name": "docs/parsers/git_log.md",
"lines_changed": 3
},
{
"name": "docs/utils.md",
"lines_changed": 7
},
{
"name": "jc/parsers/git_log.py",
"lines_changed": 1
},
{
"name": "jc/utils.py",
"lines_changed": 12
},
{
"name": "man/jc.1",
"lines_changed": 14
}
]
},
"message": "add calculated timestamp",
@@ -123,6 +161,16 @@ Examples:
"files": [
"docs/parsers/git_log.md",
"jc/parsers/git_log.py"
],
"file_stats": [
{
"name": "docs/parsers/git_log.md",
"lines_changed": "3"
},
{
"name": "jc/parsers/git_log.py",
"lines_changed": "7"
}
]
},
"message": "add timestamp docs and examples"
@@ -142,6 +190,28 @@ Examples:
"jc/parsers/git_log.py",
"jc/utils.py",
"man/jc.1"
],
"file_stats": [
{
"name": "docs/parsers/git_log.md",
"lines_changed": "3"
},
{
"name": "docs/utils.md",
"lines_changed": "7"
},
{
"name": "jc/parsers/git_log.py",
"lines_changed": "1"
},
{
"name": "jc/utils.py",
"lines_changed": "12"
},
{
"name": "man/jc.1",
"lines_changed": "14"
}
]
},
"message": "add calculated timestamp"
@@ -172,4 +242,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/git_log.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/git_log.py)
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,7 +1,7 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.git_log_s"></a>
# jc.parsers.git\_log\_s
# jc.parsers.git_log_s
jc - JSON Convert `git log` command output streaming parser
@@ -56,6 +56,12 @@ Schema:
"deletions": integer,
"files": [
string
],
"file_stats": [
{
"name": string,
"lines_changed": integer
}
]
}
@@ -82,7 +88,6 @@ Examples:
### parse
```python
@add_jc_meta
def parse(data: Iterable[str],
raw: bool = False,
quiet: bool = False,
@@ -108,4 +113,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/git_log_s.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/git_log_s.py)
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,7 +1,7 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.git_ls_remote"></a>
# jc.parsers.git\_ls\_remote
# jc.parsers.git_ls_remote
jc - JSON Convert `git ls-remote` command output parser
@@ -71,7 +71,7 @@ Examples:
```python
def parse(data: str,
raw: bool = False,
quiet: bool = False) -> Union[JSONDictType, List[JSONDictType]]
quiet: bool = False) -> Union[Dict[str, Any], List[Dict[str, Any]]]
```
Main text parsing function
@@ -89,4 +89,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/git_ls_remote.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/git_ls_remote.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -142,4 +142,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/gpg.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/gpg.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -132,4 +132,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, aix, freebsd
Source: [`jc/parsers/group.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/group.py)
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -100,4 +100,6 @@ Returns:
### Parser Information
Compatibility: linux, aix, freebsd
Source: [`jc/parsers/gshadow.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/gshadow.py)
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -60,4 +60,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Source: [`jc/parsers/hash.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/hash.py)
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -91,4 +91,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Source: [`jc/parsers/hashsum.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/hashsum.py)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -340,4 +340,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/hciconfig.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/hciconfig.py)
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -87,4 +87,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Source: [`jc/parsers/history.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/history.py)
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)

115
docs/parsers/host.md Normal file
View File

@@ -0,0 +1,115 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.host"></a>
# jc.parsers.host
jc - JSON Convert `host` command output parser
Supports parsing of the most commonly used RR types (A, AAAA, MX, TXT)
Usage (cli):
$ host google.com | jc --host
or
$ jc host google.com
Usage (module):
import jc
result = jc.parse('host', host_command_output)
Schema:
[
{
"hostname": string,
"address": [
string
],
"v6-address": [
string
],
"mail": [
string
]
}
]
[
{
"nameserver": string,
"zone": string,
"mname": string,
"rname": string,
"serial": integer,
"refresh": integer,
"retry": integer,
"expire": integer,
"minimum": integer
}
]
Examples:
$ host google.com | jc --host
[
{
"hostname": "google.com",
"address": [
"142.251.39.110"
],
"v6-address": [
"2a00:1450:400e:811::200e"
],
"mail": [
"smtp.google.com."
]
}
]
$ jc host -C sunet.se
[
{
"nameserver": "2001:6b0:7::2",
"zone": "sunet.se",
"mname": "sunic.sunet.se.",
"rname": "hostmaster.sunet.se.",
"serial": "2023090401",
"refresh": "28800",
"retry": "7200",
"expire": "604800",
"minimum": "300"
},
{
...
}
]
<a id="jc.parsers.host.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = 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:
List of Dictionaries. Raw or processed structured data.
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/host.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/host.py)
Version 1.0 by Pettai (pettai@sunet.se)

View File

@@ -97,4 +97,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/hosts.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/hosts.py)
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -0,0 +1,336 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.http_headers"></a>
# jc.parsers.http_headers
jc - JSON Convert HTTP headers parser
Converts HTTP request and response headers into a list of dictionaries.
Well-known headers are processed to allow multiple instances which are
aggregated into an array along with any comma-separated values. Integer,
float, and datetimes are converted where defined in the specifications.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
https://datatracker.ietf.org/doc/html/rfc2616
https://datatracker.ietf.org/doc/html/rfc3229
https://datatracker.ietf.org/doc/html/rfc7089
https://datatracker.ietf.org/doc/html/rfc7231
https://datatracker.ietf.org/doc/html/rfc5789
If you are converting HTTP headers from `curl` verbose output, use the
`curl-head` parser which will strip the `>` and `<` characters and remove
non-header lines that begin with `*`.
Usage (cli):
$ cat headers.txt | jc --http-headers
Usage (module):
import jc
result = jc.parse('http_headers', http_headers_output)
Schema:
[
{
"_type": string, # request or response
"_request_method": string,
"_request_uri": string,
"_request_version": string,
"_response_version": string,
"_response_status": integer,
"_response_reason": string or null,
"<header>": string,
# well-known headers:
"accept": [
string
],
"accept-ch": [
string
],
"accept-ch-lifetime": integer,
"accept-encoding": [
string
],
"accept-language": [
string
],
"accept-patch": [
string
],
"accept-post": [
string
],
"accept-ranges": [
string
],
"access-control-allow-headers": [
string
],
"access-control-allow-methods": [
string
],
"access-control-expose-headers": [
string
],
"access-control-max-age": integer,
"access-control-request-headers": [
string
],
"age": integer,
"allow": [
string
],
"alt-svc": [
string
],
"cache-control": [
string
],
"clear-site-data": [
string
],
"connection": [
string
],
"content-encoding": [
string
],
"content-dpr": integer,
"content-language": [
string
],
"content-length": integer,
"content-security-policy": [
string
],
"content-security-policy-report-only": [
string
],
"cookie": [
string
],
"critical-ch": [
string
],
"date": string,
"date_epoch_utc": integer,
"expect-ct": [
string
],
"expires": string,
"expires_epoch_utc": integer,
"device-memory": integer,
"downlink": integer,
"dpr": integer,
"forwarded": [
string
],
"if-match": [
string
],
"if-modified-since": string,
"if-modified-since_epoch_utc": integer,
"if-none-match": [
string
],
"if-range": string,
"if-range_epoch_utc": integer,
"if-unmodified-since": string,
"if-unmodified-since_epoch_utc": integer,
"im": [
string
],
"keep-alive": [
string
],
"large-allocation": integer,
"last-modified": string,
"last-modified_epoch_utc": integer,
"link": [
string
],
"max-forwards": integer,
"memento-datetime": string,
"memento-datetime_epoch_utc": integer,
"permissions-policy": [
string
],
"permissions-policy-report-only": [
string
],
"pragma": [
string
],
"proxy-authenticate": [
string
],
"reporting-endpoints": [
string
],
"retry-after": string,
"retry-after_epoch_utc": integer,
"rtt": integer,
"sec-ch-ua": [
string
],
"sec-ch-ua-full-version-list": [
string
],
"server": [
string
],
"server-timing": [
string
],
"set-cookie": [
string
],
"timing-allow-origin": [
string
],
"trailer": [
string
],
"transfer-encoding": [
string
],
"upgrade": [
string
],
"upgrade-insecure-requests": integer,
"vary": [
string
],
"via": [
string
],
"warning": [
string
],
"www-authenticate": [
string
],
"x-cache-hits": [
integer
],
"x-content-duration": float
}
]
Examples:
$ cat headers.txt | jc --http-headers -p
[
{
"_type": "request",
"_request_method": "HEAD",
"_request_uri": "/",
"_request_version": "HTTP/1.1",
"host": "example.com",
"user-agent": "curl/8.1.2",
"accept": [
"*/*"
]
},
{
"_type": "response",
"_response_version": "HTTP/1.1",
"_response_status": 200,
"_response_reason": [
"OK"
],
"accept-ranges": [
"bytes"
],
"age": 140203,
"cache-control": [
"max-age=604800"
],
"content-type": "text/html; charset=UTF-8",
"date": "Sun, 04 Feb 2024 02:25:07 GMT",
"etag": "\"3147526947\"",
"expires": "Sun, 11 Feb 2024 02:25:07 GMT",
"last-modified": "Thu, 17 Oct 2019 07:18:26 GMT",
"server": [
"ECS (sac/252F)"
],
"x-cache": "HIT",
"content-length": 1256,
"date_epoch_utc": 1707013507,
"expires_epoch_utc": 1707618307,
"last-modified_epoch_utc": 1571296706
}
]
$ cat headers.txt | jc --http-headers -p -r
[
{
"_type": "request",
"_request_method": "HEAD",
"_request_uri": "/",
"_request_version": "HTTP/1.1",
"host": "example.com",
"user-agent": "curl/8.1.2",
"accept": [
"*/*"
]
},
{
"_type": "response",
"_response_version": "HTTP/1.1",
"_response_status": 200,
"_response_reason": [
"OK"
],
"accept-ranges": [
"bytes"
],
"age": "140203",
"cache-control": [
"max-age=604800"
],
"content-type": "text/html; charset=UTF-8",
"date": "Sun, 04 Feb 2024 02:25:07 GMT",
"etag": "\"3147526947\"",
"expires": "Sun, 11 Feb 2024 02:25:07 GMT",
"last-modified": "Thu, 17 Oct 2019 07:18:26 GMT",
"server": [
"ECS (sac/252F)"
],
"x-cache": "HIT",
"content-length": "1256"
}
]
<a id="jc.parsers.http_headers.parse"></a>
### parse
```python
def parse(data: str,
raw: bool = False,
quiet: bool = False) -> List[Dict[str, Any]]
```
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
Source: [`jc/parsers/http_headers.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/http_headers.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -128,4 +128,8 @@ Returns:
### Parser Information
Compatibility: linux, darwin, aix, freebsd
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/id.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/id.py)
This parser can be used with the `--slurp` command-line option.
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -222,7 +222,7 @@ Examples:
```python
def parse(data: str,
raw: bool = False,
quiet: bool = False) -> List[JSONDictType]
quiet: bool = False) -> List[Dict[str, Any]]
```
Main text parsing function
@@ -240,4 +240,6 @@ Returns:
### Parser Information
Compatibility: linux, aix, freebsd, darwin
Version 2.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/ifconfig.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ifconfig.py)
Version 2.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -96,4 +96,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 2.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/ini.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ini.py)
Version 2.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,7 +1,7 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.ini_dup"></a>
# jc.parsers.ini\_dup
# jc.parsers.ini_dup
jc - JSON Convert INI with duplicate key file parser
@@ -22,12 +22,12 @@ contained in lists/arrays.
Usage (cli):
$ cat foo.ini | jc --ini
$ cat foo.ini | jc --ini-dup
Usage (module):
import jc
result = jc.parse('ini', ini_file_output)
result = jc.parse('ini_dup', ini_file_output)
Schema:
@@ -67,7 +67,7 @@ Examples:
fruit = peach
color = green
$ cat example.ini | jc --ini -p
$ cat example.ini | jc --ini-dup -p
{
"foo": [
"fiz"
@@ -118,4 +118,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/ini_dup.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ini_dup.py)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -182,4 +182,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/iostat.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/iostat.py)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,7 +1,7 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.iostat_s"></a>
# jc.parsers.iostat\_s
# jc.parsers.iostat_s
jc - JSON Convert `iostat` command output streaming parser
@@ -108,7 +108,6 @@ Examples:
### parse
```python
@add_jc_meta
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
```
@@ -130,4 +129,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/iostat_s.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/iostat_s.py)
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,7 +1,7 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.ip_address"></a>
# jc.parsers.ip\_address
# jc.parsers.ip_address
jc - JSON Convert IP Address string parser
@@ -552,4 +552,8 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/ip_address.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ip_address.py)
This parser can be used with the `--slurp` command-line option.
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,7 +1,7 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.ip_route"></a>
# jc.parsers.ip\_route
# jc.parsers.ip_route
jc - JSON Convert `ip route` command output parser
@@ -71,4 +71,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/ip_route.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ip_route.py)
Version 1.0 by Julian Jackson (jackson.julian55@yahoo.com)

461
docs/parsers/ipconfig.md Normal file
View File

@@ -0,0 +1,461 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.ipconfig"></a>
# jc.parsers.ipconfig
jc - JSON Convert `ipconfig` Windows command output parser
Usage (cli):
$ ipconfig /all | jc --ipconfig
$ ipconfig | jc --ipconfig
$ jc ipconfig /all
Usage (module):
import jc
result = jc.parse('ipconfig', ipconfig_command_output)
Schema:
{
"host_name": string,
"primary_dns_suffix": string,
"node_type": string,
"ip_routing_enabled": boolean,
"wins_proxy_enabled": boolean,
"dns_suffix_search_list": [
string
],
"adapters": [
{
"name_long": string,
"name": string,
"type": string,
"connection_specific_dns_suffix": string,
"connection_specific_dns_suffix_search_list": [
string
]
"description": string,
"physical_address": string,
"dhcp_enabled": boolean,
"autoconfiguration_enabled": boolean,
"ipv6_addresses": [
{
"address": string,
"status": string,
},
],
"temporary_ipv6_addresses": [
{
"address": string,
"status": string,
},
],
"link_local_ipv6_addresses": [
{
"address": string,
"status": string,
"prefix_length": integer,
}
],
"ipv4_addresses": [
{
"address": string, # [2]
"subnet_mask": string,
"status": string,
"autoconfigured": boolean # [1]
}
],
"default_gateways": [
string
],
"dhcp_server": null,
"dhcpv6_iaid": string,
"dhcpv6_client_duid": string,
"dns_servers": [
string
],
"primary_wins_server": string,
"lease_expires": string,
"lease_expires_epoch": integer, # [0]
"lease_expires_iso": string,
"lease_obtained": string,
"lease_obtained_epoch": integer, # [0]
"lease_obtained_iso": string,
"netbios_over_tcpip": boolean,
"media_state": string,
"extras": [
<string>: string
]
}
],
"extras": []
}
Notes:
[0] - The epoch calculated timestamp field is naive. (i.e. based on
the local time of the system the parser is run on)
[1] - 'autoconfigured' under 'ipv4_address' is only providing
indication if the ipv4 address was labeled as "Autoconfiguration
IPv4 Address" vs "IPv4 Address". It does not infer any
information from other fields
[2] - Windows XP uses 'IP Address' instead of 'IPv4 Address'. Both
values are parsed to the 'ipv4_address' object for consistency
Examples:
$ ipconfig /all | jc --ipconfig -p
{
"host_name": "DESKTOP-WIN11-HOME",
"primary_dns_suffix": null,
"node_type": "Hybrid",
"ip_routing_enabled": false,
"wins_proxy_enabled": false,
"dns_suffix_search_list": [
"localdomain"
],
"adapters": [
{
"name_long": "Ethernet adapter Ethernet",
"name": "Ethernet",
"type": "Ethernet",
"connection_specific_dns_suffix": null,
"connection_specific_dns_suffix_search_list": [],
"description": "Intel(R) I211 Gigabit Network Connection",
"physical_address": "24-4B-FE-AB-43-C3",
"dhcp_enabled": true,
"autoconfiguration_enabled": true,
"ipv6_addresses": [],
"temporary_ipv6_addresses": [],
"link_local_ipv6_addresses": [],
"ipv4_addresses": [],
"default_gateways": [],
"dhcp_server": null,
"dhcpv6_iaid": null,
"dhcpv6_client_duid": null,
"dns_servers": [],
"primary_wins_server": null,
"lease_expires": null,
"lease_obtained": null,
"netbios_over_tcpip": null,
"media_state": "Media disconnected",
"extras": []
},
{
"name_long": "Ethernet adapter Ethernet 2",
"name": "Ethernet 2",
"type": "Ethernet",
"connection_specific_dns_suffix": null,
"connection_specific_dns_suffix_search_list": [],
"description": "Realtek PCIe 2.5GbE Family Controller",
"physical_address": "24-4B-FE-57-3D-F2",
"dhcp_enabled": true,
"autoconfiguration_enabled": true,
"ipv6_addresses": [],
"temporary_ipv6_addresses": [],
"link_local_ipv6_addresses": [],
"ipv4_addresses": [],
"default_gateways": [],
"dhcp_server": null,
"dhcpv6_iaid": null,
"dhcpv6_client_duid": null,
"dns_servers": [],
"primary_wins_server": null,
"lease_expires": null,
"lease_obtained": null,
"netbios_over_tcpip": null,
"media_state": "Media disconnected",
"extras": []
},
{
"name_long": "Unknown adapter OpenVPN Data Channel Offload for NordVPN",
"name": "OpenVPN Data Channel Offload for NordVPN",
"type": "Unknown",
"connection_specific_dns_suffix": null,
"connection_specific_dns_suffix_search_list": [],
"description": "OpenVPN Data Channel Offload",
"physical_address": null,
"dhcp_enabled": true,
"autoconfiguration_enabled": true,
"ipv6_addresses": [],
"temporary_ipv6_addresses": [],
"link_local_ipv6_addresses": [],
"ipv4_addresses": [],
"default_gateways": [],
"dhcp_server": null,
"dhcpv6_iaid": null,
"dhcpv6_client_duid": null,
"dns_servers": [],
"primary_wins_server": null,
"lease_expires": null,
"lease_obtained": null,
"netbios_over_tcpip": null,
"media_state": "Media disconnected",
"extras": []
},
{
"name_long": "Unknown adapter Local Area Connection",
"name": "Local Area Connection",
"type": "Unknown",
"connection_specific_dns_suffix": null,
"connection_specific_dns_suffix_search_list": [],
"description": "TAP-NordVPN Windows Adapter V9",
"physical_address": "00-FF-4C-F4-5E-49",
"dhcp_enabled": true,
"autoconfiguration_enabled": true,
"ipv6_addresses": [],
"temporary_ipv6_addresses": [],
"link_local_ipv6_addresses": [],
"ipv4_addresses": [],
"default_gateways": [],
"dhcp_server": null,
"dhcpv6_iaid": null,
"dhcpv6_client_duid": null,
"dns_servers": [],
"primary_wins_server": null,
"lease_expires": null,
"lease_obtained": null,
"netbios_over_tcpip": null,
"media_state": "Media disconnected",
"extras": []
},
{
"name_long": "Wireless LAN adapter Local Area Connection* 1",
"name": "Local Area Connection* 1",
"type": "Wireless LAN",
"connection_specific_dns_suffix": null,
"connection_specific_dns_suffix_search_list": [],
"description": "Microsoft Wi-Fi Direct Virtual Adapter",
"physical_address": "A8-7E-EA-5A-7F-DE",
"dhcp_enabled": true,
"autoconfiguration_enabled": true,
"ipv6_addresses": [],
"temporary_ipv6_addresses": [],
"link_local_ipv6_addresses": [],
"ipv4_addresses": [],
"default_gateways": [],
"dhcp_server": null,
"dhcpv6_iaid": null,
"dhcpv6_client_duid": null,
"dns_servers": [],
"primary_wins_server": null,
"lease_expires": null,
"lease_obtained": null,
"netbios_over_tcpip": null,
"media_state": "Media disconnected",
"extras": []
},
{
"name_long": "Wireless LAN adapter Local Area Connection* 2",
"name": "Local Area Connection* 2",
"type": "Wireless LAN",
"connection_specific_dns_suffix": null,
"connection_specific_dns_suffix_search_list": [],
"description": "Microsoft Wi-Fi Direct Virtual Adapter #2",
"physical_address": "AA-7E-EA-F3-64-C3",
"dhcp_enabled": true,
"autoconfiguration_enabled": true,
"ipv6_addresses": [],
"temporary_ipv6_addresses": [],
"link_local_ipv6_addresses": [],
"ipv4_addresses": [],
"default_gateways": [],
"dhcp_server": null,
"dhcpv6_iaid": null,
"dhcpv6_client_duid": null,
"dns_servers": [],
"primary_wins_server": null,
"lease_expires": null,
"lease_obtained": null,
"netbios_over_tcpip": null,
"media_state": "Media disconnected",
"extras": []
},
{
"name_long": "Ethernet adapter VMware Network Adapter VMnet1",
"name": "VMware Network Adapter VMnet1",
"type": "Ethernet",
"connection_specific_dns_suffix": null,
"connection_specific_dns_suffix_search_list": [],
"description": "VMware Virtual Ethernet Adapter for VMnet1",
"physical_address": "00-50-56-CC-27-73",
"dhcp_enabled": true,
"autoconfiguration_enabled": true,
"ipv6_addresses": [],
"temporary_ipv6_addresses": [],
"link_local_ipv6_addresses": [
{
"address": "fe80::f47d:9c7f:69dc:591e",
"prefix_length": 8,
"status": "Preferred"
}
],
"ipv4_addresses": [
{
"address": "192.168.181.1",
"subnet_mask": "255.255.255.0",
"status": "Preferred",
"autoconfigured": false
}
],
"default_gateways": [],
"dhcp_server": "192.168.181.254",
"dhcpv6_iaid": "771772502",
"dhcpv6_client_duid": "00-01-00-01-2C-CF-19-EB-24-4B-FE-5B-9B-E6",
"dns_servers": [],
"primary_wins_server": null,
"lease_expires": "2024-09-19T18:01:29",
"lease_obtained": "2024-09-19T08:31:29",
"netbios_over_tcpip": true,
"media_state": null,
"extras": []
},
{
"name_long": "Ethernet adapter VMware Network Adapter VMnet8",
"name": "VMware Network Adapter VMnet8",
"type": "Ethernet",
"connection_specific_dns_suffix": null,
"connection_specific_dns_suffix_search_list": [],
"description": "VMware Virtual Ethernet Adapter for VMnet8",
"physical_address": "00-50-56-C9-A3-78",
"dhcp_enabled": true,
"autoconfiguration_enabled": true,
"ipv6_addresses": [],
"temporary_ipv6_addresses": [],
"link_local_ipv6_addresses": [
{
"address": "fe80::4551:bf0d:59dd:a4f0",
"prefix_length": 10,
"status": "Preferred"
}
],
"ipv4_addresses": [
{
"address": "192.168.213.1",
"subnet_mask": "255.255.255.0",
"status": "Preferred",
"autoconfigured": false
}
],
"default_gateways": [],
"dhcp_server": "192.168.213.254",
"dhcpv6_iaid": "788549718",
"dhcpv6_client_duid": "00-01-00-01-2C-CF-19-EB-24-4B-FE-5B-9B-E6",
"dns_servers": [],
"primary_wins_server": "192.168.213.2",
"lease_expires": "2024-09-19T18:01:29",
"lease_obtained": "2024-09-19T08:31:29",
"netbios_over_tcpip": true,
"media_state": null,
"extras": []
},
{
"name_long": "Wireless LAN adapter Wi-Fi",
"name": "Wi-Fi",
"type": "Wireless LAN",
"connection_specific_dns_suffix": "localdomain",
"connection_specific_dns_suffix_search_list": [],
"description": "Intel(R) Wi-Fi 6 AX200 160MHz",
"physical_address": "A8-7E-EA-55-26-B0",
"dhcp_enabled": true,
"autoconfiguration_enabled": true,
"ipv6_addresses": [
{
"address": "fd63:cc9c:65eb:3f95:57c2:aa:10d8:db08",
"status": "Preferred"
}
],
"temporary_ipv6_addresses": [
{
"address": "fd63:cc9c:65eb:3f95:8928:348e:d692:b7ef",
"status": "Preferred"
}
],
"link_local_ipv6_addresses": [
{
"address": "fe80::4fae:1380:5a1b:8b6b",
"prefix_length": 11,
"status": "Preferred"
}
],
"ipv4_addresses": [
{
"address": "192.168.1.169",
"subnet_mask": "255.255.255.0",
"status": "Preferred",
"autoconfigured": false
}
],
"default_gateways": [
"192.168.1.1"
],
"dhcp_server": "192.168.1.1",
"dhcpv6_iaid": "162037482",
"dhcpv6_client_duid": "00-01-00-01-2C-CF-19-EB-24-4B-FE-5B-9B-E6",
"dns_servers": [
"192.168.1.1"
],
"primary_wins_server": null,
"lease_expires": "2024-09-20T08:31:30",
"lease_obtained": "2024-09-19T08:31:30",
"netbios_over_tcpip": true,
"media_state": null,
"extras": []
},
{
"name_long": "Ethernet adapter Bluetooth Network Connection",
"name": "Bluetooth Network Connection",
"type": "Ethernet",
"connection_specific_dns_suffix": null,
"connection_specific_dns_suffix_search_list": [],
"description": "Bluetooth Device (Personal Area Network)",
"physical_address": "A8-7E-EA-43-23-14",
"dhcp_enabled": true,
"autoconfiguration_enabled": true,
"ipv6_addresses": [],
"temporary_ipv6_addresses": [],
"link_local_ipv6_addresses": [],
"ipv4_addresses": [],
"default_gateways": [],
"dhcp_server": null,
"dhcpv6_iaid": null,
"dhcpv6_client_duid": null,
"dns_servers": [],
"primary_wins_server": null,
"lease_expires": null,
"lease_obtained": null,
"netbios_over_tcpip": null,
"media_state": "Media disconnected",
"extras": []
}
],
"extras": []
}
<a id="jc.parsers.ipconfig.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:
Parsed dictionary. The raw and processed data structures are the same.
### Parser Information
Compatibility: windows
Source: [`jc/parsers/ipconfig.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ipconfig.py)
Version 1.0 by joehacksalot (joehacksalot@gmail.com)

View File

@@ -5,7 +5,7 @@
jc - JSON Convert `iptables` command output parser
Supports `-vLn` and `--line-numbers` for all tables.
Supports `-vLnx` and `--line-numbers` for all tables.
Usage (cli):
@@ -25,12 +25,15 @@ Schema:
[
{
"chain": string,
"default_policy": string,
"default_packets": integer,
"default_bytes": integer,
"rules": [
{
"num" integer,
"pkts": integer,
"bytes": integer, # converted based on suffix
"target": string,
"target": string, # Null if blank
"prot": string,
"opt": string, # "--" = Null
"in": string,
@@ -49,6 +52,9 @@ Examples:
[
{
"chain": "PREROUTING",
"default_policy": "DROP",
"default_packets": 0,
"default_bytes": 0,
"rules": [
{
"num": 1,
@@ -108,6 +114,9 @@ Examples:
[
{
"chain": "PREROUTING",
"default_policy": "DROP",
"default_packets": "0",
"default_bytes": "0",
"rules": [
{
"num": "1",
@@ -186,4 +195,6 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/iptables.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/iptables.py)
Version 1.12 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,37 +0,0 @@
[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 has been renamed to datetime-iso (cli) or datetime_iso (module).
This parser will be removed in a future version, so please start using
the new parser name.
<a id="jc.parsers.iso_datetime.parse"></a>
### parse
```python
def parse(data, raw=False, quiet=False)
```
This parser is deprecated and calls datetime_iso. Please use datetime_iso
directly. This parser will be removed in the future.
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.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,7 +1,7 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.iw_scan"></a>
# jc.parsers.iw\_scan
# jc.parsers.iw_scan
jc - JSON Convert `iw dev <device> scan` command output parser
@@ -144,4 +144,6 @@ Returns:
### Parser Information
Compatibility: linux
Version 0.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/iw_scan.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/iw_scan.py)
Version 0.75 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -90,7 +90,7 @@ Examples:
```python
def parse(data: str,
raw: bool = False,
quiet: bool = False) -> List[JSONDictType]
quiet: bool = False) -> List[Dict[str, Any]]
```
Main text parsing function
@@ -108,4 +108,6 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.1 by Thomas Vincent (vrince@gmail.com)
Source: [`jc/parsers/iwconfig.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/iwconfig.py)
Version 1.2 by Thomas Vincent (vrince@gmail.com)

View File

@@ -1,7 +1,7 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.jar_manifest"></a>
# jc.parsers.jar\_manifest
# jc.parsers.jar_manifest
jc - JSON Convert Java `MANIFEST.MF` file parser
@@ -100,4 +100,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/jar_manifest.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/jar_manifest.py)
Version 0.01 by Matt J (https://github.com/listuser)

View File

@@ -116,4 +116,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Source: [`jc/parsers/jobs.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/jobs.py)
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -70,4 +70,8 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/jwt.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/jwt.py)
This parser can be used with the `--slurp` command-line option.
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -79,4 +79,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 2.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/kv.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/kv.py)
Version 2.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

91
docs/parsers/kv_dup.md Normal file
View File

@@ -0,0 +1,91 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.kv_dup"></a>
# jc.parsers.kv_dup
jc - JSON Convert `Key/Value` with duplicate key file and string parser
Supports files containing simple key/value pairs and preserves duplicate
values. All values are contained in lists/arrays.
- Delimiter can be `=` or `:`. Missing values are supported.
- Comment prefix can be `#` or `;`. Comments must be on their own line.
- If multi-line values are used, each line will be a separate item in the
value list. Blank lines in multi-line values are not supported.
> Note: Values starting and ending with quotation marks will have the marks
> removed. If you would like to keep the quotation marks, use the `-r`
> command-line argument or the `raw=True` argument in `parse()`.
Usage (cli):
$ cat foo.txt | jc --kv-dup
Usage (module):
import jc
result = jc.parse('kv_dup', kv_file_output)
Schema:
Key/Value document converted to a dictionary - see the python configparser
standard library documentation for more details.
{
"<key1>": [
string
],
"<key2>": [
string
]
}
Examples:
$ cat keyvalue.txt
# this file contains key/value pairs
name = John Doe
address=555 California Drive
age: 34
; comments can include # or ;
# delimiter can be = or :
# quoted values have quotation marks stripped by default
# but can be preserved with the -r argument
occupation:"Engineer"
occupation = "Pilot"
$ cat keyvalue.txt | jc --kv-dup -p
{
"name": ["John Doe"],
"address": ["555 California Drive"],
"age": ["34"],
"occupation": ["Engineer", "Pilot"]
}
<a id="jc.parsers.kv_dup.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 representing a Key/Value pair document.
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/kv_dup.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/kv_dup.py)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -127,4 +127,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, aix, freebsd
Source: [`jc/parsers/last.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/last.py)
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -140,4 +140,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Source: [`jc/parsers/ls.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ls.py)
Version 1.12 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,7 +1,7 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.ls_s"></a>
# jc.parsers.ls\_s
# jc.parsers.ls_s
jc - JSON Convert `ls` and `vdir` command output streaming parser
@@ -77,7 +77,6 @@ Examples:
### parse
```python
@add_jc_meta
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
```
@@ -99,4 +98,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Source: [`jc/parsers/ls_s.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ls_s.py)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -69,7 +69,7 @@ Examples:
```python
def parse(data: str,
raw: bool = False,
quiet: bool = False) -> List[JSONDictType]
quiet: bool = False) -> List[Dict[str, Any]]
```
Main text parsing function
@@ -86,4 +86,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/lsattr.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/lsattr.py)
Version 1.0 by Mark Rotner (rotner.mr@gmail.com)

View File

@@ -0,0 +1,63 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.lsb_release"></a>
# jc.parsers.lsb_release
jc - JSON Convert `lsb_release` command parser
This parser is an alias to the Key/Value parser (`--kv`).
Usage (cli):
$ lsb_release -a | jc --lsb-release
or
$ jc lsb_release -a
Usage (module):
import jc
result = jc.parse('lsb_release', lsb_release_command_output)
Schema:
{
"<key>": string
}
Examples:
$ lsb_release -a | jc --lsb-release -p
{
"Distributor ID": "Ubuntu",
"Description": "Ubuntu 16.04.6 LTS",
"Release": "16.04",
"Codename": "xenial"
}
<a id="jc.parsers.lsb_release.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False) -> Dict[str, Any]
```
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
Source: [`jc/parsers/lsb_release.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/lsb_release.py)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -22,46 +22,53 @@ Schema:
[
{
"name": string,
"maj_min": string,
"rm": boolean,
"size": string,
"ro": boolean,
"type": string,
"mountpoint": string,
"kname": string,
"fstype": string,
"label": string,
"uuid": string,
"partlabel": string,
"partuuid": string,
"ra": integer,
"model": string,
"serial": string,
"state": string,
"owner": string,
"group": string,
"mode": string,
"alignment": integer,
"min_io": integer,
"opt_io": integer,
"phy_sec": integer,
"log_sec": integer,
"rota": boolean,
"sched": string,
"rq_size": integer,
"disc_aln": integer,
"disc_gran": string,
"disc_max": string,
"disc_zero": boolean,
"wsame": string,
"wwn": string,
"rand": boolean,
"pkname": string,
"hctl": string,
"tran": string,
"rev": string,
"vendor": string
"name": string,
"maj_min": string,
"rm": boolean,
"size": string,
"size_bytes": integer
"ro": boolean,
"type": string,
"mountpoint": string,
"mountpoints": [
string
],
"kname": string,
"fstype": string,
"label": string,
"uuid": string,
"partlabel": string,
"partuuid": string,
"ra": integer,
"model": string,
"serial": string,
"state": string,
"owner": string,
"group": string,
"mode": string,
"alignment": integer,
"min_io": integer,
"opt_io": integer,
"phy_sec": integer,
"log_sec": integer,
"rota": boolean,
"sched": string,
"rq_size": integer,
"disc_aln": integer,
"disc_gran": string,
"disc_gran_bytes": integer,
"disc_max": string,
"disc_max_bytes": integer,
"disc_zero": boolean,
"wsame": string,
"wsame_bytes": integer,
"wwn": string,
"rand": boolean,
"pkname": string,
"hctl": string,
"tran": string,
"rev": string,
"vendor": string
}
]
@@ -74,6 +81,7 @@ Examples:
"maj_min": "8:0",
"rm": false,
"size": "20G",
"size_bytes": 20000000000,
"ro": false,
"type": "disk",
"mountpoint": null
@@ -83,6 +91,7 @@ Examples:
"maj_min": "8:1",
"rm": false,
"size": "1G",
"size_bytes": 1000000000
"ro": false,
"type": "part",
"mountpoint": "/boot"
@@ -100,6 +109,7 @@ Examples:
"maj_min": "8:0",
"rm": false,
"size": "20G",
"size_bytes": 20000000000,
"ro": false,
"type": "disk",
"mountpoint": null,
@@ -126,9 +136,12 @@ Examples:
"rq_size": 128,
"disc_aln": 0,
"disc_gran": "0B",
"disc_gran_bytes": 0,
"disc_max": "0B",
"disc_max_bytes": 0,
"disc_zero": false,
"wsame": "32M",
"wsame_bytes": 32000000,
"wwn": null,
"rand": true,
"pkname": null,
@@ -142,6 +155,7 @@ Examples:
"maj_min": "8:1",
"rm": false,
"size": "1G",
"size_bytes": 1000000000
"ro": false,
"type": "part",
"mountpoint": "/boot",
@@ -168,9 +182,12 @@ Examples:
"rq_size": 128,
"disc_aln": 0,
"disc_gran": "0B",
"disc_gran_bytes": 0,
"disc_max": "0B",
"disc_max_bytes": 0,
"disc_zero": false,
"wsame": "32M",
"wsame_bytes": 32000000,
"wwn": null,
"rand": true,
"pkname": "sda",
@@ -192,6 +209,7 @@ Examples:
"maj_min": "8:0",
"rm": "0",
"size": "20G",
"size_bytes": 20000000000,
"ro": "0",
"type": "disk",
"mountpoint": null,
@@ -218,9 +236,12 @@ Examples:
"rq_size": "128",
"disc_aln": "0",
"disc_gran": "0B",
"disc_gran_bytes": 0,
"disc_max": "0B",
"disc_max_bytes": 0,
"disc_zero": "0",
"wsame": "32M",
"wsame_bytes": 32000000,
"wwn": null,
"rand": "1",
"pkname": null,
@@ -234,6 +255,7 @@ Examples:
"maj_min": "8:1",
"rm": "0",
"size": "1G",
"size_bytes": 1000000000
"ro": "0",
"type": "part",
"mountpoint": "/boot",
@@ -260,9 +282,12 @@ Examples:
"rq_size": "128",
"disc_aln": "0",
"disc_gran": "0B",
"disc_gran_bytes": 0,
"disc_max": "0B",
"disc_max_bytes": 0,
"disc_zero": "0",
"wsame": "32M",
"wsame_bytes": 32000000,
"wwn": null,
"rand": "1",
"pkname": "sda",
@@ -297,4 +322,6 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/lsblk.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/lsblk.py)
Version 1.10 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -148,4 +148,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/lsmod.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/lsmod.py)
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -142,4 +142,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, aix, freebsd
Source: [`jc/parsers/lsof.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/lsof.py)
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -53,7 +53,6 @@ Schema:
"sdevice_id_int": integer,
"rev": string,
"physlot": string,
"physlot_int": integer,
"progif": string,
"progif_int": integer
}
@@ -89,7 +88,6 @@ Examples:
"sdevice_id": "07e0",
"sdevice_id_int": 2016,
"physlot": "37",
"physlot_int": 55,
"progif": "01",
"progif_int": 1
},
@@ -127,7 +125,7 @@ Examples:
```python
def parse(data: str,
raw: bool = False,
quiet: bool = False) -> List[JSONDictType]
quiet: bool = False) -> List[Dict[str, Any]]
```
Main text parsing function
@@ -145,4 +143,6 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/lspci.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/lspci.py)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -330,4 +330,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/lsusb.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/lsusb.py)
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -87,4 +87,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/m3u.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/m3u.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -249,4 +249,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/mdadm.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/mdadm.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -98,4 +98,6 @@ Returns:
### Parser Information
Compatibility: linux, darwin, freebsd, aix
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
Source: [`jc/parsers/mount.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/mount.py)
Version 1.11 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -137,4 +137,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/mpstat.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/mpstat.py)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,7 +1,7 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.mpstat_s"></a>
# jc.parsers.mpstat\_s
# jc.parsers.mpstat_s
jc - JSON Convert `mpstat` command output streaming parser
@@ -100,7 +100,6 @@ Examples:
### parse
```python
@add_jc_meta
def parse(data: Iterable[str],
raw: bool = False,
quiet: bool = False,
@@ -125,4 +124,6 @@ Returns:
### Parser Information
Compatibility: linux
Source: [`jc/parsers/mpstat_s.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/mpstat_s.py)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

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