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

Compare commits

...

340 Commits

Author SHA1 Message Date
Kelly Brazil
c12b48537a Merge pull request #242 from kellyjonbrazil/dev
Dev v1.19.0
2022-05-13 20:31:06 +00:00
Kelly Brazil
0bf69713ab Merge branch 'master' into dev 2022-05-13 20:26:12 +00:00
Kelly Brazil
c05f1475ed doc update 2022-05-13 13:23:14 -07:00
Kelly Brazil
416c262f02 remove top parsers 2022-05-13 13:17:16 -07:00
Kelly Brazil
40a5976f11 doc update 2022-05-13 12:45:27 -07:00
Kelly Brazil
dc582fbec8 fix for git-log coner cases 2022-05-13 12:44:01 -07:00
Kelly Brazil
7047f0a449 df fix for trailining newline char 2022-05-12 16:06:44 -07:00
Kelly Brazil
d7a884a567 doc update 2022-05-12 11:28:20 -07:00
Kelly Brazil
28de57792c formatting 2022-05-12 11:16:44 -07:00
Kelly Brazil
a230cdbd21 fix chage docs 2022-05-12 10:47:14 -07:00
Kelly Brazil
251a261679 add chage example 2022-05-11 18:56:13 -07:00
Kelly Brazil
3baef254fd maxsplit line 2022-05-11 18:47:56 -07:00
Kelly Brazil
9e69e928b2 add chage tests 2022-05-11 16:18:39 -07:00
Kelly Brazil
6eb595d2ca add chage parser 2022-05-11 16:12:29 -07:00
Kelly Brazil
acf07a5144 allow install on python 3.6 systems even though it is not supported 2022-05-11 08:00:05 -07:00
Kelly Brazil
7f53c58057 add ignore exception tests 2022-05-10 16:23:12 -07:00
Kelly Brazil
a069dc4855 add top -b parser 2022-05-10 16:08:56 -07:00
Kelly Brazil
febf544202 add git-log-s tests 2022-05-10 16:08:45 -07:00
Kelly Brazil
f2dd7b8815 doc update 2022-05-09 16:16:29 -07:00
Kelly Brazil
d758e37fe3 doc update 2022-05-09 16:10:41 -07:00
Kelly Brazil
9bc02a5623 doc update 2022-05-09 16:09:40 -07:00
Kelly Brazil
eb0ec265d0 Merge pull request #240 from fiskhest/master
Update README.md
2022-05-06 14:30:02 +00:00
fiskhest
1f236dc02a Update README.md 2022-05-06 16:20:33 +02:00
Kelly Brazil
86c279cbb2 add sep char test 2022-05-02 11:15:41 -07:00
Kelly Brazil
4a7f1bed3a doc update 2022-05-02 09:16:12 -07:00
Kelly Brazil
a730ae18c8 changelog update 2022-05-01 11:07:27 -07:00
Kelly Brazil
930bf439c0 check for separator characters in table cells. If detected, print a warning. 2022-05-01 11:04:35 -07:00
Kelly Brazil
f5f3133b87 add note about table column separators not being allowed in cell data 2022-05-01 10:27:34 -07:00
Kelly Brazil
cbca96de84 changelog update 2022-05-01 09:56:23 -07:00
Kelly Brazil
4d8ae3f124 doc update 2022-05-01 09:55:08 -07:00
Kelly Brazil
653127431d update plugin language 2022-04-29 06:50:37 -07:00
Kelly Brazil
22acef3765 generator to iterable object 2022-04-29 06:47:10 -07:00
Kelly Brazil
0d5bf11f0d change iterator to iterable 2022-04-29 06:42:11 -07:00
Kelly Brazil
a824ccaff3 add git-log-s parser 2022-04-28 16:23:56 -07:00
Kelly Brazil
97ac965ba5 version bump 2022-04-28 16:23:14 -07:00
Kelly Brazil
3e7f284df5 simplify streaming docs 2022-04-28 13:38:24 -07:00
Kelly Brazil
5c749fe26f simplify docs 2022-04-28 13:30:11 -07:00
Kelly Brazil
aa48b46f48 try page character 2022-04-28 11:09:19 -07:00
Kelly Brazil
6eaa4ae176 try arrow link 2022-04-28 11:05:43 -07:00
Kelly Brazil
60c330b342 move gentoo up 2022-04-28 10:59:12 -07:00
Kelly Brazil
fdeb994121 try using a table for parser list 2022-04-28 10:49:35 -07:00
Kelly Brazil
65ed92fe7b move safe_print_json. change argument from string to list_or_dict 2022-04-28 09:28:56 -07:00
Kelly Brazil
9c8730786b Merge pull request #238 from kellyjonbrazil/master
sync to dev
2022-04-28 16:21:22 +00:00
Kelly Brazil
7608823ea7 add git-log 2022-04-27 11:31:35 -07:00
Kelly Brazil
4f8c1a2ca2 version bump 2022-04-27 09:43:55 -07:00
Kelly Brazil
37489dd4e1 doc update 2022-04-27 09:10:38 -07:00
Kelly Brazil
a53aa1d0b8 fix bug when no slaves are present 2022-04-27 09:02:30 -07:00
Kelly Brazil
f7b64a5762 formatting 2022-04-27 08:26:12 -07:00
Kelly Brazil
9b1fe0d9a4 create safe_print_json function 2022-04-27 08:24:54 -07:00
Kelly Brazil
b876645fc5 doc update 2022-04-27 07:38:17 -07:00
Kelly Brazil
d9c0b8f8ad make _safe_print and _asciify private 2022-04-27 07:37:31 -07:00
Kelly Brazil
78d2b239c8 doc update 2022-04-26 17:51:30 -07:00
Kelly Brazil
5a12d98893 update history tests 2022-04-26 17:49:27 -07:00
Kelly Brazil
621f11e6f9 simplify history code 2022-04-26 17:46:16 -07:00
Kelly Brazil
8417f2fe4e use UTF-8 encoding in subprocess.Popen 2022-04-26 15:01:12 -07:00
Kelly Brazil
3ef2a0a065 rename j_data to j_string 2022-04-26 14:29:59 -07:00
Kelly Brazil
faec16d1f2 add line feed 2022-04-26 14:28:18 -07:00
Kelly Brazil
a4ef52b533 refactor try/except blocks to safe_print function 2022-04-26 14:25:34 -07:00
Kelly Brazil
0b407123c2 simplify json_out code 2022-04-26 10:18:49 -07:00
Kelly Brazil
98eedc69ec doc update 2022-04-26 09:57:50 -07:00
Kelly Brazil
dd231ae293 for for UnicodeEncodeError exception when printing JSON 2022-04-26 09:57:12 -07:00
Kelly Brazil
ad6196ddab Merge pull request #236 from kellyjonbrazil/dev
add gentoo to readme
2022-04-26 07:14:46 -07:00
Kelly Brazil
49ca0cecf4 Merge pull request #235 from mgorny/gentoo-install
Add Gentoo Linux install command
2022-04-26 07:10:47 -07:00
Michał Górny
148f2fb6db Add Gentoo Linux install command 2022-04-26 10:38:15 +02:00
Kelly Brazil
e04cd298fb version bump 2022-04-25 19:25:58 -07:00
Kelly Brazil
5bb4e2b4b6 revert f-string to regular string 2022-04-25 19:22:18 -07:00
Kelly Brazil
7b22db50d3 remove single quotes around asciified string 2022-04-25 18:50:36 -07:00
Kelly Brazil
fecb2193ae Merge pull request #234 from kellyjonbrazil/dev
Dev v1.18.7
2022-04-25 17:17:49 -07:00
Kelly Brazil
46af3bd0c0 add UnicodeError fix 2022-04-25 17:04:19 -07:00
Kelly Brazil
c245c89f82 don't try to detect locale, just asciify on exception 2022-04-25 16:51:00 -07:00
Kelly Brazil
a8f0cd9dae C locale fixes 2022-04-25 14:48:59 -07:00
Kelly Brazil
3101189d47 doc update 2022-04-25 08:39:33 -07:00
Kelly Brazil
3f0b644b85 fix test 2022-04-25 08:37:03 -07:00
Kelly Brazil
25c2c483f8 Merge pull request #233 from chriscroome/dev
Update name of alternative from name to alternative
2022-04-25 08:34:34 -07:00
Chris Croome
8bc2ea14a3 Whitespace fix 2022-04-25 11:20:36 +01:00
Chris Croome
8d4f22d9a5 Merge branch 'dev' of github.com:chriscroome/jc into dev 2022-04-25 11:16:47 +01:00
Chris Croome
d2adc2630c Use alternative rather than name to match manpage 2022-04-25 11:16:20 +01:00
Chris Croome
727f2b589e Use alternative rather than name toi match manpage 2022-04-25 11:14:18 +01:00
Kelly Brazil
abbfc92da0 clarify plugin filename requirements 2022-04-22 17:05:22 -07:00
Kelly Brazil
73b7e71cad add tests 2022-04-22 16:25:45 -07:00
Kelly Brazil
4825b16f07 doc update 2022-04-22 15:23:11 -07:00
Kelly Brazil
d2013366cc add update-alternatives examples 2022-04-22 15:20:20 -07:00
Kelly Brazil
96609a2c70 add update-alternatives --get-selections parser 2022-04-22 15:10:48 -07:00
Kelly Brazil
39306573da add update-alternatives parser 2022-04-22 14:47:07 -07:00
Kelly Brazil
01e330aa97 precompile regex patterns 2022-04-22 13:33:36 -07:00
Kelly Brazil
f08a74097d add tests 2022-04-22 12:12:45 -07:00
Kelly Brazil
79e37a7383 fix for oneline output 2022-04-22 12:12:38 -07:00
Kelly Brazil
3eebb6ee19 add update-alternatives parser info 2022-04-22 12:11:56 -07:00
Kelly Brazil
096fffdb79 use stat examples 2022-04-20 10:03:36 -04:00
Kelly Brazil
728d882ed0 add timestamp docs and examples 2022-04-20 09:50:19 -04:00
Kelly Brazil
b53e42aca6 add calculated timestamp 2022-04-20 09:44:42 -04:00
Kelly Brazil
477329ce5b add linefeed to version text 2022-04-20 08:26:26 -04:00
Kelly Brazil
283dc4efd5 add python interpreter version and path to -v and -a output 2022-04-19 17:44:15 -04:00
Kelly Brazil
d490bbcaa0 normalize add/update 2022-04-19 15:26:31 -04:00
Kelly Brazil
f49ddf8e5c doc update 2022-04-19 15:18:04 -04:00
Kelly Brazil
e1e341652b doc update 2022-04-19 15:10:40 -04:00
Kelly Brazil
ecda667549 process integers 2022-04-19 15:10:35 -04:00
Kelly Brazil
a0d96a188a doc update 2022-04-19 14:45:20 -04:00
Kelly Brazil
6c0f0cddfe fix for datetime objects in yaml files 2022-04-19 14:43:47 -04:00
Kelly Brazil
c7173ecd89 fix mypy issues 2022-04-19 14:34:53 -04:00
Kelly Brazil
e98240c905 extend instead of append list 2022-04-19 14:20:44 -04:00
Kelly Brazil
6cb7e25974 add docs 2022-04-19 13:17:24 -04:00
Kelly Brazil
c37980c05c add stat support 2022-04-19 13:17:16 -04:00
Kelly Brazil
b5943bd39d initial docstring 2022-04-19 10:32:55 -04:00
Kelly Brazil
49a3a7db3b initial git-log parser 2022-04-19 09:30:38 -04:00
Kelly Brazil
0c55240e9d move test templates to fix test failures on some systems 2022-04-13 10:54:28 -07:00
Kelly Brazil
f91988aed5 iterator -> iterable 2022-04-12 14:22:06 -07:00
Kelly Brazil
3c3ad9fc6a iterator -> iterable in doc 2022-04-12 14:20:58 -07:00
Kelly Brazil
291ab79e22 fix arch linux command 2022-04-12 11:07:34 -07:00
Kelly Brazil
e6d5892c14 Merge pull request #226 from kellyjonbrazil/master
sync to dev
2022-04-12 11:02:37 -07:00
Kelly Brazil
dcca7a57d5 Merge pull request #225 from adrianteri/patch-1
Update README
2022-04-12 11:00:51 -07:00
003
4ee8a69337 Update README
Specify the Arch package is in the AUR and NOT in the standard Archlinux repositories.
2022-04-12 20:53:39 +03:00
Kelly Brazil
c0414e7db7 clean up background tasks 2022-04-10 17:18:20 -07:00
Kelly Brazil
a419175fe6 enhance parallelization 2022-04-10 17:14:34 -07:00
Kelly Brazil
cd6dead034 man page update 2022-04-10 16:54:34 -07:00
Kelly Brazil
45342ea9fe parallelize doc gneration 2022-04-10 16:54:22 -07:00
Kelly Brazil
585bf0e159 xrandr update 2022-04-10 10:32:51 -07:00
Kelly Brazil
3a860b9bab add rotation field 2022-04-10 10:31:13 -07:00
Kelly Brazil
269180df77 Merge pull request #223 from anekos/fix/support-rotated-devices
Fix/support rotated devices
2022-04-10 10:19:50 -07:00
anekos
a1afed8d95 doc update 2022-04-10 19:53:37 +09:00
anekos
e39f150a21 Support rotated devices 2022-04-10 19:53:37 +09:00
Kelly Brazil
e85f11c6fc doc formatting 2022-04-04 12:00:41 -07:00
Kelly Brazil
49a9d7b07e doc update 2022-04-04 11:42:16 -07:00
Kelly Brazil
a2ef9c429e allow duplicate keys 2022-04-04 11:38:52 -07:00
Kelly Brazil
d5e9074f1c version bump 2022-04-04 11:38:04 -07:00
Kelly Brazil
774699f085 Merge pull request #220 from kellyjonbrazil/master
sync to dev
2022-04-04 18:21:15 +00:00
Kelly Brazil
7138eef3d1 fix newline chars in doc 2022-03-30 14:39:56 -07:00
Kelly Brazil
fad5e544aa formatting 2022-03-29 09:58:44 -07:00
Kelly Brazil
64757e2cf5 doc formatting 2022-03-29 09:35:54 -07:00
Kelly Brazil
e05be3f08b Merge pull request #213 from kellyjonbrazil/dev
Dev v1.18.6
2022-03-25 22:36:05 +00:00
Kelly Brazil
789f0735df doc update 2022-03-25 15:32:37 -07:00
Kelly Brazil
34bc775317 doc update 2022-03-25 15:32:11 -07:00
Kelly Brazil
38de059a1b doc update 2022-03-24 16:58:45 -07:00
Kelly Brazil
304ae6268f minor optimization by changing the expression order 2022-03-24 16:58:39 -07:00
Kelly Brazil
978caf4522 minor optimization by reordering expressions 2022-03-24 12:37:46 -07:00
Kelly Brazil
17df5bfcfc cache _is_separator function 2022-03-24 11:58:13 -07:00
Kelly Brazil
5e6a5068cf allow iterables for simple table parser 2022-03-24 11:57:01 -07:00
Kelly Brazil
619de68a61 formatting 2022-03-24 09:39:53 -07:00
Kelly Brazil
6748c3cc91 remove lines from corner detection and add rounded corners 2022-03-24 09:31:12 -07:00
Kelly Brazil
0a462978b7 fix for special characters in headers 2022-03-23 15:08:33 -07:00
Kelly Brazil
e66a82ff49 doc update 2022-03-23 10:50:34 -07:00
Kelly Brazil
f3aa797d96 add more pretty table separators 2022-03-22 17:47:19 -07:00
Kelly Brazil
e5b478218c add quiet=True to parse tests 2022-03-22 16:05:07 -07:00
Kelly Brazil
35e0e9c32a remove print statement 2022-03-22 15:57:43 -07:00
Kelly Brazil
17c3c2f029 add bold bar seperator and ANSI code tests 2022-03-22 15:55:59 -07:00
Kelly Brazil
cf83e6398b add fancy separators 2022-03-22 15:13:07 -07:00
Kelly Brazil
94e061b881 add asciitable parser tests 2022-03-22 14:53:34 -07:00
Kelly Brazil
720480e39c doc update 2022-03-22 13:21:10 -07:00
Kelly Brazil
82a63fe159 doc update 2022-03-22 12:42:07 -07:00
Kelly Brazil
9c1ec9940e doc update 2022-03-22 12:35:56 -07:00
Kelly Brazil
f23f19da45 doc update 2022-03-22 12:25:59 -07:00
Kelly Brazil
aea2e1b0a9 fix tests so blank strings are now None 2022-03-22 12:25:51 -07:00
Kelly Brazil
7d95d679bf add asciitable parser 2022-03-22 12:25:24 -07:00
Kelly Brazil
b3b140066b doc update 2022-03-22 07:21:19 -07:00
Kelly Brazil
b204c423c1 doc update 2022-03-22 07:05:14 -07:00
Kelly Brazil
d451c309bb change multiple or statements to any() 2022-03-22 06:30:07 -07:00
Kelly Brazil
01d53da68e remove debug print 2022-03-21 19:11:27 -07:00
Kelly Brazil
53dd05e52c fix rstrip and add tests 2022-03-21 19:10:02 -07:00
Kelly Brazil
ab564f5be8 add tests 2022-03-21 17:57:14 -07:00
Kelly Brazil
00c39450f9 enhance type annotation 2022-03-21 13:36:54 -07:00
Kelly Brazil
f611d08b50 formatting 2022-03-21 13:33:35 -07:00
Kelly Brazil
90e79b7df3 formatting 2022-03-21 13:27:44 -07:00
Kelly Brazil
4eb2d725d5 formatting 2022-03-21 13:09:50 -07:00
Kelly Brazil
51ae5ebcac new streamlined parser 2022-03-21 13:06:34 -07:00
Kelly Brazil
9ecbdb0916 use generator instead of iterable in function return annotation 2022-03-20 10:16:29 -07:00
Kelly Brazil
b3a2886fd0 formatting 2022-03-20 10:12:29 -07:00
Kelly Brazil
ceacec0f46 remove errant os sep import 2022-03-18 16:57:47 -07:00
Kelly Brazil
ff0f794b01 working 2022-03-18 16:53:23 -07:00
Kelly Brazil
70fafbf3f8 remove asciitable so tests pass for now 2022-03-18 14:19:00 -07:00
Kelly Brazil
5a248a8fc5 add multiline asciitable parser 2022-03-18 13:05:57 -07:00
Kelly Brazil
4a3a4e10df add asciitable and asciitable-m parsers 2022-03-18 13:03:43 -07:00
Kelly Brazil
c27bd5ff39 pad lines in sparse_table_parse and use str.isspace() 2022-03-17 16:24:18 -07:00
Kelly Brazil
f804c9627f copy input list so we don't mutate the caller's data 2022-03-15 16:04:58 -07:00
Kelly Brazil
3ab25d02f9 use _parser_is_streaming from lib 2022-03-14 12:30:09 -07:00
Kelly Brazil
9e80fd2b97 fallback if info and doc items don't exist 2022-03-14 12:17:18 -07:00
Kelly Brazil
ff9527a098 import cleanup and use all_parser_info in parsers_text 2022-03-14 11:35:57 -07:00
Kelly Brazil
7dac2f8dc3 doc update 2022-03-14 10:50:10 -07:00
Kelly Brazil
32e4d55e86 use parser_info for help_doc 2022-03-14 10:46:54 -07:00
Kelly Brazil
f9a9062147 add documentation argument to parser_info and all_parser_info 2022-03-14 10:46:23 -07:00
Kelly Brazil
89e5919796 add -A to second example 2022-03-14 09:56:50 -07:00
Kelly Brazil
e5f5b2591d changelog update 2022-03-14 09:45:17 -07:00
Kelly Brazil
77c667eec0 ubuntu fixes 2022-03-14 09:43:18 -07:00
Kelly Brazil
b257ce8c2f add mpstat_s tests 2022-03-13 12:25:50 -07:00
Kelly Brazil
c693c868ca add mpstat streaming parser 2022-03-11 15:59:38 -08:00
Kelly Brazil
6f98b27a05 add mpstat tests 2022-03-11 15:33:31 -08:00
Kelly Brazil
d7efd25d88 add mpstat to docs 2022-03-11 14:54:06 -08:00
Kelly Brazil
2cddb1f0bb working mpstat 2022-03-11 14:00:19 -08:00
Kelly Brazil
ae1c331595 initial working version 2022-03-11 13:15:39 -08:00
Kelly Brazil
bc97052ed4 initial add mpstat parser 2022-03-11 12:37:17 -08:00
Kelly Brazil
6c3e0e2aa0 formatting 2022-03-11 12:37:01 -08:00
Kelly Brazil
dd052e0146 add underscores to column examples 2022-03-11 10:25:24 -08:00
Kelly Brazil
54e8f58145 add table result examples 2022-03-10 16:50:55 -08:00
Kelly Brazil
def7aa5764 formatting 2022-03-10 15:36:11 -08:00
Kelly Brazil
6986c74f6d remove direct parser module example from doc 2022-03-10 15:18:27 -08:00
Kelly Brazil
b784db404d streaming doc formatting update 2022-03-10 13:32:26 -08:00
Kelly Brazil
8aee4517bb doc formatting 2022-03-10 13:02:50 -08:00
Kelly Brazil
a5fb8fbf94 streaming doc update 2022-03-10 10:10:57 -08:00
Kelly Brazil
b9365e2ac2 add pidstat-s tests 2022-03-10 09:23:36 -08:00
Kelly Brazil
696338c1a3 add streaming test template 2022-03-10 09:04:12 -08:00
Kelly Brazil
4f0616190b doc update 2022-03-10 08:14:58 -08:00
Kelly Brazil
3278cb0de3 add type hints 2022-03-10 08:14:46 -08:00
Kelly Brazil
4fc04256a5 rollback noReturn to tuple 2022-03-10 08:00:37 -08:00
Kelly Brazil
e4ae0fea63 fix type annotation 2022-03-09 16:28:55 -08:00
Kelly Brazil
d3727ea090 doc update 2022-03-09 16:09:35 -08:00
Kelly Brazil
0d13909cf6 add pidstat-s parser 2022-03-09 16:07:29 -08:00
Kelly Brazil
c52ca20e28 fix comment 2022-03-09 16:07:17 -08:00
Kelly Brazil
21f27f26c8 add pidstat tests 2022-03-09 15:37:10 -08:00
Kelly Brazil
5e7a87f397 add test template 2022-03-09 15:37:04 -08:00
Kelly Brazil
845d763829 format docs to fit 80 columns 2022-03-09 15:09:22 -08:00
Kelly Brazil
f5c7d52ec7 formatting 2022-03-09 14:43:56 -08:00
Kelly Brazil
c3198a5874 formatting 2022-03-09 14:17:48 -08:00
Kelly Brazil
bbd4afa735 add pidstat to docs 2022-03-09 14:09:58 -08:00
Kelly Brazil
ae754a84bf doc update 2022-03-09 14:06:34 -08:00
Kelly Brazil
3389eb5deb initial working parser 2022-03-09 13:18:04 -08:00
Kelly Brazil
01f2c1e71f add pidstat parser 2022-03-09 12:13:32 -08:00
Kelly Brazil
8bfbf8f1bc simplify error message 2022-03-09 12:13:07 -08:00
Kelly Brazil
f4242669ba minor cleanup 2022-03-09 10:52:40 -08:00
Kelly Brazil
bebd9331f1 Merge pull request #211 from kellyjonbrazil/master
sync to dev
2022-03-09 18:49:01 +00:00
Kelly Brazil
ac61e9ad2c add pypi link 2022-03-08 13:21:05 -08:00
Kelly Brazil
648ef4d8a9 update badge links 2022-03-08 13:19:20 -08:00
Kelly Brazil
727fc9a701 doc update 2022-03-05 15:19:25 -08:00
Kelly Brazil
306512d6bb force AM/PM to uppercase in date parser 2022-03-05 15:13:47 -08:00
Kelly Brazil
6afb1d389c Merge pull request #209 from kellyjonbrazil/dev
Dev v1.18.4
2022-03-05 21:49:36 +00:00
Kelly Brazil
9861983481 doc update 2022-03-05 13:45:28 -08:00
Kelly Brazil
ca79053db0 document pydoc version 2022-03-05 12:15:47 -08:00
Kelly Brazil
29c263f878 pydoc formatting fixes 2022-03-05 12:15:14 -08:00
Kelly Brazil
128c3c170a doc update 2022-03-04 16:38:49 -08:00
Kelly Brazil
a531ab8864 formatting 2022-03-04 16:35:06 -08:00
Kelly Brazil
0c1be7cc11 reduce dig example size 2022-03-04 16:29:36 -08:00
Kelly Brazil
e4222b45f5 fix names to mod names 2022-03-04 16:24:13 -08:00
Kelly Brazil
ac32c69c31 formatting 2022-03-04 13:35:16 -08:00
Kelly Brazil
cb2dfeac8d change name to JSON Convert 2022-03-04 13:27:39 -08:00
Kelly Brazil
9a3602e70b doc update 2022-03-04 08:57:11 -08:00
Kelly Brazil
a9f53ee258 optimize streaming parser detection in cli 2022-03-03 17:50:19 -08:00
Kelly Brazil
6be3d3d982 doc update 2022-03-03 17:38:47 -08:00
Kelly Brazil
e49df72083 use streaming parser list to find streaming parsers 2022-03-03 17:37:01 -08:00
Kelly Brazil
7ede7be7bf add standard and streaming list functions 2022-03-03 17:36:40 -08:00
Kelly Brazil
4758e28a36 formatting 2022-03-02 15:24:18 -08:00
Kelly Brazil
4a1ee151b3 add dhcp6 options to docs 2022-03-02 10:57:09 -08:00
Kelly Brazil
8c8afc1a92 formatting 2022-03-02 10:15:01 -08:00
Kelly Brazil
ed205f7720 doc update 2022-02-28 12:55:05 -08:00
Kelly Brazil
d65f7ae992 add nmcli 2022-02-28 12:26:06 -08:00
Kelly Brazil
e2ffef57b9 fix test 2022-02-28 12:20:39 -08:00
Kelly Brazil
002caa9fb3 add fedora tests 2022-02-28 12:19:02 -08:00
Kelly Brazil
b7c6faf3da enhance error message 2022-02-25 11:23:20 -08:00
Kelly Brazil
554ca61d17 add tests 2022-02-25 11:19:20 -08:00
Kelly Brazil
7b9722d255 fix formatting 2022-02-24 21:21:02 -08:00
Kelly Brazil
5505bde8ef doc update 2022-02-24 20:53:54 -08:00
Kelly Brazil
dbcd9a4060 bump version to 1.0 2022-02-24 20:52:28 -08:00
Kelly Brazil
4bdeb2b3aa simplify warning message 2022-02-24 20:52:18 -08:00
Kelly Brazil
6ae1d03187 doc fix 2022-02-24 20:47:15 -08:00
Kelly Brazil
f75b06abe4 doc update 2022-02-24 20:43:20 -08:00
Kelly Brazil
1923925710 update changelog 2022-02-24 20:35:00 -08:00
Kelly Brazil
2c5c57ae04 version bump 2022-02-24 20:33:10 -08:00
Kelly Brazil
f4d11d697e finish use cases and doc 2022-02-24 20:31:58 -08:00
Kelly Brazil
7f409b7082 enhance ParseError cli message 2022-02-24 20:31:09 -08:00
Kelly Brazil
937fa5aad2 split dhcp options 2022-02-24 18:22:19 -08:00
Kelly Brazil
19dcef5135 firm up flow. add/remove text. parse routes 2022-02-24 17:10:39 -08:00
Kelly Brazil
3d01356461 add text_kv function 2022-02-24 14:53:26 -08:00
Kelly Brazil
2d6f666fa4 add dev show and conn show parsers 2022-02-24 12:21:13 -08:00
Kelly Brazil
4dda895f12 initial nmcli parser 2022-02-24 11:25:14 -08:00
Kelly Brazil
52617b1722 Merge pull request #208 from kellyjonbrazil/master
sync to dev
2022-02-21 16:35:12 +00:00
Kelly Brazil
961968a0fc fix schema 2022-02-14 15:14:22 -08:00
Kelly Brazil
f026a788e5 add xrandr example 2022-02-14 11:30:03 -08:00
Kelly Brazil
2f7c03eb35 Merge pull request #207 from kellyjonbrazil/dev
Dev v1.18.3
2022-02-14 10:36:08 -08:00
Kelly Brazil
3afaa48eee doc update 2022-02-14 10:31:41 -08:00
Kelly Brazil
3201452564 add -p to example 2022-02-14 10:06:09 -08:00
Kelly Brazil
7ee1e34fc7 doc update 2022-02-14 10:03:52 -08:00
Kelly Brazil
67dbf05016 add type annotations 2022-02-14 09:58:31 -08:00
Kelly Brazil
4ac9f2e3da doc update 2022-02-14 09:37:37 -08:00
Kelly Brazil
3f5f6e39a7 formatting 2022-02-14 09:20:16 -08:00
Kelly Brazil
4723db8e3c doc updates 2022-02-14 09:14:46 -08:00
Kelly Brazil
ca914ec77d add nodata test 2022-02-14 09:14:38 -08:00
Kelly Brazil
dcc7f3f357 Merge pull request #204 from lyterk/xrandr
New parser: xrandr
2022-02-13 17:45:53 -08:00
Kevin Lyter
cbdc666236 Return empty object if no results and filenames
- If no results are returned, return {} instead of {"screens": [],
"unassociated_devices": []}
- simple_xrandr -> xrandr_simple
2022-02-09 22:06:23 -08:00
Kelly Brazil
184ef3a1fa doc update 2022-02-08 14:45:33 -08:00
Kelly Brazil
c732f75944 doc update 2022-02-08 14:43:14 -08:00
Kelly Brazil
7a1ae4f5fc add library tests 2022-02-08 13:32:22 -08:00
Kelly Brazil
d04bc3757c add xrandr 2022-02-08 07:33:26 -08:00
Kelly Brazil
73e8391653 formatting 2022-02-07 16:58:06 -08:00
Kelly Brazil
f6c1463c15 formatting 2022-02-07 16:31:43 -08:00
Kelly Brazil
d392c7f901 doc update 2022-02-07 15:44:54 -08:00
Kelly Brazil
d0387f5820 add timestamp format hints for better performance 2022-02-07 15:44:46 -08:00
Kelly Brazil
76f92908a3 add format hints for performance optimization 2022-02-07 15:43:24 -08:00
Kelly Brazil
1a115da67b add lru_cache maxsize for python 3.7 support 2022-02-07 08:34:34 -08:00
Kelly Brazil
f0a37ccf30 use lru_cache for significant performance boost to timestamp 2022-02-07 08:30:11 -08:00
Kelly Brazil
f331f53a53 use !r formatting instead of quotes 2022-02-07 08:06:48 -08:00
Kelly Brazil
8611aff06b add examples 2022-02-07 06:42:35 -08:00
Kelly Brazil
2f3f78e8d3 refine streaming parsers 2022-02-07 06:29:17 -08:00
Kelly Brazil
d1e0ee6123 use new streaming functions 2022-02-06 08:56:18 -08:00
Kelly Brazil
45314c9808 move some functions to streaming 2022-02-06 08:55:42 -08:00
Kelly Brazil
df00945b46 move try/except inside for loop 2022-02-04 16:03:44 -08:00
Kelly Brazil
fda0050d86 add rsync-s tests 2022-02-04 14:39:45 -08:00
Kelly Brazil
a76d46f9ec refactor ignore_exceptions 2022-02-04 12:14:16 -08:00
Kevin Lyter
6b069a82d0 Add xrandr to lib.py 2022-02-03 22:40:40 -08:00
Kevin Lyter
6b793d0521 Clean up types
* | operator => Union[]
* Remove unused import Iterator
* Remove comment
2022-02-03 22:40:35 -08:00
Kevin Lyter
ce9103f7cc Delete old files in template folder 2022-02-03 18:12:46 -08:00
Kelly Brazil
671d6dee36 doc update 2022-02-03 15:47:46 -08:00
Kelly Brazil
49929c714c add add_jc_meta decorator 2022-02-03 15:44:18 -08:00
Kelly Brazil
2986771f07 require python v3.7 and above since v3.6 is now deprecated 2022-02-03 09:21:20 -08:00
Kevin Lyter
520082d963 New parser: xrandr
Tests passing, working as intended in plugin directory
2022-02-02 20:33:25 -08:00
Kelly Brazil
021e296d45 move variable inits and regexes up 2022-02-02 17:06:20 -08:00
Kelly Brazil
42e56fbcea move regex up 2022-02-02 17:05:53 -08:00
Kelly Brazil
a5b62a4055 add processing and docs 2022-02-02 16:03:14 -08:00
Kelly Brazil
be98c9b7f6 simplify try/except by moving outside for loop 2022-02-02 15:59:12 -08:00
Kelly Brazil
aceeb84507 doc update 2022-02-02 15:58:29 -08:00
Kelly Brazil
1391063217 first draft rsync streaming parser 2022-02-02 11:49:39 -08:00
Kelly Brazil
52157addd0 fix compatible list 2022-02-02 11:49:24 -08:00
Kelly Brazil
ec0bc6615e formatting 2022-02-01 19:20:19 -08:00
Kelly Brazil
2f80800e38 simplify all_parser_info comprehension 2022-02-01 19:06:41 -08:00
Kelly Brazil
3959d3347c doc update 2022-02-01 18:33:07 -08:00
Kelly Brazil
b57d25c69a clean up return type for parser_info 2022-02-01 18:30:37 -08:00
Kelly Brazil
63e43a7cab doc updates 2022-02-01 17:57:12 -08:00
Kelly Brazil
21719f9a26 type annotation updates 2022-02-01 17:54:22 -08:00
Kelly Brazil
96ec70de4f remove unneeded optional 2022-02-01 17:18:55 -08:00
Kelly Brazil
a15a1967dc fix typo 2022-02-01 17:18:39 -08:00
Kelly Brazil
a10d756629 fixy mypy issues 2022-02-01 16:49:31 -08:00
Kelly Brazil
0700dc7a64 remove cygwin from compatible 2022-02-01 16:42:51 -08:00
Kelly Brazil
ca654b2140 fix parser order 2022-02-01 16:42:10 -08:00
Kelly Brazil
4ff3b87c1c remove future field from docstring 2022-02-01 16:18:38 -08:00
Kelly Brazil
ea244fb7a9 formatting 2022-02-01 16:17:03 -08:00
Kelly Brazil
8061f30e6f add centos -i nochange test 2022-02-01 16:16:33 -08:00
Kelly Brazil
8f3b12e81e add fixes for mac -i output 2022-02-01 14:52:51 -08:00
Kelly Brazil
d0694ce0db add nochange log test for mac 2022-02-01 14:20:53 -08:00
Kelly Brazil
0cd4c4bc7f add nochange tests 2022-02-01 13:58:51 -08:00
Kelly Brazil
12f90c349c update regexes for unchanged files 2022-02-01 13:54:25 -08:00
Kelly Brazil
26b8a1f167 remove packages from binaries and packages header 2022-02-01 09:58:18 -08:00
Kelly Brazil
3abe382c06 add examples 2022-01-31 16:01:42 -08:00
Kelly Brazil
1e2edc2c7b add timestamp 2022-01-31 15:54:05 -08:00
Kelly Brazil
5fe032a674 fix typo 2022-01-31 13:44:44 -08:00
Kelly Brazil
e825c02df1 add rsync tests 2022-01-31 13:23:31 -08:00
Kelly Brazil
a4a4d170b5 update docstring 2022-01-31 13:23:22 -08:00
Kelly Brazil
d0fcd523cb fix process conversions 2022-01-31 11:13:23 -08:00
Kelly Brazil
f72b7dc75d change keyname to files and remove future key 2022-01-30 16:37:45 -08:00
Kelly Brazil
4101dc6bf7 add log-file support 2022-01-30 16:21:03 -08:00
Kelly Brazil
ea5011b616 updated schema. add log-file option support 2022-01-29 17:24:43 -08:00
Kelly Brazil
d6de81747f add int/float conversions 2022-01-28 15:00:05 -08:00
Kelly Brazil
38f04b1c96 add summary 2022-01-28 14:45:01 -08:00
Kelly Brazil
84169e1a91 add rsync parser 2022-01-28 14:08:43 -08:00
Kelly Brazil
1f96586a5e reorder imports 2022-01-28 14:08:21 -08:00
405 changed files with 312591 additions and 2069 deletions

104
CHANGELOG
View File

@@ -1,5 +1,59 @@
jc changelog
20220513 v1.19.0
- Add chage --list command parser tested on linux
- Add git log command streaming parser
- Fix git log standard parser for coner-cases where hash values are in messages
- Fix df command parser for rare instances when a newline is found at the end
- Allow jc to pip install on unsupported python version 3.6
- Fix asciitable-m parser to skip some rows that contain column separator
characters in cell data. A warning message will be printed to STDOUT
unless `-q` or `quiet=True` is used.
20220427 v1.18.8
- Fix update-alternatives --query parser for cases where `slaves` are not present
- Fix UnicodeEncodeError on some systems where LANG=C is set and unicode
characters are in the output
- Update history parser: do not drop non-ASCII characters if the system
is configured for UTF-8 encoding
- Enhance "magic syntax" to always use UTF-8 encoding
20220425 v1.18.7
- Add git log command parser
- Add update-alternatives --query parser
- Add update-alternatives --get-selections parser
- Fix key/value and ini parsers to allow duplicate keys
- Fix yaml file parser for files including timestamp objects
- Update xrandr parser: add a 'rotation' field
- Fix failing tests by moving template files
- Add python interpreter version and path to -v and -a output
20220325 v1.18.6
- Add pidstat command parser tested on linux
- Add pidstat command streaming parser tested on linux
- Add mpstat command parser tested on linux
- Add mpstat command streaming parser tested on linux
- Add single-line ASCII and Unicode table parser
- Add multi-line ASCII and Unicode table parser
- Add documentation option to parser_info() and all_parser_info()
20220305 v1.18.5
- Fix date parser to ensure AM/PM period string is always uppercase
20220304 v1.18.4
- Add nmcli command parser tested on linux
- Enhance parse error messages at the cli
- Add standard and streaming parser list functions to the public API
- Enhance python developer documentation formatting
20220214 v1.18.3
- Add rsync command and log file parser tested on linux and macOS
- Add rsync command and log file streaming parser tested on linux and macOS
- Add xrandr command parser tested on linux
- Enhance timestamp performance with caching and format hints
- Refactor ignore_exceptions functionality in streaming parsers
- Fix man page in packages
20220127 v1.18.2
- Fix for plugin parsers with underscores in the name
- Add type hints to public API functions
@@ -335,16 +389,16 @@ jc changelog
- Add axfr support for dig command parser
20200312 v1.9.2
- Updated arp parser to fix OSX detection for some edge cases
- Update arp parser to fix OSX detection for some edge cases
20200312 v1.9.1
- Updated file command parser to make filename splitting more robust
- Update file command parser to make filename splitting more robust
20200311 v1.9.0
- Added ntpq command parser
- Added timedatectl status command parser
- Added airport -I and airport -s command parser
- Added file command parser
- Add ntpq command parser
- Add timedatectl status command parser
- Add airport -I and airport -s command parser
- Add file command parser
- Optimized history command parser by https://github.com/philippeitis
- Magic syntax fix for certain edge cases
@@ -352,23 +406,23 @@ jc changelog
- CLI optimizations by https://github.com/philippeitis
- Refactored magic syntax function and added tests (https://github.com/philippeitis)
- Github actions for CI testing on multiple platforms by https://github.com/philippeitis
- Updated ls parser to fix parsing error in OSX with -lR when there are empty folders
- Update ls parser to fix parsing error in OSX with -lR when there are empty folders
20200303 v1.8.0
- Added blkid command parser
- Added last and lastb command parser
- Added who command parser
- Added CSV file parser
- Added /etc/passwd file parser
- Added /etc/shadow file parser
- Added /etc/group file parser
- Added /etc/gshadow file parser
- Add blkid command parser
- Add last and lastb command parser
- Add who command parser
- Add CSV file parser
- Add /etc/passwd file parser
- Add /etc/shadow file parser
- Add /etc/group file parser
- Add /etc/gshadow file parser
20200227 v1.7.5
- Updated ls parser to support filenames with newline characters
- Update ls parser to support filenames with newline characters
20200219 v1.7.4
- Updated ls parser to support multiple directories, globbing, and -R (recursive)
- Update ls parser to support multiple directories, globbing, and -R (recursive)
20200211 v1.7.3
- Add alternative 'magic' syntax: e.g. `jc ls -al`
@@ -385,8 +439,8 @@ jc changelog
- Add crontab file parser with user support (tested on linux)
- Add __version__ variable to parser modules
- Add exit code on error
- Updated history parser to output "line" as an integer
- Updated compatibility list for some parsers
- Update history parser to output "line" as an integer
- Update compatibility list for some parsers
- Bugfix in crontab file parser: header insertion was clobbering first row
- Just-in-time loading of parser modules instead of loading all at start
@@ -399,7 +453,7 @@ jc changelog
- Add tests for ls, dig, ps, w, uptime on OSX
- Add about option
- Add universal parsers to refactor repetitive code
- Updated ifconfig parser to output 'state' as an array
- Update ifconfig parser to output 'state' as an array
20191117 v1.5.1
- Add ss parser
@@ -412,11 +466,11 @@ jc changelog
- Add -d option to debug parsing issues
- Add compatibility warnings to stderr
- Add documentation
- Updated iptables parser to allow --line-numbers option
- Updated lsblk parser to allow parsing of added columns
- Updated mount parser: changed 'access' field name to 'options'
- Updated netstat parser to allow parsing of unix sockets and raw network connections
- Updated w parser to fix unaligned data where blanks are possible
- Update iptables parser to allow --line-numbers option
- Update lsblk parser to allow parsing of added columns
- Update mount parser: changed 'access' field name to 'options'
- Update netstat parser to allow parsing of unix sockets and raw network connections
- Update w parser to fix unaligned data where blanks are possible
- Clean up code and reorganize package
20191031 v1.1.1

View File

@@ -265,6 +265,21 @@ blkid -o udev -ip /dev/sda2 | jc --blkid -p # or: jc -p blkid -o udev
}
]
```
### chage --list
```bash
chage --list joeuser | jc --chage -p # or: jc -p chage --list joeuser
```
```json
{
"password_last_changed": "never",
"password_expires": "never",
"password_inactive": "never",
"account_expires": "never",
"min_days_between_password_change": 0,
"max_days_between_password_change": 99999,
"warning_days_before_password_expires": 7
}
```
### cksum
```bash
cksum * | jc --cksum -p # or: jc -p cksum *
@@ -1059,6 +1074,53 @@ cat /etc/fstab | jc --fstab -p
}
]
```
### git log
```bash
git log --stat | jc --git-log -p or: jc -p git log --stat
```
```json
[
{
"commit": "728d882ed007b3c8b785018874a0eb06e1143b66",
"author": "Kelly Brazil",
"author_email": "kellyjonbrazil@gmail.com",
"date": "Wed Apr 20 09:50:19 2022 -0400",
"stats": {
"files_changed": 2,
"insertions": 90,
"deletions": 12,
"files": [
"docs/parsers/git_log.md",
"jc/parsers/git_log.py"
]
},
"message": "add timestamp docs and examples",
"epoch": 1650462619,
"epoch_utc": null
},
{
"commit": "b53e42aca623181aa9bc72194e6eeef1e9a3a237",
"author": "Kelly Brazil",
"author_email": "kellyjonbrazil@gmail.com",
"date": "Wed Apr 20 09:44:42 2022 -0400",
"stats": {
"files_changed": 5,
"insertions": 29,
"deletions": 6,
"files": [
"docs/parsers/git_log.md",
"docs/utils.md",
"jc/parsers/git_log.py",
"jc/utils.py",
"man/jc.1"
]
},
"message": "add calculated timestamp",
"epoch": 1650462282,
"epoch_utc": null
}
]
```
### /etc/group file
```bash
cat /etc/group | jc --group -p
@@ -2149,6 +2211,29 @@ mount | jc --mount -p # or: jc -p mount
}
]
```
### mpstat
```bash
mpstat | jc --mpstat -p # or jc -p mpstat
```
```json
[
{
"cpu": "all",
"percent_usr": 12.94,
"percent_nice": 0.0,
"percent_sys": 26.42,
"percent_iowait": 0.43,
"percent_irq": 0.0,
"percent_soft": 0.16,
"percent_steal": 0.0,
"percent_guest": 0.0,
"percent_gnice": 0.0,
"percent_idle": 60.05,
"type": "cpu",
"time": "01:58:14 PM"
}
]
```
### netstat
```bash
netstat -apee | jc --netstat -p # or: jc -p netstat -apee
@@ -2387,6 +2472,47 @@ netstat -i | jc --netstat -p # or: jc -p netstat -i
}
]
```
### nmcli
```bash
nmcli connection show ens33 | jc --nmcli -p # or jc -p nmcli connection show ens33
```
```json
[
{
"connection_id": "ens33",
"connection_uuid": "d92ece08-9e02-47d5-b2d2-92c80e155744",
"connection_stable_id": null,
"connection_type": "802-3-ethernet",
"connection_interface_name": "ens33",
"connection_autoconnect": "yes",
"ip4_address_1": "192.168.71.180/24",
"ip4_gateway": "192.168.71.2",
"ip4_route_1": {
"dst": "0.0.0.0/0",
"nh": "192.168.71.2",
"mt": 100
},
"ip4_route_2": {
"dst": "192.168.71.0/24",
"nh": "0.0.0.0",
"mt": 100
},
"ip4_dns_1": "192.168.71.2",
"ip4_domain_1": "localdomain",
"dhcp4_option_1": {
"name": "broadcast_address",
"value": "192.168.71.255"
},
"ip6_address_1": "fe80::c1cb:715d:bc3e:b8a0/64",
"ip6_gateway": null,
"ip6_route_1": {
"dst": "fe80::/64",
"nh": "::",
"mt": 100
}
}
]
```
### ntpq
```bash
ntpq -p | jc --ntpq -p # or: jc -p ntpq -p
@@ -2456,6 +2582,47 @@ cat /etc/passwd | jc --passwd -p
}
]
```
### pidstat
```bash
pidstat -hl | jc --pidstat -p # or jc -p pidstat -hl
```
```json
[
{
"time": 1646859134,
"uid": 0,
"pid": 1,
"percent_usr": 0.0,
"percent_system": 0.03,
"percent_guest": 0.0,
"percent_cpu": 0.03,
"cpu": 0,
"command": "/usr/lib/systemd/systemd --switched-root --system..."
},
{
"time": 1646859134,
"uid": 0,
"pid": 6,
"percent_usr": 0.0,
"percent_system": 0.0,
"percent_guest": 0.0,
"percent_cpu": 0.0,
"cpu": 0,
"command": "ksoftirqd/0"
},
{
"time": 1646859134,
"uid": 0,
"pid": 2263,
"percent_usr": 0.0,
"percent_system": 0.0,
"percent_guest": 0.0,
"percent_cpu": 0.0,
"cpu": 0,
"command": "kworker/0:0"
}
]
```
### ping
```bash
ping 8.8.8.8 -c 3 | jc --ping -p # or: jc -p ping 8.8.8.8 -c 3
@@ -2743,6 +2910,39 @@ rpm_qia | jc --rpm_qi -p # or: jc -p rpm -qia
}
]
```
### rsync
```bash
rsync -i -a source/ dest | jc --rsync -p # or jc -p rsync -i -a source/ dest
```
```json
[
{
"summary": {
"sent": 1708,
"received": 8209,
"bytes_sec": 19834.0,
"total_size": 235,
"speedup": 0.02
},
"files": [
{
"filename": "./",
"metadata": ".d..t......",
"update_type": "not updated",
"file_type": "directory",
"checksum_or_value_different": false,
"size_different": false,
"modification_time_different": true,
"permissions_different": false,
"owner_different": false,
"group_different": false,
"acl_different": false,
"extended_attribute_different": false
}
]
}
]
```
### sfdisk
```bash
sfdisk -l | jc --sfdisk -p # or jc -p sfdisk -l
@@ -3507,6 +3707,69 @@ uname -a | jc --uname -p # or: jc -p uname -a
"kernel_version": "#74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019"
}
```
### update-alternatives --get-selections
```bash
update-alternatives --get-selections | jc --update-alt-gs -p # or: jc -p update-alternatives --get-selections
```
```json
[
{
"name": "arptables",
"status": "auto",
"current": "/usr/sbin/arptables-nft"
},
{
"name": "awk",
"status": "auto",
"current": "/usr/bin/gawk"
}
]
```
### update-alternatives --query
```bash
update-alternatives --query editor | jc --update-alt-q -p # or: jc -p update-alternatives --query editor
```
```json
{
"name": "editor",
"link": "/usr/bin/editor",
"slaves": [
{
"name": "editor.1.gz",
"path": "/usr/share/man/man1/editor.1.gz"
},
{
"name": "editor.da.1.gz",
"path": "/usr/share/man/da/man1/editor.1.gz"
}
],
"status": "auto",
"best": "/bin/nano",
"value": "/bin/nano",
"alternatives": [
{
"name": "/bin/ed",
"priority": -100,
"slaves": [
{
"name": "editor.1.gz",
"path": "/usr/share/man/man1/ed.1.gz"
}
]
},
{
"name": "/bin/nano",
"priority": 40,
"slaves": [
{
"name": "editor.1.gz",
"path": "/usr/share/man/man1/nano.1.gz"
}
]
}
]
}
```
### upower
```bash
upower -i /org/freedesktop/UPower/devices/battery | jc --upower -p # or jc -p upower -i /org/freedesktop/UPower/devices/battery
@@ -3751,6 +4014,68 @@ cat cd_catalog.xml | jc --xml -p
}
}
```
### xrandr
```bash
$ xrandr | jc --xrandr -p # or jc -p xrandr
```
```json
{
"screens": [
{
"screen_number": 0,
"minimum_width": 8,
"minimum_height": 8,
"current_width": 1920,
"current_height": 1080,
"maximum_width": 32767,
"maximum_height": 32767,
"associated_device": {
"associated_modes": [
{
"resolution_width": 1920,
"resolution_height": 1080,
"is_high_resolution": false,
"frequencies": [
{
"frequency": 60.03,
"is_current": true,
"is_preferred": true
},
{
"frequency": 59.93,
"is_current": false,
"is_preferred": false
}
]
},
{
"resolution_width": 1680,
"resolution_height": 1050,
"is_high_resolution": false,
"frequencies": [
{
"frequency": 59.88,
"is_current": false,
"is_preferred": false
}
]
}
],
"is_connected": true,
"is_primary": true,
"device_name": "eDP1",
"resolution_width": 1920,
"resolution_height": 1080,
"offset_width": 0,
"offset_height": 0,
"dimension_width": 310,
"dimension_height": 170
}
}
],
"unassociated_devices": []
}
```
### YAML files
```bash
cat istio.yaml

253
README.md
View File

@@ -1,7 +1,5 @@
![Tests](https://github.com/kellyjonbrazil/jc/workflows/Tests/badge.svg?branch=master)
![Pypi](https://img.shields.io/pypi/v/jc.svg)
> `jc` was recently featured in the [Console Open Source Newsletter](https://console.substack.com/p/console-89)
[![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
@@ -13,7 +11,7 @@ Ansible filter plugin in the `community.general` collection. See this
for an example.
# JC
JSON CLI output utility
JSON Convert
`jc` JSONifies the output of many CLI tools and file-types for easier parsing in
scripts. See the [**Parsers**](#parsers) section for supported commands and
@@ -55,16 +53,9 @@ will be a python dictionary, or list of dictionaries, instead of JSON:
>>> cmd_output = subprocess.check_output(['dig', 'example.com'], text=True)
>>> data = jc.parse('dig', cmd_output)
>>>
>>> data
[{'id': 64612, 'opcode': 'QUERY', 'status': 'NOERROR', 'flags': ['qr', 'rd',
'ra'], 'query_num': 1, 'answer_num': 1, 'authority_num': 0, 'additional_num':
1, 'opt_pseudosection': {'edns': {'version': 0, 'flags': [], 'udp': 4096}},
'question': {'name': 'example.com.', 'class': 'IN', 'type': 'A'}, 'answer':
>>> data[0]['answer']
[{'name': 'example.com.', 'class': 'IN', 'type': 'A', 'ttl': 29658, 'data':
'93.184.216.34'}], 'query_time': 52, 'server':
'2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)', 'when':
'Fri Apr 16 16:13:00 PDT 2021', 'rcvd': 56, 'when_epoch': 1618614780,
'when_epoch_utc': None}]
'93.184.216.34'}]
```
> For `jc` Python package documentation, use `help('jc')`, `help('jc.lib')`, or
@@ -108,27 +99,29 @@ correct [binary](https://github.com/kellyjonbrazil/jc/releases) for your
architecture and running it anywhere on your filesystem.
### Pip (macOS, linux, unix, Windows)
[![Pypi](https://img.shields.io/pypi/v/jc.svg)](https://pypi.org/project/jc/)
```bash
pip3 install jc
```
### OS Package Repositories
| OS | Command |
|-----------------------|-------------------------------------------------------------------------------|
| Debian/Ubuntu linux | `apt-get install jc` |
| Fedora linux | `dnf install jc` |
| openSUSE linux | `zypper install jc` |
| Arch linux | `pacman -S jc` |
| NixOS linux | `nix-env -iA nixpkgs.jc` or `nix-env -iA nixos.jc` |
| Guix System linux | `guix install jc` |
| macOS | `brew install jc` |
| FreeBSD | `portsnap fetch update && cd /usr/ports/textproc/py-jc && make install clean` |
| Ansible filter plugin | `ansible-galaxy collection install community.general` |
| OS | Command |
|--------------------------------------|-------------------------------------------------------------------------------|
| Debian/Ubuntu linux | `apt-get install jc` |
| Fedora linux | `dnf install jc` |
| openSUSE linux | `zypper install jc` |
| Archlinux Community Repository | `paru -S jc` or `aura -S jc` or `yay -S jc` |
| NixOS linux | `nix-env -iA nixpkgs.jc` or `nix-env -iA nixos.jc` |
| Guix System linux | `guix install jc` |
| Gentoo Linux | `emerge dev-python/jc` |
| macOS | `brew install jc` |
| FreeBSD | `portsnap fetch update && cd /usr/ports/textproc/py-jc && make install clean` |
| Ansible filter plugin | `ansible-galaxy collection install community.general` |
> For more OS Packages, see https://repology.org/project/jc/versions.
### Binaries and Packages
### Binaries
For precompiled binaries, see [Releases](https://github.com/kellyjonbrazil/jc/releases)
on Github.
@@ -151,91 +144,108 @@ option.
### Parsers
- `--acpi` enables the `acpi` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/acpi))
- `--airport` enables the `airport -I` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/airport))
- `--airport-s` enables the `airport -s` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/airport_s))
- `--arp` enables the `arp` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/arp))
- `--blkid` enables the `blkid` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/blkid))
- `--cksum` enables the `cksum` and `sum` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/cksum))
- `--crontab` enables the `crontab` command and file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/crontab))
- `--crontab-u` enables the `crontab` file parser with user support ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/crontab_u))
- `--csv` enables the CSV file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/csv))
- `--csv-s` enables the CSV file streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/csv_s))
- `--date` enables the `date` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/date))
- `--df` enables the `df` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/df))
- `--dig` enables the `dig` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/dig))
- `--dir` enables the `dir` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/dir))
- `--dmidecode` enables the `dmidecode` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/dmidecode))
- `--dpkg-l` enables the `dpkg -l` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/dpkg_l))
- `--du` enables the `du` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/du))
- `--env` enables the `env` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/env))
- `--file` enables the `file` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/file))
- `--finger` enables the `finger` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/finger))
- `--free` enables the `free` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/free))
- `--fstab` enables the `/etc/fstab` file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/fstab))
- `--group` enables the `/etc/group` file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/group))
- `--gshadow` enables the `/etc/gshadow` file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/gshadow))
- `--hash` enables the `hash` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/hash))
- `--hashsum` enables the hashsum command parser (`md5sum`, `shasum`, etc.) ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/hashsum))
- `--hciconfig` enables the `hciconfig` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/hciconfig))
- `--history` enables the `history` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/history))
- `--hosts` enables the `/etc/hosts` file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/hosts))
- `--id` enables the `id` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/id))
- `--ifconfig` enables the `ifconfig` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ifconfig))
- `--ini` enables the INI file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ini))
- `--iostat` enables the `iostat` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat))
- `--iostat-s` enables the `iostat` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat_s))
- `--iptables` enables the `iptables` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/iptables))
- `--iw-scan` enables the `iw dev [device] scan` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/iw_scan))
- `--jar-manifest` enables the MANIFEST.MF file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/jar_manifest))
- `--jobs` enables the `jobs` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/jobs))
- `--kv` enables the Key/Value file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/kv))
- `--last` enables the `last` and `lastb` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/last))
- `--ls` enables the `ls` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ls))
- `--ls-s` enables the `ls` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ls_s))
- `--lsblk` enables the `lsblk` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/lsblk))
- `--lsmod` enables the `lsmod` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/lsmod))
- `--lsof` enables the `lsof` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/lsof))
- `--lsusb` enables the `lsusb` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/lsusb))
- `--mount` enables the `mount` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/mount))
- `--netstat` enables the `netstat` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/netstat))
- `--ntpq` enables the `ntpq -p` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ntpq))
- `--passwd` enables the `/etc/passwd` file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/passwd))
- `--ping` enables the `ping` and `ping6` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ping))
- `--ping-s` enables the `ping` and `ping6` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ping_s))
- `--pip-list` enables the `pip list` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/pip_list))
- `--pip-show` enables the `pip show` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/pip_show))
- `--ps` enables the `ps` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ps))
- `--route` enables the `route` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/route))
- `--rpm-qi` enables the `rpm -qi` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/rpm_qi))
- `--sfdisk` enables the `sfdisk` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/sfdisk))
- `--shadow` enables the `/etc/shadow` file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/shadow))
- `--ss` enables the `ss` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ss))
- `--stat` enables the `stat` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/stat))
- `--stat-s` enables the `stat` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/stat_s))
- `--sysctl` enables the `sysctl` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/sysctl))
- `--systemctl` enables the `systemctl` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl))
- `--systemctl-lj` enables the `systemctl list-jobs` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl_lj))
- `--systemctl-ls` enables the `systemctl list-sockets` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl_ls))
- `--systemctl-luf` enables the `systemctl list-unit-files` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl_luf))
- `--systeminfo` enables the `systeminfo` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/systeminfo))
- `--time` enables the `/usr/bin/time` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/time))
- `--timedatectl` enables the `timedatectl status` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/timedatectl))
- `--tracepath` enables the `tracepath` and `tracepath6` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/tracepath))
- `--traceroute` enables the `traceroute` and `traceroute6` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/traceroute))
- `--ufw` enables the `ufw status` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw))
- `--ufw-appinfo` enables the `ufw app info [application]` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw_appinfo))
- `--uname` enables the `uname -a` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/uname))
- `--upower` enables the `upower` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/upower))
- `--uptime` enables the `uptime` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/uptime))
- `--vmstat` enables the `vmstat` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/vmstat))
- `--vmstat-s` enables the `vmstat` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/vmstat_s))
- `--w` enables the `w` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/w))
- `--wc` enables the `wc` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/wc))
- `--who` enables the `who` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/who))
- `--xml` enables the XML file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/xml))
- `--yaml` enables the YAML file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/yaml))
- `--zipinfo` enables the `zipinfo` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/zipinfo))
| Argument | Command or Filetype | Documentation |
|--------------|-------------------------|-------------------|
| `--acpi` | `acpi` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/acpi) |
| `--airport` | `airport -I` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/airport) |
| `--airport-s` | `airport -s` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/airport_s) |
| `--arp` | `arp` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/arp) |
| `--asciitable` | ASCII and Unicode table parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/asciitable) |
| `--asciitable-m` | multi-line ASCII and Unicode table parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/asciitable_m) |
| `--blkid` | `blkid` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/blkid) |
| `--chage` | `chage --list` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/chage) |
| `--cksum` | `cksum` and `sum` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/cksum) |
| `--crontab` | `crontab` command and file parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/crontab) |
| `--crontab-u` | `crontab` file parser with user support | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/crontab_u) |
| `--csv` | CSV file parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/csv) |
| `--csv-s` | CSV file streaming parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/csv_s) |
| `--date` | `date` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/date) |
| `--df` | `df` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/df) |
| `--dig` | `dig` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/dig) |
| `--dir` | `dir` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/dir) |
| `--dmidecode` | `dmidecode` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/dmidecode) |
| `--dpkg-l` | `dpkg -l` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/dpkg_l) |
| `--du` | `du` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/du) |
| `--env` | `env` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/env) |
| `--file` | `file` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/file) |
| `--finger` | `finger` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/finger) |
| `--free` | `free` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/free) |
| `--fstab` | `/etc/fstab` file parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/fstab) |
| `--git-log` | `git log` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/git_log) |
| `--git-log-s` | `git log` command streaming parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/git_log_s) |
| `--group` | `/etc/group` file parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/group) |
| `--gshadow` | `/etc/gshadow` file parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/gshadow) |
| `--hash` | `hash` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/hash) |
| `--hashsum` | hashsum command parser (`md5sum`, `shasum`, etc.) | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/hashsum) |
| `--hciconfig` | `hciconfig` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/hciconfig) |
| `--history` | `history` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/history) |
| `--hosts` | `/etc/hosts` file parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/hosts) |
| `--id` | `id` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/id) |
| `--ifconfig` | `ifconfig` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/ifconfig) |
| `--ini` | INI file parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/ini) |
| `--iostat` | `iostat` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat) |
| `--iostat-s` | `iostat` command streaming parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat_s) |
| `--iptables` | `iptables` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/iptables) |
| `--iw-scan` | `iw dev [device] scan` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/iw_scan) |
| `--jar-manifest` | MANIFEST.MF file parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/jar_manifest) |
| `--jobs` | `jobs` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/jobs) |
| `--kv` | Key/Value file parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/kv) |
| `--last` | `last` and `lastb` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/last) |
| `--ls` | `ls` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/ls) |
| `--ls-s` | `ls` command streaming parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/ls_s) |
| `--lsblk` | `lsblk` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/lsblk) |
| `--lsmod` | `lsmod` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/lsmod) |
| `--lsof` | `lsof` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/lsof) |
| `--lsusb` | `lsusb` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/lsusb) |
| `--mount` | `mount` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/mount) |
| `--mpstat` | `mpstat` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/mpstat) |
| `--mpstat-s` | `mpstat` command streaming parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/mpstat_s) |
| `--netstat` | `netstat` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/netstat) |
| `--nmcli` | `nmcli` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/nmcli) |
| `--ntpq` | `ntpq -p` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/ntpq) |
| `--passwd` | `/etc/passwd` file parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/passwd) |
| `--pidstat` | `pidstat` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/pidstat) |
| `--pidstat-s` | `pidstat` command streaming parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/pidstat_s) |
| `--ping` | `ping` and `ping6` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/ping) |
| `--ping-s` | `ping` and `ping6` command streaming parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/ping_s) |
| `--pip-list` | `pip list` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/pip_list) |
| `--pip-show` | `pip show` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/pip_show) |
| `--ps` | `ps` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/ps) |
| `--route` | `route` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/route) |
| `--rpm-qi` | `rpm -qi` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/rpm_qi) |
| `--rsync` | `rsync` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/rsync) |
| `--rsync-s` | `rsync` command streaming parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/rsync_s) |
| `--sfdisk` | `sfdisk` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/sfdisk) |
| `--shadow` | `/etc/shadow` file parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/shadow) |
| `--ss` | `ss` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/ss) |
| `--stat` | `stat` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/stat) |
| `--stat-s` | `stat` command streaming parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/stat_s) |
| `--sysctl` | `sysctl` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/sysctl) |
| `--systemctl` | `systemctl` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl) |
| `--systemctl-lj` | `systemctl list-jobs` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl_lj) |
| `--systemctl-ls` | `systemctl list-sockets` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl_ls) |
| `--systemctl-luf` | `systemctl list-unit-files` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl_luf) |
| `--systeminfo` | `systeminfo` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/systeminfo) |
| `--time` | `/usr/bin/time` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/time) |
| `--timedatectl` | `timedatectl status` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/timedatectl) |
| `--tracepath` | `tracepath` and `tracepath6` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/tracepath) |
| `--traceroute` | `traceroute` and `traceroute6` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/traceroute) |
| `--ufw` | `ufw status` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw) |
| `--ufw-appinfo` | `ufw app info [application]` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw_appinfo) |
| `--uname` | `uname -a` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/uname) |
| `--update-alt-gs` | `update-alternatives --get-selections` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/update_alt_gs) |
| `--update-alt-q` | `update-alternatives --query` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/update_alt_q) |
| `--upower` | `upower` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/upower) |
| `--uptime` | `uptime` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/uptime) |
| `--vmstat` | `vmstat` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/vmstat) |
| `--vmstat-s` | `vmstat` command streaming parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/vmstat_s) |
| `--w` | `w` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/w) |
| `--wc` | `wc` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/wc) |
| `--who` | `who` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/who) |
| `--xml` | XML file parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/xml) |
| `--xrandr` | `xrandr` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/xrandr) |
| `--yaml` | YAML file parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/yaml) |
| `--zipinfo` | `zipinfo` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/zipinfo) |
### Options
- `-a` about `jc`. Prints information about `jc` and the parsers (in JSON, of
@@ -368,14 +378,14 @@ $ ping 1.1.1.1 | jc --ping-s -u | jq
#### Using Streaming Parsers as Python Modules
Streaming parsers accept any iterable object and return an iterator object
(generator) allowing lazy processing of the data. The input data should
iterate on lines of string data. Examples of good input data are `sys.stdin` or
Streaming parsers accept any iterable object and return an iterable object
allowing lazy processing of the data. The input data should iterate on lines
of string data. Examples of good input data are `sys.stdin` or
`str.splitlines()`.
To use the generator object in your code, simply loop through it or use the
[next()](https://docs.python.org/3/library/functions.html#next) builtin
function:
To use the returned iterable object in your code, simply loop through it or
use the [next()](https://docs.python.org/3/library/functions.html#next)
builtin function:
```python
import jc
@@ -397,9 +407,9 @@ Local parser plugins are standard python module files. Use the
or [`jc/parsers/foo_s.py (streaming)`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo_s.py)
parser as a template and simply place a `.py` file in the `jcparsers` subfolder.
Local plugin filenames must be valid python module names, therefore must consist
entirely of alphanumerics and start with a letter. Local plugins may override
default parsers.
Local plugin filenames must be valid python module names and therefore must
start with a letter and consist entirely of alphanumerics and underscores.
Local plugins may override default parsers.
> Note: The application data directory follows the
[XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)
@@ -419,6 +429,9 @@ or by exporting to the environment before running commands:
$ export LANG=C
```
On some older systems UTF-8 output will be downgraded to ASCII with `\\u`
escape sequences if the `C` locale does not support UTF-8 encoding.
#### Timezones
Some parsers have calculated epoch timestamp fields added to the output. Unless

View File

@@ -1,6 +1,6 @@
#!/bin/bash
# Generate docs.md
# requires pydoc-markdown 4.5.0
# requires pydoc-markdown 4.6.1
readme_config=$(cat <<'EOF'
{
"processors": [
@@ -18,7 +18,7 @@ readme_config=$(cat <<'EOF'
"Class": 3,
"Method": 3,
"Function": 3,
"Data": 3
"Variable": 3
}
}
}
@@ -43,7 +43,7 @@ toc_config=$(cat <<'EOF'
"Class": 3,
"Method": 3,
"Function": 3,
"Data": 3
"Variable": 3
}
}
}
@@ -68,7 +68,7 @@ parser_config=$(cat <<'EOF'
"Class": 3,
"Method": 3,
"Function": 3,
"Data": 3
"Variable": 3
}
}
}
@@ -76,17 +76,30 @@ EOF
)
cd jc
echo Building docs for: package
pydoc-markdown -m jc "${readme_config}" > ../docs/readme.md
(
echo Building docs for: package
pydoc-markdown -m jc "${readme_config}" > ../docs/readme.md; echo "+++ package docs complete"
) &
echo Building docs for: lib
pydoc-markdown -m jc.lib "${toc_config}" > ../docs/lib.md
(
echo Building docs for: lib
pydoc-markdown -m jc.lib "${toc_config}" > ../docs/lib.md; echo "+++ lib docs complete"
) &
echo Building docs for: utils
pydoc-markdown -m jc.utils "${toc_config}" > ../docs/utils.md
(
echo Building docs for: utils
pydoc-markdown -m jc.utils "${toc_config}" > ../docs/utils.md; echo "+++ utils docs complete"
) &
echo Building docs for: universal parser
pydoc-markdown -m jc.parsers.universal "${toc_config}" > ../docs/parsers/universal.md
(
echo Building docs for: streaming
pydoc-markdown -m jc.streaming "${toc_config}" > ../docs/streaming.md; echo "+++ streaming docs complete"
) &
(
echo Building docs for: universal parser
pydoc-markdown -m jc.parsers.universal "${toc_config}" > ../docs/parsers/universal.md; echo "+++ universal parser docs complete"
) &
# a bit of inception here... jc is being used to help
# automate the generation of its own documentation. :)
@@ -100,7 +113,7 @@ do
done < <(jc -a | jq -c '.parsers[] | select(.plugin != true)')
for parser in "${parsers[@]}"
do
do (
parser_name=$(jq -r '.name' <<< "$parser")
compatible=$(jq -r '.compatible | join(", ")' <<< "$parser")
version=$(jq -r '.version' <<< "$parser")
@@ -114,4 +127,8 @@ do
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"
) &
done
wait
echo "Document Generation Complete"

View File

@@ -4,6 +4,8 @@
* [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)
@@ -12,15 +14,19 @@
# jc.lib
jc - JSON CLI output utility
JC lib module
jc - JSON Convert lib module
<a id="jc.lib.parse"></a>
### parse
```python
def parse(parser_mod_name: str, data: Union[str, Iterable[str]], quiet: bool = False, raw: bool = False, ignore_exceptions: bool = None, **kwargs) -> Union[Dict, List[Dict], Iterator[Dict]]
def parse(parser_mod_name: str,
data: Union[str, Iterable[str]],
quiet: bool = False,
raw: bool = False,
ignore_exceptions: bool = None,
**kwargs) -> Union[Dict, List[Dict], Iterator[Dict]]
```
Parse the string data using the supplied parser module.
@@ -34,9 +40,7 @@ Example:
>>> jc.parse('date', 'Tue Jan 18 10:23:07 PST 2022')
{'year': 2022, 'month': 'Jan', 'month_num': 1, 'day'...}
To get a list of available parser module names, use `parser_mod_list()`
or `plugin_parser_mod_list()`. `plugin_parser_mod_list()` is a subset
of `parser_mod_list()`.
To get a list of available parser module names, use `parser_mod_list()`.
You can also use the lower-level parser modules directly:
@@ -64,7 +68,7 @@ Parameters:
variants of the module name.
data: (string or data to parse (string for normal
iterator) parsers, iterator of strings for
iterable) parsers, iterable of strings for
streaming parsers)
raw: (boolean) output preprocessed JSON if True
@@ -100,28 +104,62 @@ def plugin_parser_mod_list() -> 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() -> 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() -> 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
```python
def parser_info(parser_mod_name: str) -> Union[Dict, None]
def parser_info(parser_mod_name: str, documentation: bool = False) -> Dict
```
Returns a dictionary that includes the module metadata.
Returns a dictionary that includes the parser module metadata.
This function will accept **module_name**, **cli-name**, and
**--argument-name** variants of the module name string.
Parameters:
parser_mod_name: (string) name of the parser module. This
function will accept module_name,
cli-name, and --argument-name
variants of the module name.
documentation: (boolean) include parser docstring if True
<a id="jc.lib.all_parser_info"></a>
### all\_parser\_info
```python
def all_parser_info() -> List[Optional[Dict]]
def all_parser_info(documentation: bool = False) -> List[Dict]
```
Returns a list of dictionaris that includes metadata for all modules.
Returns a list of dictionaries that includes metadata for all parser
modules.
Parameters:
documentation: (boolean) include parser docstrings if True
<a id="jc.lib.get_help"></a>

View File

@@ -3,7 +3,7 @@
# jc.parsers.acpi
jc - JSON CLI output utility `acpi` command output parser
jc - JSON Convert `acpi` command output parser
Usage (cli):
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('acpi', acpi_command_output)
or
import jc.parsers.acpi
result = jc.parsers.acpi.parse(acpi_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.airport
jc - JSON CLI output utility `airport -I` command output parser
jc - JSON Convert `airport -I` command output parser
The `airport` program can be found at `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport`.
@@ -20,11 +20,6 @@ Usage (module):
import jc
result = jc.parse('airport', airport_command_output)
or
import jc.parsers.airport
result = jc.parsers.airport.parse(airport_command_output)
Schema:
{

View File

@@ -3,7 +3,7 @@
# jc.parsers.airport\_s
jc - JSON CLI output utility `airport -s` command output parser
jc - JSON Convert `airport -s` command output parser
The `airport` program can be found at `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport`.
@@ -20,11 +20,6 @@ Usage (module):
import jc
result = jc.parse('airport_s', airport_s_command_output)
or
import jc.parsers.airport_s
result = jc.parsers.airport_s.parse(airport_s_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.arp
jc - JSON CLI output utility `arp` command output parser
jc - JSON Convert `arp` command output parser
Supports `arp` and `arp -a` output.
@@ -20,11 +20,6 @@ Usage (module):
import jc
result = jc.parse('arp', arp_command_output)
or
import jc.parsers.arp
result = jc.parsers.arp.parse(arp_command_output)
Schema:
[
@@ -127,7 +122,7 @@ Examples:
### parse
```python
def parse(data, raw=False, quiet=False)
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
```
Main text parsing function
@@ -145,4 +140,4 @@ Returns:
### Parser Information
Compatibility: linux, aix, freebsd, darwin
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)

139
docs/parsers/asciitable.md Normal file
View File

@@ -0,0 +1,139 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.asciitable"></a>
# jc.parsers.asciitable
jc - JSON Convert `asciitable` parser
This parser converts ASCII and Unicode text tables with single-line rows.
Column headers must be at least two spaces apart from each other and must
be unique.
For example:
╒══════════╤═════════╤════════╕
│ foo │ bar │ baz │
╞══════════╪═════════╪════════╡
│ good day │ │ 12345 │
├──────────┼─────────┼────────┤
│ hi there │ abc def │ 3.14 │
╘══════════╧═════════╧════════╛
or
+-----------------------------+
| foo bar baz |
+-----------------------------+
| good day 12345 |
| hi there abc def 3.14 |
+-----------------------------+
or
| foo | bar | baz |
|----------|---------|--------|
| good day | | 12345 |
| hi there | abc def | 3.14 |
or
foo bar baz
--------- -------- ------
good day 12345
hi there abc def 3.14
or
foo bar baz
good day 12345
hi there abc def 3.14
etc...
Headers (keys) are converted to snake-case. All values are returned as
strings, except empty strings, which are converted to None/null.
Usage (cli):
$ cat table.txt | jc --asciitable
Usage (module):
import jc
result = jc.parse('asciitable', asciitable_string)
Schema:
[
{
"column_name1": string, # empty string is null
"column_name2": string # empty string is null
}
]
Examples:
$ echo '
> ╒══════════╤═════════╤════════╕
> │ foo │ bar │ baz │
> ╞══════════╪═════════╪════════╡
> │ good day │ │ 12345 │
> ├──────────┼─────────┼────────┤
> │ hi there │ abc def │ 3.14 │
> ╘══════════╧═════════╧════════╛' | jc --asciitable -p
[
{
"foo": "good day",
"bar": null,
"baz": "12345"
},
{
"foo": "hi there",
"bar": "abc def",
"baz": "3.14"
}
]
$ echo '
> foo bar baz
> --------- -------- ------
> good day 12345
> hi there abc def 3.14' | jc --asciitable -p
[
{
"foo": "good day",
"bar": null,
"baz": "12345"
},
{
"foo": "hi there",
"bar": "abc def",
"baz": "3.14"
}
]
<a id="jc.parsers.asciitable.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -0,0 +1,128 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.asciitable_m"></a>
# jc.parsers.asciitable\_m
jc - JSON Convert `asciitable-m` parser
This parser converts various styles of ASCII and Unicode text tables with
multi-line rows. Tables must have a header row and separator line between
rows.
For example:
╒══════════╤═════════╤════════╕
│ foo │ bar baz │ fiz │
│ │ │ buz │
╞══════════╪═════════╪════════╡
│ good day │ 12345 │ │
│ mate │ │ │
├──────────┼─────────┼────────┤
│ hi there │ abc def │ 3.14 │
│ │ │ │
╘══════════╧═════════╧════════╛
Cells with multiple lines within rows will be joined with a newline
character ('\\n').
Headers (keys) are converted to snake-case and newlines between multi-line
headers are joined with an underscore. All values are returned as strings,
except empty strings, which are converted to None/null.
> Note: table column separator characters (e.g. `|`) cannot be present
inside the cell data. If detected, a warning message will be printed to
STDERR and the line will be skipped. The warning message can be suppressed
by using the `-q` command option or by setting `quiet=True` in `parse()`.
Usage (cli):
$ cat table.txt | jc --asciitable-m
Usage (module):
import jc
result = jc.parse('asciitable_m', asciitable-string)
Schema:
[
{
"column_name1": string, # empty string is null
"column_name2": string # empty string is null
}
]
Examples:
$ echo '
> +----------+---------+--------+
> | foo | bar | baz |
> | | | buz |
> +==========+=========+========+
> | good day | 12345 | |
> | mate | | |
> +----------+---------+--------+
> | hi there | abc def | 3.14 |
> | | | |
> +==========+=========+========+' | jc --asciitable-m -p
[
{
"foo": "good day\\nmate",
"bar": "12345",
"baz_buz": null
},
{
"foo": "hi there",
"bar": "abc def",
"baz_buz": "3.14"
}
]
$ echo '
> ╒══════════╤═════════╤════════╕
> │ foo │ bar │ baz │
> │ │ │ buz │
> ╞══════════╪═════════╪════════╡
> │ good day │ 12345 │ │
> │ mate │ │ │
> ├──────────┼─────────┼────────┤
> │ hi there │ abc def │ 3.14 │
> │ │ │ │
> ╘══════════╧═════════╧════════╛' | jc --asciitable-m -p
[
{
"foo": "good day\\nmate",
"bar": "12345",
"baz_buz": null
},
{
"foo": "hi there",
"bar": "abc def",
"baz_buz": "3.14"
}
]
<a id="jc.parsers.asciitable_m.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.blkid
jc - JSON CLI output utility `blkid` command output parser
jc - JSON Convert `blkid` command output parser
Usage (cli):
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('blkid', blkid_command_output)
or
import jc.parsers.blkid
result = jc.parsers.blkid.parse(blkid_command_output)
Schema:
[

82
docs/parsers/chage.md Normal file
View File

@@ -0,0 +1,82 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.chage"></a>
# jc.parsers.chage
jc - JSON Convert `chage --list` command output parser
Supports `chage -l <username>` or `chage --list <username>`
Usage (cli):
$ chage -l johndoe | jc --chage
or
$ jc chage -l johndoe
Usage (module):
import jc
result = jc.parse('chage', chage_command_output)
Schema:
{
"password_last_changed": string,
"password_expires": string,
"password_inactive": string,
"account_expires": string,
"min_days_between_password_change": integer,
"max_days_between_password_change": integer,
"warning_days_before_password_expires": integer
}
Examples:
$ chage --list joeuser | jc --chage -p
{
"password_last_changed": "never",
"password_expires": "never",
"password_inactive": "never",
"account_expires": "never",
"min_days_between_password_change": 0,
"max_days_between_password_change": 99999,
"warning_days_before_password_expires": 7
}
$ chage --list joeuser | jc --chage -p -r
{
"password_last_changed": "never",
"password_expires": "never",
"password_inactive": "never",
"account_expires": "never",
"min_days_between_password_change": "0",
"max_days_between_password_change": "99999",
"warning_days_before_password_expires": "7"
}
<a id="jc.parsers.chage.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False) -> Dict
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.
### Parser Information
Compatibility: linux
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.cksum
jc - JSON CLI output utility `cksum` command output parser
jc - JSON Convert `cksum` command output parser
This parser works with the following checksum calculation utilities:
- `sum`
@@ -22,11 +22,6 @@ Usage (module):
import jc
result = jc.parse('cksum', cksum_command_output)
or
import jc.parsers.cksum
result = jc.parsers.cksum.parse(cksum_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.crontab
jc - JSON CLI output utility `crontab -l` command output and crontab
jc - JSON Convert `crontab -l` command output and crontab
file parser
Supports `crontab -l` command output and crontab files.
@@ -21,11 +21,6 @@ Usage (module):
import jc
result = jc.parse('crontab', crontab_output)
or
import jc.parsers.crontab
result = jc.parsers.crontab.parse(crontab_output)
Schema:
{

View File

@@ -3,7 +3,7 @@
# jc.parsers.crontab\_u
jc - JSON CLI output utility `crontab -l` command output and crontab
jc - JSON Convert `crontab -l` command output and crontab
file parser
This version of the `crontab -l` parser supports output that contains user
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('crontab_u', crontab_u_output)
or
import jc.parsers.crontab_u
result = jc.parsers.crontab_u.parse(crontab_u_output)
Schema:
{

View File

@@ -3,7 +3,7 @@
# jc.parsers.csv
jc - JSON CLI output utility `csv` file parser
jc - JSON Convert `csv` file parser
The `csv` parser will attempt to automatically detect the delimiter
character. If the delimiter cannot be detected it will default to comma.
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('csv', csv_output)
or
import jc.parsers.csv
result = jc.parsers.csv.parse(csv_output)
Schema:
csv file converted to a Dictionary:

View File

@@ -3,9 +3,10 @@
# jc.parsers.csv\_s
jc - JSON CLI output utility `csv` file streaming parser
jc - JSON Convert `csv` file streaming parser
> This streaming parser outputs JSON Lines
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
Dictionaries (module)
The `csv` streaming parser will attempt to automatically detect the
delimiter character. If the delimiter cannot be detected it will default
@@ -21,19 +22,11 @@ Usage (cli):
Usage (module):
import jc
# result is an iterable object (generator)
result = jc.parse('csv_s', csv_output.splitlines())
for item in result:
# do something
or
import jc.parsers.csv_s
# result is an iterable object (generator)
result = jc.parsers.csv_s.parse(csv_output.splitlines())
for item in result:
# do something
Schema:
csv file converted to a Dictionary:
@@ -44,13 +37,11 @@ Schema:
"column_name2": string,
# below object only exists if using -qq or ignore_exceptions=True
"_jc_meta":
{
"success": boolean, # false if error parsing
"error": string, # exists if "success" is false
"line": string # exists if "success" is false
}
"_jc_meta": {
"success": boolean, # false if error parsing
"error": string, # exists if "success" is false
"line": string # exists if "success" is false
}
}
Examples:
@@ -73,10 +64,11 @@ Examples:
### parse
```python
@add_jc_meta
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
```
Main text parsing generator function. Returns an iterator object.
Main text parsing generator function. Returns an iterable object.
Parameters:
@@ -87,15 +79,11 @@ Parameters:
quiet: (boolean) suppress warning messages if True
ignore_exceptions: (boolean) ignore parsing exceptions if True
Yields:
Dictionary. Raw or processed structured data.
Returns:
Iterator object
Iterable of Dictionaries
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.date
jc - JSON CLI output utility `date` command output parser
jc - JSON Convert `date` command output parser
The `epoch` calculated timestamp field is naive. (i.e. based on the local
time of the system the parser is run on)
@@ -24,11 +24,6 @@ Usage (module):
import jc
result = jc.parse('date', date_command_output)
or
import jc.parsers.date
result = jc.parsers.date.parse(date_command_output)
Schema:
{
@@ -105,4 +100,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, freebsd
Version 2.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 2.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.df
jc - JSON CLI output utility `df` command output parser
jc - JSON Convert `df` command output parser
Usage (cli):
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('df', df_command_output)
or
import jc.parsers.df
result = jc.parsers.df.parse(df_command_output)
Schema:
[
@@ -125,4 +120,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, freebsd
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.10 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.dig
jc - JSON CLI output utility `dig` command output parser
jc - JSON Convert `dig` command output parser
Options supported:
- `+noall +answer` options are supported in cases where only the answer
@@ -29,11 +29,6 @@ Usage (module):
import jc
result = jc.parse('dig', dig_command_output)
or
import jc.parsers.dig
result = jc.parsers.dig.parse(dig_command_output)
Schema:
[
@@ -350,4 +345,4 @@ Returns:
### Parser Information
Compatibility: linux, aix, freebsd, darwin, win32, cygwin
Version 2.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 2.3 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.dir
jc - JSON CLI output utility `dir` command output parser
jc - JSON Convert `dir` command output parser
Options supported:
- `/T timefield`
@@ -26,11 +26,6 @@ Usage (module):
import jc
result = jc.parse('dir', dir_command_output)
or
import jc.parsers.dir
result = jc.parsers.dir.parse(dir_command_output)
Schema:
[
@@ -148,4 +143,4 @@ Returns:
### Parser Information
Compatibility: win32
Version 1.4 by Rasheed Elsaleh (rasheed@rebelliondefense.com)
Version 1.5 by Rasheed Elsaleh (rasheed@rebelliondefense.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.dmidecode
jc - JSON CLI output utility `dmidecode` command output parser
jc - JSON Convert `dmidecode` command output parser
Usage (cli):
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('dmidecode', dmidecode_command_output)
or
import jc.parsers.dmidecode
result = jc.parsers.dmidecode.parse(dmidecode_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.dpkg\_l
jc - JSON CLI output utility `dpkg -l` command output parser
jc - JSON Convert `dpkg -l` command output parser
Set the `COLUMNS` environment variable to a large value to avoid field
truncation. For example:
@@ -23,11 +23,6 @@ Usage (module):
import jc
result = jc.parse('dpkg_l', dpkg_command_output)
or
import jc.parsers.dpkg_l
result = jc.parsers.dpkg_l.parse(dpkg_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.du
jc - JSON CLI output utility `du` command output parser
jc - JSON Convert `du` command output parser
Usage (cli):
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('du', du_command_output)
or
import jc.parsers.du
result = jc.parsers.du.parse(du_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.env
jc - JSON CLI output utility `env` and `printenv` command output parser
jc - JSON Convert `env` and `printenv` command output parser
This parser will output a list of dictionaries each containing `name` and
`value` keys. If you would like a simple dictionary output, then use the
@@ -23,11 +23,6 @@ Usage (module):
import jc
result = jc.parse('env', env_command_output)
or
import jc.parsers.env
result = jc.parsers.env.parse(env_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.file
jc - JSON CLI output utility `file` command output parser
jc - JSON Convert `file` command output parser
Usage (cli):
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('file', file_command_output)
or
import jc.parsers.file
result = jc.parsers.file.parse(file_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.finger
jc - JSON CLI output utility `finger` command output parser
jc - JSON Convert `finger` command output parser
Supports `-s` output option. Does not support the `-l` detail option.
@@ -20,11 +20,6 @@ Usage (module):
import jc
result = jc.parse('finger', finger_command_output)
or
import jc.parsers.finger
result = jc.parsers.finger.parse(finger_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.free
jc - JSON CLI output utility `free` command output parser
jc - JSON Convert `free` command output parser
Usage (cli):
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('free', free_command_output)
or
import jc.parsers.free
result = jc.parsers.free.parse(free_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.fstab
jc - JSON CLI output utility `fstab` file parser
jc - JSON Convert `fstab` file parser
Usage (cli):
@@ -14,11 +14,6 @@ Usage (module):
import jc
result = jc.parse('fstab', fstab_command_output)
or
import jc.parsers.fstab
result = jc.parsers.fstab.parse(fstab_command_output)
Schema:
[

175
docs/parsers/git_log.md Normal file
View File

@@ -0,0 +1,175 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.git_log"></a>
# jc.parsers.git\_log
jc - JSON Convert `git log` command output parser
Can be used with the following format options:
- `oneline`
- `short`
- `medium`
- `full`
- `fuller`
Additional options supported:
- `--stat`
- `--shortstat`
The `epoch` calculated timestamp field is naive. (i.e. based on the
local time of the system the parser is run on)
The `epoch_utc` calculated timestamp field is timezone-aware and is
only available if the timezone field is UTC.
Usage (cli):
$ git log | jc --git-log
or
$ jc git log
Usage (module):
import jc
result = jc.parse('git_log', git_log_command_output)
Schema:
[
{
"commit": string,
"author": string,
"author_email": string,
"date": string,
"epoch": integer, [0]
"epoch_utc": integer, [1]
"commit_by": string,
"commit_by_email": string,
"commit_by_date": string,
"message": string,
"stats" : {
"files_changed": integer,
"insertions": integer,
"deletions": integer,
"files": [
string
]
}
}
]
[0] naive timestamp if "date" field is parsable, else null
[1] timezone aware timestamp availabe for UTC, else null
Examples:
$ git log --stat | jc --git-log -p
[
{
"commit": "728d882ed007b3c8b785018874a0eb06e1143b66",
"author": "Kelly Brazil",
"author_email": "kellyjonbrazil@gmail.com",
"date": "Wed Apr 20 09:50:19 2022 -0400",
"stats": {
"files_changed": 2,
"insertions": 90,
"deletions": 12,
"files": [
"docs/parsers/git_log.md",
"jc/parsers/git_log.py"
]
},
"message": "add timestamp docs and examples",
"epoch": 1650462619,
"epoch_utc": null
},
{
"commit": "b53e42aca623181aa9bc72194e6eeef1e9a3a237",
"author": "Kelly Brazil",
"author_email": "kellyjonbrazil@gmail.com",
"date": "Wed Apr 20 09:44:42 2022 -0400",
"stats": {
"files_changed": 5,
"insertions": 29,
"deletions": 6,
"files": [
"docs/parsers/git_log.md",
"docs/utils.md",
"jc/parsers/git_log.py",
"jc/utils.py",
"man/jc.1"
]
},
"message": "add calculated timestamp",
"epoch": 1650462282,
"epoch_utc": null
},
...
]
$ git log --stat | jc --git-log -p -r
[
{
"commit": "728d882ed007b3c8b785018874a0eb06e1143b66",
"author": "Kelly Brazil",
"author_email": "kellyjonbrazil@gmail.com",
"date": "Wed Apr 20 09:50:19 2022 -0400",
"stats": {
"files_changed": "2",
"insertions": "90",
"deletions": "12",
"files": [
"docs/parsers/git_log.md",
"jc/parsers/git_log.py"
]
},
"message": "add timestamp docs and examples"
},
{
"commit": "b53e42aca623181aa9bc72194e6eeef1e9a3a237",
"author": "Kelly Brazil",
"author_email": "kellyjonbrazil@gmail.com",
"date": "Wed Apr 20 09:44:42 2022 -0400",
"stats": {
"files_changed": "5",
"insertions": "29",
"deletions": "6",
"files": [
"docs/parsers/git_log.md",
"docs/utils.md",
"jc/parsers/git_log.py",
"jc/utils.py",
"man/jc.1"
]
},
"message": "add calculated timestamp"
},
...
]
<a id="jc.parsers.git_log.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

111
docs/parsers/git_log_s.md Normal file
View File

@@ -0,0 +1,111 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.git_log_s"></a>
# jc.parsers.git\_log\_s
jc - JSON Convert `git log` command output streaming parser
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
Dictionaries (module)
Can be used with the following format options:
- `oneline`
- `short`
- `medium`
- `full`
- `fuller`
Additional options supported:
- `--stat`
- `--shortstat`
The `epoch` calculated timestamp field is naive. (i.e. based on the
local time of the system the parser is run on)
The `epoch_utc` calculated timestamp field is timezone-aware and is
only available if the timezone field is UTC.
Usage (cli):
$ git log | jc --git-log-s
Usage (module):
import jc
result = jc.parse('git_log_s', git_log_command_output.splitlines())
for item in result:
# do something
Schema:
{
"commit": string,
"author": string,
"author_email": string,
"date": string,
"epoch": integer, [0]
"epoch_utc": integer, [1]
"commit_by": string,
"commit_by_email": string,
"commit_by_date": string,
"message": string,
"stats" : {
"files_changed": integer,
"insertions": integer,
"deletions": integer,
"files": [
string
]
}
# below object only exists if using -qq or ignore_exceptions=True
"_jc_meta": {
"success": boolean, # false if error parsing
"error": string, # exists if "success" is false
"line": string # exists if "success" is false
}
}
[0] naive timestamp if "date" field is parsable, else null
[1] timezone aware timestamp availabe for UTC, else null
Examples:
$ git log | jc --git-log-s
{"commit":"a730ae18c8e81c5261db132df73cd74f272a0a26","author":"Kelly...}
{"commit":"930bf439c06c48a952baec05a9896c8d92b7693e","author":"Kelly...}
...
<a id="jc.parsers.git_log_s.parse"></a>
### parse
```python
@add_jc_meta
def parse(data: Iterable[str],
raw: bool = False,
quiet: bool = False,
ignore_exceptions: bool = False) -> Union[Iterable[Dict], tuple]
```
Main text parsing generator function. Returns an iterable object.
Parameters:
data: (iterable) line-based text data to parse
(e.g. sys.stdin or str.splitlines())
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
ignore_exceptions: (boolean) ignore parsing exceptions if True
Returns:
Iterable of Dictionaries
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.group
jc - JSON CLI output utility `/etc/group` file parser
jc - JSON Convert `/etc/group` file parser
Usage (cli):
@@ -14,11 +14,6 @@ Usage (module):
import jc
result = jc.parse('group', group_file_output)
or
import jc.parsers.group
result = jc.parsers.group.parse(group_file_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.gshadow
jc - JSON CLI output utility `/etc/gshadow` file parser
jc - JSON Convert `/etc/gshadow` file parser
Usage (cli):
@@ -14,11 +14,6 @@ Usage (module):
import jc
result = jc.parse('gshadow', gshadow_file_output)
or
import jc.parsers.gshadow
result = jc.parsers.gshadow.parse(gshadow_file_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.hash
jc - JSON CLI output utility `hash` command output parser
jc - JSON Convert `hash` command output parser
Usage (cli):
@@ -14,11 +14,6 @@ Usage (module):
import jc
result = jc.parse('hash', hash_command_output)
or
import jc.parsers.hash
result = jc.parsers.hash.parse(hash_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.hashsum
jc - JSON CLI output utility `hash sum` command output parser
jc - JSON Convert `hash sum` command output parser
This parser works with the following hash calculation utilities:
- `md5`
@@ -28,11 +28,6 @@ Usage (module):
import jc
result = jc.parse('hashsum', md5sum_command_output)
or
import jc.parsers.hashsum
result = jc.parsers.hashsum.parse(md5sum_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.hciconfig
jc - JSON CLI output utility `hciconfig` command output parser
jc - JSON Convert `hciconfig` command output parser
Usage (cli):
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('hciconfig', hciconfig_command_output)
or
import jc.parsers.hciconfig
result = jc.parsers.hciconfig.parse(hciconfig_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.history
jc - JSON CLI output utility `history` command output parser
jc - JSON Convert `history` command output parser
This parser will output a list of dictionaries each containing `line` and
`command` keys. If you would like a simple dictionary output, then use the
@@ -22,11 +22,6 @@ Usage (module):
import jc
result = jc.parse('history', history_command_output)
or
import jc.parsers.history
result = jc.parsers.history.parse(history_command_output)
Schema:
[
@@ -92,4 +87,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.hosts
jc - JSON CLI output utility `/etc/hosts` file parser
jc - JSON Convert `/etc/hosts` file parser
Usage (cli):
@@ -14,11 +14,6 @@ Usage (module):
import jc
result = jc.parse('hosts', hosts_file_output)
or
import jc.parsers.hosts
result = jc.parsers.hosts.parse(hosts_file_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.id
jc - JSON CLI output utility `id` command output parser
jc - JSON Convert `id` command output parser
Usage (cli):
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('id', id_command_output)
or
import jc.parsers.id
result = jc.parsers.id.parse(id_command_output)
Schema:
{

View File

@@ -3,7 +3,7 @@
# jc.parsers.ifconfig
jc - JSON CLI output utility `ifconfig` command output parser
jc - JSON Convert `ifconfig` command output parser
Note: No `ifconfig` options are supported.
@@ -20,11 +20,6 @@ Usage (module):
import jc
result = jc.parse('ifconfig', ifconfig_command_output)
or
import jc.parsers.ifconfig
result = jc.parsers.ifconfig.parse(ifconfig_command_output)
Schema:
[

View File

@@ -3,15 +3,17 @@
# jc.parsers.ini
jc - JSON CLI output utility `INI` file parser
jc - JSON Convert `INI` file parser
Parses standard `INI` files and files containing simple key/value pairs.
Delimiter can be `=` or `:`. Missing values are supported. Comment prefix
can be `#` or `;`. Comments must be on their own line.
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()`.
- Delimiter can be `=` or `:`. Missing values are supported.
- Comment prefix can be `#` or `;`. Comments must be on their own line.
- If duplicate keys are found, only the last value will be used.
> Note: Values starting and ending with quotation marks will have the marks
removed. If you would like to keep the quotation marks, use the `-r`
command-line argument or the `raw=True` argument in `parse()`.
Usage (cli):
@@ -22,11 +24,6 @@ Usage (module):
import jc
result = jc.parse('ini', ini_file_output)
or
import jc.parsers.ini
result = jc.parsers.ini.parse(ini_file_output)
Schema:
ini or key/value document converted to a dictionary - see the
@@ -94,4 +91,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.iostat
jc - JSON CLI output utility `iostat` command output parser
jc - JSON Convert `iostat` command output parser
Note: `iostat` version 11 and higher include a JSON output option
@@ -20,11 +20,6 @@ Usage (module):
import jc
result = jc.parse('iostat', iostat_command_output)
or
import jc.parsers.iostat
result = jc.parsers.iostat.parse(iostat_command_output)
Schema:
[

View File

@@ -3,9 +3,10 @@
# jc.parsers.iostat\_s
jc - JSON CLI output utility `iostat` command output streaming parser
jc - JSON Convert `iostat` command output streaming parser
> This streaming parser outputs JSON Lines
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
Dictionaries (module)
Note: `iostat` version 11 and higher include a JSON output option
@@ -13,22 +14,21 @@ Usage (cli):
$ iostat | jc --iostat-s
> Note: When piping `jc` converted `iostat` output to other processes it may
appear the output is hanging due to the OS pipe buffers. This is because
`iostat` output is too small to quickly fill up the buffer. Use the `-u`
option to unbuffer the `jc` output if you would like immediate output. See
the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
for more information.
Usage (module):
import jc
# result is an iterable object (generator)
result = jc.parse('iostat_s', iostat_command_output.splitlines())
for item in result:
# do something
or
import jc.parsers.iostat_s
# result is an iterable object (generator)
result = jc.parsers.iostat_s.parse(iostat_command_output.splitlines())
for item in result:
# do something
Schema:
{
@@ -83,14 +83,12 @@ Schema:
"percent_rrqm": float,
"percent_wrqm": float,
# Below object only exists if using -qq or ignore_exceptions=True
"_jc_meta":
{
"success": boolean, # false if error parsing
"error": string, # exists if "success" is false
"line": string # exists if "success" is false
}
# below object only exists if using -qq or ignore_exceptions=True
"_jc_meta": {
"success": boolean, # false if error parsing
"error": string, # exists if "success" is false
"line": string # exists if "success" is false
}
}
Examples:
@@ -110,10 +108,11 @@ Examples:
### parse
```python
@add_jc_meta
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
```
Main text parsing generator function. Returns an iterator object.
Main text parsing generator function. Returns an iterable object.
Parameters:
@@ -124,15 +123,11 @@ Parameters:
quiet: (boolean) suppress warning messages if True
ignore_exceptions: (boolean) ignore parsing exceptions if True
Yields:
Dictionary. Raw or processed structured data.
Returns:
Iterator object
Iterable of Dictionaries
### Parser Information
Compatibility: linux
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.iptables
jc - JSON CLI output utility `iptables` command output parser
jc - JSON Convert `iptables` command output parser
Supports `-vLn` and `--line-numbers` for all tables.
@@ -20,11 +20,6 @@ Usage (module):
import jc
result = jc.parse('iptables', iptables_command_output)
or
import jc.parsers.iptables
result = jc.parsers.iptables.parse(iptables_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.iw\_scan
jc - JSON CLI output utility `iw dev <device> scan` command output parser
jc - JSON Convert `iw dev <device> scan` command output parser
This parser is considered beta quality. Not all fields are parsed and there
are not enough samples to test.
@@ -21,11 +21,6 @@ Usage (module):
import jc
result = jc.parse('iw_scan', iw_scan_command_output)
or
import jc.parsers.iw_scan
result = jc.parsers.iw_scan.parse(iw_scan_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.jar\_manifest
jc - JSON CLI output utility `MANIFEST.MF` file parser
jc - JSON Convert `MANIFEST.MF` file parser
Usage (cli):
@@ -14,11 +14,6 @@ Usage (module):
import jc
result = jc.parse('jar_manifest', jar_manifest_file_output)
or
import jc.parsers.jar_manifest
result = jc.parsers.jar_manifest.parse(jar_manifest_file_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.jobs
jc - JSON CLI output utility `jobs` command output parser
jc - JSON Convert `jobs` command output parser
Also supports the `-l` option.
@@ -19,11 +19,6 @@ Usage (module):
import jc
result = jc.parse('jobs', jobs_command_output)
or
import jc.parsers.jobs
result = jc.parsers.jobs.parse(jobs_command_output)
Schema:
[

View File

@@ -3,15 +3,17 @@
# jc.parsers.kv
jc - JSON CLI output utility `Key/Value` file parser
jc - JSON Convert `Key/Value` file parser
Supports files containing simple key/value pairs. Delimiter can be `=` or
`:`. Missing values are supported. Comment prefix can be `#` or `;`.
Comments must be on their own line.
Supports files containing simple key/value pairs.
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()`.
- Delimiter can be `=` or `:`. Missing values are supported.
- Comment prefix can be `#` or `;`. Comments must be on their own line.
- If duplicate keys are found, only the last value will be used.
> Note: Values starting and ending with quotation marks will have the marks
removed. If you would like to keep the quotation marks, use the `-r`
command-line argument or the `raw=True` argument in `parse()`.
Usage (cli):
@@ -22,11 +24,6 @@ Usage (module):
import jc
result = jc.parse('kv', kv_file_output)
or
import jc.parsers.kv
result = jc.parsers.kv.parse(kv_file_output)
Schema:
key/value document converted to a dictionary - see the
@@ -83,4 +80,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.last
jc - JSON CLI output utility `last` and `lastb` command output parser
jc - JSON Convert `last` and `lastb` command output parser
Supports `-w` and `-F` options.
@@ -24,11 +24,6 @@ Usage (module):
import jc
result = jc.parse('last', last_command_output)
or
import jc.parsers.last
result = jc.parsers.last.parse(last_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.ls
jc - JSON CLI output utility `ls` and `vdir` command output parser
jc - JSON Convert `ls` and `vdir` command output parser
Options supported:
- `lbaR1`
@@ -34,11 +34,6 @@ Usage (module):
import jc
result = jc.parse('ls', ls_command_output)
or
import jc.parsers.ls
result = jc.parsers.ls.parse(ls_command_output)
Schema:
[
@@ -144,4 +139,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.10 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.11 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,10 +3,10 @@
# jc.parsers.ls\_s
jc - JSON CLI output utility `ls` and `vdir` command output streaming
parser
jc - JSON Convert `ls` and `vdir` command output streaming parser
> This streaming parser outputs JSON Lines
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
Dictionaries (module)
Requires the `-l` option to be used on `ls`. If there are newline characters
in the filename, then make sure to use the `-b` option on `ls`.
@@ -27,19 +27,11 @@ Usage (cli):
Usage (module):
import jc
# result is an iterable object (generator)
result = jc.parse('ls_s', ls_command_output.splitlines())
for item in result:
# do something
or
import jc.parsers.ls_s
# result is an iterable object (generator)
result = jc.parsers.ls_s.parse(ls_command_output.splitlines())
for item in result:
# do something
Schema:
{
@@ -54,14 +46,12 @@ Schema:
"epoch": integer, # [0]
"epoch_utc": integer, # [1]
# Below object only exists if using -qq or ignore_exceptions=True
"_jc_meta":
{
"success": boolean, # false if error parsing
"error": string, # exists if "success" is false
"line": string # exists if "success" is false
}
# below object only exists if using -qq or ignore_exceptions=True
"_jc_meta": {
"success": boolean, # false if error parsing
"error": string, # exists if "success" is false
"line": string # exists if "success" is false
}
}
[0] naive timestamp if date field exists and can be converted.
@@ -87,10 +77,11 @@ Examples:
### parse
```python
@add_jc_meta
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
```
Main text parsing generator function. Returns an iterator object.
Main text parsing generator function. Returns an iterable object.
Parameters:
@@ -101,15 +92,11 @@ Parameters:
quiet: (boolean) suppress warning messages if True
ignore_exceptions: (boolean) ignore parsing exceptions if True
Yields:
Dictionary. Raw or processed structured data.
Returns:
Iterator object
Iterable of Dictionaries
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 0.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.lsblk
jc - JSON CLI output utility `lsblk` command output parser
jc - JSON Convert `lsblk` command output parser
Usage (cli):
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('lsblk', lsblk_command_output)
or
import jc.parsers.lsblk
result = jc.parsers.lsblk.parse(lsblk_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.lsmod
jc - JSON CLI output utility `lsmod` command output parser
jc - JSON Convert `lsmod` command output parser
Usage (cli):
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('lsmod', lsmod_command_output)
or
import jc.parsers.lsmod
result = jc.parsers.lsmod.parse(lsmod_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.lsof
jc - JSON CLI output utility `lsof` command output parser
jc - JSON Convert `lsof` command output parser
Usage (cli):
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('lsof', lsof_command_output)
or
import jc.parsers.lsof
result = jc.parsers.lsof.parse(lsof_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.lsusb
jc - JSON CLI output utility `lsusb` command output parser
jc - JSON Convert `lsusb` command output parser
Supports the `-v` option or no options.
@@ -20,11 +20,6 @@ Usage (module):
import jc
result = jc.parse('lsusb', lsusb_command_output)
or
import jc.parsers.lsusb
result = jc.parsers.lsusb.parse(lsusb_command_output)
Schema:
Note: <item> object keynames are assigned directly from the lsusb

View File

@@ -3,7 +3,7 @@
# jc.parsers.mount
jc - JSON CLI output utility `mount` command output parser
jc - JSON Convert `mount` command output parser
Usage (cli):
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('mount', mount_command_output)
or
import jc.parsers.mount
result = jc.parsers.mount.parse(mount_command_output)
Schema:
[

140
docs/parsers/mpstat.md Normal file
View File

@@ -0,0 +1,140 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.mpstat"></a>
# jc.parsers.mpstat
jc - JSON Convert `mpstat` command output parser
Note: Latest versions of `mpstat` support JSON output (v11.5.1+)
Usage (cli):
$ mpstat | jc --mpstat
or
$ jc mpstat
Usage (module):
import jc
result = jc.parse('mpstat', mpstat_command_output)
Schema:
[
{
"type": string,
"time": string,
"cpu": string,
"node": string,
"average": boolean,
"percent_usr": float,
"percent_nice": float,
"percent_sys": float,
"percent_iowait": float,
"percent_irq": float,
"percent_soft": float,
"percent_steal": float,
"percent_guest": float,
"percent_gnice": float,
"percent_idle": float,
"intr_s": float,
"<x>_s": float, # <x> is an integer
"nmi_s": float,
"loc_s": float,
"spu_s": float,
"pmi_s": float,
"iwi_s": float,
"rtr_s": float,
"res_s": float,
"cal_s": float,
"tlb_s": float,
"trm_s": float,
"thr_s": float,
"dfr_s": float,
"mce_s": float,
"mcp_s": float,
"err_s": float,
"mis_s": float,
"pin_s": float,
"npi_s": float,
"piw_s": float,
"hi_s": float,
"timer_s": float,
"net_tx_s": float,
"net_rx_s": float,
"block_s": float,
"irq_poll_s": float,
"block_iopoll_s": float,
"tasklet_s": float,
"sched_s": float,
"hrtimer_s": float,
"rcu_s": float
}
]
Examples:
$ mpstat | jc --mpstat -p
[
{
"cpu": "all",
"percent_usr": 12.94,
"percent_nice": 0.0,
"percent_sys": 26.42,
"percent_iowait": 0.43,
"percent_irq": 0.0,
"percent_soft": 0.16,
"percent_steal": 0.0,
"percent_guest": 0.0,
"percent_gnice": 0.0,
"percent_idle": 60.05,
"type": "cpu",
"time": "01:58:14 PM"
}
]
$ mpstat | jc --mpstat -p -r
[
{
"cpu": "all",
"percent_usr": "12.94",
"percent_nice": "0.00",
"percent_sys": "26.42",
"percent_iowait": "0.43",
"percent_irq": "0.00",
"percent_soft": "0.16",
"percent_steal": "0.00",
"percent_guest": "0.00",
"percent_gnice": "0.00",
"percent_idle": "60.05",
"type": "cpu",
"time": "01:58:14 PM"
}
]
<a id="jc.parsers.mpstat.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
### Parser Information
Compatibility: linux
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

128
docs/parsers/mpstat_s.md Normal file
View File

@@ -0,0 +1,128 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.mpstat_s"></a>
# jc.parsers.mpstat\_s
jc - JSON Convert `mpstat` command output streaming parser
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
Dictionaries (module)
Note: Latest versions of `mpstat` support JSON output (v11.5.1+)
Usage (cli):
$ mpstat | jc --mpstat-s
Usage (module):
import jc
result = jc.parse('mpstat_s', mpstat_command_output.splitlines())
for item in result:
# do something
Schema:
{
"type": string,
"time": string,
"cpu": string,
"node": string,
"average": boolean,
"percent_usr": float,
"percent_nice": float,
"percent_sys": float,
"percent_iowait": float,
"percent_irq": float,
"percent_soft": float,
"percent_steal": float,
"percent_guest": float,
"percent_gnice": float,
"percent_idle": float,
"intr_s": float,
"<x>_s": float, # <x> is an integer
"nmi_s": float,
"loc_s": float,
"spu_s": float,
"pmi_s": float,
"iwi_s": float,
"rtr_s": float,
"res_s": float,
"cal_s": float,
"tlb_s": float,
"trm_s": float,
"thr_s": float,
"dfr_s": float,
"mce_s": float,
"mcp_s": float,
"err_s": float,
"mis_s": float,
"pin_s": float,
"npi_s": float,
"piw_s": float,
"hi_s": float,
"timer_s": float,
"net_tx_s": float,
"net_rx_s": float,
"block_s": float,
"irq_poll_s": float,
"block_iopoll_s": float,
"tasklet_s": float,
"sched_s": float,
"hrtimer_s": float,
"rcu_s": float,
# below object only exists if using -qq or ignore_exceptions=True
"_jc_meta": {
"success": boolean, # false if error parsing
"error": string, # exists if "success" is false
"line": string # exists if "success" is false
}
}
Examples:
$ mpstat -A | jc --mpstat-s
{"cpu":"all","percent_usr":0.22,"percent_nice":0.0,"percent_sys":...}
{"cpu":"0","percent_usr":0.22,"percent_nice":0.0,"percent_sys":0....}
{"cpu":"all","intr_s":37.61,"type":"interrupts","time":"03:15:06 PM"}
...
$ mpstat -A | jc --mpstat-s -r
{"cpu":"all","percent_usr":"0.22","percent_nice":"0.00","percent_...}
{"cpu":"0","percent_usr":"0.22","percent_nice":"0.00","percent_sy...}
{"cpu":"all","intr_s":"37.61","type":"interrupts","time":"03:15:06 PM"}
...
<a id="jc.parsers.mpstat_s.parse"></a>
### parse
```python
@add_jc_meta
def parse(data: Iterable[str],
raw: bool = False,
quiet: bool = False,
ignore_exceptions: bool = False) -> Union[Iterable[Dict], tuple]
```
Main text parsing generator function. Returns an iterable object.
Parameters:
data: (iterable) line-based text data to parse
(e.g. sys.stdin or str.splitlines())
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
ignore_exceptions: (boolean) ignore parsing exceptions if True
Returns:
Iterable of Dictionaries
### Parser Information
Compatibility: linux
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.netstat
jc - JSON CLI output utility `netstat` command output parser
jc - JSON Convert `netstat` command output parser
Caveats:
- Use of multiple `l` options is not supported on OSX (e.g. `netstat -rlll`)
@@ -23,11 +23,6 @@ Usage (module):
import jc
result = jc.parse('netstat', netstat_command_output)
or
import jc.parsers.netstat
result = jc.parsers.netstat.parse(netstat_command_output)
Schema:
[

171
docs/parsers/nmcli.md Normal file
View File

@@ -0,0 +1,171 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.nmcli"></a>
# jc.parsers.nmcli
jc - JSON Convert `nmcli` command output parser
Supports the following `nmcli` subcommands:
- `nmcli general`
- `nmcli general permissions`
- `nmcli connection`
- `nmcli connection show <device_name>`
- `nmcli device`
- `nmcli device show`
- `nmcli device show <device_name>`
Usage (cli):
$ nmcli device show lo | jc --nmcli
or
$ jc nmcli device show lo
Usage (module):
import jc
result = jc.parse('nmcli', nmcli_command_output)
Schema:
Because there are so many options, the schema is not strictly defined.
Integer and Float value conversions are attempted and the original
values are kept if they fail. If you don't want automatic conversion,
then use the -r or raw=True option to disable it.
The structure is flat, for the most part, but there are a couple of
"well-known" keys that are further parsed into objects for convenience.
These are documented below.
[
{
"<key>": string/integer/float, [0]
"dhcp4_option_x": {
"name": string,
"value": string/integer/float,
},
"dhcp6_option_x": {
"name": string,
"value": string/integer/float,
},
"ip4_route_x": {
"dst": string,
"nh": string,
"mt": integer
},
"ip6_route_x": {
"dst": string,
"nh": string,
"mt": integer,
"table": integer
}
}
]
[0] all values of `---` are converted to null
Examples:
$ nmcli connection show ens33 | jc --nmcli -p
[
{
"connection_id": "ens33",
"connection_uuid": "d92ece08-9e02-47d5-b2d2-92c80e155744",
"connection_stable_id": null,
"connection_type": "802-3-ethernet",
"connection_interface_name": "ens33",
"connection_autoconnect": "yes",
...
"ip4_address_1": "192.168.71.180/24",
"ip4_gateway": "192.168.71.2",
"ip4_route_1": {
"dst": "0.0.0.0/0",
"nh": "192.168.71.2",
"mt": 100
},
"ip4_route_2": {
"dst": "192.168.71.0/24",
"nh": "0.0.0.0",
"mt": 100
},
"ip4_dns_1": "192.168.71.2",
"ip4_domain_1": "localdomain",
"dhcp4_option_1": {
"name": "broadcast_address",
"value": "192.168.71.255"
},
...
"ip6_address_1": "fe80::c1cb:715d:bc3e:b8a0/64",
"ip6_gateway": null,
"ip6_route_1": {
"dst": "fe80::/64",
"nh": "::",
"mt": 100
}
}
]
$ nmcli connection show ens33 | jc --nmcli -p -r
[
{
"connection_id": "ens33",
"connection_uuid": "d92ece08-9e02-47d5-b2d2-92c80e155744",
"connection_stable_id": null,
"connection_type": "802-3-ethernet",
"connection_interface_name": "ens33",
"connection_autoconnect": "yes",
...
"ip4_address_1": "192.168.71.180/24",
"ip4_gateway": "192.168.71.2",
"ip4_route_1": {
"dst": "0.0.0.0/0",
"nh": "192.168.71.2",
"mt": "100"
},
"ip4_route_2": {
"dst": "192.168.71.0/24",
"nh": "0.0.0.0",
"mt": "100"
},
"ip4_dns_1": "192.168.71.2",
"ip4_domain_1": "localdomain",
"dhcp4_option_1": {
"name": "broadcast_address",
"value": "192.168.71.255"
},
...
"ip6_address_1": "fe80::c1cb:715d:bc3e:b8a0/64",
"ip6_gateway": null,
"ip6_route_1": {
"dst": "fe80::/64",
"nh": "::",
"mt": "100"
}
}
]
<a id="jc.parsers.nmcli.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
### Parser Information
Compatibility: linux
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.ntpq
jc - JSON CLI output utility `ntpq -p` command output parser
jc - JSON Convert `ntpq -p` command output parser
Usage (cli):
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('ntpq', ntpq_command_output)
or
import jc.parsers.ntpq
result = jc.parsers.ntpq.parse(ntpq_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.passwd
jc - JSON CLI output utility `/etc/passwd` file Parser
jc - JSON Convert `/etc/passwd` file Parser
Usage (cli):
@@ -14,11 +14,6 @@ Usage (module):
import jc
result = jc.parse('passwd', passwd_file_output)
or
import jc.parsers.passwd
result = jc.parsers.passwd.parse(passwd_file_output)
Schema:
[

151
docs/parsers/pidstat.md Normal file
View File

@@ -0,0 +1,151 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.pidstat"></a>
# jc.parsers.pidstat
jc - JSON Convert `pidstat` command output parser
Must use the `-h` option in `pidstat`. All other `pidstat` options are
supported in combination with `-h`.
Usage (cli):
$ pidstat -h | jc --pidstat
or
$ jc pidstat -h
Usage (module):
import jc
result = jc.parse('pidstat', pidstat_command_output)
Schema:
[
{
"time": integer,
"uid": integer,
"pid": integer,
"percent_usr": float,
"percent_system": float,
"percent_guest": float,
"percent_cpu": float,
"cpu": integer,
"minflt_s": float,
"majflt_s": float,
"vsz": integer,
"rss": integer,
"percent_mem": float,
"stksize": integer,
"stkref": integer,
"kb_rd_s": float,
"kb_wr_s": float,
"kb_ccwr_s": float,
"cswch_s": float,
"nvcswch_s": float,
"command": string
}
]
Examples:
$ pidstat -hl | jc --pidstat -p
[
{
"time": 1646859134,
"uid": 0,
"pid": 1,
"percent_usr": 0.0,
"percent_system": 0.03,
"percent_guest": 0.0,
"percent_cpu": 0.03,
"cpu": 0,
"command": "/usr/lib/systemd/systemd --switched-root --system..."
},
{
"time": 1646859134,
"uid": 0,
"pid": 6,
"percent_usr": 0.0,
"percent_system": 0.0,
"percent_guest": 0.0,
"percent_cpu": 0.0,
"cpu": 0,
"command": "ksoftirqd/0"
},
{
"time": 1646859134,
"uid": 0,
"pid": 2263,
"percent_usr": 0.0,
"percent_system": 0.0,
"percent_guest": 0.0,
"percent_cpu": 0.0,
"cpu": 0,
"command": "kworker/0:0"
}
]
$ pidstat -hl | jc --pidstat -p -r
[
{
"time": "1646859134",
"uid": "0",
"pid": "1",
"percent_usr": "0.00",
"percent_system": "0.03",
"percent_guest": "0.00",
"percent_cpu": "0.03",
"cpu": "0",
"command": "/usr/lib/systemd/systemd --switched-root --system..."
},
{
"time": "1646859134",
"uid": "0",
"pid": "6",
"percent_usr": "0.00",
"percent_system": "0.00",
"percent_guest": "0.00",
"percent_cpu": "0.00",
"cpu": "0",
"command": "ksoftirqd/0"
},
{
"time": "1646859134",
"uid": "0",
"pid": "2263",
"percent_usr": "0.00",
"percent_system": "0.00",
"percent_guest": "0.00",
"percent_cpu": "0.00",
"cpu": "0",
"command": "kworker/0:0"
}
]
<a id="jc.parsers.pidstat.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
### Parser Information
Compatibility: linux
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

110
docs/parsers/pidstat_s.md Normal file
View File

@@ -0,0 +1,110 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.pidstat_s"></a>
# jc.parsers.pidstat\_s
jc - JSON Convert `pidstat` command output streaming parser
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
Dictionaries (module)
Must use the `-h` option in `pidstat`. All other `pidstat` options are
supported in combination with `-h`.
Usage (cli):
$ pidstat | jc --pidstat-s
> Note: When piping `jc` converted `pidstat` output to other processes it
may appear the output is hanging due to the OS pipe buffers. This is
because `pidstat` output is too small to quickly fill up the buffer. Use
the `-u` option to unbuffer the `jc` output if you would like immediate
output. See the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
for more information.
Usage (module):
import jc
result = jc.parse('pidstat_s', pidstat_command_output.splitlines())
for item in result:
# do something
Schema:
{
"time": integer,
"uid": integer,
"pid": integer,
"percent_usr": float,
"percent_system": float,
"percent_guest": float,
"percent_cpu": float,
"cpu": integer,
"minflt_s": float,
"majflt_s": float,
"vsz": integer,
"rss": integer,
"percent_mem": float,
"stksize": integer,
"stkref": integer,
"kb_rd_s": float,
"kb_wr_s": float,
"kb_ccwr_s": float,
"cswch_s": float,
"nvcswch_s": float,
"command": string,
# below object only exists if using -qq or ignore_exceptions=True
"_jc_meta": {
"success": boolean, # false if error parsing
"error": string, # exists if "success" is false
"line": string # exists if "success" is false
}
}
Examples:
$ pidstat -hl | jc --pidstat-s
{"time":1646859134,"uid":0,"pid":1,"percent_usr":0.0,"percent_syste...}
{"time":1646859134,"uid":0,"pid":6,"percent_usr":0.0,"percent_syste...}
{"time":1646859134,"uid":0,"pid":9,"percent_usr":0.0,"percent_syste...}
...
$ pidstat -hl | jc --pidstat-s -r
{"time":"1646859134","uid":"0","pid":"1","percent_usr":"0.00","perc...}
{"time":"1646859134","uid":"0","pid":"6","percent_usr":"0.00","perc...}
{"time":"1646859134","uid":"0","pid":"9","percent_usr":"0.00","perc...}
...
<a id="jc.parsers.pidstat_s.parse"></a>
### parse
```python
@add_jc_meta
def parse(data: Iterable[str],
raw: bool = False,
quiet: bool = False,
ignore_exceptions: bool = False) -> Union[Iterable[Dict], tuple]
```
Main text parsing generator function. Returns an iterable object.
Parameters:
data: (iterable) line-based text data to parse
(e.g. sys.stdin or str.splitlines())
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
ignore_exceptions: (boolean) ignore parsing exceptions if True
Returns:
Iterable of Dictionaries
### Parser Information
Compatibility: linux
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.ping
jc - JSON CLI output utility `ping` command output parser
jc - JSON Convert `ping` command output parser
Supports `ping` and `ping6` output.
@@ -23,11 +23,6 @@ Usage (module):
import jc
result = jc.parse('ping', ping_command_output)
or
import jc.parsers.ping
result = jc.parsers.ping.parse(ping_command_output)
Schema:
{

View File

@@ -3,9 +3,10 @@
# jc.parsers.ping\_s
jc - JSON CLI output utility `ping` command output streaming parser
jc - JSON Convert `ping` command output streaming parser
> This streaming parser outputs JSON Lines
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
Dictionaries (module)
Supports `ping` and `ping6` output.
@@ -23,19 +24,11 @@ Usage (cli):
Usage (module):
import jc
# result is an iterable object (generator)
result = jc.parse('ping_s', ping_command_output.splitlines())
for item in result:
# do something
or
import jc.parsers.ping_s
# result is an iterable object (generator)
result = jc.parsers.ping_s.parse(ping_command_output.splitlines())
for item in result:
# do something
Schema:
{
@@ -61,14 +54,12 @@ Schema:
"round_trip_ms_max": float,
"round_trip_ms_stddev": float,
# Below object only exists if using -qq or ignore_exceptions=True
"_jc_meta":
{
"success": boolean, # false if error parsing
"error": string, # exists if "success" is false
"line": string # exists if "success" is false
}
# below object only exists if using -qq or ignore_exceptions=True
"_jc_meta": {
"success": boolean, # false if error parsing
"error": string, # exists if "success" is false
"line": string # exists if "success" is false
}
}
[0] 'reply', 'timeout', 'summary', etc. See `_error_type.type_map`
@@ -93,10 +84,11 @@ Examples:
### parse
```python
@add_jc_meta
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
```
Main text parsing generator function. Returns an iterator object.
Main text parsing generator function. Returns an iterable object.
Parameters:
@@ -107,15 +99,11 @@ Parameters:
quiet: (boolean) suppress warning messages if True
ignore_exceptions: (boolean) ignore parsing exceptions if True
Yields:
Dictionary. Raw or processed structured data.
Returns:
Iterator object
Iterable of Dictionaries
### Parser Information
Compatibility: linux, darwin, freebsd
Version 0.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.pip\_list
jc - JSON CLI output utility `pip-list` command output parser
jc - JSON Convert `pip-list` command output parser
Usage (cli):
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('pip_list', pip_list_command_output)
or
import jc.parsers.pip_list
result = jc.parsers.pip_list.parse(pip_list_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.pip\_show
jc - JSON CLI output utility `pip-show` command output parser
jc - JSON Convert `pip-show` command output parser
Usage (cli):
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('pip_show', pip_show_command_output)
or
import jc.parsers.pip_show
result = jc.parsers.pip_show.parse(pip_show_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.ps
jc - JSON CLI output utility `ps` command output parser
jc - JSON Convert `ps` command output parser
`ps` options supported:
- `ef`
@@ -22,11 +22,6 @@ Usage (module):
import jc
result = jc.parse('ps', ps_command_output)
or
import jc.parsers.ps
result = jc.parsers.ps.parse(ps_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.route
jc - JSON CLI output utility `route` command output parser
jc - JSON Convert `route` command output parser
Usage (cli):
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('route', route_command_output)
or
import jc.parsers.route
result = jc.parsers.route.parse(route_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.rpm\_qi
jc - JSON CLI output utility `rpm -qi` command output parser
jc - JSON Convert `rpm -qi` command output parser
Works with `rpm -qi [package]` or `rpm -qia`.
@@ -26,11 +26,6 @@ Usage (module):
import jc
result = jc.parse('rpm_qi', rpm_qi_command_output)
or
import jc.parsers.rpm_qi
result = jc.parsers.rpm_qi.parse(rpm_qi_command_output)
Schema:
[
@@ -189,4 +184,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

160
docs/parsers/rsync.md Normal file
View File

@@ -0,0 +1,160 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.rsync"></a>
# jc.parsers.rsync
jc - JSON Convert `rsync` command output parser
Supports the `-i` or `--itemize-changes` options with all levels of
verbosity. This parser will process the STDOUT output or a log file
generated with the `--log-file` option.
Usage (cli):
$ rsync -i -a source/ dest | jc --rsync
or
$ jc rsync -i -a source/ dest
or
$ cat rsync-backup.log | jc --rsync
Usage (module):
import jc
result = jc.parse('rsync', rsync_command_output)
Schema:
[
{
"summary": {
"date": string,
"time": string,
"process": integer,
"sent": integer,
"received": integer,
"total_size": integer,
"matches": integer,
"hash_hits": integer,
"false_alarms": integer,
"data": integer,
"bytes_sec": float,
"speedup": float
},
"files": [
{
"filename": string,
"date": string,
"time": string,
"process": integer,
"metadata": string,
"update_type": string/null, [0]
"file_type": string/null, [1]
"checksum_or_value_different": bool/null,
"size_different": bool/null,
"modification_time_different": bool/null,
"permissions_different": bool/null,
"owner_different": bool/null,
"group_different": bool/null,
"acl_different": bool/null,
"extended_attribute_different": bool/null,
"epoch": integer, [2]
}
]
}
]
[0] 'file sent', 'file received', 'local change or creation',
'hard link', 'not updated', 'message'
[1] 'file', 'directory', 'symlink', 'device', 'special file'
[2] naive timestamp if time and date fields exist and can be converted.
Examples:
$ rsync -i -a source/ dest | jc --rsync -p
[
{
"summary": {
"sent": 1708,
"received": 8209,
"bytes_sec": 19834.0,
"total_size": 235,
"speedup": 0.02
},
"files": [
{
"filename": "./",
"metadata": ".d..t......",
"update_type": "not updated",
"file_type": "directory",
"checksum_or_value_different": false,
"size_different": false,
"modification_time_different": true,
"permissions_different": false,
"owner_different": false,
"group_different": false,
"acl_different": false,
"extended_attribute_different": false
},
...
]
}
]
$ rsync | jc --rsync -p -r
[
{
"summary": {
"sent": "1,708",
"received": "8,209",
"bytes_sec": "19,834.00",
"total_size": "235",
"speedup": "0.02"
},
"files": [
{
"filename": "./",
"metadata": ".d..t......",
"update_type": "not updated",
"file_type": "directory",
"checksum_or_value_different": false,
"size_different": false,
"modification_time_different": true,
"permissions_different": false,
"owner_different": false,
"group_different": false,
"acl_different": false,
"extended_attribute_different": false
},
...
]
}
]
<a id="jc.parsers.rsync.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
### Parser Information
Compatibility: linux, darwin, freebsd
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

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

@@ -0,0 +1,117 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.rsync_s"></a>
# jc.parsers.rsync\_s
jc - JSON Convert `rsync` command output streaming parser
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
Dictionaries (module)
Supports the `-i` or `--itemize-changes` options with all levels of
verbosity. This parser will process the STDOUT output or a log file
generated with the `--log-file` option.
Usage (cli):
$ rsync -i -a source/ dest | jc --rsync-s
or
$ cat rsync-backup.log | jc --rsync-s
Usage (module):
import jc
result = jc.parse('rsync_s', rsync_command_output.splitlines())
for item in result:
# do something
Schema:
{
"type": string, # 'file' or 'summary'
"date": string,
"time": string,
"process": integer,
"sent": integer,
"received": integer,
"total_size": integer,
"matches": integer,
"hash_hits": integer,
"false_alarms": integer,
"data": integer,
"bytes_sec": float,
"speedup": float,
"filename": string,
"date": string,
"time": string,
"process": integer,
"metadata": string,
"update_type": string/null, [0]
"file_type": string/null, [1]
"checksum_or_value_different": bool/null,
"size_different": bool/null,
"modification_time_different": bool/null,
"permissions_different": bool/null,
"owner_different": bool/null,
"group_different": bool/null,
"acl_different": bool/null,
"extended_attribute_different": bool/null,
"epoch": integer, [2]
# below object only exists if using -qq or ignore_exceptions=True
"_jc_meta": {
"success": boolean, # false if error parsing
"error": string, # exists if "success" is false
"line": string # exists if "success" is false
}
}
[0] 'file sent', 'file received', 'local change or creation',
'hard link', 'not updated', 'message'
[1] 'file', 'directory', 'symlink', 'device', 'special file'
[2] naive timestamp if time and date fields exist and can be converted.
Examples:
$ rsync -i -a source/ dest | jc --rsync-s
{"type":"file","filename":"./","metadata":".d..t......","update_...}
...
$ cat rsync_backup.log | jc --rsync-s
{"type":"file","filename":"./","date":"2022/01/28","time":"03:53...}
...
<a id="jc.parsers.rsync_s.parse"></a>
### parse
```python
@add_jc_meta
def parse(data: Iterable[str],
raw: bool = False,
quiet: bool = False,
ignore_exceptions: bool = False) -> Union[Iterable[Dict], tuple]
```
Main text parsing generator function. Returns an iterable object.
Parameters:
data: (iterable) line-based text data to parse
(e.g. sys.stdin or str.splitlines())
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
ignore_exceptions: (boolean) ignore parsing exceptions if True
Returns:
Iterable of Dictionaries
### Parser Information
Compatibility: linux, darwin, freebsd
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.sfdisk
jc - JSON CLI output utility `sfdisk` command output parser
jc - JSON Convert `sfdisk` command output parser
Supports the following `sfdisk` options:
- `-l`
@@ -27,11 +27,6 @@ Usage (module):
import jc
result = jc.parse('sfdisk', sfdisk_command_output)
or
import jc.parsers.sfdisk
result = jc.parsers.sfdisk.parse(sfdisk_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.shadow
jc - JSON CLI output utility `/etc/shadow` file parser
jc - JSON Convert `/etc/shadow` file parser
Usage (cli):
@@ -14,11 +14,6 @@ Usage (module):
import jc
result = jc.parse('shadow', shadow_file_output)
or
import jc.parsers.shadow
result = jc.parsers.shadow.parse(shadow_file_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.ss
jc - JSON CLI output utility `ss` command output parser
jc - JSON Convert `ss` command output parser
Extended information options like -e and -p are not supported and may cause
parsing irregularities.
@@ -21,11 +21,6 @@ Usage (module):
import jc
result = jc.parse('ss', ss_command_output)
or
import jc.parsers.ss
result = jc.parsers.ss.parse(ss_command_output)
Schema:
Information from https://www.cyberciti.biz/files/ss.html used to define

View File

@@ -3,7 +3,7 @@
# jc.parsers.stat
jc - JSON CLI output utility `stat` command output parser
jc - JSON Convert `stat` command output parser
The `xxx_epoch` calculated timestamp fields are naive. (i.e. based on the
local time of the system the parser is run on)
@@ -24,11 +24,6 @@ Usage (module):
import jc
result = jc.parse('stat', stat_command_output)
or
import jc.parsers.stat
result = jc.parsers.stat.parse(stat_command_output)
Schema:
[
@@ -198,4 +193,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, freebsd
Version 1.10 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.11 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,9 +3,10 @@
# jc.parsers.stat\_s
jc - JSON CLI output utility `stat` command output streaming parser
jc - JSON Convert `stat` command output streaming parser
> This streaming parser outputs JSON Lines
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
Dictionaries (module)
The `xxx_epoch` calculated timestamp fields are naive. (i.e. based on the
local time of the system the parser is run on).
@@ -20,19 +21,11 @@ Usage (cli):
Usage (module):
import jc
# result is an iterable object (generator)
result = jc.parse('stat_s', stat_command_output.splitlines())
for item in result:
# do something
or
import jc.parsers.stat_s
# result is an iterable object (generator)
result = jc.parsers.stat_s.parse(stat_command_output.splitlines())
for item in result:
# do something
Schema:
{
@@ -68,14 +61,12 @@ Schema:
"block_size": integer,
"unix_flags": string,
# Below object only exists if using -qq or ignore_exceptions=True
"_jc_meta":
{
"success": boolean, # false if error parsing
"error": string, # exists if "success" is false
"line": string # exists if "success" is false
}
# below object only exists if using -qq or ignore_exceptions=True
"_jc_meta": {
"success": boolean, # false if error parsing
"error": string, # exists if "success" is false
"line": string # exists if "success" is false
}
}
Examples:
@@ -91,10 +82,11 @@ Examples:
### parse
```python
@add_jc_meta
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
```
Main text parsing generator function. Returns an iterator object.
Main text parsing generator function. Returns an iterable object.
Parameters:
@@ -105,15 +97,11 @@ Parameters:
quiet: (boolean) suppress warning messages if True
ignore_exceptions: (boolean) ignore parsing exceptions if True
Yields:
Dictionary. Raw or processed structured data.
Returns:
Iterator object
Iterable of Dictionaries
### Parser Information
Compatibility: linux, darwin, freebsd
Version 0.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.sysctl
jc - JSON CLI output utility `sysctl -a` command output parser
jc - JSON Convert `sysctl -a` command output parser
Note: Since `sysctl` output is not easily parsable only a very simple
key/value object will be output. An attempt is made to convert obvious
@@ -23,11 +23,6 @@ Usage (module):
import jc
result = jc.parse('sysctl', sysctl_command_output)
or
import jc.parsers.sysctl
result = jc.parsers.sysctl.parse(sysctl_command_output)
Schema:
{

View File

@@ -3,7 +3,7 @@
# jc.parsers.systemctl
jc - JSON CLI output utility `systemctl` command output parser
jc - JSON Convert `systemctl` command output parser
Usage (cli):
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('systemctl', systemctl_command_output)
or
import jc.parsers.systemctl
result = jc.parsers.systemctl.parse(systemctl_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.systemctl\_lj
jc - JSON CLI output utility `systemctl list-jobs` command output parser
jc - JSON Convert `systemctl list-jobs` command output parser
Usage (cli):
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('systemctl_lj', systemctl_lj_command_output)
or
import jc.parsers.systemctl_lj
result = jc.parsers.systemctl_lj.parse(systemctl_lj_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.systemctl\_ls
jc - JSON CLI output utility `systemctl list-sockets` command output
jc - JSON Convert `systemctl list-sockets` command output
parser
Usage (cli):
@@ -19,11 +19,6 @@ Usage (module):
import jc
result = jc.parse('systemctl_ls', systemctl_ls_command_output)
or
import jc.parsers.systemctl_ls
result = jc.parsers.systemctl_ls.parse(systemctl_ls_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.systemctl\_luf
jc - JSON CLI output utility `systemctl list-unit-files` command output
jc - JSON Convert `systemctl list-unit-files` command output
parser
Usage (cli):
@@ -19,11 +19,6 @@ Usage (module):
import jc
result = jc.parse('systemctl_luf', systemctl_luf_command_output)
or
import jc.parsers.systemctl_luf
result = jc.parsers.systemctl_luf.parse(systemctl_luf_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.systeminfo
jc - JSON CLI output utility `systeminfo` command output parser
jc - JSON Convert `systeminfo` command output parser
Blank or missing elements are set to `null`.
@@ -24,11 +24,6 @@ Usage (module):
import jc
result = jc.parse('systeminfo', systeminfo_command_output)
or
import jc.parsers.systeminfo
result = jc.parsers.systeminfo.parse(systeminfo_command_output)
Schema:
{
@@ -239,4 +234,4 @@ Returns:
### Parser Information
Compatibility: win32
Version 1.1 by Jon Smith (jon@rebelliondefense.com)
Version 1.2 by Jon Smith (jon@rebelliondefense.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.time
jc - JSON CLI output utility `/usr/bin/time` command output parser
jc - JSON Convert `/usr/bin/time` command output parser
Output from `/usr/bin/time` is sent to `STDERR`, so the `-o` option can be
used to redirect the output to a file that can be read by `jc`.
@@ -24,11 +24,6 @@ Usage (module):
import jc
result = jc.parse('time', time_command_output)
or
import jc.parsers.time
result = jc.parsers.time.parse(time_command_output)
Schema:
Source: https://www.freebsd.org/cgi/man.cgi?query=getrusage

View File

@@ -3,7 +3,7 @@
# jc.parsers.timedatectl
jc - JSON CLI output utility `timedatectl` command output parser
jc - JSON Convert `timedatectl` command output parser
The `epoch_utc` calculated timestamp field is timezone-aware and is only
available if the `universal_time` field is available.
@@ -21,11 +21,6 @@ Usage (module):
import jc
result = jc.parse('timedatectl', timedatectl_command_output)
or
import jc.parsers.timedatectl
result = jc.parsers.timedatectl.parse(timedatectl_command_output)
Schema:
{
@@ -92,4 +87,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.tracepath
jc - JSON CLI output utility `tracepath` command output parser
jc - JSON Convert `tracepath` command output parser
Supports `tracepath` and `tracepath6` output.
@@ -20,11 +20,6 @@ Usage (module):
import jc
result = jc.parse('tracepath', tracepath_command_output)
or
import jc.parsers.tracepath
result = jc.parsers.tracepath.parse(tracepath_command_output)
Schema:
{

View File

@@ -3,7 +3,7 @@
# jc.parsers.traceroute
jc - JSON CLI output utility `traceroute` command output parser
jc - JSON Convert `traceroute` command output parser
Supports `traceroute` and `traceroute6` output.
@@ -27,11 +27,6 @@ Usage (module):
import jc
result = jc.parse('traceroute', traceroute_command_output)
or
import jc.parsers.traceroute
result = jc.parsers.traceroute.parse(traceroute_command_output)
Schema:
{

View File

@@ -3,7 +3,7 @@
# jc.parsers.ufw
jc - JSON CLI output utility `ufw status` command output parser
jc - JSON Convert `ufw status` command output parser
Usage (cli):
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('ufw', ufw_command_output)
or
import jc.parsers.ufw
result = jc.parsers.ufw.parse(ufw_command_output)
Schema:
{

View File

@@ -3,7 +3,7 @@
# jc.parsers.ufw\_appinfo
jc - JSON CLI output utility `ufw app info [application]` command
jc - JSON Convert `ufw app info [application]` command
output parser
Supports individual apps via `ufw app info [application]` and all apps list
@@ -26,11 +26,6 @@ Usage (module):
import jc
result = jc.parse('ufw_appinfo', ufw_appinfo_command_output)
or
import jc.parsers.ufw_appinfo
result = jc.parsers.ufw_appinfo.parse(ufw_appinfo_command_output)
Schema:
[

View File

@@ -3,7 +3,7 @@
# jc.parsers.uname
jc - JSON CLI output utility `uname -a` command output parser
jc - JSON Convert `uname -a` command output parser
Note: Must use `uname -a`
@@ -20,11 +20,6 @@ Usage (module):
import jc
result = jc.parse('uname', uname_command_output)
or
import jc.parsers.uname
result = jc.parsers.uname.parse(uname_command_output)
Schema:
{

View File

@@ -8,21 +8,35 @@
# jc.parsers.universal
jc - JSON CLI output utility universal Parsers
jc - JSON Convert universal parsers
<a id="jc.parsers.universal.simple_table_parse"></a>
### simple\_table\_parse
```python
def simple_table_parse(data: List[str]) -> List[Dict]
def simple_table_parse(data: Iterable[str]) -> List[Dict]
```
Parse simple tables. The last column may contain data with spaces.
Parse simple tables. There should be no blank cells. The last column
may contain data with spaces.
Example Table:
col_1 col_2 col_3 col_4 col_5
apple orange pear banana my favorite fruits
carrot squash celery spinach my favorite veggies
chicken beef pork eggs my favorite proteins
[{'col_1': 'apple', 'col_2': 'orange', 'col_3': 'pear', 'col_4':
'banana', 'col_5': 'my favorite fruits'}, {'col_1': 'carrot',
'col_2': 'squash', 'col_3': 'celery', 'col_4': 'spinach', 'col_5':
'my favorite veggies'}, {'col_1': 'chicken', 'col_2': 'beef',
'col_3': 'pork', 'col_4': 'eggs', 'col_5': 'my favorite proteins'}]
Parameters:
data: (list) Text data to parse that has been split into lines
data: (iter) Text data to parse that has been split into lines
via .splitlines(). Item 0 must be the header row.
Any spaces in header names should be changed to
underscore '_'. You should also ensure headers are
@@ -40,23 +54,38 @@ Returns:
### sparse\_table\_parse
```python
def sparse_table_parse(data: List[str], delim: Optional[str] = '\u2063') -> List[Dict]
def sparse_table_parse(data: Iterable[str],
delim: str = '\u2063') -> List[Dict]
```
Parse tables with missing column data or with spaces in column data.
Blank cells are converted to None in the resulting dictionary. Data
elements must line up within column boundaries.
Example Table:
col_1 col_2 col_3 col_4 col_5
apple orange fuzzy peach my favorite fruits
green beans celery spinach my favorite veggies
chicken beef brown eggs my favorite proteins
[{'col_1': 'apple', 'col_2': 'orange', 'col_3': None, 'col_4':
'fuzzy peach', 'col_5': 'my favorite fruits'}, {'col_1':
'green beans', 'col_2': None, 'col_3': 'celery', 'col_4': 'spinach',
'col_5': 'my favorite veggies'}, {'col_1': 'chicken', 'col_2':
'beef', 'col_3': None, 'col_4': 'brown eggs', 'col_5':
'my favorite proteins'}]
Parameters:
data: (list) Text data to parse that has been split into lines
via .splitlines(). Item 0 must be the header row.
Any spaces in header names should be changed to
underscore '_'. You should also ensure headers are
lowercase by using .lower(). Do not change the
position of header names as the positions are used
to find the data.
data: (iter) An iterable of string lines (e.g. str.splitlines())
Item 0 must be the header row. Any spaces in header
names should be changed to underscore '_'. You
should also ensure headers are lowercase by using
.lower(). Do not change the position of header
names as the positions are used to find the data.
Also, ensure there are no blank lines (list items)
in the data.
Also, ensure there are no blank line items.
delim: (string) Delimiter to use. By default `u\\2063`
(invisible separator) is used since it is unlikely

View File

@@ -0,0 +1,71 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.update_alt_gs"></a>
# jc.parsers.update\_alt\_gs
jc - JSON Convert `update-alternatives --get-selections` command output parser
Usage (cli):
$ update-alternatives --get-selections | jc --update-alt-gs
or
$ jc update-alternatives --get-selections
Usage (module):
import jc
result = jc.parse('update-alt-gs',
update_alternatives_get_selections_command_output)
Schema:
[
{
"name": string,
"status": string,
"current": string
}
]
Examples:
$ update-alternatives --get-selections | jc --update-alt-gs -p
[
{
"name": "arptables",
"status": "auto",
"current": "/usr/sbin/arptables-nft"
},
{
"name": "awk",
"status": "auto",
"current": "/usr/bin/gawk"
}
]
<a id="jc.parsers.update_alt_gs.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
### Parser Information
Compatibility: linux
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -0,0 +1,157 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.update_alt_q"></a>
# jc.parsers.update\_alt\_q
jc - JSON Convert `update-alternatives --query` command output parser
Usage (cli):
$ update-alternatives --query | jc --update-alt-q
or
$ jc update-alternatives --query
Usage (module):
import jc
result = jc.parse('update_alt_q',
update_alternatives_query_command_output)
Schema:
{
"name": string,
"link": string,
"slaves": [
{
"name": string,
"path": string
}
],
"status": string,
"best": string,
"value": string, # (null if 'none')
"alternatives": [
{
"alternative": string,
"priority": integer,
"slaves": [
{
"name": string,
"path": string
}
]
}
]
}
Examples:
$ update-alternatives --query editor | jc --update-alt-q -p
{
"name": "editor",
"link": "/usr/bin/editor",
"slaves": [
{
"name": "editor.1.gz",
"path": "/usr/share/man/man1/editor.1.gz"
},
{
"name": "editor.da.1.gz",
"path": "/usr/share/man/da/man1/editor.1.gz"
}
],
"status": "auto",
"best": "/bin/nano",
"value": "/bin/nano",
"alternatives": [
{
"alternative": "/bin/ed",
"priority": -100,
"slaves": [
{
"name": "editor.1.gz",
"path": "/usr/share/man/man1/ed.1.gz"
}
]
},
{
"alternative": "/bin/nano",
"priority": 40,
"slaves": [
{
"name": "editor.1.gz",
"path": "/usr/share/man/man1/nano.1.gz"
}
]
}
]
}
$ update-alternatives --query | jc --update-alt-q -p -r
{
"name": "editor",
"link": "/usr/bin/editor",
"slaves": [
{
"name": "editor.1.gz",
"path": "/usr/share/man/man1/editor.1.gz"
},
{
"name": "editor.da.1.gz",
"path": "/usr/share/man/da/man1/editor.1.gz"
}
],
"status": "auto",
"best": "/bin/nano",
"value": "/bin/nano",
"alternatives": [
{
"alternative": "/bin/ed",
"priority": "-100",
"slaves": [
{
"name": "editor.1.gz",
"path": "/usr/share/man/man1/ed.1.gz"
}
]
},
{
"alternative": "/bin/nano",
"priority": "40",
"slaves": [
{
"name": "editor.1.gz",
"path": "/usr/share/man/man1/nano.1.gz"
}
]
}
]
}
<a id="jc.parsers.update_alt_q.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False) -> Dict
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.
### Parser Information
Compatibility: linux
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.upower
jc - JSON CLI output utility `upower` command output parser
jc - JSON Convert `upower` command output parser
The `updated_epoch` calculated timestamp field is naive. (i.e. based on the
local time of the system the parser is run on)
@@ -24,11 +24,6 @@ Usage (module):
import jc
result = jc.parse('upower', upower_command_output)
or
import jc.parsers.upower
result = jc.parsers.upower.parse(upower_command_output)
Schema:
[
@@ -226,4 +221,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.uptime
jc - JSON CLI output utility `uptime` command output parser
jc - JSON Convert `uptime` command output parser
Usage (cli):
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('uptime', uptime_command_output)
or
import jc.parsers.uptime
result = jc.parsers.uptime.parse(uptime_command_output)
Schema:
{

View File

@@ -3,7 +3,7 @@
# jc.parsers.vmstat
jc - JSON CLI output utility `vmstat` command output parser
jc - JSON Convert `vmstat` command output parser
Options supported: `-a`, `-w`, `-d`, `-t`
@@ -26,11 +26,6 @@ Usage (module):
import jc
result = jc.parse('vmstat', vmstat_command_output)
or
import jc.parsers.vmstat
result = jc.parsers.vmstat.parse(vmstat_command_output)
Schema:
[
@@ -154,4 +149,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,9 +3,10 @@
# jc.parsers.vmstat\_s
jc - JSON CLI output utility `vmstat` command output streaming parser
jc - JSON Convert `vmstat` command output streaming parser
> This streaming parser outputs JSON Lines
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
Dictionaries (module)
Options supported: `-a`, `-w`, `-d`, `-t`
@@ -20,28 +21,20 @@ Usage (cli):
$ vmstat | jc --vmstat-s
> Note: When piping `jc` converted `vmstat` output to other processes it may
appear the output is hanging due to the OS pipe buffers. This is because
`vmstat` output is too small to quickly fill up the buffer. Use the `-u`
option to unbuffer the `jc` output if you would like immediate output. See
the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
for more information.
appear the output is hanging due to the OS pipe buffers. This is because
`vmstat` output is too small to quickly fill up the buffer. Use the `-u`
option to unbuffer the `jc` output if you would like immediate output. See
the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
for more information.
Usage (module):
import jc
# result is an iterable object (generator)
result = jc.parse('vmstat_s', vmstat_command_output.splitlines())
for item in result:
# do something
or
import jc.parsers.vmstat_s
# result is an iterable object (generator)
result = jc.parsers.vmstat_s.parse(vmstat_command_output.splitlines())
for item in result:
# do something
Schema:
{
@@ -80,14 +73,12 @@ Schema:
"epoch": integer, # [0]
"epoch_utc": integer # [1]
# Below object only exists if using -qq or ignore_exceptions=True
"_jc_meta":
{
"success": boolean, # [2]
"error": string, # [3]
"line": string # [3]
}
# below object only exists if using -qq or ignore_exceptions=True
"_jc_meta": {
"success": boolean, # [2]
"error": string, # [3]
"line": string # [3]
}
}
[0] naive timestamp if -t flag is used
@@ -110,10 +101,11 @@ Examples:
### parse
```python
@add_jc_meta
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
```
Main text parsing generator function. Returns an iterator object.
Main text parsing generator function. Returns an iterable object.
Parameters:
@@ -124,15 +116,11 @@ Parameters:
quiet: (boolean) suppress warning messages if True
ignore_exceptions: (boolean) ignore parsing exceptions if True
Yields:
Dictionary. Raw or processed structured data.
Returns:
Iterator object
Iterable of Dictionaries
### Parser Information
Compatibility: linux
Version 0.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -3,7 +3,7 @@
# jc.parsers.w
jc - JSON CLI output utility `w` command output parser
jc - JSON Convert `w` command output parser
Usage (cli):
@@ -18,11 +18,6 @@ Usage (module):
import jc
result = jc.parse('w', w_command_output)
or
import jc.parsers.w
result = jc.parsers.w.parse(w_command_output)
Schema:
[

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