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

Compare commits

...

919 Commits

Author SHA1 Message Date
Kelly Brazil
fd7861db11 Merge pull request #127 from kellyjonbrazil/dev
Dev v1.15.3
2021-04-26 12:12:02 -07:00
Kelly Brazil
35464bbbfb date update 2021-04-26 12:08:10 -07:00
Kelly Brazil
db8ddd7f0e fix for scenarios where the default port range didn't always display, or overrode existing port ranges. 2021-04-26 12:04:03 -07:00
Kelly Brazil
72207c54ee update ufw app info docs to support multiple apps (ufw app info all) 2021-04-26 10:02:02 -07:00
Kelly Brazil
a683f68003 change schema to a list of dictionaries to support ufw app info all use case 2021-04-26 10:00:44 -07:00
Kelly Brazil
8d2d3db3fa formatting 2021-04-25 21:10:21 -07:00
Kelly Brazil
eca785450d add caveats to readme and manpage 2021-04-25 21:06:47 -07:00
Kelly Brazil
5b40a97ce4 add caveats to man page 2021-04-25 20:55:43 -07:00
Kelly Brazil
66cb4e9bde update ufw parser docs 2021-04-25 20:49:35 -07:00
Kelly Brazil
d1f33645ca update ufw tests 2021-04-25 20:40:38 -07:00
Kelly Brazil
5eff65c326 update schema to support port lists and port range lists. Also support other transports than tcp and udp 2021-04-25 20:10:52 -07:00
Kelly Brazil
929c38715d formatting 2021-04-24 12:53:29 -07:00
Kelly Brazil
8c91a7b760 formatting 2021-04-24 12:52:26 -07:00
Kelly Brazil
14289ecd6c more timezone info 2021-04-24 12:50:40 -07:00
Kelly Brazil
b833c44783 add ufw-appinfo parser 2021-04-24 12:47:24 -07:00
Kelly Brazil
e23aa818ea add tests section and timezone info 2021-04-24 12:47:12 -07:00
Kelly Brazil
473d919c13 add another ufw test sample 2021-04-24 10:58:31 -07:00
Kelly Brazil
9f925d6ac9 doc update 2021-04-24 10:22:37 -07:00
Kelly Brazil
f6ca32b3a3 update ufw docs with a note on lists of ports 2021-04-24 10:22:19 -07:00
Kelly Brazil
4cbe84c3d6 add ufw-appinfo tests 2021-04-23 16:15:04 -07:00
Kelly Brazil
ffac5bf9d3 doc update 2021-04-23 16:14:53 -07:00
Kelly Brazil
9aa424f9f8 fix ufw example 2021-04-23 16:14:39 -07:00
Kelly Brazil
0a8495c68e update docs 2021-04-23 16:14:25 -07:00
Kelly Brazil
6aea066cf0 make normalized list appear only when data exists. set magic commands 2021-04-23 16:14:11 -07:00
Kelly Brazil
ff3c2d809e add ufw-appinfo to docs 2021-04-23 09:57:41 -07:00
Kelly Brazil
145059fc89 clean up output if sections are blank 2021-04-23 09:04:11 -07:00
Kelly Brazil
20e5c19de4 fix key error if tcp or udp don't exist 2021-04-23 08:30:34 -07:00
Kelly Brazil
4c98fd4b87 doc update 2021-04-23 08:26:00 -07:00
Kelly Brazil
125e54213e update schema and add normalized fields 2021-04-23 08:13:53 -07:00
Kelly Brazil
0152e0665f initial working ufw-appinfo parser 2021-04-22 16:52:01 -07:00
Kelly Brazil
0679bcbc56 fix ufw tests 2021-04-22 08:33:57 -07:00
Kelly Brazil
5500648aa0 fix ufw docs for int conversions and service behavior 2021-04-22 08:33:45 -07:00
Kelly Brazil
bb50caad4d fix prefix int conversions. don't reset _transport if service is really a list of ports 2021-04-22 08:16:42 -07:00
Kelly Brazil
7eef5d94d5 ufw doc update 2021-04-21 16:55:25 -07:00
Kelly Brazil
74f623f8d6 add support for rule comments and LIMIT and REJECT actions 2021-04-21 16:55:14 -07:00
Kelly Brazil
f638aca092 add deb package name fix 2021-04-21 10:10:36 -07:00
Kelly Brazil
da35eaf80a formatting 2021-04-21 09:10:10 -07:00
Kelly Brazil
ade0e8e8fc add ufw tests 2021-04-21 09:09:23 -07:00
Kelly Brazil
90076090f0 fix int conversions if 'rules' key does not exist 2021-04-21 09:09:09 -07:00
Kelly Brazil
23635def8b add ufw to docs 2021-04-21 07:51:32 -07:00
Kelly Brazil
4eeec087bd add ufw example 2021-04-21 07:49:49 -07:00
Kelly Brazil
7331961038 update docs with new examples that have to_service always existing. 2021-04-21 07:41:32 -07:00
Kelly Brazil
e4acb3d5b7 always make to/from_service None if ports are assigned 2021-04-21 07:08:50 -07:00
Kelly Brazil
c60549a994 change field name from to/from_subnet to to/from_ip_prefix 2021-04-20 22:08:12 -07:00
Kelly Brazil
d46fc8bbfa set to/from_transport to None if to/from_service is set 2021-04-20 21:58:52 -07:00
Kelly Brazil
b133d1f90d strip interface value 2021-04-20 21:52:39 -07:00
Kelly Brazil
5be615a97e add examples for docs 2021-04-20 21:45:13 -07:00
Kelly Brazil
ea1d820f96 convert integer fields 2021-04-20 21:29:49 -07:00
Kelly Brazil
47e262cf72 clean up fields 2021-04-20 21:21:42 -07:00
Kelly Brazil
eec673be90 working raw parser 2021-04-20 20:32:59 -07:00
Kelly Brazil
9a0fb2a7c8 parse major sections 2021-04-20 14:17:01 -07:00
Kelly Brazil
b5145d6c14 version bump to v1.15.3 2021-04-20 13:39:12 -07:00
Kelly Brazil
9747ca414d minor optimization to convert_to_int(). No longer runs through convert_to_float(), but uses standard float() function. 2021-04-20 10:50:20 -07:00
Kelly Brazil
312d465b61 update link 2021-04-19 14:18:12 -07:00
Kelly Brazil
7dcf87d24a formatting 2021-04-19 13:12:55 -07:00
Kelly Brazil
cf3cfd16a9 rename tests 2021-04-19 09:59:58 -07:00
Kelly Brazil
fcc7e52949 Merge pull request #123 from kellyjonbrazil/dev
Dev v1.15.2
2021-04-18 17:28:27 -07:00
Kelly Brazil
3ab9d48014 update changelog 2021-04-18 17:24:42 -07:00
Kelly Brazil
7eddf41c5f dont round up int conversions and fix tests 2021-04-18 17:21:08 -07:00
Kelly Brazil
27a196c938 doc update 2021-04-18 16:42:42 -07:00
Kelly Brazil
e4324f05fb fix indentation in doc 2021-04-18 16:42:34 -07:00
Kelly Brazil
d36b332bd7 use jc.utils for conversions 2021-04-18 16:33:47 -07:00
Kelly Brazil
1f034826f6 use jc.utils for conversions 2021-04-18 13:01:25 -07:00
Kelly Brazil
246c707c98 use jc.utils conversions 2021-04-18 11:46:42 -07:00
Kelly Brazil
b5d8968144 add convert_to_int function 2021-04-17 17:22:59 -07:00
Kelly Brazil
f7b9fbefdd add query_size info for dig 2021-04-17 17:22:44 -07:00
Kelly Brazil
b1fc453383 fix _IfconfigParser name 2021-04-17 17:22:30 -07:00
Kelly Brazil
7581c8d0f4 add query_size field. handle user-specified dig output better - especially when querying dnssec 2021-04-17 17:07:20 -07:00
Kelly Brazil
32bf8ad6f4 update dig docs 2021-04-17 15:02:45 -07:00
Kelly Brazil
b083bcc10f update man page 2021-04-16 16:30:17 -07:00
Kelly Brazil
4f6fdd120d use dig as example 2021-04-16 16:30:04 -07:00
Kelly Brazil
eb0038be24 update dig examples 2021-04-16 16:29:44 -07:00
Kelly Brazil
7ecdf819fa remove dig example from readme, 2021-04-16 16:29:27 -07:00
Kelly Brazil
c6aa4d0835 update docs with new dig parser examples 2021-04-16 16:19:20 -07:00
Kelly Brazil
7c584b89a6 add additional section 2021-04-16 16:04:06 -07:00
Kelly Brazil
c166c0bfda add opt_pseudosection section to output and fix existing tests 2021-04-16 15:22:22 -07:00
Kelly Brazil
a8dd3f7802 working dig axfr fixes 2021-04-16 13:11:02 -07:00
Kelly Brazil
3b0e2f03f3 clean up examples 2021-04-16 08:46:20 -07:00
Kelly Brazil
8390ae48c8 fix server entry when IPv6 address is in value (maxsplit on colons) 2021-04-15 16:53:03 -07:00
Kelly Brazil
2db82c0a7e add systeminfo example 2021-04-14 20:43:58 -07:00
Kelly Brazil
6147954075 update tests 2021-04-14 20:39:35 -07:00
Kelly Brazil
691df271fc add info docstring 2021-04-14 20:30:31 -07:00
Kelly Brazil
89f52b95f7 update systeminfo parser with updated timestamps, normalized blank fields, and new doc style 2021-04-14 20:20:46 -07:00
Kelly Brazil
146acc1bf6 rename functions to make them private 2021-04-14 16:46:16 -07:00
Kelly Brazil
c4a345f59a Merge pull request #106 from jon-rd/j/systeminfo
Add windows systeminfo command parser
2021-04-14 16:39:44 -07:00
Kelly Brazil
dfd2703f75 bump dev to v1.15.2 2021-04-14 16:39:05 -07:00
Jon Smith
325fab2de7 update documentation for parsed structures 2021-04-14 11:52:13 -05:00
Jon Smith
f3d00cf38a append mb to memory key names; adjust expected timestamps to utc tz 2021-04-14 11:38:50 -05:00
Jon Smith
14838f7f5d update schema with nic, hyperv, and process changes 2021-04-14 11:38:50 -05:00
Jon Smith
af74047b81 update schema based on processor/hotfix changes 2021-04-14 11:38:50 -05:00
Jon Smith
660c59129c Add parsing of processors/hotfixs 2021-04-14 11:38:50 -05:00
Jon Smith
89a88e186e Add systeminfo.md file 2021-04-14 11:38:50 -05:00
Jon Smith
f861cf95b9 Change to v0.5; add parser to cli.py; add to docgen 2021-04-14 11:38:50 -05:00
Jon Smith
ee8f06cbdb Add windows systeminfo command parser 2021-04-14 11:38:49 -05:00
Kelly Brazil
a2e8b3c7b6 Merge pull request #121 from kellyjonbrazil/master
Merge pull request #120 from kellyjonbrazil/dev
2021-04-13 16:40:43 -07:00
Kelly Brazil
6c83846075 Merge pull request #120 from kellyjonbrazil/dev
Dev v1.15.1
2021-04-13 14:59:17 -07:00
Kelly Brazil
e0681eebb9 Merge branch 'master' into dev 2021-04-13 14:57:44 -07:00
Kelly Brazil
e5732d1cea update changelog 2021-04-13 14:54:38 -07:00
Kelly Brazil
6e7ae3cd3f formatting of timedatectl docs 2021-04-13 14:51:46 -07:00
Kelly Brazil
f95632d1aa add install_date calculated fields 2021-04-13 14:49:57 -07:00
Kelly Brazil
2f8b7b26e5 update docs for v1.15.1 2021-04-13 14:35:17 -07:00
Kelly Brazil
10292f7502 Merge pull request #119 from kellyjonbrazil/dpkg_l-fix
add _l to module name
2021-04-12 13:15:40 -07:00
Kelly Brazil
aef54705f5 add _l to module name 2021-04-12 13:15:12 -07:00
Kelly Brazil
bba5980fa5 man page update 2021-04-12 13:13:18 -07:00
Kelly Brazil
977425abfb add _l to package name in docs 2021-04-12 13:12:08 -07:00
Kelly Brazil
37a3565a1b Merge pull request #118 from kellyjonbrazil/rpm-qi-doc-fix
fix rpm-qi docs
2021-04-12 13:06:30 -07:00
Kelly Brazil
13deb8bfb6 fix rpm-qi docs 2021-04-12 13:05:34 -07:00
Kelly Brazil
a3ed9d075a remove old parser doc 2021-04-12 13:04:22 -07:00
Kelly Brazil
fb0ced549e fix rpm-qi docs (used underscore instead of dash in name) 2021-04-12 13:01:17 -07:00
Kelly Brazil
7eb31bc7d2 update airport_s docs 2021-04-09 19:55:03 -07:00
Kelly Brazil
6a06a39142 use herestring instead of echo -e into jq 2021-04-09 16:36:20 -07:00
Kelly Brazil
bdcdaee6c5 Merge pull request #117 from kellyjonbrazil/doc_update
add new docs
2021-04-09 15:11:05 -07:00
Kelly Brazil
605353fdce add new docs 2021-04-09 15:10:38 -07:00
Kelly Brazil
490c9e1769 add more cli tests for magic command 2021-04-09 11:38:17 -07:00
Kelly Brazil
6ebebb659d update changelog 2021-04-09 11:10:08 -07:00
Kelly Brazil
0e70c5ee12 update documentation link 2021-04-09 11:04:17 -07:00
Kelly Brazil
cd531acf60 clean up comment 2021-04-09 11:02:19 -07:00
Kelly Brazil
908ac1f61c update docs - remove compatibility section since it is now automatically generated from info() 2021-04-09 10:56:43 -07:00
Kelly Brazil
f5c7e7e404 add updated docs with home link and parser info at the bottom 2021-04-09 10:36:42 -07:00
Kelly Brazil
001c700b5b add home link to the top of the md file 2021-04-09 10:36:03 -07:00
Kelly Brazil
9b41e9bef0 Add parser information header 2021-04-09 10:32:58 -07:00
Kelly Brazil
34bd6e32dc pull each parser as a json object into a bash array and iterate on it to add supplementary information like version, author, and compatibility 2021-04-09 10:26:34 -07:00
Kelly Brazil
c5d058490b move parser doc printing to its own function 2021-04-09 09:12:41 -07:00
Kelly Brazil
dd1ae6d9a7 add man page inside the pypi package for easier packaging in homebrew 2021-04-09 08:09:37 -07:00
Kelly Brazil
d8ea9bde82 doc update 2021-04-08 16:42:57 -07:00
Kelly Brazil
125edc9c90 bail out for -h, -a, and -v in magic() 2021-04-08 16:42:45 -07:00
Kelly Brazil
15ea43e394 add man file to package for easier packaging in homebrew 2021-04-08 16:28:05 -07:00
Kelly Brazil
b55b02687c doc update 2021-04-08 16:14:11 -07:00
Kelly Brazil
da611f0ac6 update docs 2021-04-08 15:53:06 -07:00
Kelly Brazil
b8b8dfead4 update docs 2021-04-08 15:52:49 -07:00
Kelly Brazil
4290a3cbd1 make IfconfigParser class private 2021-04-08 14:00:56 -07:00
Kelly Brazil
a5e2203cee update ifconfig doc 2021-04-08 12:45:08 -07:00
Kelly Brazil
e28c08b136 update documentation 2021-04-08 12:42:01 -07:00
Kelly Brazil
a4b6846f63 man update 2021-04-08 11:37:39 -07:00
Kelly Brazil
2bc8307861 Merge branch 'master' into dev
# Conflicts:
#	man/jc.1
2021-04-08 11:33:50 -07:00
Kelly Brazil
9b39917c79 update docstrings for new help functionality 2021-04-08 11:24:02 -07:00
Kelly Brazil
57c13cc0a3 add support for parser help 2021-04-08 10:54:15 -07:00
Kelly Brazil
b7355fd30d new docstring format for improved documentation 2021-04-08 10:20:24 -07:00
Kelly Brazil
93ae309e40 bump version to 1.15.1 2021-04-08 10:20:00 -07:00
Kelly Brazil
5d8f8365e2 gzip man page 2021-04-07 14:27:34 -07:00
Kelly Brazil
f26909eefb formatting 2021-04-07 11:18:33 -07:00
Kelly Brazil
55bfbb2797 formatting 2021-04-07 11:13:27 -07:00
Kelly Brazil
8970b8342a Merge pull request #115 from kellyjonbrazil/master
Sync master and dev
2021-04-07 09:34:45 -07:00
Kelly Brazil
5285e699c3 fix rpm-qi parser name 2021-04-07 08:07:50 -07:00
Kelly Brazil
275f3860d5 Merge pull request #114 from kellyjonbrazil/dev
Dev v1.15.0
2021-04-07 07:54:41 -07:00
Kelly Brazil
a73fdb7478 update dates 2021-04-07 07:50:17 -07:00
Kelly Brazil
f2d746403a typo fix 2021-04-06 20:30:56 -07:00
Kelly Brazil
b7dbf2c49b doc formatting 2021-04-06 18:53:50 -07:00
Kelly Brazil
21f3c97788 rename rpm_qai to rpm_qi 2021-04-06 18:38:04 -07:00
Kelly Brazil
14b727cc71 add rpm_qi tests 2021-04-06 18:34:08 -07:00
Kelly Brazil
abee226591 rename rpm_qia to rpm_qi 2021-04-06 18:32:47 -07:00
Kelly Brazil
293ad39f4b typo fix 2021-04-06 16:48:31 -07:00
Kelly Brazil
9244302581 rpm parser doc update 2021-04-06 15:07:39 -07:00
Kelly Brazil
753cac25fb only add description if it exists 2021-04-06 14:46:27 -07:00
Kelly Brazil
0548263e89 add rpm -qai parser 2021-04-06 14:39:39 -07:00
Kelly Brazil
53776a9bf8 note -a output is JSON 2021-04-06 11:36:10 -07:00
Kelly Brazil
cc7def9b76 add OSX finger tests 2021-04-06 11:29:30 -07:00
Kelly Brazil
11a4422c25 add centos 7.7 finger tests 2021-04-06 11:23:29 -07:00
Kelly Brazil
3a44785260 del details key if details are blank 2021-04-06 11:23:09 -07:00
Kelly Brazil
e0d430c26c update -r raw option info 2021-04-06 11:00:46 -07:00
Kelly Brazil
417b70020a add idle time fields to finger parser 2021-04-06 10:51:41 -07:00
Kelly Brazil
7b29c464b7 date updated 2021-04-06 10:04:02 -07:00
Kelly Brazil
26d5529d86 remove aix support, add note for -s support. schema update 2021-04-06 10:03:51 -07:00
Kelly Brazil
852103c478 tweak regex to support arbitrary 'detail' data 2021-04-06 10:02:46 -07:00
Kelly Brazil
26a115421b add finger parser 2021-04-05 17:16:38 -07:00
Kelly Brazil
755b941a9a doc update 2021-04-05 17:14:33 -07:00
Kelly Brazil
fd1ca82d86 add finger parser 2021-04-05 17:09:22 -07:00
Kelly Brazil
6fe175344f change examples link to github.io 2021-04-05 13:38:09 -07:00
Kelly Brazil
3590cda13a docs formatting 2021-04-05 12:07:52 -07:00
Kelly Brazil
2f1011dd85 readme update 2021-04-05 12:03:35 -07:00
Kelly Brazil
2b155261b3 use new github.io links for documentation 2021-04-05 12:01:53 -07:00
Kelly Brazil
02f4d606d0 add documentation links to README.md 2021-04-05 11:49:30 -07:00
Kelly Brazil
577811f00b Set theme jekyll-theme-cayman 2021-04-05 11:42:59 -07:00
Kelly Brazil
b4098d67a3 latest 2021-04-05 09:42:35 -07:00
Kelly Brazil
88bd7554ae add status messages 2021-04-05 09:42:25 -07:00
Kelly Brazil
b5ec16c5ca formatting 2021-04-05 09:23:20 -07:00
Kelly Brazil
68fcb60a14 add updatedocs script 2021-04-04 20:56:10 -07:00
Kelly Brazil
e4781d60ce update parser descriptions with backticks surrounding command names 2021-04-04 20:52:34 -07:00
Kelly Brazil
6201fb346a test backticks in description 2021-04-04 20:31:58 -07:00
Kelly Brazil
f88c8343f9 update iw-scan description for documentation 2021-04-04 20:30:53 -07:00
Kelly Brazil
25410d3316 create readmegen.py script. move jinja2 templates to templates folder 2021-04-04 20:28:54 -07:00
Kelly Brazil
4ff9952938 change OSX to macOS 2021-04-04 15:57:44 -07:00
Kelly Brazil
5e3f63a412 add license and copyright info. use variables instead of hard-coded values 2021-04-04 15:53:23 -07:00
Kelly Brazil
e1f57be69e add license info 2021-04-04 15:52:50 -07:00
Kelly Brazil
2c65d5eecc man page updates 2021-04-04 14:40:22 -07:00
Kelly Brazil
aa621f2f1e enhance man page 2021-04-04 14:29:37 -07:00
Kelly Brazil
ac932c6e59 update timestamp docs 2021-04-03 14:48:30 -07:00
Kelly Brazil
029f79da16 added info regarding updated dev scripts for automating doc generation 2021-04-02 21:52:08 -07:00
Kelly Brazil
153b2b4a7a use jc to help automate the generation of its own docs 2021-04-02 21:50:04 -07:00
Kelly Brazil
709b2fe4ee add -h and -v options 2021-04-02 18:08:46 -07:00
Kelly Brazil
09c1fccc58 manpage updates 2021-04-02 18:04:55 -07:00
Kelly Brazil
fd254d99b7 add manpage generator 2021-04-02 17:40:09 -07:00
Kelly Brazil
88bd2c1722 fix typo 2021-04-02 16:31:22 -07:00
Kelly Brazil
d03e2f0fc1 add parser schema guidelines 2021-04-02 15:01:21 -07:00
Kelly Brazil
3f12a393bd formatting 2021-04-02 13:25:23 -07:00
Kelly Brazil
8c21284c50 remove redundant license info 2021-04-02 13:23:26 -07:00
Kelly Brazil
e7d396c215 update issues link 2021-04-02 13:21:56 -07:00
Kelly Brazil
f238fac0eb add contributing guidelines 2021-04-02 13:19:47 -07:00
Kelly Brazil
017228f80d add tested on Windows 10 2021-04-02 12:14:26 -07:00
Kelly Brazil
286c5fa943 add dir parser 2021-04-02 12:12:43 -07:00
Kelly Brazil
74cfc13abe fixup dir parser tests 2021-04-02 12:10:05 -07:00
Kelly Brazil
0ee4a6c377 update schema and add epoch naive timestamp 2021-04-02 12:01:39 -07:00
Kelly Brazil
283433578d add dir parser 2021-04-02 12:01:23 -07:00
Kelly Brazil
9559c85057 add windows dir format 2021-04-02 12:01:05 -07:00
Kelly Brazil
c5c020f565 add /S option 2021-04-02 11:16:03 -07:00
Kelly Brazil
95ec79bceb Merge pull request #107 from rasheed-rd/add-dir-parser
Add windows dir command parser
2021-04-02 11:14:26 -07:00
Kelly Brazil
8f8be8aa33 add -1 option info 2021-04-02 11:14:06 -07:00
Rasheed Elsaleh
5b60c7445a Add support for /S and update documentation 2021-04-02 13:43:06 -04:00
Rasheed Elsaleh
d9dbcc8b52 Add parent dir to structure. Add test cases. Remove support for /Q 2021-04-02 13:13:05 -04:00
Kelly Brazil
79bc525970 add codes field to schema 2021-04-01 20:42:36 -07:00
Kelly Brazil
9dae1091dd typo fix 2021-04-01 20:41:05 -07:00
Kelly Brazil
74d3ac686a add dpkg-l tests 2021-04-01 20:37:12 -07:00
Kelly Brazil
cf3cc636ba add dpkg-l parser info 2021-04-01 20:25:56 -07:00
Kelly Brazil
a720441e1d add dpkg -l example 2021-04-01 20:24:19 -07:00
Kelly Brazil
0a7ed0959d rename err to error 2021-04-01 20:17:21 -07:00
Kelly Brazil
eb83c9b86d replace parse_datetime_to_timestamp with timestamp class 2021-04-01 20:13:40 -07:00
Kelly Brazil
5c0142dd19 add dpkg-l parser 2021-04-01 20:12:58 -07:00
Kelly Brazil
c326c8dc83 add TypeError to except block. add /usr/bin/time tests 2021-04-01 12:52:10 -07:00
Kelly Brazil
fc4082a03f remove old parse_datetime_to_timestamp function 2021-04-01 11:26:02 -07:00
Kelly Brazil
c8655565ff use new timestamp class 2021-04-01 11:23:24 -07:00
Kelly Brazil
638f879f16 use new timestamp class 2021-04-01 11:21:27 -07:00
Kelly Brazil
1d221bf7e6 use new timestamp class 2021-04-01 11:19:49 -07:00
Kelly Brazil
60ea71f0ef use new timestamp class 2021-04-01 11:18:03 -07:00
Kelly Brazil
d8bdd35a3f use new timestamp class 2021-04-01 11:17:53 -07:00
Kelly Brazil
7463891c53 use new timestamp class 2021-04-01 11:13:02 -07:00
Kelly Brazil
7537aec76f use jc.utils.timestamp instead of jc.utils.parse_datetime_to_timestamp() 2021-04-01 11:08:27 -07:00
Kelly Brazil
62234e39a8 use jc.utils.timestamp instead of jc.utils.parse_datetime_to_timestamp() 2021-04-01 11:08:20 -07:00
Kelly Brazil
be004b7b3f make parse_datetime_to_timestamp function a class called timestamp for easier use 2021-04-01 11:07:37 -07:00
Kelly Brazil
82539444b2 fix indentation for int and float conversions. add real_time field to schema 2021-03-31 20:48:44 -07:00
Kelly Brazil
a571d3cbaf fix typo 2021-03-31 20:41:04 -07:00
Kelly Brazil
a038c14c23 change microseconds to centiseconds 2021-03-31 20:39:03 -07:00
Kelly Brazil
25a85d874c update docs 2021-03-31 20:21:29 -07:00
Kelly Brazil
884c36ff42 add /usr/bin/time parser 2021-03-31 20:19:46 -07:00
Kelly Brazil
b98e72b8b4 add ls parser info 2021-03-30 21:33:23 -07:00
Kelly Brazil
05885c0096 add epoch and epoch_utc timestamps 2021-03-30 21:29:34 -07:00
Kelly Brazil
4c9761231a add when_epoch and when_epoch_utc fields 2021-03-30 20:41:10 -07:00
Kelly Brazil
656eaa1508 formatting 2021-03-30 16:43:53 -07:00
Kelly Brazil
1560dcddcf add acpi, upower parsers and -v version option 2021-03-30 16:43:02 -07:00
Kelly Brazil
08d4cd4870 add time calculations to acpi parser 2021-03-30 16:34:01 -07:00
Kelly Brazil
9767a50ced update who parser to add epoch naive timestamp 2021-03-30 11:59:44 -07:00
Kelly Brazil
cd86890ed1 add website to info and use variables for version info 2021-03-30 08:05:26 -07:00
Kelly Brazil
ba0dd3b9ca add parse_timedate_to_timestamp test for format 7300 2021-03-29 21:25:19 -07:00
Kelly Brazil
8d7fa07ffd unformat json 2021-03-29 21:20:19 -07:00
Kelly Brazil
cade1bfe6e update timedatectl tests for new epoch_utc field 2021-03-29 21:19:12 -07:00
Kelly Brazil
daec4ab0a7 add epoch_utc field to timedatectl parser 2021-03-29 21:16:40 -07:00
Kelly Brazil
3c96bc3196 version bump 2021-03-29 20:57:58 -07:00
Kelly Brazil
7f7d8d4bd6 update stat docs 2021-03-29 20:36:10 -07:00
Kelly Brazil
47263661a4 update stat example 2021-03-29 20:30:20 -07:00
Kelly Brazil
4c42a086d2 clean up debug code 2021-03-29 20:25:54 -07:00
Kelly Brazil
5d2541a5c4 remove auto c locale and use a manual format rule for windows and linux compatibility 2021-03-29 20:22:35 -07:00
Kelly Brazil
d91d170b49 try manual c locale format for windows 2021-03-29 20:16:05 -07:00
Kelly Brazil
6d1f4584a9 try manually setting time format for windows compatibility 2021-03-29 20:05:42 -07:00
Kelly Brazil
1d76d96bcf debug windows issue 2021-03-29 16:58:57 -07:00
Kelly Brazil
e8847c998c update stat tests 2021-03-29 16:35:26 -07:00
Kelly Brazil
da88e49bae add new examples 2021-03-29 15:36:16 -07:00
Kelly Brazil
65c3a12e54 simplify None data scenario 2021-03-29 15:32:04 -07:00
Kelly Brazil
d8d600cc36 add reference to -h for help 2021-03-29 14:51:48 -07:00
Kelly Brazil
507999b117 add stat command timestamp detection 2021-03-29 14:45:13 -07:00
Kelly Brazil
8ad164eb34 fix tests for compact output 2021-03-29 12:33:54 -07:00
Kelly Brazil
a507df140b add compact json info 2021-03-29 12:25:58 -07:00
Kelly Brazil
8912a99986 make default json output more compact 2021-03-29 12:25:48 -07:00
Kelly Brazil
1953f98828 add version info. add json now supports unicode output 2021-03-29 11:44:43 -07:00
Kelly Brazil
7515218ddd use jc.utils for all warning and error messages. simply error and warning formatting. 2021-03-29 11:42:01 -07:00
Kelly Brazil
36c1120136 formatting 2021-03-29 10:59:56 -07:00
Kelly Brazil
8fa0fe64d8 add -v to helptext. minor formatting 2021-03-29 10:52:02 -07:00
Kelly Brazil
c1a8201b14 add copyright 2021-03-29 10:24:58 -07:00
Kelly Brazil
398bbac48c simplify return value for parse_datetime_to_timestamp() 2021-03-29 10:23:52 -07:00
Kelly Brazil
ea71a42bbd formatting 2021-03-29 09:43:19 -07:00
Kelly Brazil
1c16d25b17 add version option (-v) and copyright information. add 'ensure_ascii=False' to json dumps to properly show UTF-8 copyright character 2021-03-29 09:41:15 -07:00
Kelly Brazil
9d12ded889 help description change 2021-03-26 16:32:17 -07:00
Kelly Brazil
5312701515 add - make all external python requirements optional 2021-03-26 16:29:10 -07:00
Kelly Brazil
808c7bc0a9 make xmltodict library optional 2021-03-26 16:14:35 -07:00
Kelly Brazil
4d394015f4 make ruamel.yaml library optional 2021-03-26 16:10:28 -07:00
Kelly Brazil
3638298af8 make pygments library optional 2021-03-26 15:54:45 -07:00
Kelly Brazil
5f00973e40 remove parenthesis to normalize text for naive timezone detection 2021-03-26 15:38:57 -07:00
Kelly Brazil
0f6e2c14fc simplify timestamp failure logic 2021-03-26 14:57:19 -07:00
Kelly Brazil
51813da619 add offset timezones. fix timestamp logic on conversion failure 2021-03-26 14:56:45 -07:00
Kelly Brazil
e7751322ea formatting 2021-03-26 14:55:47 -07:00
Kelly Brazil
26ef298437 change return to always include the entire object but all keys may be None if conversion fails 2021-03-26 14:55:16 -07:00
Kelly Brazil
badaf8ce73 comment formatting 2021-03-26 14:00:33 -07:00
Kelly Brazil
b123a62203 move locale change formats to the end of the list 2021-03-26 13:11:34 -07:00
Kelly Brazil
cfd77e4252 reset locale to None on exception 2021-03-26 13:01:12 -07:00
Kelly Brazil
38f814072e better normalization of datetime string. better UTC detection. More formats supported with detected locale. 2021-03-26 11:55:12 -07:00
Kelly Brazil
a0db7754e3 add nixos install info 2021-03-26 09:32:49 -07:00
Kelly Brazil
f07620afc7 move version to jc.__init__.py
add -h option for help instead of always showing on error
use jc.utils.error_message for the following errors: missing/incorrect arguments, parser not found, missing piped data
2021-03-26 09:28:03 -07:00
Kelly Brazil
c1b0d27752 remove old commented commands 2021-03-25 20:45:38 -07:00
Kelly Brazil
430a5108aa move all tests to github actions 2021-03-25 20:42:58 -07:00
Kelly Brazil
111ce92fc9 attempt all tests in github actions with timezone correction 2021-03-25 20:37:35 -07:00
Kelly Brazil
c851e8a58d force github action 2021-03-25 20:33:25 -07:00
Kelly Brazil
39f4bcd9b4 Change Windows timezone
use "Pacific Standard Time"
2021-03-25 20:30:13 -07:00
Kelly Brazil
4a610c4c81 force github action 2021-03-25 19:57:32 -07:00
Kelly Brazil
89ee11945d Change timezone provider
uses: szenius/set-timezone@v1.0
2021-03-25 19:55:21 -07:00
Kelly Brazil
dadb09b74a force github action 2021-03-25 19:52:43 -07:00
Kelly Brazil
1b1f638b97 Change timezone change provider
change to actions/set-timezone-action
2021-03-25 19:49:03 -07:00
Kelly Brazil
794fc4ed44 add parse_datetime_to_timestamp() tests 2021-03-25 19:43:16 -07:00
Kelly Brazil
72f735bf92 Set Timezone to America/Los_Angeles
Using zcong1993/setup-timezone
2021-03-25 19:42:02 -07:00
Kelly Brazil
912877f25a additional timezone info 2021-03-25 15:34:54 -07:00
Kelly Brazil
2772c5ae43 formatting 2021-03-25 15:10:07 -07:00
Rasheed Elsaleh
a7ad24d2cb Add dir parser
Add usage commands

Fix example options

update dir.md
2021-03-25 18:09:47 -04:00
Kelly Brazil
a364a6a9fa add note regarding calculated timestamps 2021-03-25 15:08:23 -07:00
Kelly Brazil
7b2dc86a8d update last example with new timestamp fields 2021-03-25 12:07:36 -07:00
Kelly Brazil
ad645636d0 update uptime docs 2021-03-25 11:43:30 -07:00
Kelly Brazil
2f2f297b29 update uptime fixtures with new fields 2021-03-25 11:35:21 -07:00
Kelly Brazil
099ae3fde0 fix issue when there is no data 2021-03-25 11:17:44 -07:00
Kelly Brazil
e9febe98ac add localtest partition lines for readability 2021-03-25 11:17:01 -07:00
Kelly Brazil
5fbd07cccf rewrite of uptime parser including new fields 2021-03-25 10:31:12 -07:00
Kelly Brazil
5fed4698c2 update docs and version number 2021-03-24 21:57:04 -07:00
Kelly Brazil
ed7eb0983a use parse_datetime_to_timestamp function instead of custom format string 2021-03-24 21:51:43 -07:00
Kelly Brazil
90c7e18e5f update date example 2021-03-24 21:50:32 -07:00
Kelly Brazil
953ab5c3bd make upower tests local only 2021-03-24 21:29:30 -07:00
Kelly Brazil
699c97d8a0 add last parser info 2021-03-24 21:24:47 -07:00
Kelly Brazil
e4ca0de92a add upower tests 2021-03-24 21:24:25 -07:00
Kelly Brazil
04745a36b8 doc update 2021-03-24 20:21:06 -07:00
Kelly Brazil
5936940532 rewrite of date parser using datetime library 2021-03-24 20:20:53 -07:00
Kelly Brazil
b3eb064b67 clarify format definition comments 2021-03-24 17:13:01 -07:00
Kelly Brazil
e4b41057e3 update upower fixture names 2021-03-24 17:02:17 -07:00
Kelly Brazil
1d41c46cc7 normalize datetime string to remove all timezones except UTC 2021-03-24 17:01:56 -07:00
Kelly Brazil
a5c444587b add before and after midnight date tests 2021-03-24 15:13:10 -07:00
Kelly Brazil
a56f471be9 update fixture to use UTC for better testing 2021-03-24 15:05:22 -07:00
Kelly Brazil
6a6b26ed8d fix 12 to 24 hour conversion for midnight cases 2021-03-24 15:04:39 -07:00
Kelly Brazil
f62446c152 rename variables. add another european time format 2021-03-24 15:04:09 -07:00
Kelly Brazil
56011f1f17 updated upower examples 2021-03-24 14:14:22 -07:00
Kelly Brazil
6d44091c80 refactor parse_datetime_to_timestamp() 2021-03-24 14:01:06 -07:00
Kelly Brazil
440c458eb4 no need for ternary clause 2021-03-24 12:57:19 -07:00
Kelly Brazil
798250af61 use jc.utils.parse_datetime_to_timestamp() function for timestamp creation 2021-03-24 12:49:53 -07:00
Kelly Brazil
c762de29c6 doc updates 2021-03-24 12:47:57 -07:00
Kelly Brazil
0701e65e97 add parse_datetime_to_timestamp() function 2021-03-24 12:36:54 -07:00
Kelly Brazil
209d54e8b5 add hour_24 to schema docs 2021-03-24 07:39:11 -07:00
Kelly Brazil
2b38462de7 update examples 2021-03-23 14:59:03 -07:00
Kelly Brazil
1e8e553316 add hour_24 field 2021-03-23 14:47:44 -07:00
Kelly Brazil
ab42e6bb15 formatting 2021-03-23 14:10:42 -07:00
Kelly Brazil
6802884540 ensure period is always uppercase in dict value. update period documentation 2021-03-23 14:04:36 -07:00
Kelly Brazil
7cb8577b96 correct epoch_utc calculation. Fix for 12 hour vs. 24 hour representation 2021-03-23 13:55:23 -07:00
Kelly Brazil
55810ccd1f set epoch_dt conversion again if not C locale 2021-03-22 22:10:35 -07:00
Kelly Brazil
f9921720cd revert to local testing for naive datetime objects 2021-03-22 22:01:07 -07:00
Kelly Brazil
cda1ebd271 try tzset() 2021-03-22 21:53:50 -07:00
Kelly Brazil
6901e4a23a try setting timezone env variable before tests to ensure it is the same on all test systems 2021-03-22 21:49:26 -07:00
Kelly Brazil
6bc21d3c73 fix date parser tests - local tests only since timezones may not match on github actions VMs 2021-03-22 21:05:39 -07:00
Kelly Brazil
1ef231e26a add date parser updates 2021-03-22 20:57:36 -07:00
Kelly Brazil
3cd43f0f98 formatting 2021-03-22 20:57:16 -07:00
Kelly Brazil
1565019966 fix weekday numbering to be ISO 8601 compliant. Add naive calculated epoch timestamp field 2021-03-22 20:56:57 -07:00
Kelly Brazil
0a4de2d3a1 add naive datetime calculation info to docs 2021-03-22 20:22:35 -07:00
Kelly Brazil
a058f6c174 added naive epoch calculation info to docs 2021-03-22 20:21:46 -07:00
Kelly Brazil
d8e5d03b01 naive updated_epoch timestamp calculation added 2021-03-22 20:21:12 -07:00
Kelly Brazil
9dc62eff2e remove epoch conversions 2021-03-21 15:43:37 -07:00
Kelly Brazil
d4fea17c57 use UTC when calculating epoch timestamp. reset time locale to default after changing 2021-03-21 14:03:36 -07:00
Kelly Brazil
3dd7a5b77e add upower docs 2021-03-19 11:00:50 -07:00
Kelly Brazil
d77c90a3ba fix quoted values in detail level. Add examples 2021-03-19 10:43:20 -07:00
Kelly Brazil
01f0c20df0 add sample using C locale timestamp 2021-03-18 16:59:46 -07:00
Kelly Brazil
aafbe576b3 working parser and processor 2021-03-18 16:59:19 -07:00
Kelly Brazil
bd68ad4034 don't modify detail_type value since it is no longer a key 2021-03-17 14:31:51 -07:00
Kelly Brazil
bfee017c13 made the schema more explicit by hardcoding more items. still working on the schema 2021-03-17 14:21:19 -07:00
Kelly Brazil
61f532cfd0 working history list 2021-03-17 13:30:47 -07:00
Kelly Brazil
58dbbb75b6 simplified logic 2021-03-17 13:10:52 -07:00
Kelly Brazil
8d88b91fcf move if statements and generalize the history detail detection 2021-03-17 12:49:48 -07:00
Kelly Brazil
ad39fc6029 working upower parser. history lines are ignored 2021-03-17 11:26:06 -07:00
Kelly Brazil
89f1fd96e6 add acpi tests 2021-03-16 12:12:01 -07:00
Kelly Brazil
bd425f2493 version bump to v1.15.0. Add acpi docs 2021-03-16 11:45:56 -07:00
Kelly Brazil
46962ff02a remove redundant lines 2021-03-12 16:45:15 -08:00
Kelly Brazil
e4cb88b051 remove unneeded line-state assignment 2021-03-12 12:47:59 -08:00
Kelly Brazil
32840703dc remove redundant code 2021-03-12 08:55:04 -08:00
Kelly Brazil
1f7aafd041 fix for full charge batter case. Clean up battery object logic 2021-03-12 08:45:32 -08:00
Kelly Brazil
7378d5dce4 remove comment 2021-03-11 21:06:24 -08:00
Kelly Brazil
84f76866cd working process function 2021-03-11 21:05:29 -08:00
Kelly Brazil
322da9ea6a working parser 2021-03-11 20:43:31 -08:00
Kelly Brazil
58645301ec add acpi command parser 2021-03-11 19:55:47 -08:00
Kelly Brazil
1e18dd30a8 Merge pull request #102 from kellyjonbrazil/dev
Dev v1.14.4
2021-03-05 11:50:37 -08:00
Kelly Brazil
cc6a19adcc fix typo in comments 2021-03-05 09:41:17 -08:00
Kelly Brazil
2a5588b177 packaging fix for yaml parser and pyoxidizer 2021-03-05 09:38:22 -08:00
Kelly Brazil
20f9b7f88b fix typo 2021-02-25 11:09:56 -08:00
Kelly Brazil
d7e32313cd fix typo 2021-02-25 11:09:14 -08:00
Kelly Brazil
fb5654d3c4 formatting 2021-02-11 11:27:54 -08:00
Kelly Brazil
258f1433b3 add locale info to readme 2021-02-11 11:27:01 -08:00
Kelly Brazil
fb723ae8bd Merge pull request #101 from kellyjonbrazil/dev
Dev v1.14.3
2021-02-10 11:01:57 -08:00
Kelly Brazil
283b89e37c simplify answer data logic 2021-02-10 10:55:53 -08:00
Kelly Brazil
f450f9eb8b add hciconfig tests 2021-02-10 10:47:56 -08:00
Kelly Brazil
b3f8cf99a4 work for both tabs and spaces 2021-02-10 08:03:36 -08:00
Kelly Brazil
4301ea8cae remove debug line 2021-02-09 16:12:36 -08:00
Kelly Brazil
c672d1c174 initial working hciconfig parser 2021-02-09 16:03:00 -08:00
Kelly Brazil
229e953a38 initial add of hciconfig parser 2021-02-09 13:26:24 -08:00
Kelly Brazil
87b506dc9b fix for spaces in dig answer data 2021-02-05 06:55:06 -08:00
Kelly Brazil
15c9002d9e simplify logic by taking out 'not' in JC_COLORS parsing 2021-01-08 11:56:56 -08:00
Kelly Brazil
042aaa61b9 minor updates 2021-01-08 08:23:29 -08:00
Kelly Brazil
ef856c6ba5 clarify -q option 2021-01-07 12:09:41 -08:00
Kelly Brazil
9cf5be73e3 typo fix 2021-01-06 16:19:47 -08:00
Kelly Brazil
63fc149e2a typo fix 2021-01-06 16:17:25 -08:00
Kelly Brazil
3c25839350 Merge pull request #98 from kellyjonbrazil/dev
Dev v1.14.1
2021-01-06 14:37:24 -08:00
Kelly Brazil
58246e33b7 update compatibility info and changelog date 2021-01-06 14:33:38 -08:00
Kelly Brazil
8b1407c706 pull env-specific tests from CI/CD and run locally only 2021-01-06 14:22:26 -08:00
Kelly Brazil
2fde4a4e22 doc updates 2021-01-06 12:07:58 -08:00
Kelly Brazil
60b9e97982 last parser enhancements: augment hostname with CONSOLE for GUI login, add convenience fields when -F is used: login_epoch, logout_epoch, duration_seconds, calculate duration to hours:minutes 2021-01-06 12:02:47 -08:00
Kelly Brazil
0adac79c0f Add last parser enhancements 2021-01-06 11:09:59 -08:00
Kelly Brazil
9f485b5981 change mac_address fieldname to bssid. Add credit to Phillip 2021-01-06 11:09:37 -08:00
Kelly Brazil
db17d21b8f Merge pull request #97 from pschmitt/iw_scan_fix_space_detection
iw_scan: Improve detection of lines starting with spaces
2021-01-06 10:42:30 -08:00
Philipp Schmitt
996d394e89 iw_scan: Improve detection of lines starting with spaces 2021-01-06 10:32:17 +01:00
Kelly Brazil
5885b960f9 doc updates 2021-01-05 22:12:13 -08:00
Kelly Brazil
79987b35f3 formatting 2021-01-05 22:07:22 -08:00
Kelly Brazil
661b3ef311 doc updates 2021-01-05 22:04:44 -08:00
Kelly Brazil
fb422726a8 update test to add 'down' condition 2021-01-05 21:55:06 -08:00
Kelly Brazil
4fb6f3ea59 add support for down in addition to crash 2021-01-05 21:51:30 -08:00
Kelly Brazil
f78fe771e1 add iw-scan tests 2021-01-05 21:38:51 -08:00
Kelly Brazil
567b887253 doc updates 2021-01-05 21:26:43 -08:00
Kelly Brazil
e516e6b946 fix country/environment fields and process int/float conversions 2021-01-05 21:17:40 -08:00
Kelly Brazil
62748676aa initial iw-scan parser 2021-01-05 20:44:22 -08:00
Kelly Brazil
7351c72e45 add fixes and tests for entries that contain 'crash' 2021-01-05 15:16:40 -08:00
Kelly Brazil
2b7405c5e2 doc updates 2021-01-05 13:58:38 -08:00
Kelly Brazil
e2c77cb935 add test for last -F output 2021-01-05 13:00:38 -08:00
Kelly Brazil
7ac621e4c9 add -F support 2021-01-05 12:29:29 -08:00
Kelly Brazil
d8b5d6c66c version bump to 1.14.1 2021-01-05 09:45:37 -08:00
Kelly Brazil
22b461eb4b Add period field for en_US.UTF-8 locale 2021-01-05 09:42:05 -08:00
Kelly Brazil
b37ee8555a changelog update 2021-01-04 18:02:07 -08:00
Kelly Brazil
1d0ad2f045 doc fixes 2021-01-04 18:01:16 -08:00
Kelly Brazil
ceccfb2c81 add test output for iw-scan and date on ubuntu 20.04 2021-01-04 17:05:26 -08:00
Kelly Brazil
03c02953cd add wc doc 2021-01-01 12:01:56 -08:00
Kelly Brazil
f254a0eaa1 version bump 2020-12-31 16:45:10 -08:00
Kelly Brazil
9e3b88727c Merge pull request #91 from kellyjonbrazil/dev
Dev v1.14.0
2020-12-31 16:40:36 -08:00
Kelly Brazil
b12217466e spelling 2020-12-31 16:37:47 -08:00
Kelly Brazil
8b9c932f9b update date 2020-12-31 16:37:14 -08:00
Kelly Brazil
5986ce03db add printenv info 2020-12-31 16:36:27 -08:00
Kelly Brazil
a7b0e936e4 add vdir and printenv info 2020-12-31 14:21:24 -08:00
Kelly Brazil
cb02211424 add wc tests 2020-12-31 14:19:45 -08:00
Kelly Brazil
bd443bf392 add printenv to env docs 2020-12-31 14:11:25 -08:00
Kelly Brazil
1f547edd36 add printenv to env docs 2020-12-31 14:10:56 -08:00
Kelly Brazil
e4bac3a493 add wc parser 2020-12-31 14:10:37 -08:00
Kelly Brazil
5e6bfa681a add vdir info 2020-12-31 13:18:53 -08:00
Kelly Brazil
276160125e add new commands to README 2020-12-30 14:04:49 -08:00
Kelly Brazil
d4ae5543f2 add hash tests 2020-12-30 13:11:13 -08:00
Kelly Brazil
55f360e267 add hash command parser 2020-12-30 12:58:52 -08:00
Kelly Brazil
fdedab2a0c description updates 2020-12-30 11:33:29 -08:00
Kelly Brazil
a9be42e303 specify parser warnings for quiet option 2020-12-30 11:28:42 -08:00
Kelly Brazil
6da9510e46 add cksum tests 2020-12-30 11:22:17 -08:00
Kelly Brazil
0431798178 add cksum parser 2020-12-30 11:02:02 -08:00
Kelly Brazil
62432f3c48 update hashsum description 2020-12-30 09:59:54 -08:00
Kelly Brazil
9fbbc30906 add supported commands to docs 2020-12-29 13:09:03 -08:00
Kelly Brazil
d1567d1f62 add hashsum documentation 2020-12-29 13:05:04 -08:00
Kelly Brazil
6ca1f5970b Merge branch 'dev' of https://github.com/kellyjonbrazil/jc into dev 2020-12-29 12:59:02 -08:00
Kelly Brazil
1c880b9e24 force git tests 2020-12-29 12:58:04 -08:00
Kelly Brazil
3b7d54c720 add python 3.9 2020-12-29 12:55:30 -08:00
Kelly Brazil
44a7406057 add hashsum tests 2020-12-29 12:51:43 -08:00
Kelly Brazil
8157dcfdb1 fix for files with spaces in the name 2020-12-29 12:25:20 -08:00
Kelly Brazil
28762aea15 add hashsum parser 2020-12-29 11:36:20 -08:00
Kelly Brazil
439871ea9f add ubuntu 2020-11-19 07:07:30 -08:00
Kelly Brazil
c9180b005c formatting 2020-08-30 11:58:42 -07:00
Kelly Brazil
b14e0725f8 add ansible plugin blog post link 2020-08-30 11:57:55 -07:00
Kelly Brazil
70fe3dcb4d formatting 2020-08-26 15:21:45 -07:00
Kelly Brazil
8c554604a4 formatting 2020-08-26 14:41:01 -07:00
Kelly Brazil
a0a35454bd add link to the web demo 2020-08-26 14:39:40 -07:00
Kelly Brazil
e8467e2af5 remove extra space 2020-08-20 10:57:13 -07:00
Kelly Brazil
7515deb566 add ansible install command 2020-08-20 10:39:34 -07:00
Kelly Brazil
ed9e52af24 spelling 2020-08-20 10:37:15 -07:00
Kelly Brazil
592a380410 add Ansible note 2020-08-20 10:35:49 -07:00
Kelly Brazil
1a458d2d5b update link 2020-08-11 07:00:07 -07:00
Kelly Brazil
0e4cf53b92 add parser docs link 2020-08-11 06:36:30 -07:00
Kelly Brazil
e2f06ccb33 formatting 2020-08-06 13:00:33 -07:00
Kelly Brazil
8abff004cd indentation fix 2020-08-06 12:59:30 -07:00
Kelly Brazil
c4a0e2e3fe fix indentation 2020-08-06 12:58:53 -07:00
Kelly Brazil
4f10f79c73 standardize doc 2020-08-06 12:55:24 -07:00
Kelly Brazil
69e7a560fd add output info to docs 2020-08-06 07:48:08 -07:00
Kelly Brazil
59b1055808 enhance docs 2020-08-05 16:51:58 -07:00
Kelly Brazil
6ed48c6289 enhance docs 2020-08-05 15:34:17 -07:00
Kelly Brazil
f2fb4d3f41 improve docs 2020-08-05 15:10:48 -07:00
Kelly Brazil
6aeea59ea8 doc updates 2020-08-05 15:08:42 -07:00
Kelly Brazil
d016f3bbb3 improve documentation 2020-08-05 15:07:33 -07:00
Kelly Brazil
7131c29718 add module usage info to docs 2020-08-05 13:32:59 -07:00
Kelly Brazil
7432442983 add usage 2020-08-05 13:31:52 -07:00
Kelly Brazil
5344883394 spelling/add ping parser update 2020-08-05 11:35:52 -07:00
Kelly Brazil
3fcd2f6c2e version bump 2020-08-05 11:34:29 -07:00
Kelly Brazil
f3d84bd5bf tighten crontab and crontab-u parser variable detection 2020-08-05 11:28:37 -07:00
Kelly Brazil
549780c232 add debian/apt-get info 2020-08-05 11:04:07 -07:00
Kelly Brazil
2a6da69b82 improve linux/bsd check 2020-08-05 09:58:01 -07:00
Kelly Brazil
5c538816cf ping parser fix for raspberry pi 2020-08-04 17:36:35 -07:00
Kelly Brazil
7b8b378a7d add pydoc-markdown version requirement 2020-08-03 12:39:18 -07:00
Kelly Brazil
e30a75e25c Merge pull request #76 from kellyjonbrazil/dev
Dev v1.13.2
2020-08-03 10:18:39 -07:00
Kelly Brazil
85ad5cfd0b date change 2020-08-03 10:14:13 -07:00
Kelly Brazil
88b9d5068c finish date parser 2020-08-03 09:26:37 -07:00
Kelly Brazil
f8c4948a09 remove comment 2020-07-31 16:52:48 -07:00
Kelly Brazil
412322447f add month_num and weekday_num fields 2020-07-31 16:51:05 -07:00
Kelly Brazil
d4f289e40f documentation fixup 2020-07-31 14:47:06 -07:00
Kelly Brazil
e1f3feb8f5 cover empty data case in process 2020-07-31 14:45:30 -07:00
Kelly Brazil
37d3bc699c add date parser 2020-07-31 14:39:02 -07:00
Kelly Brazil
672fd18016 date bump 2020-07-31 12:59:44 -07:00
Kelly Brazil
bc2c23a2a0 version bump 2020-07-31 12:58:58 -07:00
Kelly Brazil
865f7e7812 add kv parser to man page 2020-07-31 12:58:11 -07:00
Kelly Brazil
720212b552 fixup traceroute example with new behavior 2020-07-31 11:02:24 -07:00
Kelly Brazil
d3be61f608 version bump 2020-07-31 10:59:46 -07:00
Kelly Brazil
13418b16b8 doc update 2020-07-31 10:56:51 -07:00
Kelly Brazil
42d2017cd6 traceroute updates: handle missing header row, add annotations, don't print timeouts as probes 2020-07-31 10:53:47 -07:00
Kelly Brazil
4345e76ead change to use --kv for key/value files 2020-07-30 16:49:38 -07:00
Kelly Brazil
741431322b update tests for kv parser 2020-07-30 16:45:36 -07:00
Kelly Brazil
980beaaf41 fix docgen issue 2020-07-30 16:21:03 -07:00
Kelly Brazil
2205034e09 add kv parser 2020-07-30 16:20:51 -07:00
Kelly Brazil
82b9c87a66 update docs 2020-07-30 16:20:24 -07:00
Kelly Brazil
dda517a937 shorten more examples 2020-07-29 14:36:20 -07:00
Kelly Brazil
4e6d283b9e shorten netstat example 2020-07-29 14:27:13 -07:00
Kelly Brazil
55acab05aa change name to CHANGELOG 2020-07-29 11:55:16 -07:00
Kelly Brazil
ed38a18d23 remove more examples 2020-07-29 11:49:00 -07:00
Kelly Brazil
95b3c11203 remove more examples 2020-07-29 11:43:22 -07:00
Kelly Brazil
dce318f4fd remove examples to reduce file size 2020-07-29 11:40:47 -07:00
Kelly Brazil
85127f0fb8 move examples to root 2020-07-29 11:34:43 -07:00
Kelly Brazil
fb45058244 add examples file 2020-07-29 11:32:18 -07:00
Kelly Brazil
45bb5ae389 spelling 2020-07-28 11:03:41 -07:00
Kelly Brazil
339238ab36 version bump and add route -6 tests 2020-07-27 20:37:33 -07:00
Kelly Brazil
032cda8b3d Merge pull request #74 from kellyjonbrazil/dev
Dev v1.13.0
2020-07-27 19:12:21 -07:00
Kelly Brazil
6badd3fb1e add parser count test 2020-07-27 19:02:23 -07:00
Kelly Brazil
724d825745 add tracepath parser 2020-07-27 19:02:11 -07:00
Kelly Brazil
ff1e32ad2e version bump 2020-07-27 16:49:34 -07:00
Kelly Brazil
a5f97febd3 update traceroute, tracepath, and uname tests 2020-07-27 16:47:41 -07:00
Kelly Brazil
5baa6cc865 add route parser update 2020-07-27 15:44:13 -07:00
Kelly Brazil
7a4f30b843 fix for iface issue 2020-07-27 15:37:44 -07:00
Kelly Brazil
b2c385dc4f change 'if' to 'iface' 2020-07-27 15:30:09 -07:00
Kelly Brazil
5d5da8d33f more fixes for ipv6 fix 2020-07-27 15:27:11 -07:00
Kelly Brazil
e604571578 fix next_hop fix 2020-07-27 15:20:51 -07:00
Kelly Brazil
f9dacc3f95 fixup for ipv6 2020-07-27 15:18:13 -07:00
Kelly Brazil
6086920332 update ParseError message 2020-07-27 15:13:32 -07:00
Kelly Brazil
f52f3163bc add tracepath example 2020-07-27 13:57:58 -07:00
Kelly Brazil
d18ff73e88 update author info 2020-07-27 13:51:51 -07:00
Kelly Brazil
1e5d602cae working tracepath parser 2020-07-27 13:48:46 -07:00
Kelly Brazil
12912521ec doc update 2020-07-27 11:04:27 -07:00
Kelly Brazil
842ea3a94b add tracepath parser skeleton 2020-07-27 11:02:13 -07:00
Kelly Brazil
a8560dbc15 add tracepath 2020-07-27 11:01:57 -07:00
Kelly Brazil
a65e27540a update docs 2020-07-27 11:01:45 -07:00
Kelly Brazil
c3c5ed11e6 change name from tr to trparse 2020-07-27 10:33:40 -07:00
Kelly Brazil
ce24149335 formatting 2020-07-27 10:33:25 -07:00
Kelly Brazil
0314ca8c48 add trparse acknowledgement 2020-07-27 10:33:15 -07:00
Kelly Brazil
ebd8ee49a9 add key/value info to ini example 2020-07-27 10:28:15 -07:00
Kelly Brazil
38d10c9781 add ping and traceroute examples 2020-07-27 09:29:30 -07:00
Kelly Brazil
360106c24d add tracepath 2020-07-27 09:23:01 -07:00
Kelly Brazil
ca470a5d02 add tracepath fixtures 2020-07-27 09:20:00 -07:00
Kelly Brazil
57f66e6b1d add exception with hint to use "uname -a" 2020-07-27 09:19:48 -07:00
Kelly Brazil
e774f67924 turn off interpolation and coerce None to '' 2020-07-24 16:53:17 -07:00
Kelly Brazil
ac10e576c1 spelling 2020-07-24 16:29:27 -07:00
Kelly Brazil
bcae0a99cd add key/value to ini description 2020-07-24 16:23:45 -07:00
Kelly Brazil
c73c2ff879 add ping, traceroute, and ini update 2020-07-24 16:23:30 -07:00
Kelly Brazil
c39b1a3356 add ping, traceroute and update ini description 2020-07-24 16:17:51 -07:00
Kelly Brazil
125dc2d9e0 add info about key/value files to doc 2020-07-24 16:17:16 -07:00
Kelly Brazil
b7d4ddc7ce add tests for key/value files 2020-07-24 16:16:54 -07:00
Kelly Brazil
f5e546c6fa add support for simple key/value pairs 2020-07-24 16:16:24 -07:00
Kelly Brazil
928e39cd10 add generic traceroute tests 2020-07-24 14:16:41 -07:00
Kelly Brazil
d0b7ea68a0 check for key in dictionary 2020-07-24 13:47:47 -07:00
Kelly Brazil
8444690133 add traceroute 2020-07-24 13:47:29 -07:00
Kelly Brazil
c03c42d767 add traceroute tests 2020-07-24 13:47:23 -07:00
Kelly Brazil
ab67688a00 add test skeleton 2020-07-23 16:45:09 -07:00
Kelly Brazil
5dcb7166da add traceroute doc 2020-07-23 16:44:57 -07:00
Kelly Brazil
14697b86d7 add MIT license 2020-07-23 15:48:08 -07:00
Kelly Brazil
4f4b6276d4 update docstring 2020-07-23 15:46:22 -07:00
Kelly Brazil
7bc497e129 updated process() function to set integers and floats 2020-07-23 15:42:33 -07:00
Kelly Brazil
68a37a6a5a remove unused function load() 2020-07-23 12:48:33 -07:00
Kelly Brazil
6f5cd1d7c5 change to use f-string 2020-07-23 12:03:21 -07:00
Kelly Brazil
126b1b121c add traceroute6 example 2020-07-23 11:31:56 -07:00
Kelly Brazil
2341e456a0 use ParseError instead of generic Exception 2020-07-23 11:31:35 -07:00
Kelly Brazil
72d80e95bb remove unused regex patterns 2020-07-23 10:52:40 -07:00
Kelly Brazil
f5ec82440c simplify regex patterns 2020-07-23 10:19:56 -07:00
Kelly Brazil
c8e526ead3 fixes for bsd-style ipv6 output 2020-07-22 17:23:24 -07:00
Kelly Brazil
066adfb764 handle warning lines in the traceroute output 2020-07-22 15:02:02 -07:00
Kelly Brazil
5b444d4717 add traceroute parser 2020-07-22 12:19:27 -07:00
Kelly Brazil
69c95adc8d add osx ipv6 ping dup test 2020-07-22 09:06:11 -07:00
Kelly Brazil
2b0e0d8f5c add ipv6 dup test 2020-07-21 17:34:30 -07:00
Kelly Brazil
778d1bacbf update docs to add "duplicates" fields 2020-07-21 15:16:39 -07:00
Kelly Brazil
7e1b041016 add duplicate replies tests 2020-07-21 15:12:43 -07:00
Kelly Brazil
313b9b329c update fixtures for added 'duplicate' fields 2020-07-21 15:05:54 -07:00
Kelly Brazil
6830062256 add support for duplicate replies 2020-07-21 14:47:25 -07:00
Kelly Brazil
323072c982 add source_ip to schema doc 2020-07-21 09:02:44 -07:00
Kelly Brazil
8719d96bdd change description 2020-07-20 16:54:43 -07:00
Kelly Brazil
dd5d318ab5 version bump and add ping command 2020-07-20 16:25:20 -07:00
Kelly Brazil
d6dc7f5e65 add osx ping tests 2020-07-20 16:11:18 -07:00
Kelly Brazil
c203664eb5 freebsd ping tests 2020-07-20 15:46:27 -07:00
Kelly Brazil
19ecf1fa19 add Fedora32 tests 2020-07-20 14:35:41 -07:00
Kelly Brazil
b8deb0426c add ubuntu ping tests 2020-07-20 13:51:39 -07:00
Kelly Brazil
3b8371f020 add centos ping tests 2020-07-20 12:49:05 -07:00
Kelly Brazil
20bb1cdf39 add TypeError to except for None values 2020-07-20 11:53:06 -07:00
Kelly Brazil
301daa48d0 update documentation 2020-07-19 15:30:54 -07:00
Kelly Brazil
8421ec8803 remove cygwin compatibility 2020-07-19 15:19:47 -07:00
Kelly Brazil
74211eb012 add examples 2020-07-19 15:16:04 -07:00
Kelly Brazil
60bd42f298 add process() logic 2020-07-19 15:13:52 -07:00
Kelly Brazil
14bdd74526 add ping test fixtures 2020-07-19 14:46:02 -07:00
Kelly Brazil
fb0f3eda04 add ping commands 2020-07-19 14:45:50 -07:00
Kelly Brazil
91ee6e6701 add osx ping test fixtures 2020-07-19 14:18:56 -07:00
Kelly Brazil
51f4e6927c add support for pattern in osx/bsd 2020-07-19 14:18:40 -07:00
Kelly Brazil
94988d8667 add fedora ping fixtures 2020-07-19 13:50:40 -07:00
Kelly Brazil
fe36f5a98c add fixtures for ping 2020-07-19 12:56:53 -07:00
Kelly Brazil
f9eb18b927 change 'request_timeout' field to 'type', fix compatibility, other formatting fixes 2020-07-19 12:56:34 -07:00
Kelly Brazil
cc60f36748 add ping parser 2020-07-18 12:35:46 -07:00
Kelly Brazil
604ade791f add ping parser 2020-07-17 15:57:07 -07:00
Kelly Brazil
690ac52a91 add man page 2020-07-13 07:18:48 -07:00
Kelly Brazil
34ed772775 version bump 2020-07-11 09:46:47 -07:00
Kelly Brazil
d5ab95571f fix tests when using older versions of pygments 2020-07-11 09:44:08 -07:00
Kelly Brazil
ffb3a0ee5f Merge pull request #73 from kellyjonbrazil/dev
Dev v1.12.0
2020-07-10 16:34:56 -07:00
Kelly Brazil
94b12b57aa spelling 2020-07-10 16:30:08 -07:00
Kelly Brazil
6d149e8457 version bump 2020-07-10 16:25:03 -07:00
Kelly Brazil
1ad89c90d8 add pacman 2020-07-10 15:58:02 -07:00
Kelly Brazil
fb71c7b020 function name spelling 2020-07-10 15:49:35 -07:00
Kelly Brazil
28ed17ad3b add parser_count test to test_cli_about_jc 2020-07-10 15:45:21 -07:00
Kelly Brazil
0c2a4e2bf7 add cli tests 2020-07-10 15:35:05 -07:00
Kelly Brazil
62bec30de2 add json_out tests 2020-07-10 14:44:50 -07:00
Kelly Brazil
3fced77e4e add set_env_colors tests 2020-07-10 12:23:48 -07:00
Kelly Brazil
a09d1d8b76 move environment variable assignment to main() to simplify tests 2020-07-10 12:23:25 -07:00
Kelly Brazil
8f4243fbd8 formatting 2020-07-10 10:54:34 -07:00
Kelly Brazil
47aaf20549 add sysctl command parser 2020-07-10 10:50:51 -07:00
Kelly Brazil
0c5289ea50 add sysctl tests 2020-07-10 10:47:23 -07:00
Kelly Brazil
3e53323514 don't filter out empty lines 2020-07-10 09:58:56 -07:00
Kelly Brazil
a5ee9861b9 update fixtures 2020-07-10 09:28:32 -07:00
Kelly Brazil
feb8ca7654 spelling 2020-07-10 09:28:20 -07:00
Kelly Brazil
a7abe4473b spelling 2020-07-10 09:03:04 -07:00
Kelly Brazil
780b9b61de specify IndexError exception in try/except block 2020-07-10 08:30:31 -07:00
Kelly Brazil
19ace36ffa add fixtures 2020-07-10 08:21:30 -07:00
Kelly Brazil
5fff8afc9f add fixes for freebsd where values can be on separate lines under the key 2020-07-10 08:21:15 -07:00
Kelly Brazil
4ad230c927 doc update and add test fixtures 2020-07-09 16:35:36 -07:00
Kelly Brazil
dd98eb1ec8 append duplicate key values to original key instead of adding unique keys 2020-07-09 16:25:41 -07:00
Kelly Brazil
c6baf42e72 doc updates 2020-07-09 16:18:33 -07:00
Kelly Brazil
e2bac97d56 fix for multiple identical keys in sysctl output 2020-07-09 14:51:15 -07:00
Kelly Brazil
d112ee94d0 use try/except and add support for floats in process() 2020-07-09 14:26:35 -07:00
Kelly Brazil
27b21b2faf formatting and docstring updates 2020-07-09 11:11:29 -07:00
Kelly Brazil
8c96d5cd20 reduce pygments version requirement 2020-07-09 10:59:36 -07:00
Kelly Brazil
c29ed3fd69 formatting of quotation marks and docstrings 2020-07-09 10:54:49 -07:00
Kelly Brazil
cedf603f12 minor formatting 2020-07-09 09:59:00 -07:00
Kelly Brazil
279161c36f Merge pull request #72 from duelafn/pygments-2.3
Support older pygments
2020-07-09 09:48:58 -07:00
Dean Serenevy
ce0b43d919 Remove dependency on 3rd party packaging library 2020-07-09 12:44:41 -04:00
Dean Serenevy
ddafa5bf06 Support older pygments 2020-07-09 11:39:34 -04:00
Kelly Brazil
bc7116c31b fix JC_COLORS env bug and simplify set_env_colors() 2020-07-09 08:30:10 -07:00
Kelly Brazil
53b7092721 remove side-effects from functions and print in main() 2020-07-08 16:40:28 -07:00
Kelly Brazil
beb9174b1b add sysctl parser 2020-07-08 15:42:06 -07:00
Kelly Brazil
aea41ed341 move verbose_debug enable earlier in code to catch more issues. add sysctl and version bump 2020-07-08 15:41:46 -07:00
Kelly Brazil
d789494cb1 change type check to use isinstance 2020-07-08 05:59:19 -07:00
Kelly Brazil
608e7b4cff add license info 2020-07-06 10:52:12 -07:00
Kelly Brazil
4ee199c02a use tracebackplus instead of cgitb since cgitb is depricated 2020-07-06 10:41:01 -07:00
Kelly Brazil
fbf47d4085 add arch linux 2020-07-01 13:28:58 -07:00
Kelly Brazil
5a238e4b42 remove updates-testing from fedora command 2020-07-01 09:11:32 -07:00
Kelly Brazil
f852b8246a wrap warning message 2020-06-30 11:50:37 -07:00
Kelly Brazil
88140d929a wrap error message in code 2020-06-30 11:37:33 -07:00
Kelly Brazil
45f7268240 add -dd to error message 2020-06-30 11:34:08 -07:00
Kelly Brazil
3a3c8e4d4a move verbose_debug under debug check 2020-06-30 11:31:08 -07:00
Kelly Brazil
c1ac183a04 simplify debug option 2020-06-30 11:26:09 -07:00
Kelly Brazil
18bb779ee5 formatting: double quotes to single quotes 2020-06-30 09:39:05 -07:00
Kelly Brazil
8b6612fe79 move JC_COLORS parsing error message 2020-06-30 07:56:34 -07:00
Kelly Brazil
fde0bc8534 improve package install info 2020-06-27 18:53:19 -07:00
Kelly Brazil
e661a78939 Merge pull request #71 from wigust/guix
add guix package info
2020-06-27 18:43:02 -07:00
Oleg Pykhalov
847e346602 add guix package info 2020-06-27 13:01:56 +03:00
Kelly Brazil
b969751688 add other references 2020-06-26 09:53:57 -07:00
Kelly Brazil
ad6f2ba03a formatting 2020-06-25 21:16:52 -07:00
Kelly Brazil
63c6a5edc0 formatting 2020-06-25 21:12:30 -07:00
Kelly Brazil
9f4cf9dd5e formatting 2020-06-25 21:11:21 -07:00
Kelly Brazil
51331b6dc0 formatting 2020-06-25 13:01:10 -07:00
Kelly Brazil
efb6761033 formatting 2020-06-25 12:59:56 -07:00
Kelly Brazil
6a4f737a0f update json syntax highlighting 2020-06-25 12:56:06 -07:00
Kelly Brazil
be6864b778 add syntax highlighting tags 2020-06-25 12:28:23 -07:00
Kelly Brazil
de3b91a36c add -dd option 2020-06-25 07:38:39 -07:00
Kelly Brazil
ef5482c3b5 add verbose debug option 2020-06-25 07:29:28 -07:00
Kelly Brazil
d20b795137 Merge pull request #70 from kellyjonbrazil/dev
Dev v1.11.7
2020-06-22 11:28:23 -07:00
Kelly Brazil
8a134065df update fixtures for last chain fix 2020-06-22 11:23:37 -07:00
Kelly Brazil
22aee1bfa4 version bump 2020-06-22 11:23:15 -07:00
Kelly Brazil
b282820fd6 fix to include the final chain in output 2020-06-22 11:09:09 -07:00
Kelly Brazil
3ee098306d version bump 2020-06-22 10:48:51 -07:00
Kelly Brazil
09e8f379a6 iptables code optimizations 2020-06-22 10:47:34 -07:00
Kelly Brazil
69018cdb3a fix date 2020-06-14 17:39:14 -07:00
Kelly Brazil
d0d7254c6a add docstring 2020-06-14 17:23:10 -07:00
Kelly Brazil
cc0f0971d7 Improve and standardize empty data check for all parsers 2020-06-14 17:17:40 -07:00
Kelly Brazil
2af61730f0 Merge pull request #68 from kellyjonbrazil/dev
Dev v1.11.5
2020-06-12 12:34:34 -07:00
Kelly Brazil
83f41b83dc version bump 2020-06-12 12:30:19 -07:00
Kelly Brazil
1fb84fce88 fix for no data 2020-06-12 12:25:07 -07:00
Kelly Brazil
a8837e1244 remove --upgrade from pip install 2020-06-12 07:57:40 -07:00
Kelly Brazil
04d2eec558 fix for no data 2020-06-11 17:59:06 -07:00
Kelly Brazil
1b57ec92f0 fix for no data 2020-06-11 17:52:03 -07:00
Kelly Brazil
4d88595404 enhance empty data check 2020-06-11 17:16:11 -07:00
Kelly Brazil
52b1272a3a enhance empty data check 2020-06-11 17:13:45 -07:00
Kelly Brazil
d2ccad6a83 fix for no data 2020-06-11 17:09:51 -07:00
Kelly Brazil
cad6dde4ac fix for no data 2020-06-10 17:54:06 -07:00
Kelly Brazil
06811c3539 add test for no data 2020-06-10 17:41:54 -07:00
Kelly Brazil
0cb23c2b21 add fix for no data 2020-06-10 17:40:18 -07:00
Kelly Brazil
ac4688dca2 add test for no data 2020-06-10 17:35:40 -07:00
Kelly Brazil
326c3b4670 add test for no data 2020-06-10 17:34:22 -07:00
Kelly Brazil
9b29d0c268 add test for no data 2020-06-10 17:32:39 -07:00
Kelly Brazil
e0013c3871 add test for no data 2020-06-10 17:31:14 -07:00
Kelly Brazil
a75744075b add no data test 2020-06-10 17:29:41 -07:00
Kelly Brazil
525aec1a02 fix for no data 2020-06-10 17:27:46 -07:00
Kelly Brazil
0bf9a7a072 add test for no data 2020-06-10 17:22:59 -07:00
Kelly Brazil
d8f2f4c95b fix for no data 2020-06-10 17:20:09 -07:00
Kelly Brazil
35d733b44f fix for no data 2020-06-10 17:10:53 -07:00
Kelly Brazil
9179b4175c add nodata tests 2020-06-10 16:40:11 -07:00
Kelly Brazil
bb07d78c78 add nodata fix 2020-06-10 16:39:49 -07:00
Kelly Brazil
07b179cd7f Merge pull request #67 from kellyjonbrazil/Dev
Dev v1.11.4
2020-06-10 06:07:42 -07:00
Kelly Brazil
054422d837 add test for empty directory 2020-06-10 06:04:50 -07:00
Kelly Brazil
3e052d1810 version bump 2020-06-10 05:53:20 -07:00
Kelly Brazil
c8e72805cf fix error on empty directory 2020-06-10 05:51:12 -07:00
Kelly Brazil
12a80e7db0 add fedora package info 2020-06-09 15:13:53 -07:00
Kelly Brazil
ee7ff9a09d Merge pull request #66 from kellyjonbrazil/dev
Dev v1.11.3
2020-06-09 11:22:39 -07:00
Kelly Brazil
f6478fb636 version bump 2020-06-09 11:18:47 -07:00
Kelly Brazil
811a0b0495 add info regarding the local parser plugin files 2020-06-08 10:54:42 -07:00
Kelly Brazil
aeb48edf72 use $LOCALAPPDATA variable for windows 2020-06-08 10:48:58 -07:00
Kelly Brazil
b1e94f0df7 heading formatting 2020-06-08 10:44:09 -07:00
Kelly Brazil
60050e3c0f fix linux/unix directory and add note about the XDG specification followed 2020-06-08 10:42:45 -07:00
Kelly Brazil
39ef09aa5b add local parser plugin feature 2020-06-07 13:30:22 -07:00
Kelly Brazil
8377d43116 formatting 2020-06-07 13:26:03 -07:00
Kelly Brazil
54e4c447ab clean up formatting 2020-06-07 12:52:16 -07:00
Kelly Brazil
937a9fa9cf vendorize appdirs module 2020-06-07 12:41:50 -07:00
Kelly Brazil
808ff6cf0e more acknowledgments updates 2020-06-07 12:29:10 -07:00
Kelly Brazil
7f5c649a95 update acknowledgments 2020-06-07 12:23:28 -07:00
Kelly Brazil
b72727dec9 update custom parsers info 2020-06-07 12:13:40 -07:00
Kelly Brazil
3fc88bfb33 Merge pull request #65 from duelafn/local-parsers
Load custom parsers from <user_data_dir>/jc/jcparsers
2020-06-07 12:04:44 -07:00
Dean Serenevy
9f2279d586 Load custom parsers from <user_data_dir>/jc/jcparsers 2020-06-06 14:42:27 -04:00
Kelly Brazil
346a14cb9b change osx_device to unix_device 2020-05-30 20:44:14 -07:00
Kelly Brazil
dac00d17ff add nixos test 2020-05-30 20:33:50 -07:00
Kelly Brazil
9ca7cd4060 update docs 2020-05-30 20:33:39 -07:00
Kelly Brazil
aa31628970 update docs 2020-05-30 20:33:00 -07:00
Kelly Brazil
bed694fcf5 version bump 2020-05-30 20:13:21 -07:00
Kelly Brazil
4b4af69fa1 fix date 2020-05-30 20:12:51 -07:00
Kelly Brazil
9d96190a5b Merge pull request #64 from kellyjonbrazil/dev
Dev v1.11.2
2020-05-30 20:08:32 -07:00
Kelly Brazil
fa44d48c09 freebsd fixes, tests, and fixtures 2020-05-30 19:50:38 -07:00
Kelly Brazil
4ef961c278 add freebsd test and fixtures 2020-05-30 19:18:01 -07:00
Kelly Brazil
292a837d5c add tests and fixtures for freebsd12 2020-05-30 18:54:09 -07:00
Kelly Brazil
aa7b915d84 version bump 2020-05-30 18:53:46 -07:00
Kelly Brazil
c46fe73236 add last fixes for freebsd 2020-05-30 18:53:35 -07:00
Kelly Brazil
039b2c129c freebsd fixes 2020-05-30 18:42:26 -07:00
Kelly Brazil
8f2e5e4808 fix compatible logic 2020-05-30 17:46:09 -07:00
Kelly Brazil
c4da8e4f78 add nixos and freebsd to tested. update new arp fields 2020-05-30 17:05:41 -07:00
Kelly Brazil
bcab9078a4 add w parser fix 2020-05-30 17:02:09 -07:00
Kelly Brazil
b3c6c1ea92 strip whitespace in string fields and add tests 2020-05-30 17:01:59 -07:00
Kelly Brazil
a3af8662bd add permanent field 2020-05-30 16:26:07 -07:00
Kelly Brazil
35940d0bc8 add freebsd permanent and expires fields 2020-05-30 16:25:53 -07:00
Kelly Brazil
26994cdcb7 add freebsd compatibility info 2020-05-30 15:51:54 -07:00
Kelly Brazil
017159a829 add freebsd nestat tests and fixtures 2020-05-30 15:51:06 -07:00
Kelly Brazil
b4e9c85e08 fixup -T freebsd output and add whitespace stripping to parse_post 2020-05-30 15:50:45 -07:00
Kelly Brazil
189146cd84 add more ints. remove whitespace strip code and move to freebsd_osx module 2020-05-30 15:50:07 -07:00
Kelly Brazil
af34153ffa version bump 2020-05-30 15:48:56 -07:00
Kelly Brazil
bf2ff3ffbb fix compatibility search for platform names that append the version number (e.g. freebsd12) 2020-05-30 15:48:29 -07:00
Kelly Brazil
6423c9efd6 integer and float updates 2020-05-29 15:48:51 -07:00
Kelly Brazil
58ab0d4ece strip whitespace from string fields 2020-05-29 15:14:44 -07:00
Kelly Brazil
83a738bf4d update fixtures for osx_flags and osx_inode name change to unix_flags and unix_inode 2020-05-29 14:16:11 -07:00
Kelly Brazil
3640671fc6 rename module 2020-05-29 14:15:28 -07:00
Kelly Brazil
1da623b30e add items 2020-05-29 14:14:48 -07:00
Kelly Brazil
b10ca64646 change osx_inode and osx_flags to unix_inode and unix_flags. Also rename netstat_osx module to netstat_freebsd_osx 2020-05-29 14:14:37 -07:00
Kelly Brazil
2128763ee6 fix osx version from 16.4 to 14.6 2020-05-29 13:25:19 -07:00
Kelly Brazil
a27e7ed39c test updates for added route_flags_pretty and flags_pretty fields 2020-05-29 13:24:52 -07:00
Kelly Brazil
f07b7eaa47 add flags_pretty 2020-05-29 12:55:16 -07:00
Kelly Brazil
6ce18de84c add route_flags_pretty 2020-05-29 12:51:04 -07:00
Kelly Brazil
8631b756e7 add freebsd test files 2020-05-29 12:05:46 -07:00
Kelly Brazil
7414d98412 add freebsd compatibility 2020-05-29 12:05:34 -07:00
Kelly Brazil
d7b19892e8 add freebsd support for netstat -i 2020-05-29 12:04:58 -07:00
Kelly Brazil
96df396eaf formatting 2020-05-29 07:35:25 -07:00
Kelly Brazil
2f6f640317 spelling 2020-05-27 17:11:20 -07:00
Kelly Brazil
c4a0a50f3a add nix-env 2020-05-27 17:08:54 -07:00
Kelly Brazil
658f8a3842 add zypper and ports info 2020-05-27 14:58:16 -07:00
Kelly Brazil
bfb876a1e3 formatting 2020-05-27 09:52:13 -07:00
Kelly Brazil
90c34b1f4e fix dmidecode example 2020-05-26 17:31:56 -07:00
Kelly Brazil
3f9164ea77 bold formatting 2020-05-23 21:11:17 -07:00
Kelly Brazil
7fd6fecbf5 formatting 2020-05-23 21:09:49 -07:00
Kelly Brazil
8029f72363 change osx_flags from integer to string 2020-05-23 21:09:40 -07:00
Kelly Brazil
c7fdce5d3b Merge pull request #62 from kellyjonbrazil/dev
Dev v1.11.0
2020-05-22 16:37:50 -07:00
Kelly Brazil
84f48aa369 version bump 2020-05-22 16:30:22 -07:00
Kelly Brazil
2e9a0a9c12 add features 2020-05-22 16:21:55 -07:00
Kelly Brazil
c1f6f2b950 osx fixes and tests 2020-05-22 16:21:40 -07:00
Kelly Brazil
ede21bca13 add OSX support for stat 2020-05-22 16:05:04 -07:00
Kelly Brazil
8dd9a9f9cb add netstat -i tests 2020-05-22 15:12:10 -07:00
Kelly Brazil
04f92cd133 add linux support for netstat -i 2020-05-22 14:04:11 -07:00
Kelly Brazil
8be8d2393b add netstat -i support for OSX 2020-05-22 13:38:25 -07:00
Kelly Brazil
0a879681be add netstat -r to docs 2020-05-22 12:56:27 -07:00
Kelly Brazil
2ca1587a49 add linux netstat -r tests 2020-05-22 12:44:51 -07:00
Kelly Brazil
ec2cd2d708 add netstat -r support for linux 2020-05-22 12:00:26 -07:00
Kelly Brazil
5d0dbece93 add netstat -r functionality for OSX 2020-05-22 11:09:41 -07:00
Kelly Brazil
df1e4b414b remove unused folder 2020-05-22 08:00:18 -07:00
Kelly Brazil
40760991e7 update copyright date 2020-05-22 07:51:47 -07:00
Kelly Brazil
464f5f86cf update description 2020-05-22 07:50:22 -07:00
Kelly Brazil
7b09e9fccd set empty values to Null and update fixtures 2020-05-21 17:01:17 -07:00
Kelly Brazil
6cba7d4298 remove linux from description 2020-05-21 11:10:00 -07:00
Kelly Brazil
9730f62e49 fixup name field and update test fixtures 2020-05-21 09:44:28 -07:00
Kelly Brazil
e0c1c87f54 formatting 2020-05-21 09:07:01 -07:00
Kelly Brazil
931b3d2b83 formatting 2020-05-20 19:56:28 -07:00
Kelly Brazil
e5d561baee add multipath condition for osx detection 2020-05-20 17:31:51 -07:00
Kelly Brazil
2867593e7a changelog update 2020-05-20 17:28:44 -07:00
Kelly Brazil
dd52fee563 osx netstat tests and fixtures 2020-05-20 17:25:25 -07:00
Kelly Brazil
8e1f885827 fix filtered netstat views 2020-05-20 16:43:53 -07:00
Kelly Brazil
2d39a58f90 doc update 2020-05-20 16:14:03 -07:00
Kelly Brazil
9c4fa2ae26 integer conversions and icmp fix 2020-05-20 15:39:47 -07:00
Kelly Brazil
de52d84e82 fix udp state and udp46 entries 2020-05-20 12:02:32 -07:00
Kelly Brazil
ce9b55059a organize files 2020-05-20 11:24:38 -07:00
Kelly Brazil
bcd370a6a0 code cleanup 2020-05-20 08:19:45 -07:00
Kelly Brazil
c8216850ab code cleanup 2020-05-20 07:19:24 -07:00
Kelly Brazil
f5feedb90b fix comments 2020-05-19 17:38:14 -07:00
Kelly Brazil
a4371cd187 support netstat -A 2020-05-19 17:36:16 -07:00
Kelly Brazil
9d5ba4c834 formatting 2020-05-19 17:14:04 -07:00
Kelly Brazil
1639dee1bb fix parse_post 2020-05-19 17:13:03 -07:00
Kelly Brazil
9363f430f2 use list extend method to simplify code 2020-05-19 16:26:41 -07:00
Kelly Brazil
9192a09073 parse all sections 2020-05-19 16:26:04 -07:00
Kelly Brazil
b915eb9755 initial osx parser 2020-05-19 15:15:08 -07:00
Kelly Brazil
1cfcc2b592 tighten up line test logic when counting tabs 2020-05-14 09:58:16 -07:00
Kelly Brazil
7138dd02b7 cleanup variables after adding to item 2020-05-14 09:51:10 -07:00
Kelly Brazil
b4276643b7 add dmidecode tests and fixtures 2020-05-14 09:43:13 -07:00
Kelly Brazil
2ef00763bf fix first item 2020-05-14 09:33:45 -07:00
Kelly Brazil
54364928fc fix oddities like hybrid single/multiline data and items containing multiple records 2020-05-14 08:57:23 -07:00
Kelly Brazil
09b3b4932b add dmidecode output fixtures 2020-05-13 10:51:38 -07:00
Kelly Brazil
29d6670119 convert integers 2020-05-13 10:18:49 -07:00
Kelly Brazil
2f654b5f1a doc update 2020-05-13 10:13:27 -07:00
Kelly Brazil
e53b9f5992 add caveats to documentation 2020-05-13 10:12:40 -07:00
Kelly Brazil
addb234e61 add dmidecode doc 2020-05-13 09:44:20 -07:00
Kelly Brazil
76eca3b659 add dmidecode 2020-05-13 09:43:35 -07:00
Kelly Brazil
f90dec4c0e add examples to documentation 2020-05-13 09:43:23 -07:00
Kelly Brazil
8900a59d4c simplify logic by removing redundant block 2020-05-13 09:31:12 -07:00
Kelly Brazil
6685138200 fix for missing multi-line values that come immediately after a previous multi-line value 2020-05-13 09:25:02 -07:00
Kelly Brazil
4d3e65b980 fix missing values 2020-05-13 09:00:32 -07:00
Kelly Brazil
e9282bb546 add dmidecode parser 2020-05-13 08:22:52 -07:00
Kelly Brazil
f5627a4594 version bump 2020-05-11 11:03:02 -07:00
Kelly Brazil
81ffdb2510 remove shebang for Fedora packaging 2020-05-11 10:54:26 -07:00
Kelly Brazil
4c00a99850 version bump 2020-05-11 10:37:14 -07:00
Kelly Brazil
2bfcb45b28 make cli.py executable 2020-05-11 10:32:42 -07:00
Kelly Brazil
ab0c10e791 remove execute permissions 2020-05-11 10:27:16 -07:00
Kelly Brazil
2c1935115d Merge pull request #61 from kellyjonbrazil/dev
Dev v1.10.10
2020-05-09 11:47:05 -07:00
Kelly Brazil
d98e43dc78 add netstat item 2020-05-09 11:42:56 -07:00
Kelly Brazil
9348988d64 add netstat test for Fedora32 2020-05-09 11:41:30 -07:00
Kelly Brazil
1285c66467 netstat with bluetooth section 2020-05-09 11:36:23 -07:00
Kelly Brazil
b7191bbc13 handle bluetooth section (ignore for now) 2020-05-09 11:36:03 -07:00
Kelly Brazil
98b97509f7 version bump 2020-05-09 11:25:13 -07:00
Kelly Brazil
2b2b570490 add tests for 'gone - no logout' 2020-05-09 11:22:26 -07:00
Kelly Brazil
cce2d1ff29 add condition for 'gone - no logout' 2020-05-09 11:22:01 -07:00
Kelly Brazil
b79600c572 version bump 2020-05-09 11:01:48 -07:00
Kelly Brazil
140f1a8543 test fixes for issue #60 2020-05-09 11:00:04 -07:00
Kelly Brazil
e34657cfde fix issue #60 that was skipping the first file in some instances using -R without -l 2020-05-08 15:26:11 -07:00
Kelly Brazil
99070fa607 version bump 2020-05-08 10:51:13 -07:00
Kelly Brazil
2b46785b1f add MIT license to vendorized IfconfigParser class 2020-05-08 10:49:30 -07:00
Kelly Brazil
c72562524b fully remove tests from packaging 2020-05-08 09:30:31 -07:00
Kelly Brazil
b7dd6441c7 version bump 2020-05-08 08:20:33 -07:00
Kelly Brazil
31fcc2f755 remove manifest.in - no longer needed due to removing tests 2020-05-08 08:20:21 -07:00
Kelly Brazil
b391aa14bc add license_file to metadata 2020-05-08 08:19:51 -07:00
Kelly Brazil
d3c45debbb remove tests and add license file 2020-05-08 08:19:31 -07:00
Kelly Brazil
5b08469b87 Merge pull request #57 from kellyjonbrazil/dev
Dev v1.10.7
2020-05-01 15:55:50 -07:00
Kelly Brazil
4a77ec63a4 add IfconfigParser class 2020-05-01 14:57:50 -07:00
Kelly Brazil
d13606b6dc modify dependencies for easier packaging into Fedora 2020-05-01 14:37:23 -07:00
Kelly Brazil
05291c93bb vendorize ifconfig-parser module for easier packaging in Fedora 2020-05-01 14:36:54 -07:00
Kelly Brazil
8cf00a208e change text to strings 2020-04-29 15:57:55 -07:00
Kelly Brazil
06d73c8876 formatting 2020-04-23 07:06:44 -07:00
Kelly Brazil
649c646ea2 add brew install option 2020-04-22 16:08:34 -07:00
Kelly Brazil
b7756d9250 version bump 2020-04-20 16:33:26 -07:00
Kelly Brazil
1cd2cd954c remove references to homebrew/shim to allow tests to pass in homebrew packaging ci/cd 2020-04-20 16:31:22 -07:00
Kelly Brazil
72020b8da9 move packages info to jc-packages github page 2020-04-17 10:20:25 -07:00
Kelly Brazil
cf9720b749 update install info 2020-04-16 14:03:31 -07:00
Kelly Brazil
967b9db7f9 spelling 2020-04-15 21:27:22 -07:00
Kelly Brazil
bb3acb1182 formatting 2020-04-15 21:25:06 -07:00
Kelly Brazil
560c7f7e6d formatting 2020-04-15 21:23:55 -07:00
Kelly Brazil
79b2841764 add new binary package install info 2020-04-15 21:22:43 -07:00
Kelly Brazil
a06a89cbd1 version bump 2020-04-14 11:15:24 -07:00
Kelly Brazil
431bd969eb use sys.exit(0) instead of exit() 2020-04-14 11:10:31 -07:00
Kelly Brazil
c87b722aec spelling 2020-04-12 13:23:58 -07:00
Kelly Brazil
3688b8b014 Merge pull request #56 from kellyjonbrazil/dev
Dev v1.10.4
2020-04-12 13:21:38 -07:00
Kelly Brazil
07b8d9e0c0 version bump 2020-04-12 13:18:28 -07:00
Kelly Brazil
7454b53e39 formatting 2020-04-12 13:13:28 -07:00
Kelly Brazil
3d6a76024d update with JC_COLORS info 2020-04-12 13:10:57 -07:00
Kelly Brazil
421b980957 JC_COLORS working 2020-04-12 13:03:09 -07:00
Kelly Brazil
4a22e27d6a add set_env_colors function 2020-04-12 12:43:51 -07:00
Kelly Brazil
99f7842dee fix brek on pipe error 2020-04-09 13:38:33 -07:00
Kelly Brazil
7f869b4b18 change colors to ansi and match jello style 2020-04-09 07:31:21 -07:00
Kelly Brazil
9665f4ee84 add pypi badge 2020-04-07 08:44:15 -07:00
Kelly Brazil
606904d48b Merge pull request #53 from kellyjonbrazil/dev
Dev v1.10.1
2020-04-04 17:28:21 -07:00
Kelly Brazil
3f5279b97c version bump to 1.10.1 2020-04-04 17:25:55 -07:00
Kelly Brazil
f5ec21e6ac use in instead of find() 2020-04-04 17:19:32 -07:00
Kelly Brazil
578a284465 use in instead of find() 2020-04-04 17:18:39 -07:00
Kelly Brazil
422e392d9d use in instead of find() 2020-04-04 17:17:43 -07:00
Kelly Brazil
54dfffd34a use in instead of find() 2020-04-04 17:16:25 -07:00
Kelly Brazil
cffba64d2b use in and startswith() instead of find() 2020-04-04 17:15:03 -07:00
Kelly Brazil
56a0c12a59 use in instead of find() 2020-04-04 17:12:22 -07:00
Kelly Brazil
c174d3de18 use in and startswith() instead of find() 2020-04-04 17:10:46 -07:00
Kelly Brazil
a9c59ef9fc fix logic to not for ' type ' in cleandata[0] 2020-04-04 17:07:38 -07:00
Kelly Brazil
abdb9b2673 use in instead of find() 2020-04-04 17:05:17 -07:00
Kelly Brazil
548aaab626 remove old commented code 2020-04-04 17:04:20 -07:00
Kelly Brazil
20571c87ae us in instead of find() 2020-04-04 17:01:56 -07:00
Kelly Brazil
19e49200de version bump 2020-04-04 16:59:48 -07:00
Kelly Brazil
d32f5c67a9 use startswith() instead of find() 2020-04-04 16:59:03 -07:00
Kelly Brazil
b83b626435 use startswith() instead of find() 2020-04-04 16:57:23 -07:00
Kelly Brazil
ab2c1b25ec use startswith() and in instead of find() 2020-04-04 16:56:11 -07:00
Kelly Brazil
f2d46313a4 use startswith() instead of find() 2020-04-04 16:53:55 -07:00
Kelly Brazil
87e4796a6c use in instead of .find() 2020-04-04 16:52:45 -07:00
Kelly Brazil
0014a5c2f4 us startswith() and in instead of .find() 2020-04-04 16:51:36 -07:00
Kelly Brazil
7af56e0dad use startswith() and in instead of find() 2020-04-04 16:50:05 -07:00
Kelly Brazil
a5ae6e3c01 use startswith() instead of find() 2020-04-04 16:48:16 -07:00
Kelly Brazil
fe1a0d1faf use in instead of .find() 2020-04-04 16:46:09 -07:00
Kelly Brazil
302f05cdda prettify style block 2020-04-03 14:50:20 -07:00
Kelly Brazil
c0044be7b0 rename color grey to gray 2020-04-03 14:48:19 -07:00
Kelly Brazil
0110078807 update badge 2020-04-03 14:47:08 -07:00
Kelly Brazil
42eacb45f8 rename to Tests 2020-04-03 14:45:04 -07:00
Kelly Brazil
a43e2e1991 add -m option info 2020-04-02 17:40:06 -07:00
Kelly Brazil
c8b721d4f6 version bump to 1.10.0 2020-04-02 17:35:35 -07:00
Kelly Brazil
d0bfddc3d9 add color and -m monochrome option 2020-04-02 17:29:25 -07:00
Kelly Brazil
6b925a16c8 add tests badge 2020-04-02 10:55:32 -07:00
Kelly Brazil
89ebd9fc22 add axfr info to schema 2020-03-27 07:31:08 -07:00
Kelly Brazil
6b4ba66231 Merge pull request #52 from kellyjonbrazil/dev
Dev v1.9.3
2020-03-26 17:15:13 -07:00
Kelly Brazil
5b697dc381 add more dig tests 2020-03-26 17:09:29 -07:00
Kelly Brazil
9ba73c95d1 add tests 2020-03-26 16:45:29 -07:00
Kelly Brazil
93aa390447 version bump to v1.9.3 2020-03-26 16:30:17 -07:00
Kelly Brazil
3cfb8945dd use startswith() instead of find 2020-03-26 16:29:59 -07:00
Kelly Brazil
cd8d38f2a1 add axfr support 2020-03-26 16:22:53 -07:00
Kelly Brazil
8ec8cd6294 Merge pull request #50 from kellyjonbrazil/dev
Dev v1.9.2
2020-03-12 17:09:04 -07:00
Kelly Brazil
c028113561 version bump to v1.9.2 2020-03-12 17:06:55 -07:00
Kelly Brazil
5f22e1c803 fix and test for osx arp entries without ifscope 2020-03-12 17:02:26 -07:00
Kelly Brazil
d3351787e5 change osx detection 2020-03-12 16:52:33 -07:00
Kelly Brazil
e5bea9ae3b version bump 2020-03-12 08:52:01 -07:00
Kelly Brazil
93c710abe9 Merge pull request #49 from kellyjonbrazil/dev
Dev v1.9.1
2020-03-12 08:23:10 -07:00
Kelly Brazil
c29e7cfe5c version bump to 1.9.1 2020-03-12 08:17:28 -07:00
Kelly Brazil
cb5c1ba00d add tests for fix to make the file parser splitting more robust 2020-03-11 17:04:48 -07:00
Kelly Brazil
9a012b94e1 make splitting more robust 2020-03-11 15:40:34 -07:00
Kelly Brazil
400f5a44ec Merge pull request #48 from kellyjonbrazil/dev
Dev v1.9.0
2020-03-11 13:37:22 -07:00
Kelly Brazil
a2ab5bab91 version bump to v1.9.0 2020-03-11 13:32:58 -07:00
Kelly Brazil
fc8ab27361 bugfix for misaligned columns and additional test for ntpq #31 2020-03-11 13:24:55 -07:00
Kelly Brazil
59f19d33a5 add file command tests for #41 2020-03-11 12:39:59 -07:00
Kelly Brazil
dfc9618115 add file parser for issue #41 2020-03-11 12:20:58 -07:00
Kelly Brazil
8e02e5c75a fix issue with getting options with some commands #47 2020-03-11 09:21:14 -07:00
Kelly Brazil
970493ab93 add magic commands 2020-03-11 06:22:54 -07:00
Kelly Brazil
64d78956eb update acknowledgment 2020-03-10 22:18:26 -07:00
Kelly Brazil
40c05346f4 re-adding optimizations from https://github.com/philippeitis 2020-03-10 22:16:40 -07:00
Kelly Brazil
e9b0bc1409 doc update 2020-03-10 22:03:54 -07:00
Kelly Brazil
798e6bb7d9 tests passing for airport -s. issue #46 2020-03-10 22:03:44 -07:00
Kelly Brazil
12a370deed add airport -s parser for issue #46 2020-03-10 21:51:02 -07:00
Kelly Brazil
553bfbe1a0 tests passing for airport -I. Issue #46 2020-03-10 21:02:17 -07:00
Kelly Brazil
52494321fc fixes and docs for airport parser issue #46 2020-03-10 20:55:07 -07:00
Kelly Brazil
c6c9e06496 added airport command parser 2020-03-10 20:35:52 -07:00
Kelly Brazil
e3a6c05a58 timedatectl fixes, tests, and fixtures for issue #42 2020-03-10 20:26:53 -07:00
Kelly Brazil
391d06f68d change selection_state to state 2020-03-10 20:16:41 -07:00
Kelly Brazil
99804ea06e added timedatectl status parser 2020-03-10 18:37:55 -07:00
Kelly Brazil
51935deb2a timedatectl test fixtures 2020-03-10 18:00:47 -07:00
Kelly Brazil
b24d0c3a47 ntpq docs 2020-03-10 18:00:26 -07:00
Kelly Brazil
762a886d6f add ntpq tests 2020-03-10 15:17:25 -07:00
Kelly Brazil
2c3e9ddfe4 add ntpq parser for issue #31 2020-03-10 14:18:55 -07:00
Kelly Brazil
c7cd2b63c8 delete unused test file 2020-03-09 11:46:17 -07:00
783 changed files with 93879 additions and 7225 deletions

View File

@@ -1,4 +1,4 @@
name: Test code
name: Tests
on:
push:
@@ -14,10 +14,16 @@ jobs:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: [3.6, 3.7, 3.8]
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
- name: "Set up timezone to America/Los_Angeles"
uses: szenius/set-timezone@v1.0
with:
timezoneLinux: "America/Los_Angeles"
timezoneMacos: "America/Los_Angeles"
timezoneWindows: "Pacific Standard Time"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:

1
.gitignore vendored
View File

@@ -3,5 +3,4 @@ __pycache__
dist/
build/
*.egg-info/
jc/parsers.old/
.github/

362
CHANGELOG Normal file
View File

@@ -0,0 +1,362 @@
jc changelog
20210426 v1.15.3
- Add ufw status command parser tested on linux
- Add ufw-appinfo command parser tested on linux
- Fix deb package name to conform to standard
- Add Caveats section to readme and manpage
20210418 v1.15.2
- Add systeminfo parser tested on Windows
- Update dig parser to fix an issue with IPv6 addresses in the server field
- Update dig parser to fix an issue when axfr entries contain a semicolon
- Update dig parser to add support for Additional Section and Opt Pseudosection
- Update dig parser to add query_size field
- Use dig parser as the main example in readme, documentation, and man page
- Standardize int, float, and boolean conversion rules with functions in jc.utils
20210413 v1.15.1
- New feature to show parser documentation interactively with -h --parser_name
for example: $ jc -h --arp
- Add man page to pypi package for easier packaging in homebrew
- Update rpm-qi parser to add two calculated timestamp fields: install_date_epoch and install_date_epoch_utc
- Clean up documentation and autogenerate the Parser Information section from metadata
20210407 v1.15.0
- Add acpi command parser tested on linux
- Add upower command parser tested on linux
- Add /usr/bin/time command parser tested on linux and macOS
- Add dpkg -l command parser tested on linux
- Add rpm -qi command parser tested on linux
- Add finger command parser tested on linux and macOS
- Add dir command parser tested on Windows 10
- Update date parser: complete rewrite (v2.0) providing many enhancements:
- Make weekday numbering ISO 8601 compliant
- Add a calculated naive timestamp field
- Add a calculated UTC timestamp field (only if date output is in UTC)
- Add several fields, including: hour_24, utc_offset, day_of_year, week_of_year, iso, and timezone_aware
- Update uptime parser to add uptime_days, uptime_hours, uptime_minutes, uptime_total_seconds, time_hour,
time_minute, and time_second fields
- Update last parser to use new timestamp function
- Update stat parser to add access_time_epoch, access_time_epoch_utc, modify_time_epoch, modify_time_epoch_utc,
change_time_epoch, change_time_epoch_utc, birth_time_epoch, birth_time_epoch_utc fields
- Update timedatectl parser to add epoch_utc field
- Update who parser to add epoch field
- Update dig parser to add when_epoch and when_epoch_utc fields
- Update ls parser to add epoch and epoch_utc fields
- Add -h option to display the help text. Piping errors no longer show the help text.
- Add -v option to display version information.
- Add contributing information to project root
- Make all external python library dependencies optional: pygments, ruamel.yaml, xmltodict
- JSON output now supports unencoded unicode characters
- JSON output is now more compact unless the -p (pretty) option is used
- Developer scripts added and enhanced to automate documentation and man page creation
- Enhanced man page
20210305 v1.14.4
- Packaging fix only for binaries and RPMs hosted on https://github.com/kellyjonbrazil/jc-packaging.
Packages from PyPi and OS repositories are not affected. This fixes an issue that kept the YAML
parser from initializing.
20210210 v1.14.3
- Add hciconfig parser tested on linux
- Update dig parser to simplify answer data logic
20210205 v1.14.2
- Update dig parser to fix cases where there are spaces in the answer data (e.g. TXT records)
20210106 v1.14.1
- Add iw-scan parser tested on linux (beta)
- Update date parser for Ubuntu 20.04 support
- Update last parser for last -F support
- Update last parser to add convenience fields and augment data for easier parsing
- Update man page
- Minor documentation updates
20201231 v1.14.0
- Add hashsum parser tested on linux, macos
- Add hash parser tested on linux, macos
- Add cksum parser tested on linux, macos
- Add wc parser tested on linux, macos
- Add printenv support under env parser
- Add vdir support under ls parser
- Add python 3.9 to github automation tests
20200805 v1.13.4
- Update crontab and crontab-u parsers to tighten up variable detection
- Update ping parser to tighten linux/bsd detection
20200804 v1.13.3
- Update ping parser for Raspberry Pi compatibility
20200803 v1.13.2
- Add key/value file parser (wrapper for ini parser)
- Add date command parser
- Update traceroute parser to more gracefully handle missing header row
- Update traceroute parser to handle annotations
- Update traceroute parser to only return successful probes
20200727 v1.13.1
- Add route -6 tests
20200727 v1.13.0
- Add ping and ping6 command parser tested on linux, macos, and freebsd
- Add traceroute and traceroute6 command parser tested on linux, macos, and freebsd
- Add tracepath command parser tested on linux
- Update ini parser to support files only containing key/value pairs
- Update uname parser exception with a hint to use "uname -a"
- Update route parser to support IPv6 tables
20200711 v1.12.1
- Fix tests when using older version of pygments library
20200710 v1.12.0
- Add sysctl command parser tested on linux, macOS, and freebsd
- Update the cli code to allow older versions of the pygments library (2.3.0) for debian packaging
- Code cleanup on the cli
- Add tests for the cli
- Vendorize cgitb as tracebackplus for verbose debug messages
20200625 v1.11.8
- Add verbose debug option using -dd argument
20200622 v1.11.7
- Fix iptables parser issue which would not output the last chain
20200614 v1.11.6
- Improve and standardize empty data check for all parsers
20200612 v1.11.5
- Update airport_s parser to fix error on parsing empty data
- Update arp parser to fix error on parsing empty data
- Update blkid parser to fix error on parsing empty data
- Update crontab parser to fix error on parsing empty data
- Update crontab_u parser to fix error on parsing empty data
- Update df parser to fix error on parsing empty data
- Update free parser to fix error on parsing empty data
- Update lsblk parser to fix error on parsing empty data
- Update lsmod parser to fix error on parsing empty data
- Update mount parser to fix error on parsing empty data
- Update netstat parser to fix error on parsing empty data
- Update ntpq parser to fix error on parsing empty data
- Update ps parser to fix error on parsing empty data
- Update route parser to fix error on parsing empty data
- Update systemctl parser to fix error on parsing empty data
- Update systemctl_lj parser to fix error on parsing empty data
- Update systemctl_ls parser to fix error on parsing empty data
- Update systemctl_luf parser to fix error on parsing empty data
- Update uptime parser to fix error on parsing empty data
- Update w parser to fix error on parsing empty data
- Update xml parser to fix error on parsing empty data
- Add tests to all parsers for no data condition
- Update ss parser to fix integer fields
20200610 v1.11.4
- Update ls parser to fix error on parsing an empty directory
20200609 v1.11.3
- Add local parser plugin feature (contributed by Dean Serenevy)
20200530 v1.11.2
- Update netstat parser to add freebsd support
- Update netstat parser to add route_flags_pretty field
- Update netstat parser to change osx_inode field name to unix_inode
- Update netstat parser to change osx_flags field name to unix_flags
- Update netstat parser to strip whitespace from state field
- Update route parser to add flags_pretty field
- Update arp parser to add permanent field (freebsd and osx)
- Update arp parser to add expires field (freebsd)
- Update w parser to strip whitespace from what field
- Update last parser to fix FreeBSD issues
- Update stat parser to change osx_flags field name to unix_flags
- Update stat parser to add unix_device field for freebsd and osx
- Fix freebsd compatibility message for df, fstab, mount, ntpq, stat, and uname parsers
- Fix compatibility message for platforms that include the version number at the end (e.g. freebsd12)
20200523 v1.11.1
- Update stat command parser to change osx_flags field to string
20200522 v1.11.0
- Add dmidecode command parser
- Update stat command parser to add OSX support
- Update netstat command parser to add OSX support
- Update netstat command parser to add -r (route) functionality for linux and OSX
- Update netstat command parser to add -i (interface) functionality for linux and OSX
20200511 v1.10.12
- Remove shebang from jc/cli.py for Fedora packaging
20200511 v1.10.11
- Change file permissions for Fedora packaging
20200509 v1.10.10
- Fix ls parser issue where the first file was skipped for ls -R on some platforms
- Update last parser to handle 'gone - no logout' condition
- Update netstat parser to handle bluetooth section (ignore gracefully for now)
20200508 v1.10.9
- Add license info to vendorized ifconfig-parser class
20200508 v1.10.8
- Add license file to dist for Fedora RPM packaging requirements
- Remove tests from package to keep from polluting the global site-packages
20200501 v1.10.7
- Requirements modifications for Fedora RPM packaging requirements
20200420 v1.10.6
- Remove homebrew shim references from du osx tests
20200414 v1.10.5
- Minor change of using sys.exit(0) instead of exit()
20200412 v1.10.4
- Add color customization via JC_COLORS env variable
20200409 v1.10.3
- Fix break on pipe error
20200409 v1.10.2
- Change colors to ansi and match jello colors
20200402 v1.10.1
- Code cleanup
20200402 v1.10.0
- Add color output by default when not piping data to another program
- Add -m option for monochrome output
20200326 v1.9.3
- Add axfr support for dig command parser
20200312 v1.9.2
- Updated arp parser to fix OSX detection for some edge cases
20200312 v1.9.1
- Updated 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
- Optimized history command parser by https://github.com/philippeitis
- Magic syntax fix for certain edge cases
20200308 v1.8.1
- 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
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
20200227 v1.7.5
- Updated ls parser to support filenames with newline characters
20200219 v1.7.4
- Updated ls parser to support multiple directories, globbing, and -R (recursive)
20200211 v1.7.3
- Add alternative 'magic' syntax: e.g. `jc ls -al`
- Options can now be condensed (e.g. -prq is equivalant to -p -r -q)
20200208 v1.7.2
- Include test fixtures in wheel and sdist
20200205 v1.7.1
- Add YAML file parser
- Add INI file parser
- Add XML file parser
- Add id parser (tested on linux and OSX)
- 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
- Bugfix in crontab file parser: header insertion was clobbering first row
- Just-in-time loading of parser modules instead of loading all at start
20191217 v1.6.1
- Add du parser (tested on linux and OSX)
- Add crontab parser (tested on linux and OSX)
- Add pip list parser (tested on linux and OSX)
- Add pip show parser (tested on linux and OSX)
- Add OSX support for the ifconfig, arp, df, mount, and uname parsers
- 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
20191117 v1.5.1
- Add ss parser
- Add stat parser
- Add /etc/hosts parser
- Add /etc/fstab parser
- Add systemctl parser (includes list-jobs, list-sockets, and list-unit-files)
- Add -r and raw=True options. By default, jc will now convert numbers and boolean, if possible, and add other semantic information, while the raw output will keep all values as text and provide a more literal JSON output
- Add -q and quiet=True options to suppress warnings to stderr
- 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
- Clean up code and reorganize package
20191031 v1.1.1
- Add arp parser
- Add dig parser
- Add unit tests
- fix netstat parser (remove side effects due to global variable)
20191025 v1.0.1
- Add w parser
- Add uptime parser
- Add history parser
- Flatten env parser output
- Remove problematic characters from key names in: df, free, history, lsblk, lsof, and w
- Where possible, lowercase all keys (except cases like env where the key is the variable name)
- Remove integer values
- Handle CTRL-C gracefully
20191023 v0.9.1
- Add jobs parser
- Add lsof parser
- Add lsmod parser
- No blocking if no piped data
- Better help text
- Clean up iptables parser code
20191022 v0.8.1
- Add env parser
- Add df parser
- Add free parser
- Add lsblk parser
- Add mount parser
- Add uname parser
- Add iptables parser
20191021 v0.6.4
- Flatten netstat parser output
- Clean up argument parsing
- Fix command help
20191018 v0.5.5
- Fix netstat -p parsing for Ubuntu
- Add ps parser
- Add route parser
- ls parser fixes
20191017 v0.2.0
- ifconfig, ls, and netstat support

88
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,88 @@
# Contributing to jc
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
- Reporting a bug
- Discussing the current state of the code
- Submitting a fix
- Proposing new features
- Proposing a new parser
## We Develop with Github
We use github to host code, to track issues and feature requests, as well as accept pull requests.
## We Use Github Flow, So All Code Changes Happen Through Pull Requests
Pull requests are the best way to propose changes to the codebase (we use [Github Flow](https://guides.github.com/introduction/flow/index.html)). We actively welcome your pull requests:
1. Open an issue to discuss the new feature, bug fix, or parser before opening a pull request. For new parsers, it is important to agree upon a schema before developing the parser.
2. Fork the repo and create your branch from `dev`, if available, otherwise `master`.
3. If you've added code that should be tested, add tests. All new parsers should have several sample outputs and tests.
4. Documentation is auto-generated from docstrings, so ensure they are clear and accurate.
5. Ensure the test suite passes. (Note: "**America/Los_Angeles**" timezone should be configured on the test system)
6. Make sure your code lints.
7. Issue that pull request!
## Parser Schema Guidelines
- Try to keep the schema as flat as possible - typically a list of flat dictionaries
- Keys should be lowercase, contain no special characters, and spaces should be converted to underscores
- Keys should be static, if possible. If they have to be dynamic, then they should not contain lists or dictionaries
This will make it easier to use tools like `jq` without requiring escaping of special characters, encapsulating key names in [""], keeps paths predictable, and makes iterating and searching for values easier.
**Examples**
Bad:
```
{
"Interface 1": [
192.168.1.1,
172.16.1.1
],
"Wifi Interface 1": [
10.1.1.1
]
}
```
Good:
```
[
{
"interface": "Interface 1",
"ip_addresses": [
192.168.1.1,
172.16.1.1
]
},
{
"interface": "Wifi Interface 1",
"ip_addresses": [
10.1.1.1
]
}
]
```
## Tests
It is essential to have good command output sample coverage and tests to keep the `jc` parser quality high.
Many parsers include calculated timestamp fields using the `jc.utils.timestamp` class. Naive timestamps created with this class should be generated on a system configured with the "**America/Los_Angeles**" timezone on linux/macOS/unix and "**Pacific Standard Time**" timezone on Windows for tests to pass on the Github Actions CI tests. This timezone should be configured on your local system before running the tests locally, as well.
## Any contributions you make will be under the MIT Software License
In short, when you submit code changes, your submissions are understood to be under the same [MIT License](http://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern.
## Report bugs using Github's Issues
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/kellyjonbrazil/jc/issues); it's that easy!
## Write bug reports with detail, background, and sample code
**Great Bug Reports** tend to have:
- A quick summary and/or background
- Steps to reproduce
- Be specific!
- Give sample code if you can.
- What you expected would happen
- What actually happens
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)
## Use a Consistent Coding Style
* 4 spaces for indentation rather than tabs
* Use a Python linter that will enforce PEP 8 and other best practices

3562
EXAMPLES.md Normal file

File diff suppressed because it is too large Load Diff

2
LICENSE.md Executable file → Normal file
View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2019 Kelly Brazil
Copyright (c) 2020 Kelly Brazil
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -1 +1 @@
graft tests/fixtures
include jc/man/jc.1.gz

2144
README.md Executable file → Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,119 +0,0 @@
jc changelog
20200308 v1.8.1
- CLI and history parser 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
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
20200227 v1.7.5
- Updated ls parser to support filenames with newline characters
20200219 v1.7.4
- Updated ls parser to support multiple directories, globbing, and -R (recursive)
20200211 v1.7.3
- Add alternative 'magic' syntax: e.g. `jc ls -al`
- Options can now be condensed (e.g. -prq is equivalant to -p -r -q)
20200208 v1.7.2
- Include test fixtures in wheel and sdist
20200205 v1.7.1
- Add YAML file parser
- Add INI file parser
- Add XML file parser
- Add id parser (tested on linux and OSX)
- 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
- Bugfix in crontab file parser: header insertion was clobbering first row
- Just-in-time loading of parser modules instead of loading all at start
20191217 v1.6.1
- Add du parser (tested on linux and OSX)
- Add crontab parser (tested on linux and OSX)
- Add pip list parser (tested on linux and OSX)
- Add pip show parser (tested on linux and OSX)
- Add OSX support for the ifconfig, arp, df, mount, and uname parsers
- 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
20191117 v1.5.1
- Add ss parser
- Add stat parser
- Add /etc/hosts parser
- Add /etc/fstab parser
- Add systemctl parser (includes list-jobs, list-sockets, and list-unit-files)
- Add -r and raw=True options. By default, jc will now convert numbers and boolean, if possible, and add other semantic information, while the raw output will keep all values as text and provide a more literal JSON output
- Add -q and quiet=True options to suppress warnings to stderr
- 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
- Clean up code and reorganize package
20191031 v1.1.1
- Add arp parser
- Add dig parser
- Add unit tests
- fix netstat parser (remove side effects due to global variable)
20191025 v1.0.1
- Add w parser
- Add uptime parser
- Add history parser
- Flatten env parser output
- Remove problematic characters from key names in: df, free, history, lsblk, lsof, and w
- Where possible, lowercase all keys (except cases like env where the key is the variable name)
- Remove integer values
- Handle CTRL-C gracefully
20191023 v0.9.1
- Add jobs parser
- Add lsof parser
- Add lsmod parser
- No blocking if no piped data
- Better help text
- Clean up iptables parser code
20191022 v0.8.1
- Add env parser
- Add df parser
- Add free parser
- Add lsblk parser
- Add mount parser
- Add uname parser
- Add iptables parser
20191021 v0.6.4
- Flatten netstat parser output
- Clean up argument parsing
- Fix command help
20191018 v0.5.5
- Fix netstat -p parsing for Ubuntu
- Add ps parser
- Add route parser
- ls parser fixes
20191017 v0.2.0
- ifconfig, ls, and netstat support

View File

@@ -1,51 +1,37 @@
#!/bin/bash
# Generate docs.md
# requires pydoc-markdown 2.1.0.post1
cd jc
echo Building docs for: package
pydocmd simple jc+ > ../docs/readme.md
echo Building docs for: utils
pydocmd simple utils+ > ../docs/utils.md
pydocmd simple jc.parsers.arp+ > ../docs/parsers/arp.md
pydocmd simple jc.parsers.blkid+ > ../docs/parsers/blkid.md
pydocmd simple jc.parsers.crontab+ > ../docs/parsers/crontab.md
pydocmd simple jc.parsers.crontab_u+ > ../docs/parsers/crontab_u.md
pydocmd simple jc.parsers.csv+ > ../docs/parsers/csv.md
pydocmd simple jc.parsers.df+ > ../docs/parsers/df.md
pydocmd simple jc.parsers.dig+ > ../docs/parsers/dig.md
pydocmd simple jc.parsers.du+ > ../docs/parsers/du.md
pydocmd simple jc.parsers.env+ > ../docs/parsers/env.md
pydocmd simple jc.parsers.free+ > ../docs/parsers/free.md
pydocmd simple jc.parsers.fstab+ > ../docs/parsers/fstab.md
pydocmd simple jc.parsers.group+ > ../docs/parsers/group.md
pydocmd simple jc.parsers.gshadow+ > ../docs/parsers/gshadow.md
pydocmd simple jc.parsers.history+ > ../docs/parsers/history.md
pydocmd simple jc.parsers.hosts+ > ../docs/parsers/hosts.md
pydocmd simple jc.parsers.id+ > ../docs/parsers/id.md
pydocmd simple jc.parsers.ifconfig+ > ../docs/parsers/ifconfig.md
pydocmd simple jc.parsers.ini+ > ../docs/parsers/ini.md
pydocmd simple jc.parsers.iptables+ > ../docs/parsers/iptables.md
pydocmd simple jc.parsers.jobs+ > ../docs/parsers/jobs.md
pydocmd simple jc.parsers.last+ > ../docs/parsers/last.md
pydocmd simple jc.parsers.ls+ > ../docs/parsers/ls.md
pydocmd simple jc.parsers.lsblk+ > ../docs/parsers/lsblk.md
pydocmd simple jc.parsers.lsmod+ > ../docs/parsers/lsmod.md
pydocmd simple jc.parsers.lsof+ > ../docs/parsers/lsof.md
pydocmd simple jc.parsers.mount+ > ../docs/parsers/mount.md
pydocmd simple jc.parsers.netstat+ > ../docs/parsers/netstat.md
pydocmd simple jc.parsers.passwd+ > ../docs/parsers/passwd.md
pydocmd simple jc.parsers.pip_list+ > ../docs/parsers/pip_list.md
pydocmd simple jc.parsers.pip_show+ > ../docs/parsers/pip_show.md
pydocmd simple jc.parsers.ps+ > ../docs/parsers/ps.md
pydocmd simple jc.parsers.route+ > ../docs/parsers/route.md
pydocmd simple jc.parsers.shadow+ > ../docs/parsers/shadow.md
pydocmd simple jc.parsers.ss+ > ../docs/parsers/ss.md
pydocmd simple jc.parsers.stat+ > ../docs/parsers/stat.md
pydocmd simple jc.parsers.systemctl+ > ../docs/parsers/systemctl.md
pydocmd simple jc.parsers.systemctl_lj+ > ../docs/parsers/systemctl_lj.md
pydocmd simple jc.parsers.systemctl_ls+ > ../docs/parsers/systemctl_ls.md
pydocmd simple jc.parsers.systemctl_luf+ > ../docs/parsers/systemctl_luf.md
pydocmd simple jc.parsers.uname+ > ../docs/parsers/uname.md
pydocmd simple jc.parsers.uptime+ > ../docs/parsers/uptime.md
pydocmd simple jc.parsers.w+ > ../docs/parsers/w.md
pydocmd simple jc.parsers.who+ > ../docs/parsers/who.md
pydocmd simple jc.parsers.xml+ > ../docs/parsers/xml.md
pydocmd simple jc.parsers.yaml+ > ../docs/parsers/yaml.md
# a bit of inception here... jc is being used to help
# automate the generation of its own documentation. :)
# pull jc parser objects into a bash array from jq
parsers=()
while read -r value
do
parsers+=("$value")
done < <(jc -a | jq -c '.parsers[]')
# iterate over the bash array
for parser in "${parsers[@]}"
do
parser_name=$(jq -r '.name' <<< "$parser")
compatible=$(jq -r '.compatible | join(", ")' <<< "$parser")
version=$(jq -r '.version' <<< "$parser")
author=$(jq -r '.author' <<< "$parser")
author_email=$(jq -r '.author_email' <<< "$parser")
echo "Building docs for: ${parser_name}"
echo "[Home](https://kellyjonbrazil.github.io/jc/)" > ../docs/parsers/"${parser_name}".md
pydocmd simple jc.parsers."${parser_name}"+ >> ../docs/parsers/"${parser_name}".md
echo "## Parser Information" >> ../docs/parsers/"${parser_name}".md
echo "Compatibility: ${compatible}" >> ../docs/parsers/"${parser_name}".md
echo >> ../docs/parsers/"${parser_name}".md
echo "Version ${version} by ${author} (${author_email})" >> ../docs/parsers/"${parser_name}".md
done

1
docs/_config.yml Normal file
View File

@@ -0,0 +1 @@
theme: jekyll-theme-cayman

255
docs/parsers/acpi.md Normal file
View File

@@ -0,0 +1,255 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.acpi
jc - JSON CLI output utility `acpi` command output parser
Usage (cli):
$ acpi -V | jc --acpi
or
$ jc acpi -V
Usage (module):
import jc.parsers.acpi
result = jc.parsers.acpi.parse(acpi_command_output)
Schema:
[
{
"type": string,
"id": integer,
"state": string,
"charge_percent": integer,
"until_charged": string,
"until_charged_hours": integer,
"until_charged_minuts": integer,
"until_charged_seconds": integer,
"until_charged_total_seconds": integer,
"charge_remaining": string,
"charge_remaining_hours": integer,
"charge_remaining_minutes": integer,
"charge_remaining_seconds": integer,
"charge_remaining_total_seconds": integer,
"design_capacity_mah": integer,
"last_full_capacity": integer,
"last_full_capacity_percent": integer,
"on-line": boolean,
"mode": string,
"temperature": float,
"temperature_unit": string,
"trip_points": [
{
"id": integer,
"switches_to_mode": string,
"temperature": float,
"temperature_unit": string
}
],
"messages": [
string
]
}
]
Examples:
$ acpi -V | jc --acpi -p
[
{
"type": "Battery",
"id": 0,
"state": "Charging",
"charge_percent": 71,
"until_charged": "00:29:20",
"design_capacity_mah": 2110,
"last_full_capacity": 2271,
"last_full_capacity_percent": 100,
"until_charged_hours": 0,
"until_charged_minutes": 29,
"until_charged_seconds": 20,
"until_charged_total_seconds": 1760
},
{
"type": "Adapter",
"id": 0,
"on-line": true
},
{
"type": "Thermal",
"id": 0,
"mode": "ok",
"temperature": 46.0,
"temperature_unit": "C",
"trip_points": [
{
"id": 0,
"switches_to_mode": "critical",
"temperature": 127.0,
"temperature_unit": "C"
},
{
"id": 1,
"switches_to_mode": "hot",
"temperature": 127.0,
"temperature_unit": "C"
}
]
},
{
"type": "Cooling",
"id": 0,
"messages": [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": 1,
"messages": [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": 2,
"messages": [
"x86_pkg_temp no state information available"
]
},
{
"type": "Cooling",
"id": 3,
"messages": [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": 4,
"messages": [
"intel_powerclamp no state information available"
]
},
{
"type": "Cooling",
"id": 5,
"messages": [
"Processor 0 of 10"
]
}
]
$ acpi -V | jc --acpi -p -r
[
{
"type": "Battery",
"id": "0",
"state": "Charging",
"charge_percent": "71",
"until_charged": "00:29:20",
"design_capacity_mah": "2110",
"last_full_capacity": "2271",
"last_full_capacity_percent": "100"
},
{
"type": "Adapter",
"id": "0",
"on-line": true
},
{
"type": "Thermal",
"id": "0",
"mode": "ok",
"temperature": "46.0",
"temperature_unit": "C",
"trip_points": [
{
"id": "0",
"switches_to_mode": "critical",
"temperature": "127.0",
"temperature_unit": "C"
},
{
"id": "1",
"switches_to_mode": "hot",
"temperature": "127.0",
"temperature_unit": "C"
}
]
},
{
"type": "Cooling",
"id": "0",
"messages": [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": "1",
"messages": [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": "2",
"messages": [
"x86_pkg_temp no state information available"
]
},
{
"type": "Cooling",
"id": "3",
"messages": [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": "4",
"messages": [
"intel_powerclamp no state information available"
]
},
{
"type": "Cooling",
"id": "5",
"messages": [
"Processor 0 of 10"
]
}
]
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

108
docs/parsers/airport.md Normal file
View File

@@ -0,0 +1,108 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.airport
jc - JSON CLI output utility `airport -I` command output parser
The `airport` program can be found at `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport`.
Usage (cli):
$ airport -I | jc --airport
or
$ jc airport -I
Usage (module):
import jc.parsers.airport
result = jc.parsers.airport.parse(airport_command_output)
Schema:
{
"agrctlrssi": integer,
"agrextrssi": integer,
"agrctlnoise": integer,
"agrextnoise": integer,
"state": string,
"op_mode": string,
"lasttxrate": integer,
"maxrate": integer,
"lastassocstatus": integer,
"802_11_auth": string,
"link_auth": string,
"bssid": string,
"ssid": string,
"mcs": integer,
"channel": string
}
Examples:
$ airport -I | jc --airport -p
{
"agrctlrssi": -66,
"agrextrssi": 0,
"agrctlnoise": -90,
"agrextnoise": 0,
"state": "running",
"op_mode": "station",
"lasttxrate": 195,
"maxrate": 867,
"lastassocstatus": 0,
"802_11_auth": "open",
"link_auth": "wpa2-psk",
"bssid": "3c:37:86:15:ad:f9",
"ssid": "SnazzleDazzle",
"mcs": 0,
"channel": "48,80"
}
$ airport -I | jc --airport -p -r
{
"agrctlrssi": "-66",
"agrextrssi": "0",
"agrctlnoise": "-90",
"agrextnoise": "0",
"state": "running",
"op_mode": "station",
"lasttxrate": "195",
"maxrate": "867",
"lastassocstatus": "0",
"802_11_auth": "open",
"link_auth": "wpa2-psk",
"bssid": "3c:37:86:15:ad:f9",
"ssid": "SnazzleDazzle",
"mcs": "0",
"channel": "48,80"
}
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.
## Parser Information
Compatibility: darwin
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)

136
docs/parsers/airport_s.md Normal file
View File

@@ -0,0 +1,136 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.airport_s
jc - JSON CLI output utility `airport -s` command output parser
The `airport` program can be found at `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport`.
Usage (cli):
$ airport -s | jc --airport-s
or
$ jc airport -s
Usage (module):
import jc.parsers.airport_s
result = jc.parsers.airport_s.parse(airport_s_command_output)
Schema:
[
{
"ssid": string,
"bssid": string,
"rssi": integer,
"channel": string,
"ht": boolean,
"cc": string,
"security": [
string,
]
}
]
Examples:
$ airport -s | jc --airport-s -p
[
{
"ssid": "DIRECT-4A-HP OfficeJet 3830",
"bssid": "00:67:eb:2a:a7:3b",
"rssi": -90,
"channel": "6",
"ht": true,
"cc": "--",
"security": [
"WPA2(PSK/AES/AES)"
]
},
{
"ssid": "Latitude38",
"bssid": "c0:ff:d5:d2:7a:f3",
"rssi": -85,
"channel": "11",
"ht": true,
"cc": "US",
"security": [
"WPA2(PSK/AES/AES)"
]
},
{
"ssid": "xfinitywifi",
"bssid": "6e:e3:0e:b8:45:99",
"rssi": -83,
"channel": "11",
"ht": true,
"cc": "US",
"security": [
"NONE"
]
},
...
]
$ airport -s | jc --airport -p -r
[
{
"ssid": "DIRECT-F3-HP ENVY 5660 series",
"bssid": "b0:5a:da:6f:0a:d4",
"rssi": "-93",
"channel": "1",
"ht": "Y",
"cc": "--",
"security": "WPA2(PSK/AES/AES)"
},
{
"ssid": "YouAreInfected-5",
"bssid": "5c:e3:0e:c2:85:da",
"rssi": "-85",
"channel": "36",
"ht": "Y",
"cc": "US",
"security": "WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP)"
},
{
"ssid": "YuanFamily",
"bssid": "5c:e3:0e:b8:5f:9a",
"rssi": "-84",
"channel": "11",
"ht": "Y",
"cc": "US",
"security": "WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP)"
},
...
]
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: darwin
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,17 +1,37 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.arp
jc - JSON CLI output utility arp Parser
jc - JSON CLI output utility `arp` command output parser
Usage:
Supports `arp` and `arp -a` output.
specify --arp as the first argument if the piped input is coming from:
Usage (cli):
arp
or
arp -a
$ arp | jc --arp
Compatibility:
or
'linux', 'aix', 'freebsd', 'darwin'
$ jc arp
Usage (module):
import jc.parsers.arp
result = jc.parsers.arp.parse(arp_command_output)
Schema:
[
{
"name": string,
"address": string,
"hwtype": string,
"hwaddress": string,
"flags_mask": string,
"iface": string,
"permanent": boolean,
"expires": integer
}
]
Examples:
@@ -59,6 +79,8 @@ Examples:
"hwtype": "ether",
"hwaddress": "00:50:56:f0:98:26",
"iface": "ens33"
"permanent": false,
"expires": 1182
},
{
"name": "gateway",
@@ -66,6 +88,8 @@ Examples:
"hwtype": "ether",
"hwaddress": "00:50:56:f7:4a:fc",
"iface": "ens33"
"permanent": false,
"expires": 110
}
]
@@ -77,6 +101,8 @@ Examples:
"hwtype": "ether",
"hwaddress": "00:50:56:fe:7a:b4",
"iface": "ens33"
"permanent": false,
"expires": "1182"
},
{
"name": "_gateway",
@@ -84,39 +110,17 @@ Examples:
"hwtype": "ether",
"hwaddress": "00:50:56:f7:4a:fc",
"iface": "ens33"
"permanent": false,
"expires": "110"
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"name": string,
"address": string,
"hwtype": string,
"hwaddress": string,
"flags_mask": string,
"iface": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -133,5 +137,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, aix, freebsd, darwin
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,56 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.blkid
jc - JSON CLI output utility blkid Parser
jc - JSON CLI output utility `blkid` command output parser
Usage:
Usage (cli):
specify --blkid as the first argument if the piped input is coming from blkid
$ blkid | jc --blkid
Compatibility:
or
'linux'
$ jc blkid
Usage (module):
import jc.parsers.blkid
result = jc.parsers.blkid.parse(blkid_command_output)
Schema:
[
{
"device": string,
"uuid": string,
"type": string,
"usage": string,
"part_entry_scheme": string,
"part_entry_type": string,
"part_entry_flags": string,
"part_entry_number": integer,
"part_entry_offset": integer,
"part_entry_size": integer,
"part_entry_disk": string,
"id_fs_uuid": string,
"id_fs_uuid_enc": string,
"id_fs_version": string,
"id_fs_type": string,
"id_fs_usage": string,
"id_part_entry_scheme": string,
"id_part_entry_type": string,
"id_part_entry_flags": string,
"id_part_entry_number": integer,
"id_part_entry_offset": integer,
"id_part_entry_size": integer,
"id_iolimit_minimum_io_size": integer,
"id_iolimit_physical_sector_size": integer,
"id_iolimit_logical_sector_size": integer,
"id_part_entry_disk": string,
"minimum_io_size": integer,
"physical_sector_size": integer,
"logical_sector_size": integer
}
]
Examples:
@@ -75,59 +118,12 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"device": string,
"uuid": string,
"type": string,
"usage": string,
"part_entry_scheme": string,
"part_entry_type": string,
"part_entry_flags": string,
"part_entry_number": integer,
"part_entry_offset": integer,
"part_entry_size": integer,
"part_entry_disk": string,
"id_fs_uuid": string,
"id_fs_uuid_enc": string,
"id_fs_version": string,
"id_fs_type": string,
"id_fs_usage": string,
"id_part_entry_scheme": string,
"id_part_entry_type": string,
"id_part_entry_flags": string,
"id_part_entry_number": integer,
"id_part_entry_offset": integer,
"id_part_entry_size": integer,
"id_iolimit_minimum_io_size": integer,
"id_iolimit_physical_sector_size": integer,
"id_iolimit_logical_sector_size": integer,
"id_part_entry_disk": string,
"minimum_io_size": integer,
"physical_sector_size": integer,
"logical_sector_size": integer
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -144,5 +140,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

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

@@ -0,0 +1,82 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.cksum
jc - JSON CLI output utility `cksum` command output parser
This parser works with the following checksum calculation utilities:
- `sum`
- `cksum`
Usage (cli):
$ cksum file.txt | jc --cksum
or
$ jc cksum file.txt
Usage (module):
import jc.parsers.cksum
result = jc.parsers.cksum.parse(cksum_command_output)
Schema:
[
{
"filename": string,
"checksum": integer,
"blocks": integer
}
]
Examples:
$ cksum * | jc --cksum -p
[
{
"filename": "__init__.py",
"checksum": 4294967295,
"blocks": 0
},
{
"filename": "airport.py",
"checksum": 2208551092,
"blocks": 3745
},
{
"filename": "airport_s.py",
"checksum": 1113817598,
"blocks": 4572
},
...
]
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,53 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.crontab
jc - JSON CLI output utility crontab command and file Parser
jc - JSON CLI output utility `crontab -l` command output and crontab file parser
Usage:
Supports `crontab -l` command output and crontab files.
specify --crontab as the first argument if the piped input is coming from crontab -l or a crontab file
Usage (cli):
Compatibility:
$ crontab -l | jc --crontab
'linux', 'darwin', 'aix', 'freebsd'
or
$ jc crontab -l
Usage (module):
import jc.parsers.crontab
result = jc.parsers.crontab.parse(crontab_output)
Schema:
{
"variables": [
"name": string,
"value": string
],
"schedule": [
{
"occurrence" string,
"minute": [
string
],
"hour": [
string
],
"day_of_month": [
string
],
"month": [
string
],
"day_of_week": [
string
],
"occurrence": string,
"command": string
}
]
}
Examples:
@@ -128,55 +168,12 @@ Examples:
]
}
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
Dictionary. Structured data with the following schema:
{
"variables": [
"name": string,
"value": string
],
"schedule": [
{
"occurrence" string,
"minute": [
string
],
"hour": [
string
],
"day_of_month": [
string
],
"month": [
string
],
"day_of_week": [
string
],
"occurrence": string,
"command": string
}
]
}
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -195,3 +192,7 @@ Returns:
Dictionary. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, aix, freebsd
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,50 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.crontab_u
jc - JSON CLI output utility crontab file Parser
jc - JSON CLI output utility `crontab -l` command output and crontab file parser
Usage:
This version of the `crontab -l` parser supports output that contains user information for processes.
specify --crontab-u as the first argument if the piped input is coming from a crontab file with User specified
Usage (cli):
Compatibility:
$ crontab -l | jc --crontab-u
'linux', 'darwin', 'aix', 'freebsd'
Usage (module):
import jc.parsers.crontab_u
result = jc.parsers.crontab_u.parse(crontab_u_output)
Schema:
{
"variables": [
"name": string,
"value": string
],
"schedule": [
{
"occurrence" string,
"minute": [
string
],
"hour": [
string
],
"day_of_month": [
string
],
"month": [
string
],
"day_of_week": [
string
],
"occurrence": string,
"user": string,
"command": string
}
]
}
Examples:
@@ -128,57 +165,11 @@ Examples:
}
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
Dictionary. Structured data with the following schema:
{
"variables": [
"name": string,
"value": string
],
"schedule": [
{
"occurrence" string,
"minute": [
string
],
"hour": [
string
],
"day_of_month": [
string
],
"month": [
string
],
"day_of_week": [
string
],
"occurrence": string,
"user": string,
"command": string
}
]
}
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -197,3 +188,7 @@ Returns:
Dictionary. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, aix, freebsd
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,16 +1,29 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.csv
jc - JSON CLI output utility csv Parser
jc - JSON CLI output utility `csv` file parser
Usage:
The `csv` parser will attempt to automatically detect the delimiter character. If the delimiter cannot be detected it will default to comma. The first row of the file must be a header row.
specify --csv as the first argument if the piped input is coming from a csv file.
the csv parser will attempt to automatically detect the delimiter character.
if the delimiter cannot be detected it will default to comma.
the first row of the file must be a header row.
Usage (cli):
Compatibility:
$ cat file.csv | jc --csv
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
Usage (module):
import jc.parsers.csv
result = jc.parsers.csv.parse(csv_output)
Schema:
csv file converted to a Dictionary: https://docs.python.org/3/library/csv.html
[
{
"column_name1": string,
"column_name2": string
}
]
Examples:
@@ -59,32 +72,12 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Each dictionary represents a row in the csv file:
[
{
csv file converted to a Dictionary
https://docs.python.org/3/library/csv.html
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -101,5 +94,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

99
docs/parsers/date.md Normal file
View File

@@ -0,0 +1,99 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.date
jc - JSON CLI output utility `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)
The `epoch_utc` calculated timestamp field is timezone-aware and is only available if the timezone field is UTC.
Usage (cli):
$ date | jc --date
or
$ jc date
Usage (module):
import jc.parsers.date
result = jc.parsers.date.parse(date_command_output)
Schema:
{
"year": integer,
"month": string,
"month_num": integer,
"day": integer,
"weekday": string,
"weekday_num": integer,
"hour": integer,
"hour_24": integer,
"minute": integer,
"second": integer,
"period": string,
"timezone": string,
"utc_offset": string, # null if timezone field is not UTC
"day_of_year": integer,
"week_of_year": integer,
"iso": string,
"epoch": integer, # naive timestamp
"epoch_utc": integer, # timezone-aware timestamp. Only available if timezone field is UTC
"timezone_aware": boolean # if true, all fields are correctly based on UTC
}
Examples:
$ date | jc --date -p
{
"year": 2021,
"month": "Mar",
"month_num": 3,
"day": 25,
"weekday": "Thu",
"weekday_num": 4,
"hour": 2,
"hour_24": 2,
"minute": 2,
"second": 26,
"period": "AM",
"timezone": "UTC",
"utc_offset": "+0000",
"day_of_year": 84,
"week_of_year": 12,
"iso": "2021-03-25T02:02:26+00:00",
"epoch": 1616662946,
"epoch_utc": 1616637746,
"timezone_aware": true
}
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, freebsd
Version 2.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,39 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.df
jc - JSON CLI output utility df Parser
jc - JSON CLI output utility `df` command output parser
Usage:
Usage (cli):
specify --df as the first argument if the piped input is coming from df
$ df | jc --df
Compatibility:
or
'linux', 'darwin'
$ jc df
Usage (module):
import jc.parsers.df
result = jc.parsers.df.parse(df_command_output)
Schema:
[
{
"filesystem": string,
"size": string,
"1k_blocks": integer,
"512_blocks": integer,
"used": integer,
"available": integer,
"capacity_percent": integer,
"ifree": integer,
"iused": integer,
"use_percent": integer,
"iused_percent": integer,
"mounted_on": string
}
]
Examples:
@@ -69,42 +95,12 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"filesystem": string,
"size": string,
"1k_blocks": integer,
"512_blocks": integer,
"used": integer,
"available": integer,
"capacity_percent": integer,
"ifree": integer,
"iused": integer,
"use_percent": integer,
"iused_percent": integer,
"mounted_on": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -121,5 +117,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, freebsd
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,20 +1,107 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.dig
jc - JSON CLI output utility dig Parser
jc - JSON CLI output utility `dig` command output parser
Usage:
The `when_epoch` calculated timestamp field is naive (i.e. based on the local time of the system the parser is run on)
Specify --dig as the first argument if the piped input is coming from dig
The `when_epoch_utc` calculated timestamp field is timezone-aware and is only available if the timezone field is UTC.
Compatibility:
Usage (cli):
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
$ dig example.com | jc --dig
or
$ jc dig example.com
Usage (module):
import jc.parsers.dig
result = jc.parsers.dig.parse(dig_command_output)
Schema:
[
{
"id": integer,
"opcode": string,
"status": string,
"flags": [
string
],
"query_num": integer,
"answer_num": integer,
"authority_num": integer,
"additional_num": integer,
"axfr": [
{
"name": string,
"class": string,
"type": string,
"ttl": integer,
"data": string
}
],
"opt_pseudosection": {
"edns": {
"version": integer,
"flags": [
string
],
"udp": integer
},
"cookie": string
},
"question": {
"name": string,
"class": string,
"type": string
},
"answer": [
{
"name": string,
"class": string,
"type": string,
"ttl": integer,
"data": string
}
],
"additional": [
{
"name": string,
"class": string,
"type": string,
"ttl": integer,
"data": string
}
],
"authority": [
{
"name": string,
"class": string,
"type": string,
"ttl": integer,
"data": string
}
],
"query_size": integer,
"query_time": integer, # in msec
"server": string,
"when": string,
"when_epoch": integer, # naive timestamp if when field is parsable, else null
"when_epoch_utc": integer, # timezone aware timestamp availabe for UTC, else null
"rcvd": integer
"size": string
}
]
Examples:
$ dig cnn.com www.cnn.com @205.251.194.64 | jc --dig -p
$ dig example.com | jc --dig -p
[
{
"id": 34128,
"id": 2951,
"opcode": "QUERY",
"status": "NOERROR",
"flags": [
@@ -23,117 +110,43 @@ Examples:
"ra"
],
"query_num": 1,
"answer_num": 4,
"answer_num": 1,
"authority_num": 0,
"additional_num": 1,
"opt_pseudosection": {
"edns": {
"version": 0,
"flags": [],
"udp": 4096
}
},
"question": {
"name": "cnn.com.",
"name": "example.com.",
"class": "IN",
"type": "A"
},
"answer": [
{
"name": "cnn.com.",
"name": "example.com.",
"class": "IN",
"type": "A",
"ttl": 60,
"data": "151.101.65.67"
},
{
"name": "cnn.com.",
"class": "IN",
"type": "A",
"ttl": 60,
"data": "151.101.193.67"
},
{
"name": "cnn.com.",
"class": "IN",
"type": "A",
"ttl": 60,
"data": "151.101.1.67"
},
{
"name": "cnn.com.",
"class": "IN",
"type": "A",
"ttl": 60,
"data": "151.101.129.67"
"ttl": 39302,
"data": "93.184.216.34"
}
],
"query_time": 37,
"server": "2600",
"when": "Tue Nov 12 07:14:42 PST 2019",
"rcvd": 100
},
{
"id": 15273,
"opcode": "QUERY",
"status": "NOERROR",
"flags": [
"qr",
"aa",
"rd"
],
"query_num": 1,
"answer_num": 1,
"authority_num": 4,
"additional_num": 1,
"question": {
"name": "www.cnn.com.",
"class": "IN",
"type": "A"
},
"answer": [
{
"name": "www.cnn.com.",
"class": "IN",
"type": "CNAME",
"ttl": 300,
"data": "turner-tls.map.fastly.net."
}
],
"authority": [
{
"name": "cnn.com.",
"class": "IN",
"type": "NS",
"ttl": 3600,
"data": "ns-1086.awsdns-07.org."
},
{
"name": "cnn.com.",
"class": "IN",
"type": "NS",
"ttl": 3600,
"data": "ns-1630.awsdns-11.co.uk."
},
{
"name": "cnn.com.",
"class": "IN",
"type": "NS",
"ttl": 3600,
"data": "ns-47.awsdns-05.com."
},
{
"name": "cnn.com.",
"class": "IN",
"type": "NS",
"ttl": 3600,
"data": "ns-576.awsdns-08.net."
}
],
"query_time": 23,
"server": "205.251.194.64#53(205.251.194.64)",
"when": "Tue Nov 12 07:14:42 PST 2019",
"rcvd": 212
"query_time": 49,
"server": "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
"when": "Fri Apr 16 16:05:10 PDT 2021",
"rcvd": 56,
"when_epoch": 1618614310,
"when_epoch_utc": null
}
]
$ dig cnn.com www.cnn.com @205.251.194.64 | jc --dig -p -r
[
{
"id": "23843",
"id": "46052",
"opcode": "QUERY",
"status": "NOERROR",
"flags": [
@@ -142,117 +155,41 @@ Examples:
"ra"
],
"query_num": "1",
"answer_num": "4",
"answer_num": "1",
"authority_num": "0",
"additional_num": "1",
"opt_pseudosection": {
"edns": {
"version": "0",
"flags": [],
"udp": "4096"
}
},
"question": {
"name": "cnn.com.",
"name": "example.com.",
"class": "IN",
"type": "A"
},
"answer": [
{
"name": "cnn.com.",
"name": "example.com.",
"class": "IN",
"type": "A",
"ttl": "30",
"data": "151.101.193.67"
},
{
"name": "cnn.com.",
"class": "IN",
"type": "A",
"ttl": "30",
"data": "151.101.1.67"
},
{
"name": "cnn.com.",
"class": "IN",
"type": "A",
"ttl": "30",
"data": "151.101.65.67"
},
{
"name": "cnn.com.",
"class": "IN",
"type": "A",
"ttl": "30",
"data": "151.101.129.67"
"ttl": "40426",
"data": "93.184.216.34"
}
],
"query_time": "24 msec",
"server": "192.168.1.254#53(192.168.1.254)",
"when": "Tue Nov 12 07:16:19 PST 2019",
"rcvd": "100"
},
{
"id": "8266",
"opcode": "QUERY",
"status": "NOERROR",
"flags": [
"qr",
"aa",
"rd"
],
"query_num": "1",
"answer_num": "1",
"authority_num": "4",
"additional_num": "1",
"question": {
"name": "www.cnn.com.",
"class": "IN",
"type": "A"
},
"answer": [
{
"name": "www.cnn.com.",
"class": "IN",
"type": "CNAME",
"ttl": "300",
"data": "turner-tls.map.fastly.net."
}
],
"authority": [
{
"name": "cnn.com.",
"class": "IN",
"type": "NS",
"ttl": "3600",
"data": "ns-1086.awsdns-07.org."
},
{
"name": "cnn.com.",
"class": "IN",
"type": "NS",
"ttl": "3600",
"data": "ns-1630.awsdns-11.co.uk."
},
{
"name": "cnn.com.",
"class": "IN",
"type": "NS",
"ttl": "3600",
"data": "ns-47.awsdns-05.com."
},
{
"name": "cnn.com.",
"class": "IN",
"type": "NS",
"ttl": "3600",
"data": "ns-576.awsdns-08.net."
}
],
"query_time": "26 msec",
"server": "205.251.194.64#53(205.251.194.64)",
"when": "Tue Nov 12 07:16:19 PST 2019",
"rcvd": "212"
"query_time": "48 msec",
"server": "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
"when": "Fri Apr 16 16:06:12 PDT 2021",
"rcvd": "56"
}
]
$ dig -x 1.1.1.1 | jc --dig -p
[
{
"id": 34898,
"id": 20785,
"opcode": "QUERY",
"status": "NOERROR",
"flags": [
@@ -264,6 +201,13 @@ Examples:
"answer_num": 1,
"authority_num": 0,
"additional_num": 1,
"opt_pseudosection": {
"edns": {
"version": 0,
"flags": [],
"udp": 4096
}
},
"question": {
"name": "1.1.1.1.in-addr.arpa.",
"class": "IN",
@@ -274,21 +218,23 @@ Examples:
"name": "1.1.1.1.in-addr.arpa.",
"class": "IN",
"type": "PTR",
"ttl": 952,
"ttl": 1800,
"data": "one.one.one.one."
}
],
"query_time": 103,
"server": "2600",
"when": "Tue Nov 12 07:15:33 PST 2019",
"rcvd": 78
"query_time": 40,
"server": "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
"when": "Sat Apr 17 14:50:50 PDT 2021",
"rcvd": 78,
"when_epoch": 1618696250,
"when_epoch_utc": null
}
]
$ dig -x 1.1.1.1 | jc --dig -p -r
[
{
"id": "50986",
"id": "32644",
"opcode": "QUERY",
"status": "NOERROR",
"flags": [
@@ -300,6 +246,13 @@ Examples:
"answer_num": "1",
"authority_num": "0",
"additional_num": "1",
"opt_pseudosection": {
"edns": {
"version": "0",
"flags": [],
"udp": "4096"
}
},
"question": {
"name": "1.1.1.1.in-addr.arpa.",
"class": "IN",
@@ -314,74 +267,19 @@ Examples:
"data": "one.one.one.one."
}
],
"query_time": "38 msec",
"server": "2600",
"when": "Tue Nov 12 07:17:19 PST 2019",
"query_time": "52 msec",
"server": "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
"when": "Sat Apr 17 14:51:46 PDT 2021",
"rcvd": "78"
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"id": integer,
"opcode": string,
"status": string,
"flags": [
string
],
"query_num": integer,
"answer_num": integer,
"authority_num": integer,
"additional_num": integer,
"question": {
"name": string,
"class": string,
"type": string
},
"answer": [
{
"name": string,
"class": string,
"type": string,
"ttl": integer,
"data": string
}
],
"authority": [
{
"name": string,
"class": string,
"type": string,
"ttl": integer,
"data": string
}
],
"query_time": integer, # in msec
"server": string,
"when": string,
"rcvd": integer
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -398,5 +296,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, aix, freebsd, darwin
Version 2.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

148
docs/parsers/dir.md Normal file
View File

@@ -0,0 +1,148 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.dir
jc - JSON CLI output utility `dir` command output parser
Options supported:
- `/T timefield`
- `/O sortorder`
- `/C, /-C`
- `/S`
The `epoch` calculated timestamp field is naive (i.e. based on the local time of the system the parser is run on)
Usage (cli):
C:> dir | jc --dir
or
C:> jc dir
Usage (module):
import jc.parsers.dir
result = jc.parsers.dir.parse(dir_command_output)
Schema:
[
{
"date": string,
"time": string,
"epoch": integer, # naive timestamp
"dir": boolean,
"size": integer,
"filename: string,
"parent": string
}
]
Examples:
C:> dir | jc --dir -p
[
{
"date": "03/24/2021",
"time": "03:15 PM",
"dir": true,
"size": null,
"filename": ".",
"parent": "C:\Program Files\Internet Explorer",
"epoch": 1616624100
},
{
"date": "03/24/2021",
"time": "03:15 PM",
"dir": true,
"size": null,
"filename": "..",
"parent": "C:\Program Files\Internet Explorer",
"epoch": 1616624100
},
{
"date": "12/07/2019",
"time": "02:49 AM",
"dir": true,
"size": null,
"filename": "en-US",
"parent": "C:\Program Files\Internet Explorer",
"epoch": 1575715740
},
{
"date": "12/07/2019",
"time": "02:09 AM",
"dir": false,
"size": 54784,
"filename": "ExtExport.exe",
"parent": "C:\Program Files\Internet Explorer",
"epoch": 1575713340
},
...
]
C:> dir | jc --dir -p -r
[
{
"date": "03/24/2021",
"time": "03:15 PM",
"dir": true,
"size": null,
"filename": ".",
"parent": "C:\Program Files\Internet Explorer"
},
{
"date": "03/24/2021",
"time": "03:15 PM",
"dir": true,
"size": null,
"filename": "..",
"parent": "C:\Program Files\Internet Explorer"
},
{
"date": "12/07/2019",
"time": "02:49 AM",
"dir": true,
"size": null,
"filename": "en-US",
"parent": "C:\Program Files\Internet Explorer"
},
{
"date": "12/07/2019",
"time": "02:09 AM",
"dir": false,
"size": "54,784",
"filename": "ExtExport.exe",
"parent": "C:\Program Files\Internet Explorer"
},
...
]
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: win32
Version 1.2 by Rasheed Elsaleh (rasheed@rebelliondefense.com)

153
docs/parsers/dmidecode.md Normal file
View File

@@ -0,0 +1,153 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.dmidecode
jc - JSON CLI output utility `dmidecode` command output parser
Usage (cli):
$ dmidecode | jc --dmidecode
or
$ jc dmidecode
Usage (module):
import jc.parsers.dmidecode
result = jc.parsers.dmidecode.parse(dmidecode_command_output)
Schema:
[
{
"handle": string,
"type": integer,
"bytes": integer,
"description": string,
"values": { (null if empty)
"lowercase_no_spaces_keys": string,
"multiline_key_values": [
string,
]
}
}
]
Examples:
# dmidecode | jc --dmidecode -p
[
{
"handle": "0x0000",
"type": 0,
"bytes": 24,
"description": "BIOS Information",
"values": {
"vendor": "Phoenix Technologies LTD",
"version": "6.00",
"release_date": "04/13/2018",
"address": "0xEA490",
"runtime_size": "88944 bytes",
"rom_size": "64 kB",
"characteristics": [
"ISA is supported",
"PCI is supported",
"PC Card (PCMCIA) is supported",
"PNP is supported",
"APM is supported",
"BIOS is upgradeable",
"BIOS shadowing is allowed",
"ESCD support is available",
"Boot from CD is supported",
"Selectable boot is supported",
"EDD is supported",
"Print screen service is supported (int 5h)",
"8042 keyboard services are supported (int 9h)",
"Serial services are supported (int 14h)",
"Printer services are supported (int 17h)",
"CGA/mono video services are supported (int 10h)",
"ACPI is supported",
"Smart battery is supported",
"BIOS boot specification is supported",
"Function key-initiated network boot is supported",
"Targeted content distribution is supported"
],
"bios_revision": "4.6",
"firmware_revision": "0.0"
}
},
...
]
# dmidecode | jc --dmidecode -p -r
[
{
"handle": "0x0000",
"type": "0",
"bytes": "24",
"description": "BIOS Information",
"values": {
"vendor": "Phoenix Technologies LTD",
"version": "6.00",
"release_date": "04/13/2018",
"address": "0xEA490",
"runtime_size": "88944 bytes",
"rom_size": "64 kB",
"characteristics": [
"ISA is supported",
"PCI is supported",
"PC Card (PCMCIA) is supported",
"PNP is supported",
"APM is supported",
"BIOS is upgradeable",
"BIOS shadowing is allowed",
"ESCD support is available",
"Boot from CD is supported",
"Selectable boot is supported",
"EDD is supported",
"Print screen service is supported (int 5h)",
"8042 keyboard services are supported (int 9h)",
"Serial services are supported (int 14h)",
"Printer services are supported (int 17h)",
"CGA/mono video services are supported (int 10h)",
"ACPI is supported",
"Smart battery is supported",
"BIOS boot specification is supported",
"Function key-initiated network boot is supported",
"Targeted content distribution is supported"
],
"bios_revision": "4.6",
"firmware_revision": "0.0"
}
},
...
]
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)

158
docs/parsers/dpkg_l.md Normal file
View File

@@ -0,0 +1,158 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.dpkg_l
jc - JSON CLI output utility `dpkg -l` command output parser
Set the `COLUMNS` environment variable to a large value to avoid field truncation. For example:
$ COLUMNS=500 dpkg -l | jc --dpkg-l
Usage (cli):
$ dpkg -l | jc --dpkg-l
or
$ jc dpkg -l
Usage (module):
import jc.parsers.dpkg_l
result = jc.parsers.dpkg_l.parse(dpkg_command_output)
Schema:
[
{
"codes": string,
"name": string,
"version": string,
"architecture": string,
"description": string,
"desired": string,
"status": string,
"error": string
}
]
Examples:
$ dpkg -l | jc --dpkg-l -p
[
{
"codes": "ii",
"name": "accountsservice",
"version": "0.6.45-1ubuntu1.3",
"architecture": "amd64",
"description": "query and manipulate user account information",
"desired": "install",
"status": "installed"
},
{
"codes": "rc",
"name": "acl",
"version": "2.2.52-3build1",
"architecture": "amd64",
"description": "Access control list utilities",
"desired": "remove",
"status": "config-files"
},
{
"codes": "uWR",
"name": "acpi",
"version": "1.7-1.1",
"architecture": "amd64",
"description": "displays information on ACPI devices",
"desired": "unknown",
"status": "trigger await",
"error": "reinstall required"
},
{
"codes": "rh",
"name": "acpid",
"version": "1:2.0.28-1ubuntu1",
"architecture": "amd64",
"description": "Advanced Configuration and Power Interface event daemon",
"desired": "remove",
"status": "half installed"
},
{
"codes": "pn",
"name": "adduser",
"version": "3.116ubuntu1",
"architecture": "all",
"description": "add and remove users and groups",
"desired": "purge",
"status": "not installed"
},
...
]
$ dpkg -l | jc --dpkg-l -p -r
[
{
"codes": "ii",
"name": "accountsservice",
"version": "0.6.45-1ubuntu1.3",
"architecture": "amd64",
"description": "query and manipulate user account information"
},
{
"codes": "rc",
"name": "acl",
"version": "2.2.52-3build1",
"architecture": "amd64",
"description": "Access control list utilities"
},
{
"codes": "uWR",
"name": "acpi",
"version": "1.7-1.1",
"architecture": "amd64",
"description": "displays information on ACPI devices"
},
{
"codes": "rh",
"name": "acpid",
"version": "1:2.0.28-1ubuntu1",
"architecture": "amd64",
"description": "Advanced Configuration and Power Interface event daemon"
},
{
"codes": "pn",
"name": "adduser",
"version": "3.116ubuntu1",
"architecture": "all",
"description": "add and remove users and groups"
},
...
]
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,29 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.du
jc - JSON CLI output utility du Parser
jc - JSON CLI output utility `du` command output parser
Usage:
Usage (cli):
specify --du as the first argument if the piped input is coming from du
$ du | jc --du
Compatibility:
or
'linux', 'darwin', 'aix', 'freebsd'
$ jc du
Usage (module):
import jc.parsers.du
result = jc.parsers.du.parse(du_command_output)
Schema:
[
{
"size": integer,
"name": string
}
]
Examples:
@@ -69,32 +85,12 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"size": integer,
"name": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -111,5 +107,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, aix, freebsd
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,31 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.env
jc - JSON CLI output utility env Parser
jc - JSON CLI output utility `env` and `printenv` command output parser
Usage:
This parser will output a list of dictionaries each containing `name` and `value` keys. If you would like a simple dictionary output, then use the `-r` command-line option or the `raw=True` argument in the `parse()` function.
specify --env as the first argument if the piped input is coming from env
Usage (cli):
Compatibility:
$ env | jc --env
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
or
$ jc env
Usage (module):
import jc.parsers.env
result = jc.parsers.env.parse(env_command_output)
Schema:
[
{
"name": string,
"value": string
}
]
Examples:
@@ -49,32 +67,12 @@ Examples:
"_": "/usr/bin/env"
}
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"name": string,
"value": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -92,5 +90,9 @@ Parameters:
Returns:
Dictionary of raw structured data or
list of dictionaries of processed structured data
List of Dictionaries of processed structured data
## Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)

90
docs/parsers/file.md Normal file
View File

@@ -0,0 +1,90 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.file
jc - JSON CLI output utility `file` command output parser
Usage (cli):
$ file * | jc --file
or
$ jc file *
Usage (module):
import jc.parsers.file
result = jc.parsers.file.parse(file_command_output)
Schema:
[
{
"filename": string,
"type ": string
}
]
Examples:
$ file * | jc --file -p
[
{
"filename": "Applications",
"type": "directory"
},
{
"filename": "another file with spaces",
"type": "empty"
},
{
"filename": "argstest.py",
"type": "Python script text executable, ASCII text"
},
{
"filename": "blkid-p.out",
"type": "ASCII text"
},
{
"filename": "blkid-pi.out",
"type": "ASCII text, with very long lines"
},
{
"filename": "cd_catalog.xml",
"type": "XML 1.0 document text, ASCII text, with CRLF line terminators"
},
{
"filename": "centosserial.sh",
"type": "Bourne-Again shell script text executable, UTF-8 Unicode text"
},
...
]
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, aix, freebsd, darwin
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)

118
docs/parsers/finger.md Normal file
View File

@@ -0,0 +1,118 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.finger
jc - JSON CLI output utility `finger` command output parser
Supports `-s` output option. Does not support the `-l` detail option.
Usage (cli):
$ finger | jc --finger
or
$ jc finger
Usage (module):
import jc.parsers.finger
result = jc.parsers.finger.parse(finger_command_output)
Schema:
[
{
"login": string,
"name": string,
"tty": string,
"idle": string, # null if empty
"login_time": string,
"details": string,
"tty_writeable": boolean,
"idle_minutes": integer,
"idle_hours": integer,
"idle_days": integer,
"total_idle_minutes": integer
}
]
Examples:
$ finger | jc --finger -p
[
{
"login": "jdoe",
"name": "John Doe",
"tty": "tty1",
"idle": "14d",
"login_time": "Mar 22 21:14",
"tty_writeable": false,
"idle_minutes": 0,
"idle_hours": 0,
"idle_days": 14,
"total_idle_minutes": 20160
},
{
"login": "jdoe",
"name": "John Doe",
"tty": "pts/0",
"idle": null,
"login_time": "Apr 5 15:33",
"details": "(192.168.1.22)",
"tty_writeable": true,
"idle_minutes": 0,
"idle_hours": 0,
"idle_days": 0,
"total_idle_minutes": 0
},
...
]
$ finger | jc --finger -p -r
[
{
"login": "jdoe",
"name": "John Doe",
"tty": "*tty1",
"idle": "14d",
"login_time": "Mar 22 21:14"
},
{
"login": "jdoe",
"name": "John Doe",
"tty": "pts/0",
"idle": null,
"login_time": "Apr 5 15:33",
"details": "(192.168.1.22)"
},
...
]
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, cygwin, freebsd
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,34 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.free
jc - JSON CLI output utility free Parser
jc - JSON CLI output utility `free` command output parser
Usage:
Usage (cli):
specify --free as the first argument if the piped input is coming from free
$ free | jc --free
Compatibility:
or
'linux'
$ jc free
Usage (module):
import jc.parsers.free
result = jc.parsers.free.parse(free_command_output)
Schema:
[
{
"type": string,
"total": integer,
"used": integer,
"free": integer,
"shared": integer,
"buff_cache": integer,
"available": integer
}
]
Examples:
@@ -49,37 +70,12 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"type": string,
"total": integer,
"used": integer,
"free": integer,
"shared": integer,
"buff_cache": integer,
"available": integer
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -96,5 +92,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,29 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.fstab
jc - JSON CLI output utility fstab Parser
jc - JSON CLI output utility `fstab` file parser
Usage:
Usage (cli):
specify --fstab as the first argument if the piped input is coming from a fstab file
$ cat /etc/fstab | jc --fstab
Compatibility:
Usage (module):
'linux'
import jc.parsers.fstab
result = jc.parsers.fstab.parse(fstab_command_output)
Schema:
[
{
"fs_spec": string,
"fs_file": string,
"fs_vfstype": string,
"fs_mntops": string,
"fs_freq": integer,
"fs_passno": integer
}
]
Examples:
@@ -67,36 +83,12 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"fs_spec": string,
"fs_file": string,
"fs_vfstype": string,
"fs_mntops": string,
"fs_freq": integer,
"fs_passno": integer
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -113,5 +105,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, freebsd
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,29 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.group
jc - JSON CLI output utility /etc/group file Parser
jc - JSON CLI output utility `/etc/group` file parser
Usage:
Usage (cli):
specify --group as the first argument if the piped input is coming from /etc/group
$ cat /etc/group | jc --group
Compatibility:
Usage (module):
'linux', 'darwin', 'aix', 'freebsd'
import jc.parsers.group
result = jc.parsers.group.parse(group_file_output)
Schema:
[
{
"group_name": string,
"password": string,
"gid": integer,
"members": [
string
]
}
]
Examples:
@@ -91,36 +107,12 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"group_name": string,
"password": string,
"gid": integer,
"members": [
string
]
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -137,5 +129,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, aix, freebsd
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,31 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.gshadow
jc - JSON CLI output utility /etc/gshadow file Parser
jc - JSON CLI output utility `/etc/gshadow` file parser
Usage:
Usage (cli):
specify --gshadow as the first argument if the piped input is coming from /etc/gshadow
$ cat /etc/gshadow | jc --gshadow
Compatibility:
Usage (module):
'linux', 'aix', 'freebsd'
import jc.parsers.gshadow
result = jc.parsers.gshadow.parse(gshadow_file_output)
Schema:
[
{
"group_name": string,
"password": string,
"administrators": [
string
],
"members": [
string
]
}
]
Examples:
@@ -57,38 +75,12 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"group_name": string,
"password": string,
"administrators": [
string
],
"members": [
string
]
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -105,5 +97,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, aix, freebsd
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

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

@@ -0,0 +1,65 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.hash
jc - JSON CLI output utility `hash` command output parser
Usage (cli):
$ hash | jc --hash
Usage (module):
import jc.parsers.hash
result = jc.parsers.hash.parse(hash_command_output)
Schema:
[
{
"command": string,
"hits": integer
}
]
Examples:
$ hash | jc --hash -p
[
{
"hits": 2,
"command": "/bin/cat"
},
{
"hits": 1,
"command": "/bin/ls"
}
]
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

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

@@ -0,0 +1,96 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.hashsum
jc - JSON CLI output utility `hash sum` command output parser
This parser works with the following hash calculation utilities:
- `md5`
- `md5sum`
- `shasum`
- `sha1sum`
- `sha224sum`
- `sha256sum`
- `sha384sum`
- `sha512sum`
Usage (cli):
$ md5sum file.txt | jc --hashsum
or
$ jc md5sum file.txt
Usage (module):
import jc.parsers.hashsum
result = jc.parsers.hashsum.parse(md5sum_command_output)
Schema:
[
{
"filename": string,
"hash": string,
}
]
Examples:
$ md5sum * | jc --hashsum -p
[
{
"filename": "devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm",
"hash": "65fc958c1add637ec23c4b137aecf3d3"
},
{
"filename": "digout",
"hash": "5b9312ee5aff080927753c63a347707d"
},
{
"filename": "dmidecode.out",
"hash": "716fd11c2ac00db109281f7110b8fb9d"
},
{
"filename": "file with spaces in the name",
"hash": "d41d8cd98f00b204e9800998ecf8427e"
},
{
"filename": "id-centos.out",
"hash": "4295be239a14ad77ef3253103de976d2"
},
{
"filename": "ifcfg.json",
"hash": "01fda0d9ba9a75618b072e64ff512b43"
},
...
]
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

345
docs/parsers/hciconfig.md Normal file
View File

@@ -0,0 +1,345 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.hciconfig
jc - JSON CLI output utility `hciconfig` command output parser
Usage (cli):
$ hciconfig | jc --hciconfig
or
$ jc hciconfig
Usage (module):
import jc.parsers.hciconfig
result = jc.parsers.hciconfig.parse(hciconfig_command_output)
Schema:
[
{
"device": string,
"type": string,
"bus": string,
"bd_address": string,
"acl_mtu": integer,
"acl_mtu_packets": integer,
"sco_mtu": integer,
"sco_mtu_packets": integer,
"state": [
string
],
"rx_bytes": integer,
"rx_acl": integer,
"rx_sco": integer,
"rx_events": integer,
"rx_errors": integer,
"tx_bytes": integer,
"tx_acl": integer,
"tx_sco": integer,
"tx_commands": integer,
"tx_errors": integer,
"features": [
string
],
"packet_type": [
string
],
"link_policy": [
string
],
"link_mode": [
string
],
"name": string,
"class": string,
"service_classes": [
string # 'Unspecified' is null
],
"device_class": string,
"hci_version": string,
"hci_revision": string,
"lmp_version": string,
"lmp_subversion": string,
"manufacturer": string
}
]
Examples:
$ hciconfig -a | jc --hciconfig -p
[
{
"device": "hci0",
"type": "Primary",
"bus": "USB",
"bd_address": "00:1A:7D:DA:71:13",
"acl_mtu": 310,
"acl_mtu_packets": 10,
"sco_mtu": 64,
"sco_mtu_packets": 8,
"state": [
"UP",
"RUNNING"
],
"rx_bytes": 13905869,
"rx_acl": 0,
"rx_sco": 0,
"rx_events": 393300,
"rx_errors": 0,
"tx_bytes": 62629,
"tx_acl": 0,
"tx_sco": 0,
"tx_commands": 3893,
"tx_errors": 0,
"features": [
"0xff",
"0xff",
"0x8f",
"0xfe",
"0xdb",
"0xff",
"0x5b",
"0x87"
],
"packet_type": [
"DM1",
"DM3",
"DM5",
"DH1",
"DH3",
"DH5",
"HV1",
"HV2",
"HV3"
],
"link_policy": [
"RSWITCH",
"HOLD",
"SNIFF",
"PARK"
],
"link_mode": [
"SLAVE",
"ACCEPT"
],
"name": "CSR8510 A10",
"class": "0x000000",
"service_classes": null,
"device_class": "Miscellaneous",
"hci_version": "4.0 (0x6)",
"hci_revision": "0x22bb",
"lmp_version": "4.0 (0x6)",
"lmp_subversion": "0x22bb",
"manufacturer": "Cambridge Silicon Radio (10)"
},
{
"device": "hci1",
"type": "Primary",
"bus": "USB",
"bd_address": "00:1A:7D:DA:71:13",
"acl_mtu": 310,
"acl_mtu_packets": 10,
"sco_mtu": 64,
"sco_mtu_packets": 8,
"state": [
"DOWN"
],
"rx_bytes": 4388363,
"rx_acl": 0,
"rx_sco": 0,
"rx_events": 122021,
"rx_errors": 0,
"tx_bytes": 52350,
"tx_acl": 0,
"tx_sco": 0,
"tx_commands": 3480,
"tx_errors": 2,
"features": [
"0xff",
"0xff",
"0x8f",
"0xfe",
"0xdb",
"0xff",
"0x5b",
"0x87"
],
"packet_type": [
"DM1",
"DM3",
"DM5",
"DH1",
"DH3",
"DH5",
"HV1",
"HV2",
"HV3"
],
"link_policy": [
"RSWITCH",
"HOLD",
"SNIFF",
"PARK"
],
"link_mode": [
"SLAVE",
"ACCEPT"
]
}
]
$ hciconfig -a | jc --hciconfig -p -r
[
{
"device": "hci0",
"type": "Primary",
"bus": "USB",
"bd_address": "00:1A:7D:DA:71:13",
"acl_mtu": "310",
"acl_mtu_packets": "10",
"sco_mtu": "64",
"sco_mtu_packets": "8",
"state": [
"UP",
"RUNNING"
],
"rx_bytes": "13905869",
"rx_acl": "0",
"rx_sco": "0",
"rx_events": "393300",
"rx_errors": "0",
"tx_bytes": "62629",
"tx_acl": "0",
"tx_sco": "0",
"tx_commands": "3893",
"tx_errors": "0",
"features": [
"0xff",
"0xff",
"0x8f",
"0xfe",
"0xdb",
"0xff",
"0x5b",
"0x87"
],
"packet_type": [
"DM1",
"DM3",
"DM5",
"DH1",
"DH3",
"DH5",
"HV1",
"HV2",
"HV3"
],
"link_policy": [
"RSWITCH",
"HOLD",
"SNIFF",
"PARK"
],
"link_mode": [
"SLAVE",
"ACCEPT"
],
"name": "CSR8510 A10",
"class": "0x000000",
"service_classes": [
"Unspecified"
],
"device_class": "Miscellaneous",
"hci_version": "4.0 (0x6)",
"hci_revision": "0x22bb",
"lmp_version": "4.0 (0x6)",
"lmp_subversion": "0x22bb",
"manufacturer": "Cambridge Silicon Radio (10)"
},
{
"device": "hci1",
"type": "Primary",
"bus": "USB",
"bd_address": "00:1A:7D:DA:71:13",
"acl_mtu": "310",
"acl_mtu_packets": "10",
"sco_mtu": "64",
"sco_mtu_packets": "8",
"state": [
"DOWN"
],
"rx_bytes": "4388363",
"rx_acl": "0",
"rx_sco": "0",
"rx_events": "122021",
"rx_errors": "0",
"tx_bytes": "52350",
"tx_acl": "0",
"tx_sco": "0",
"tx_commands": "3480",
"tx_errors": "2",
"features": [
"0xff",
"0xff",
"0x8f",
"0xfe",
"0xdb",
"0xff",
"0x5b",
"0x87"
],
"packet_type": [
"DM1",
"DM3",
"DM5",
"DH1",
"DH3",
"DH5",
"HV1",
"HV2",
"HV3"
],
"link_policy": [
"RSWITCH",
"HOLD",
"SNIFF",
"PARK"
],
"link_mode": [
"SLAVE",
"ACCEPT"
]
}
]
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,27 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.history
jc - JSON CLI output utility history Parser
jc - JSON CLI output utility `history` command output parser
Usage:
This parser will output a list of dictionaries each containing `line` and `command` keys. If you would like a simple dictionary output, then use the `-r` command-line option or the `raw=True` argument in the `parse()` function.
specify --history as the first argument if the piped input is coming from history
Usage (cli):
Compatibility:
$ history | jc --history
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
Usage (module):
import jc.parsers.history
result = jc.parsers.history.parse(history_command_output)
Schema:
[
{
"line": integer,
"command": string
}
]
Examples:
@@ -41,32 +55,12 @@ Examples:
...
}
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"line": integer,
"command": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -84,5 +78,9 @@ Parameters:
Returns:
Dictionary of raw structured data or
list of dictionaries of processed structured data
List of Dictionaries of processed structured data
## Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,27 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.hosts
jc - JSON CLI output utility hosts Parser
jc - JSON CLI output utility `/etc/hosts` file parser
Usage:
Usage (cli):
specify --hosts as the first argument if the piped input is coming from a hosts file
$ cat /etc/hosts | jc --hosts
Compatibility:
Usage (module):
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
import jc.parsers.hosts
result = jc.parsers.hosts.parse(hosts_file_output)
Schema:
[
{
"ip": string,
"hostname": [
string
]
}
]
Examples:
@@ -58,34 +72,12 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"ip": string,
"hostname": [
string
]
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -102,5 +94,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,49 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.id
jc - JSON CLI output utility id Parser
jc - JSON CLI output utility `id` command output parser
Usage:
Usage (cli):
specify --id as the first argument if the piped input is coming from id
$ id | jc --id
Compatibility:
or
'linux', 'darwin', 'aix', 'freebsd'
$ jc id
Usage (module):
import jc.parsers.id
result = jc.parsers.id.parse(id_command_output)
Schema:
{
"uid": {
"id": integer,
"name": string
},
"gid": {
"id": integer,
"name": string
},
"groups": [
{
"id": integer,
"name": string
},
{
"id": integer,
"name": string
}
],
"context": {
"user": string,
"role": string,
"type": string,
"level": string
}
}
Examples:
@@ -67,52 +103,12 @@ Examples:
}
}
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
Dictionary. Structured data with the following schema:
{
"uid": {
"id": integer,
"name": string
},
"gid": {
"id": integer,
"name": string
},
"groups": [
{
"id": integer,
"name": string
},
{
"id": integer,
"name": string
}
],
"context": {
"user": string,
"role": string,
"type": string,
"level": string
}
}
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -129,5 +125,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
Dictionary. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, aix, freebsd
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,15 +1,57 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.ifconfig
jc - JSON CLI output utility ifconfig Parser
jc - JSON CLI output utility `ifconfig` command output parser
Usage:
Note: No `ifconfig` options are supported.
specify --ifconfig as the first argument if the piped input is coming from ifconfig
Usage (cli):
no ifconfig options are supported.
$ ifconfig | jc --ifconfig
Compatibility:
or
'linux', 'aix', 'freebsd', 'darwin'
$ jc ifconfig
Usage (module):
import jc.parsers.ifconfig
result = jc.parsers.ifconfig.parse(ifconfig_command_output)
Schema:
[
{
"name": string,
"flags": integer,
"state": [
string
],
"mtu": integer,
"ipv4_addr": string,
"ipv4_mask": string,
"ipv4_bcast": string,
"ipv6_addr": string,
"ipv6_mask": integer,
"ipv6_scope": string,
"mac_addr": string,
"type": string,
"rx_packets": integer,
"rx_bytes": integer,
"rx_errors": integer,
"rx_dropped": integer,
"rx_overruns": integer,
"rx_frame": integer,
"tx_packets": integer,
"tx_bytes": integer,
"tx_errors": integer,
"tx_dropped": integer,
"tx_overruns": integer,
"tx_carrier": integer,
"tx_collisions": integer,
"metric": integer
}
]
Examples:
@@ -142,58 +184,12 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"name": string,
"flags": integer,
"state": [
string
],
"mtu": integer,
"ipv4_addr": string,
"ipv4_mask": string,
"ipv4_bcast": string,
"ipv6_addr": string,
"ipv6_mask": integer,
"ipv6_scope": string,
"mac_addr": string,
"type": string,
"rx_packets": integer,
"rx_bytes": integer,
"rx_errors": integer,
"rx_dropped": integer,
"rx_overruns": integer,
"rx_frame": integer,
"tx_packets": integer,
"tx_bytes": integer,
"tx_errors": integer,
"tx_dropped": integer,
"tx_overruns": integer,
"tx_carrier": integer,
"tx_collisions": integer,
"metric": integer
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -210,5 +206,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, aix, freebsd, darwin
Version 1.10 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,33 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.ini
jc - JSON CLI output utility INI Parser
jc - JSON CLI output utility `INI` file parser
Usage:
Parses standard `INI` files and files containing simple key/value pairs. Delimiter can be `=` or `:`. Missing values are supported. Comment prefix can be `#` or `;`. Comments must be on their own line.
specify --ini as the first argument if the piped input is coming from an INI file
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()`.
Compatibility:
Usage (cli):
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
$ cat foo.ini | jc --ini
Usage (module):
import jc.parsers.ini
result = jc.parsers.ini.parse(ini_file_output)
Schema:
ini or key/value document converted to a dictionary - see configparser standard
library documentation for more details.
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 or raw=True argument.
{
"key1": string,
"key2": string
}
Examples:
@@ -43,30 +63,12 @@ Examples:
}
}
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
Dictionary representing an ini document:
{
ini document converted to a dictionary
see configparser standard library documentation for more details
}
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -85,3 +87,7 @@ Returns:
Dictionary representing the ini file
## Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,15 +1,45 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.iptables
jc - JSON CLI output utility ipables Parser
jc - JSON CLI output utility `ipables` command output parser
Usage:
Supports `-vLn` and `--line-numbers` for all tables.
Specify --iptables as the first argument if the piped input is coming from iptables
Usage (cli):
Supports -vLn and --line-numbers for all tables
$ sudo iptables -L -t nat | jc --iptables
Compatibility:
or
'linux'
$ jc iptables -L -t nat
Usage (module):
import jc.parsers.iptables
result = jc.parsers.iptables.parse(iptables_command_output)
Schema:
[
{
"chain": string,
"rules": [
{
"num" integer,
"pkts": integer,
"bytes": integer, # converted based on suffix
"target": string,
"prot": string,
"opt": string, # "--" = Null
"in": string,
"out": string,
"source": string,
"destination": string,
"options": string
}
]
}
]
Examples:
@@ -131,46 +161,12 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"chain": string,
"rules": [
{
"num" integer,
"pkts": integer,
"bytes": integer, # converted based on suffix
"target": string,
"prot": string,
"opt": string, # "--" = Null
"in": string,
"out": string,
"source": string,
"destination": string,
"options": string
}
]
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -187,5 +183,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)

148
docs/parsers/iw_scan.md Normal file
View File

@@ -0,0 +1,148 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.iw_scan
jc - JSON CLI output utility `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.
Usage (cli):
$ iw dev wlan0 scan | jc --iw-scan
or
$ jc iw dev wlan0 scan
Usage (module):
import jc.parsers.iw-scan
result = jc.parsers.iw-scan.parse(iw-scan_command_output)
Schema:
[
{
"foo": string/integer/float, # best guess based on value
"bar": string/integer/float,
"baz": string/integer/float
}
]
Examples:
$ iw dev wlan0 scan | jc --iw-scan -p
[
{
"bssid": "71:31:72:65:e1:a2",
"interface": "wlan0",
"freq": 2462,
"capability": "ESS Privacy ShortSlotTime (0x0411)",
"ssid": "WLAN-1234",
"supported_rates": [
1.0,
2.0,
5.5,
11.0,
18.0,
24.0,
36.0,
54.0
],
"erp": "<no flags>",
"erp_d4.0": "<no flags>",
"rsn": "Version: 1",
"group_cipher": "CCMP",
"pairwise_ciphers": "CCMP",
"authentication_suites": "PSK",
"capabilities": "0x186c",
"extended_supported_rates": [
6.0,
9.0,
12.0,
48.0
],
"ht_rx_mcs_rate_indexes_supported": "0-15",
"primary_channel": 11,
"secondary_channel_offset": "no secondary",
"rifs": 1,
"ht_protection": "no",
"non-gf_present": 1,
"obss_non-gf_present": 0,
"dual_beacon": 0,
"dual_cts_protection": 0,
"stbc_beacon": 0,
"l-sig_txop_prot": 0,
"pco_active": 0,
"pco_phase": 0,
"bss_width_channel_transition_delay_factor": 5,
"extended_capabilities": "HT Information Exchange Supported",
"wmm": "Parameter version 1",
"be": "CW 15-1023, AIFSN 3",
"bk": "CW 15-1023, AIFSN 7",
"vi": "CW 7-15, AIFSN 2, TXOP 3008 usec",
"vo": "CW 3-7, AIFSN 2, TXOP 1504 usec",
"wps": "Version: 1.0",
"wi-fi_protected_setup_state": "2 (Configured)",
"selected_registrar": "0x0",
"response_type": "3 (AP)",
"uuid": "00000000-0000-0003-0000-75317074f1a2",
"manufacturer": "Corporation",
"model": "VGV8539JW",
"model_number": "1.47.000",
"serial_number": "J144024542",
"primary_device_type": "6-0050f204-1",
"device_name": "Wireless Router(WFA)",
"config_methods": "Label, PBC",
"rf_bands": "0x3",
"tsf_usec": 212098649788,
"sta_channel_width_mhz": 20,
"passive_dwell_tus": 20,
"active_dwell_tus": 10,
"channel_width_trigger_scan_interval_s": 300,
"scan_passive_total_per_channel_tus": 200,
"scan_active_total_per_channel_tus": 20,
"beacon_interval_tus": 100,
"signal_dbm": -80.0,
"last_seen_ms": 11420,
"selected_rates": [
1.0,
2.0,
5.5,
11.0
],
"obss_scan_activity_threshold_percent": 0.25,
"ds_parameter_set_channel": 11,
"max_amsdu_length_bytes": 7935,
"minimum_rx_ampdu_time_spacing_usec": 16
},
...
]
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 0.6 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,15 +1,34 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.jobs
jc - JSON CLI output utility jobs Parser
jc - JSON CLI output utility `jobs` command output parser
Usage:
Also supports the `-l` option.
specify --jobs as the first argument if the piped input is coming from jobs
Usage (cli):
Also supports the -l option
$ jobs | jc --jobs
Compatibility:
or
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
$ jc jobs
Usage (module):
import jc.parsers.jobs
result = jc.parsers.jobs.parse(jobs_command_output)
Schema:
[
{
"job_number": integer,
"pid": integer,
"history": string,
"status": string,
"command": string
}
]
Example:
@@ -73,35 +92,12 @@ Example:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"job_number": integer,
"pid": integer,
"history": string,
"status": string,
"command": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -118,5 +114,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

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

@@ -0,0 +1,78 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.kv
jc - JSON CLI output utility `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.
Note: Values starting and ending with quotation marks will have the marks removed. If you would like to keep the quotation marks, use the `-r` command-line argument or the `raw=True` argument in `parse()`.
Usage (cli):
$ cat foo.txt | jc --kv
Usage (module):
import jc.parsers.kv
result = jc.parsers.kv.parse(kv_file_output)
Schema:
key/value document converted to a dictionary - see configparser standard library documentation for more details.
{
"key1": string,
"key2": string
}
Examples:
$ cat keyvalue.txt
# this file contains key/value pairs
name = John Doe
address=555 California Drive
age: 34
; comments can include # or ;
# delimiter can be = or :
# quoted values have quotation marks stripped by default
# but can be preserved with the -r argument
occupation:"Engineer"
$ cat keyvalue.txt | jc --ini -p
{
"name": "John Doe",
"address": "555 California Drive",
"age": "34",
"occupation": "Engineer"
}
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Note: this is just a wrapper for jc.parsers.ini
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary representing the key/value file
## Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,40 +1,73 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.last
jc - JSON CLI output utility last Parser
jc - JSON CLI output utility `last` and `lastb` command output parser
Usage:
Supports `-w` and `-F` options.
specify --last as the first argument if the piped input is coming from last or lastb
Calculated epoch time fields are naive (i.e. based on the local time of the system the parser is run on) since there is no timezone information in the `last` command output.
Compatibility:
Usage (cli):
'linux', 'darwin', 'aix', 'freebsd'
$ last | jc --last
or
$ jc last
Usage (module):
import jc.parsers.last
result = jc.parsers.last.parse(last_command_output)
Schema:
[
{
"user": string,
"tty": string,
"hostname": string,
"login": string,
"logout": string,
"duration": string,
"login_epoch": integer, # (naive) available with last -F option
"logout_epoch": integer, # (naive) available with last -F option
"duration_seconds": integer # available with last -F option
}
]
Examples:
$ last | jc --last -p
$ last -F | jc --last -p
[
{
"user": "kbrazil",
"tty": "ttys002",
"hostname": null,
"login": "Thu Feb 27 14:31",
"login": "Mon Dec 28 17:24:10 2020",
"logout": "still logged in"
},
{
"user": "kbrazil",
"tty": "ttys003",
"hostname": null,
"login": "Thu Feb 27 10:38",
"logout": "10:38",
"duration": "00:00"
"login": "Mon Dec 28 17:24:10 2020",
"logout": "Mon Dec 28 17:25:01 2020",
"duration": "00:00",
"login_epoch": 1565891826,
"logout_epoch": 1565895404,
"duration_seconds": 3578
},
{
"user": "kbrazil",
"tty": "ttys003",
"hostname": null,
"login": "Thu Feb 27 10:18",
"logout": "10:18",
"duration": "00:00"
"login": "Mon Dec 28 17:24:10 2020",
"logout": "Mon Dec 28 17:25:01 2020",
"duration": "00:00",
"login_epoch": 1565891826,
"logout_epoch": 1565895404,
"duration_seconds": 3578
},
...
]
@@ -68,36 +101,12 @@ Examples:
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"user": string,
"tty": string,
"hostname": string,
"login": string,
"logout": string,
"duration": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -114,5 +123,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, aix, freebsd
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,25 +1,47 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.ls
jc - JSON CLI output utility ls Parser
jc - JSON CLI output utility `ls` and `vdir` command output parser
Note: The -l or -b option of ls should be used to correctly parse filenames that include newline characters.
Since ls does not encode newlines in filenames when outputting to a pipe it will cause jc to see
multiple files instead of a single file if -l or -b is not used.
Options supported:
- `lbaR1`
- `--time-style=full-iso`
Usage:
Note: The `-1`, `-l`, or `-b` option of `ls` should be used to correctly parse filenames that include newline characters. Since `ls` does not encode newlines in filenames when outputting to a pipe it will cause `jc` to see multiple files instead of a single file if `-1`, `-l`, or `-b` is not used. Alternatively, `vdir` can be used, which is the same as running `ls -lb`.
specify --ls as the first argument if the piped input is coming from ls
The `epoch` calculated timestamp field is naive (i.e. based on the local time of the system the parser is run on)
ls options supported:
The `epoch_utc` calculated timestamp field is timezone-aware and is only available if the timezone field is UTC.
-lbaR
--time-style=full-iso
-h file sizes will be available in text form with -r but larger file sizes
with human readable suffixes will be converted to Null in default view
since the parser attempts to convert this field to an integer.
Usage (cli):
Compatibility:
$ ls | jc --ls
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
or
$ jc ls
Usage (module):
import jc.parsers.ls
result = jc.parsers.ls.parse(ls_command_output)
Schema:
[
{
"filename": string,
"flags": string,
"links": integer,
"parent": string,
"owner": string,
"group": string,
"size": integer,
"date": string,
"epoch": integer, # naive timestamp if date field exists and can be converted
"epoch_utc": integer # timezone aware timestamp if date field is in UTC and can be converted
}
]
Examples:
@@ -31,12 +53,6 @@ Examples:
{
"filename": "arch"
},
{
"filename": "awk"
},
{
"filename": "base64"
},
...
]
@@ -61,15 +77,6 @@ Examples:
"size": 62744,
"date": "Aug 8 16:14"
},
{
"filename": "arch",
"flags": "-rwxr-xr-x.",
"links": 1,
"owner": "root",
"group": "root",
"size": 33080,
"date": "Aug 19 23:25"
},
...
]
@@ -94,89 +101,15 @@ Examples:
"size": "33080",
"date": "Aug 19 23:25"
},
{
"filename": "awk",
"link_to": "gawk",
"flags": "lrwxrwxrwx.",
"links": "1",
"owner": "root",
"group": "root",
"size": "4",
"date": "Aug 15 10:53"
},
{
"filename": "base64",
"flags": "-rwxr-xr-x.",
"links": "1",
"owner": "root",
"group": "root",
"size": "37360",
"date": "Aug 19 23:25"
},
{
"filename": "basename",
"flags": "-rwxr-xr-x.",
"links": "1",
"owner": "root",
"group": "root",
"size": "29032",
"date": "Aug 19 23:25"
},
{
"filename": "bash",
"flags": "-rwxr-xr-x.",
"links": "1",
"owner": "root",
"group": "root",
"size": "964600",
"date": "Aug 8 05:06"
},
...
]
$ ls -l /usr/bin | jc --ls | jq '.[] | select(.size > 50000000)'
{
"filename": "emacs",
"flags": "-r-xr-xr-x",
"links": 1,
"owner": "root",
"group": "wheel",
"size": 117164432,
"date": "May 3 2019"
}
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"filename": string,
"flags": string,
"links": integer,
"parent": string,
"owner": string,
"group": string,
"size": integer,
"date": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -193,5 +126,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,67 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.lsblk
jc - JSON CLI output utility lsblk Parser
jc - JSON CLI output utility `lsblk` command output parser
Usage:
Usage (cli):
specify --lsblk as the first argument if the piped input is coming from lsblk
$ lsblk | jc --lsblk
Compatibility:
or
'linux'
$ jc lsblk
Usage (module):
import jc.parsers.lsblk
result = jc.parsers.lsblk.parse(lsblk_command_output)
Schema:
[
{
"name": string,
"maj_min": string,
"rm": boolean,
"size": string,
"ro": boolean,
"type": string,
"mountpoint": string,
"kname": string,
"fstype": string,
"label": string,
"uuid": string,
"partlabel": string,
"partuuid": string,
"ra": integer,
"model": string,
"serial": string,
"state": string,
"owner": string,
"group": string,
"mode": string,
"alignment": integer,
"min_io": integer,
"opt_io": integer,
"phy_sec": integer,
"log_sec": integer,
"rota": boolean,
"sched": string,
"rq_size": integer,
"disc_aln": integer,
"disc_gran": string,
"disc_max": string,
"disc_zero": boolean,
"wsame": string,
"wwn": string,
"rand": boolean,
"pkname": string,
"hctl": string,
"tran": string,
"rev": string,
"vendor": string
}
]
Examples:
@@ -212,70 +266,12 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"name": string,
"maj_min": string,
"rm": boolean,
"size": string,
"ro": boolean,
"type": string,
"mountpoint": string,
"kname": string,
"fstype": string,
"label": string,
"uuid": string,
"partlabel": string,
"partuuid": string,
"ra": integer,
"model": string,
"serial": string,
"state": string,
"owner": string,
"group": string,
"mode": string,
"alignment": integer,
"min_io": integer,
"opt_io": integer,
"phy_sec": integer,
"log_sec": integer,
"rota": boolean,
"sched": string,
"rq_size": integer,
"disc_aln": integer,
"disc_gran": string,
"disc_max": string,
"disc_zero": boolean,
"wsame": string,
"wwn": string,
"rand": boolean,
"pkname": string,
"hctl": string,
"tran": string,
"rev": string,
"vendor": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -292,5 +288,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,33 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.lsmod
jc - JSON CLI output utility lsmod Parser
jc - JSON CLI output utility `lsmod` command output parser
Usage:
Usage (cli):
specify --lsmod as the first argument if the piped input is coming from lsmod
$ lsmod | jc --lsmod
Compatibility:
or
'linux'
$ jc lsmod
Usage (module):
import jc.parsers.lsmod
result = jc.parsers.lsmod.parse(lsmod_command_output)
Schema:
[
{
"module": string,
"size": integer,
"used": integer,
"by": [
string
]
}
]
Examples:
@@ -103,36 +123,12 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"module": string,
"size": integer,
"used": integer,
"by": [
string
]
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -149,5 +145,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,37 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.lsof
jc - JSON CLI output utility lsof Parser
jc - JSON CLI output utility `lsof` command output parser
Usage:
Usage (cli):
specify --lsof as the first argument if the piped input is coming from lsof
$ lsof | jc --lsof
Compatibility:
or
'linux'
$ jc lsof
Usage (module):
import jc.parsers.lsof
result = jc.parsers.lsof.parse(lsof_command_output)
Schema:
[
{
"command": string,
"pid": integer,
"tid": integer,
"user": string,
"fd": string,
"type": string,
"device": string,
"size_off": integer,
"node": integer,
"name": string
}
]
Examples:
@@ -93,40 +117,12 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"command": string,
"pid": integer,
"tid": integer,
"user": string,
"fd": string,
"type": string,
"device": string,
"size_off": integer,
"node": integer,
"name": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -143,5 +139,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,33 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.mount
jc - JSON CLI output utility mount Parser
jc - JSON CLI output utility `mount` command output parser
Usage:
Usage (cli):
specify --mount as the first argument if the piped input is coming from mount
$ mount | jc --mount
Compatibility:
or
'linux', 'darwin'
$ jc mount
Usage (module):
import jc.parsers.mount
result = jc.parsers.mount.parse(mount_command_output)
Schema:
[
{
"filesystem": string,
"mount_point": string,
"type": string,
"access": [
string
]
}
]
Example:
@@ -53,36 +73,12 @@ Example:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"filesystem": string,
"mount_point": string,
"type": string,
"access": [
string
]
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -99,5 +95,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, freebsd
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,17 +1,129 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.netstat
jc - JSON CLI output utility netstat Parser
jc - JSON CLI output utility `netstat` command output parser
Usage:
Caveats:
- Use of multiple `l` options is not supported on OSX (e.g. `netstat -rlll`)
- Use of the `A` option is not supported on OSX when using the `r` option (e.g. `netstat -rA`)
Specify --netstat as the first argument if the piped input is coming from netstat
Usage (cli):
Compatibility:
$ netstat | jc --netstat
'linux'
or
$ jc netstat
Usage (module):
import jc.parsers.netstat
result = jc.parsers.netstat.parse(netstat_command_output)
Schema:
[
{
"proto": string,
"recv_q": integer,
"send_q": integer,
"transport_protocol" string,
"network_protocol": string,
"local_address": string,
"local_port": string,
"local_port_num": integer,
"foreign_address": string,
"foreign_port": string,
"foreign_port_num": integer,
"state": string,
"program_name": string,
"pid": integer,
"user": string,
"security_context": string,
"refcnt": integer,
"flags": string,
"type": string,
"inode": integer,
"path": string,
"kind": string,
"address": string,
"unix_inode": string,
"conn": string,
"refs": string,
"nextref": string,
"name": string,
"unit": integer,
"vendor": integer,
"class": integer,
"subcla": integer,
"unix_flags": integer,
"pcbcount": integer,
"rcvbuf": integer,
"sndbuf": integer,
"rxbytes": integer,
"txbytes": integer,
"destination": string,
"gateway": string,
"route_flags": string,
"route_flags_pretty": [
string,
]
"route_refs": integer,
"use": integer,
"mtu": integer,
"expire": string,
"genmask": string,
"mss": integer,
"window": integer,
"irtt": integer,
"iface": string,
"metric": integer,
"network": string,
"address": string,
"ipkts": integer, # - = null
"ierrs": integer, # - = null
"idrop": integer, # - = null
"opkts": integer, # - = null
"oerrs": integer, # - = null
"coll": integer, # - = null
"rx_ok": integer,
"rx_err": integer,
"rx_drp": integer,
"rx_ovr": integer,
"tx_ok": integer,
"tx_err": integer,
"tx_drp": integer,
"tx_ovr": integer,
"flg": string,
"ibytes": integer,
"obytes": integer,
"r_mbuf": integer,
"s_mbuf": integer,
"r_clus": integer,
"s_clus": integer,
"r_hiwa": integer,
"s_hiwa": integer,
"r_lowa": integer,
"s_lowa": integer,
"r_bcnt": integer,
"s_bcnt": integer,
"r_bmax": integer,
"s_bmax": integer,
"rexmit": integer,
"ooorcv": integer,
"0_win": integer,
"rexmt": float,
"persist": float,
"keep": float,
"2msl": float,
"delack": float,
"rcvtime": float,
}
]
Examples:
$ sudo netstat -apee | jc --netstat -p
# netstat -apee | jc --netstat -p
[
{
"proto": "tcp",
@@ -161,200 +273,91 @@ Examples:
...
]
$ sudo netstat -apee | jc --netstat -p -r
$ netstat -r | jc --netstat -p
[
{
"proto": "tcp",
"recv_q": "0",
"send_q": "0",
"local_address": "localhost",
"foreign_address": "0.0.0.0",
"state": "LISTEN",
"user": "systemd-resolve",
"inode": "26958",
"program_name": "systemd-resolve",
"kind": "network",
"pid": "887",
"local_port": "domain",
"foreign_port": "*",
"transport_protocol": "tcp",
"network_protocol": "ipv4"
"destination": "default",
"gateway": "gateway",
"genmask": "0.0.0.0",
"route_flags": "UG",
"mss": 0,
"window": 0,
"irtt": 0,
"iface": "ens33",
"kind": "route",
"route_flags_pretty": [
"UP",
"GATEWAY"
]
},
{
"proto": "tcp",
"recv_q": "0",
"send_q": "0",
"local_address": "0.0.0.0",
"foreign_address": "0.0.0.0",
"state": "LISTEN",
"user": "root",
"inode": "30499",
"program_name": "sshd",
"kind": "network",
"pid": "1186",
"local_port": "ssh",
"foreign_port": "*",
"transport_protocol": "tcp",
"network_protocol": "ipv4"
"destination": "172.17.0.0",
"gateway": "0.0.0.0",
"genmask": "255.255.0.0",
"route_flags": "U",
"mss": 0,
"window": 0,
"irtt": 0,
"iface": "docker0",
"kind": "route",
"route_flags_pretty": [
"UP"
]
},
{
"proto": "tcp",
"recv_q": "0",
"send_q": "0",
"local_address": "localhost",
"foreign_address": "localhost",
"state": "ESTABLISHED",
"user": "root",
"inode": "46829",
"program_name": "sshd: root",
"kind": "network",
"pid": "2242",
"local_port": "ssh",
"foreign_port": "52186",
"transport_protocol": "tcp",
"network_protocol": "ipv4"
},
{
"proto": "tcp",
"recv_q": "0",
"send_q": "0",
"local_address": "localhost",
"foreign_address": "localhost",
"state": "ESTABLISHED",
"user": "root",
"inode": "46828",
"program_name": "ssh",
"kind": "network",
"pid": "2241",
"local_port": "52186",
"foreign_port": "ssh",
"transport_protocol": "tcp",
"network_protocol": "ipv4"
},
{
"proto": "tcp6",
"recv_q": "0",
"send_q": "0",
"local_address": "[::]",
"foreign_address": "[::]",
"state": "LISTEN",
"user": "root",
"inode": "30510",
"program_name": "sshd",
"kind": "network",
"pid": "1186",
"local_port": "ssh",
"foreign_port": "*",
"transport_protocol": "tcp",
"network_protocol": "ipv6"
},
{
"proto": "udp",
"recv_q": "0",
"send_q": "0",
"local_address": "localhost",
"foreign_address": "0.0.0.0",
"state": null,
"user": "systemd-resolve",
"inode": "26957",
"program_name": "systemd-resolve",
"kind": "network",
"pid": "887",
"local_port": "domain",
"foreign_port": "*",
"transport_protocol": "udp",
"network_protocol": "ipv4"
},
{
"proto": "raw6",
"recv_q": "0",
"send_q": "0",
"local_address": "[::]",
"foreign_address": "[::]",
"state": "7",
"user": "systemd-network",
"inode": "27001",
"program_name": "systemd-network",
"kind": "network",
"pid": "867",
"local_port": "ipv6-icmp",
"foreign_port": "*",
"transport_protocol": null,
"network_protocol": "ipv6"
},
{
"proto": "unix",
"refcnt": "2",
"flags": null,
"type": "DGRAM",
"state": null,
"inode": "33322",
"program_name": "systemd",
"path": "/run/user/1000/systemd/notify",
"kind": "socket",
"pid": " 1607"
},
{
"proto": "unix",
"refcnt": "2",
"flags": "ACC",
"type": "SEQPACKET",
"state": "LISTENING",
"inode": "20835",
"program_name": "init",
"path": "/run/udev/control",
"kind": "socket",
"pid": " 1"
},
...
"destination": "192.168.71.0",
"gateway": "0.0.0.0",
"genmask": "255.255.255.0",
"route_flags": "U",
"mss": 0,
"window": 0,
"irtt": 0,
"iface": "ens33",
"kind": "route",
"route_flags_pretty": [
"UP"
]
}
]
$ netstat -i | jc --netstat -p
[
{
"iface": "ens33",
"mtu": 1500,
"rx_ok": 476,
"rx_err": 0,
"rx_drp": 0,
"rx_ovr": 0,
"tx_ok": 312,
"tx_err": 0,
"tx_drp": 0,
"tx_ovr": 0,
"flg": "BMRU",
"kind": "interface"
},
{
"iface": "lo",
"mtu": 65536,
"rx_ok": 0,
"rx_err": 0,
"rx_drp": 0,
"rx_ovr": 0,
"tx_ok": 0,
"tx_err": 0,
"tx_drp": 0,
"tx_ovr": 0,
"flg": "LRU",
"kind": "interface"
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"proto": string,
"recv_q": integer,
"send_q": integer,
"transport_protocol" string,
"network_protocol": string,
"local_address": string,
"local_port": string,
"local_port_num": integer,
"foreign_address": string,
"foreign_port": string,
"foreign_port_num": integer,
"state": string,
"program_name": string,
"pid": integer,
"user": string,
"security_context": string,
"refcnt": integer,
"flags": string,
"type": string,
"inode": integer,
"path": string,
"kind": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -371,5 +374,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, freebsd
Version 1.10 by Kelly Brazil (kellyjonbrazil@gmail.com)

234
docs/parsers/ntpq.md Normal file
View File

@@ -0,0 +1,234 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.ntpq
jc - JSON CLI output utility `ntpq -p` command output parser
Usage (cli):
$ ntpq -p | jc --ntpq
or
$ jc ntpq -p
Usage (module):
import jc.parsers.ntpq
result = jc.parsers.ntpq.parse(ntpq_command_output)
Schema:
[
{
"state": string, # space/~ converted to null
"remote": string,
"refid": string,
"st": integer,
"t": string,
"when": integer, # - converted to null
"poll": integer,
"reach": integer,
"delay": float,
"offset": float,
"jitter": float
},
]
Examples:
$ ntpq -p | jc --ntpq -p
[
{
"remote": "44.190.6.254",
"refid": "127.67.113.92",
"st": 2,
"t": "u",
"when": 1,
"poll": 64,
"reach": 1,
"delay": 23.399,
"offset": -2.805,
"jitter": 2.131,
"state": null
},
{
"remote": "ntp.wdc1.us.lea",
"refid": "130.133.1.10",
"st": 2,
"t": "u",
"when": null,
"poll": 64,
"reach": 1,
"delay": 93.053,
"offset": -0.807,
"jitter": 2.839,
"state": null
},
{
"remote": "clock.team-cymr",
"refid": "204.9.54.119",
"st": 2,
"t": "u",
"when": null,
"poll": 64,
"reach": 1,
"delay": 70.337,
"offset": -2.909,
"jitter": 2.6,
"state": null
},
{
"remote": "mirror1.sjc02.s",
"refid": "216.218.254.202",
"st": 2,
"t": "u",
"when": 2,
"poll": 64,
"reach": 1,
"delay": 29.325,
"offset": 1.044,
"jitter": 4.069,
"state": null,
}
]
$ ntpq -pn| jc --ntpq -p
[
{
"remote": "44.190.6.254",
"refid": "127.67.113.92",
"st": 2,
"t": "u",
"when": 66,
"poll": 64,
"reach": 377,
"delay": 22.69,
"offset": -0.392,
"jitter": 2.085,
"state": "+"
},
{
"remote": "108.59.2.24",
"refid": "130.133.1.10",
"st": 2,
"t": "u",
"when": 63,
"poll": 64,
"reach": 377,
"delay": 90.805,
"offset": 2.84,
"jitter": 1.908,
"state": "-"
},
{
"remote": "38.229.71.1",
"refid": "204.9.54.119",
"st": 2,
"t": "u",
"when": 64,
"poll": 64,
"reach": 377,
"delay": 68.699,
"offset": -0.61,
"jitter": 2.576,
"state": "+"
},
{
"remote": "72.5.72.15",
"refid": "216.218.254.202",
"st": 2,
"t": "u",
"when": 63,
"poll": 64,
"reach": 377,
"delay": 22.654,
"offset": 0.231,
"jitter": 1.964,
"state": "*"
}
]
$ ntpq -pn| jc --ntpq -p -r
[
{
"s": "+",
"remote": "44.190.6.254",
"refid": "127.67.113.92",
"st": "2",
"t": "u",
"when": "66",
"poll": "64",
"reach": "377",
"delay": "22.690",
"offset": "-0.392",
"jitter": "2.085"
},
{
"s": "-",
"remote": "108.59.2.24",
"refid": "130.133.1.10",
"st": "2",
"t": "u",
"when": "63",
"poll": "64",
"reach": "377",
"delay": "90.805",
"offset": "2.840",
"jitter": "1.908"
},
{
"s": "+",
"remote": "38.229.71.1",
"refid": "204.9.54.119",
"st": "2",
"t": "u",
"when": "64",
"poll": "64",
"reach": "377",
"delay": "68.699",
"offset": "-0.610",
"jitter": "2.576"
},
{
"s": "*",
"remote": "72.5.72.15",
"refid": "216.218.254.202",
"st": "2",
"t": "u",
"when": "63",
"poll": "64",
"reach": "377",
"delay": "22.654",
"offset": "0.231",
"jitter": "1.964"
}
]
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, freebsd
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,30 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.passwd
jc - JSON CLI output utility /etc/passwd file Parser
jc - JSON CLI output utility `/etc/passwd` file Parser
Usage:
Usage (cli):
specify --passwd as the first argument if the piped input is coming from /etc/passwd
$ cat /etc/passwd | jc --passwd
Compatibility:
Usage (module):
'linux', 'darwin', 'aix', 'freebsd'
import jc.parsers.passwd
result = jc.parsers.passwd.parse(passwd_file_output)
Schema:
[
{
"username": string,
"password": string,
"uid": integer,
"gid": integer,
"comment": string,
"home": string,
"shell": string
}
]
Examples:
@@ -75,37 +92,12 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"username": string,
"password": string,
"uid": integer,
"gid": integer,
"comment": string,
"home": string,
"shell": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -122,5 +114,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, aix, freebsd
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)

172
docs/parsers/ping.md Normal file
View File

@@ -0,0 +1,172 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.ping
jc - JSON CLI output utility `ping` command output parser
Supports `ping` and `ping6` output.
Usage (cli):
Note: Use the ping `-c` (count) option, otherwise data will not be piped to `jc`.
$ ping -c 3 1.2.3.4 | jc --ping
or
$ jc ping -c 3 1.2.3.4
Usage (module):
import jc.parsers.ping
result = jc.parsers.ping.parse(ping_command_output)
Schema:
{
"source_ip": string,
"destination_ip": string,
"data_bytes": integer,
"pattern": string, # (null if not set)
"destination": string,
"packets_transmitted": integer,
"packets_received": integer,
"packet_loss_percent": float,
"duplicates": integer,
"round_trip_ms_min": float,
"round_trip_ms_avg": float,
"round_trip_ms_max": float,
"round_trip_ms_stddev": float,
"responses": [
{
"type": string, # ('reply' or 'timeout')
"timestamp": float,
"bytes": integer,
"response_ip": string,
"icmp_seq": integer,
"ttl": integer,
"time_ms": float,
"duplicate": boolean
}
]
}
Examples:
$ ping -c 3 -p ff cnn.com | jc --ping -p
{
"destination_ip": "151.101.1.67",
"data_bytes": 56,
"pattern": "0xff",
"destination": "cnn.com",
"packets_transmitted": 3,
"packets_received": 3,
"packet_loss_percent": 0.0,
"duplicates": 0,
"round_trip_ms_min": 28.015,
"round_trip_ms_avg": 32.848,
"round_trip_ms_max": 39.376,
"round_trip_ms_stddev": 4.79,
"responses": [
{
"type": "reply",
"bytes": 64,
"response_ip": "151.101.1.67",
"icmp_seq": 0,
"ttl": 59,
"time_ms": 28.015,
"duplicate": false
},
{
"type": "reply",
"bytes": 64,
"response_ip": "151.101.1.67",
"icmp_seq": 1,
"ttl": 59,
"time_ms": 39.376,
"duplicate": false
},
{
"type": "reply",
"bytes": 64,
"response_ip": "151.101.1.67",
"icmp_seq": 2,
"ttl": 59,
"time_ms": 31.153,
"duplicate": false
}
]
}
$ ping -c 3 -p ff cnn.com | jc --ping -p -r
{
"destination_ip": "151.101.129.67",
"data_bytes": "56",
"pattern": "0xff",
"destination": "cnn.com",
"packets_transmitted": "3",
"packets_received": "3",
"packet_loss_percent": "0.0",
"duplicates": "0",
"round_trip_ms_min": "25.078",
"round_trip_ms_avg": "29.543",
"round_trip_ms_max": "32.553",
"round_trip_ms_stddev": "3.221",
"responses": [
{
"type": "reply",
"bytes": "64",
"response_ip": "151.101.129.67",
"icmp_seq": "0",
"ttl": "59",
"time_ms": "25.078",
"duplicate": false
},
{
"type": "reply",
"bytes": "64",
"response_ip": "151.101.129.67",
"icmp_seq": "1",
"ttl": "59",
"time_ms": "30.999",
"duplicate": false
},
{
"type": "reply",
"bytes": "64",
"response_ip": "151.101.129.67",
"icmp_seq": "2",
"ttl": "59",
"time_ms": "32.553",
"duplicate": false
}
]
}
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, freebsd
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,30 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.pip_list
jc - JSON CLI output utility pip-list Parser
jc - JSON CLI output utility `pip-list` command output parser
Usage:
Usage (cli):
specify --pip-list as the first argument if the piped input is coming from pip list
$ pip list | jc --pip-list
Compatibility:
or
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
$ jc pip list
Usage (module):
import jc.parsers.pip_list
result = jc.parsers.pip_list.parse(pip_list_command_output)
Schema:
[
{
"package": string,
"version": string,
"location": string
}
]
Examples:
@@ -28,33 +45,12 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"package": string,
"version": string,
"location": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -71,5 +67,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,37 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.pip_show
jc - JSON CLI output utility pip-show Parser
jc - JSON CLI output utility `pip-show` command output parser
Usage:
Usage (cli):
specify --pip-show as the first argument if the piped input is coming from pip show
$ pip show | jc --pip-show
Compatibility:
or
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
$ jc pip show
Usage (module):
import jc.parsers.pip_show
result = jc.parsers.pip_show.parse(pip_show_command_output)
Schema:
[
{
"name": string,
"version": string,
"summary": string,
"home_page": string,
"author": string,
"author_email": string,
"license": string,
"location": string,
"requires": string,
"required_by": string
}
]
Examples:
@@ -39,41 +63,12 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"name": string,
"version": string,
"summary": string,
"home_page": string,
"author": string,
"author_email": string,
"license": string,
"location": string,
"requires": string,
"required_by": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -90,5 +85,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,17 +1,48 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.ps
jc - JSON CLI output utility ps Parser
jc - JSON CLI output utility `ps` command output parser
Usage:
`ps` options supported:
- `ef`
- `axu`
specify --ps as the first argument if the piped input is coming from ps
Usage (cli):
ps options supported:
- ef
- axu
$ ps | jc --ps
Compatibility:
or
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
$ jc ps
Usage (module):
import jc.parsers.ps
result = jc.parsers.ps.parse(ps_command_output)
Schema:
[
{
"uid": string,
"pid": integer,
"ppid": integer,
"c": integer,
"stime": string,
"tty": string, # ? or ?? = Null
"tt": string, # ?? = Null
"time": string,
"cmd": string,
"user": string,
"cpu_percent": float,
"mem_percent": float,
"vsz": integer,
"rss": integer,
"stat": string,
"start": string,
"command": string
}
]
Examples:
@@ -173,47 +204,12 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"uid": string,
"pid": integer,
"ppid": integer,
"c": integer,
"stime": string,
"tty": string, # ? or ?? = Null
"tt": string, # ?? = Null
"time": string,
"cmd": string,
"user": string,
"cpu_percent": float,
"mem_percent": float,
"vsz": integer,
"rss": integer,
"stat": string,
"start": string,
"command": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -230,5 +226,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,41 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.route
jc - JSON CLI output utility route Parser
jc - JSON CLI output utility `route` command output parser
Usage:
Usage (cli):
specify --route as the first argument if the piped input is coming from route
$ route | jc --route
Compatibility:
or
'linux'
$ jc route
Usage (module):
import jc.parsers.route
result = jc.parsers.route.parse(route_command_output)
Schema:
[
{
"destination": string,
"gateway": string,
"genmask": string,
"flags": string,
"flags_pretty": [
string,
]
"metric": integer,
"ref": integer,
"use": integer,
"mss": integer,
"window": integer,
"irtt": integer,
"iface": string
}
]
Examples:
@@ -15,53 +43,48 @@ Examples:
[
{
"destination": "default",
"gateway": "gateway",
"gateway": "_gateway",
"genmask": "0.0.0.0",
"flags": "UG",
"metric": 100,
"metric": 202,
"ref": 0,
"use": 0,
"iface": "ens33",
"mss": 0,
"window": 0,
"irtt": 0
},
{
"destination": "172.17.0.0",
"gateway": "0.0.0.0",
"genmask": "255.255.0.0",
"flags": "U",
"metric": 0,
"ref": 0,
"use": 0,
"iface": "docker",
"mss": 0,
"window": 0,
"irtt": 0
"irtt": 0,
"flags_pretty": [
"UP",
"GATEWAY"
]
},
{
"destination": "192.168.71.0",
"gateway": "0.0.0.0",
"genmask": "255.255.255.0",
"flags": "U",
"metric": 100,
"metric": 202,
"ref": 0,
"use": 0,
"iface": "ens33",
"mss": 0,
"window": 0,
"irtt": 0
"irtt": 0,
"flags_pretty": [
"UP"
]
}
]
$ route -ee | jc --route -p -r
[
{
"destination": "default",
"gateway": "gateway",
"gateway": "_gateway",
"genmask": "0.0.0.0",
"flags": "UG",
"metric": "100",
"metric": "202",
"ref": "0",
"use": "0",
"iface": "ens33",
@@ -69,25 +92,12 @@ Examples:
"window": "0",
"irtt": "0"
},
{
"destination": "172.17.0.0",
"gateway": "0.0.0.0",
"genmask": "255.255.0.0",
"flags": "U",
"metric": "0",
"ref": "0",
"use": "0",
"iface": "docker",
"mss": "0",
"window": "0",
"irtt": "0"
},
{
"destination": "192.168.71.0",
"gateway": "0.0.0.0",
"genmask": "255.255.255.0",
"flags": "U",
"metric": "100",
"metric": "202",
"ref": "0",
"use": "0",
"iface": "ens33",
@@ -97,41 +107,13 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"destination": string,
"gateway": string,
"genmask": string,
"flags": string,
"metric": integer,
"ref": integer,
"use": integer,
"mss": integer,
"window": integer,
"irtt": integer,
"iface": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -148,5 +130,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)

184
docs/parsers/rpm_qi.md Normal file
View File

@@ -0,0 +1,184 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.rpm_qi
jc - JSON CLI output utility `rpm -qi` command output parser
Works with `rpm -qi [package]` or `rpm -qia`.
The `..._epoch` calculated timestamp fields are naive (i.e. based on the local time of the system the parser is run on)
The `..._epoch_utc` calculated timestamp fields are timezone-aware and is only available if the timezone field is UTC.
Usage (cli):
$ rpm -qia | jc --rpm-qi
or
$ jc rpm -qia
Usage (module):
import jc.parsers.rpm_qi
result = jc.parsers.rpm_qi.parse(rpm_qi_command_output)
Schema:
[
{
"name": string,
"epoch": integer,
"version": string,
"release": string,
"architecture": string,
"install_date": string,
"install_date_epoch": integer, # naive timestamp
"install_date_epoch_utc": integer, # Aware timestamp if timezone is UTC
"group": string,
"size": integer,
"license": string,
"signature": string,
"source_rpm": string,
"build_date": string,
"build_epoch": integer, # naive timestamp
"build_epoch_utc": integer, # Aware timestamp if timezone is UTC
"build_host": string,
"relocations": string,
"packager": string,
"vendor": string,
"url": string,
"summary": string,
"description": string
}
]
Examples:
$ rpm -qia | jc --rpm-qi -p
[
{
"name": "make",
"epoch": 1,
"version": "3.82",
"release": "24.el7",
"architecture": "x86_64",
"install_date": "Wed 16 Oct 2019 09:21:42 AM PDT",
"group": "Development/Tools",
"size": 1160660,
"license": "GPLv2+",
"signature": "RSA/SHA256, Thu 22 Aug 2019 02:34:59 PM PDT, Key ID 24c6a8a7f4a80eb5",
"source_rpm": "make-3.82-24.el7.src.rpm",
"build_date": "Thu 08 Aug 2019 05:47:25 PM PDT",
"build_host": "x86-01.bsys.centos.org",
"relocations": "(not relocatable)",
"packager": "CentOS BuildSystem <http://bugs.centos.org>",
"vendor": "CentOS",
"url": "http://www.gnu.org/software/make/",
"summary": "A GNU tool which simplifies the build process for users",
"description": "A GNU tool for controlling the generation of executables and other...",
"build_epoch": 1565311645,
"build_epoch_utc": null,
"install_date_epoch": 1571242902,
"install_date_epoch_utc": null
},
{
"name": "kbd-legacy",
"version": "1.15.5",
"release": "15.el7",
"architecture": "noarch",
"install_date": "Thu 15 Aug 2019 10:53:08 AM PDT",
"group": "System Environment/Base",
"size": 503608,
"license": "GPLv2+",
"signature": "RSA/SHA256, Mon 12 Nov 2018 07:17:49 AM PST, Key ID 24c6a8a7f4a80eb5",
"source_rpm": "kbd-1.15.5-15.el7.src.rpm",
"build_date": "Tue 30 Oct 2018 03:40:00 PM PDT",
"build_host": "x86-01.bsys.centos.org",
"relocations": "(not relocatable)",
"packager": "CentOS BuildSystem <http://bugs.centos.org>",
"vendor": "CentOS",
"url": "http://ftp.altlinux.org/pub/people/legion/kbd",
"summary": "Legacy data for kbd package",
"description": "The kbd-legacy package contains original keymaps for kbd package...",
"build_epoch": 1540939200,
"build_epoch_utc": null,
"install_date_epoch": 1565891588,
"install_date_epoch_utc": null
},
...
]
$ rpm -qia | jc --rpm-qi -p -r
[
{
"name": "make",
"epoch": "1",
"version": "3.82",
"release": "24.el7",
"architecture": "x86_64",
"install_date": "Wed 16 Oct 2019 09:21:42 AM PDT",
"group": "Development/Tools",
"size": "1160660",
"license": "GPLv2+",
"signature": "RSA/SHA256, Thu 22 Aug 2019 02:34:59 PM PDT, Key ID 24c6a8a7f4a80eb5",
"source_rpm": "make-3.82-24.el7.src.rpm",
"build_date": "Thu 08 Aug 2019 05:47:25 PM PDT",
"build_host": "x86-01.bsys.centos.org",
"relocations": "(not relocatable)",
"packager": "CentOS BuildSystem <http://bugs.centos.org>",
"vendor": "CentOS",
"url": "http://www.gnu.org/software/make/",
"summary": "A GNU tool which simplifies the build process for users",
"description": "A GNU tool for controlling the generation of executables and other..."
},
{
"name": "kbd-legacy",
"version": "1.15.5",
"release": "15.el7",
"architecture": "noarch",
"install_date": "Thu 15 Aug 2019 10:53:08 AM PDT",
"group": "System Environment/Base",
"size": "503608",
"license": "GPLv2+",
"signature": "RSA/SHA256, Mon 12 Nov 2018 07:17:49 AM PST, Key ID 24c6a8a7f4a80eb5",
"source_rpm": "kbd-1.15.5-15.el7.src.rpm",
"build_date": "Tue 30 Oct 2018 03:40:00 PM PDT",
"build_host": "x86-01.bsys.centos.org",
"relocations": "(not relocatable)",
"packager": "CentOS BuildSystem <http://bugs.centos.org>",
"vendor": "CentOS",
"url": "http://ftp.altlinux.org/pub/people/legion/kbd",
"summary": "Legacy data for kbd package",
"description": "The kbd-legacy package contains original keymaps for kbd package..."
},
...
]
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,31 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.shadow
jc - JSON CLI output utility /etc/shadow file Parser
jc - JSON CLI output utility `/etc/shadow` file parser
Usage:
Usage (cli):
specify --shadow as the first argument if the piped input is coming from /etc/shadow
$ sudo cat /etc/shadow | jc --shadow
Compatibility:
Usage (module):
'linux', 'darwin', 'aix', 'freebsd'
import jc.parsers.shadow
result = jc.parsers.shadow.parse(shadow_file_output)
Schema:
[
{
"username": string,
"password": string,
"last_changed": integer,
"minimum": integer,
"maximum": integer,
"warn": integer,
"inactive": integer,
"expire": integer
}
]
Examples:
@@ -81,38 +99,12 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"username": string,
"password": string,
"last_changed": integer,
"minimum": integer,
"maximum": integer,
"warn": integer,
"inactive": integer,
"expire": integer
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -129,5 +121,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, aix, freebsd
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,17 +1,46 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.ss
jc - JSON CLI output utility ss Parser
jc - JSON CLI output utility `ss` command output parser
Usage:
Extended information options like -e and -p are not supported and may cause parsing irregularities.
specify --ss as the first argument if the piped input is coming from ss
Usage (cli):
Limitations:
$ ss | jc --ss
Extended information options like -e and -p are not supported and may cause parsing irregularities
or
Compatibility:
$ jc ss
'linux'
Usage (module):
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 field names
[
{
"netid": string,
"state": string,
"recv_q": integer,
"send_q": integer,
"local_address": string,
"local_port": string,
"local_port_num": integer,
"peer_address": string,
"peer_port": string,
"peer_port_num": integer,
"interface": string,
"link_layer" string,
"channel": string,
"path": string,
"pid": integer
}
]
Examples:
@@ -247,47 +276,12 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"netid": string,
"state": string,
"recv_q": integer,
"send_q": integer,
"local_address": string,
"local_port": string,
"local_port_num": integer,
"peer_address": string,
"peer_port": string,
"peer_port_num": integer,
"interface": string,
"link_layer" string,
"channel": string,
"path": string,
"pid": integer
}
]
Information from https://www.cyberciti.biz/files/ss.html used to define field names
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -304,5 +298,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,62 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.stat
jc - JSON CLI output utility stat Parser
jc - JSON CLI output utility `stat` command output parser
Usage:
The `xxx_epoch` calculated timestamp fields are naive (i.e. based on the local time of the system the parser is run on)
specify --stat as the first argument if the piped input is coming from stat
The `xxx_epoch_utc` calculated timestamp fields are timezone-aware and are only available if the timezone field is UTC.
Compatibility:
Usage (cli):
'linux'
$ stat * | jc --stat
or
$ jc stat *
Usage (module):
import jc.parsers.stat
result = jc.parsers.stat.parse(stat_command_output)
Schema:
[
{
"file": string,
"link_to" string,
"size": integer,
"blocks": integer,
"io_blocks": integer,
"type": string,
"device": string,
"inode": integer,
"links": integer,
"access": string,
"flags": string,
"uid": integer,
"user": string,
"gid": integer,
"group": string,
"access_time": string, # - = null
"access_time_epoch": integer, # naive timestamp
"access_time_epoch_utc": integer, # timezone-aware timestamp
"modify_time": string, # - = null
"modify_time_epoch": integer, # naive timestamp
"modify_time_epoch_utc": integer, # timezone-aware timestamp
"change_time": string, # - = null
"change_time_epoch": integer, # naive timestamp
"change_time_epoch_utc": integer, # timezone-aware timestamp
"birth_time": string, # - = null
"birth_time_epoch": integer, # naive timestamp
"birth_time_epoch_utc": integer, # timezone-aware timestamp
"unix_device": integer,
"rdev": integer,
"block_size": integer,
"unix_flags": string
}
]
Examples:
@@ -31,7 +80,15 @@ Examples:
"access_time": "2019-11-14 08:18:03.509681766 +0000",
"modify_time": "2019-06-06 22:28:15.000000000 +0000",
"change_time": "2019-08-12 17:21:29.521945390 +0000",
"birth_time": null
"birth_time": null,
"access_time_epoch": 1573748283,
"access_time_epoch_utc": 1573719483,
"modify_time_epoch": 1559885295,
"modify_time_epoch_utc": 1559860095,
"change_time_epoch": 1565655689,
"change_time_epoch_utc": 1565630489,
"birth_time_epoch": null,
"birth_time_epoch_utc": null
},
{
"file": "/bin/btrfs",
@@ -51,7 +108,15 @@ Examples:
"access_time": "2019-11-14 08:18:28.990834276 +0000",
"modify_time": "2018-03-12 23:04:27.000000000 +0000",
"change_time": "2019-08-12 17:21:29.545944399 +0000",
"birth_time": null
"birth_time": null,
"access_time_epoch": 1573748308,
"access_time_epoch_utc": 1573719508,
"modify_time_epoch": 1520921067,
"modify_time_epoch_utc": 1520895867,
"change_time_epoch": 1565655689,
"change_time_epoch_utc": 1565630489,
"birth_time_epoch": null,
"birth_time_epoch_utc": null
},
...
]
@@ -98,52 +163,15 @@ Examples:
"change_time": "2019-08-12 17:21:29.545944399 +0000",
"birth_time": null
},
..
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"file": string,
"link_to" string,
"size": integer,
"blocks": integer,
"io_blocks": integer,
"type": string,
"device": string,
"inode": integer,
"links": integer,
"access": string,
"flags": string,
"uid": integer,
"user": string,
"gid": integer,
"group": string,
"access_time": string, # - = null
"modify_time": string, # - = null
"change_time": string, # - = null
"birth_time": string # - = null
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -160,5 +188,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, freebsd
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)

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

@@ -0,0 +1,82 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.sysctl
jc - JSON CLI output utility `sysctl -a` command output parser
Note: Since `sysctl` output is not easily parsable only a very simple key/value object will be output. An attempt is made to convert obvious integers and floats. If no conversion is desired, use the `-r` command-line argument or the `raw=True` argument in `parse()`.
Usage (cli):
$ sysctl -a | jc --sysctl
or
$ jc sysctl -a
Usage (module):
import jc.parsers.sysctl
result = jc.parsers.sysctl.parse(sysctl_command_output)
Schema:
{
"key1": string/integer/float, # best guess based on value
"key2": string/integer/float,
"key3": string/integer/float
}
Examples:
$ sysctl -a | jc --sysctl -p
{
"user.cs_path": "/usr/bin:/bin:/usr/sbin:/sbin",
"user.bc_base_max": 99,
"user.bc_dim_max": 2048,
"user.bc_scale_max": 99,
"user.bc_string_max": 1000,
"user.coll_weights_max": 2,
"user.expr_nest_max": 32
...
}
$ sysctl -a | jc --sysctl -p -r
{
"user.cs_path": "/usr/bin:/bin:/usr/sbin:/sbin",
"user.bc_base_max": "99",
"user.bc_dim_max": "2048",
"user.bc_scale_max": "99",
"user.bc_string_max": "1000",
"user.coll_weights_max": "2",
"user.expr_nest_max": "32",
...
}
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, freebsd
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,32 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.systemctl
jc - JSON CLI output utility systemctl Parser
jc - JSON CLI output utility `systemctl` command output parser
Usage:
Usage (cli):
specify --systemctl as the first argument if the piped input is coming from systemctl
$ systemctl | jc --systemctl
Compatibility:
or
'linux'
$ jc systemctl
Usage (module):
import jc.parsers.systemctl
result = jc.parsers.systemctl.parse(systemctl_command_output)
Schema:
[
{
"unit": string,
"load": string,
"active": string,
"sub": string,
"description": string
}
]
Examples:
@@ -37,35 +56,12 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"unit": string,
"load": string,
"active": string,
"sub": string,
"description": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -82,5 +78,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,31 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.systemctl_lj
jc - JSON CLI output utility systemctl-lj Parser
jc - JSON CLI output utility `systemctl list-jobs` command output parser
Usage:
Usage (cli):
specify --systemctl-lj as the first argument if the piped input is coming from systemctl list-jobs
$ systemctl list-jobs | jc --systemctl-lj
Compatibility:
or
'linux'
$ jc systemctl list-jobs
Usage (module):
import jc.parsers.systemctl_lj
result = jc.parsers.systemctl_lj.parse(systemctl_lj_command_output)
Schema:
[
{
"job": integer,
"unit": string,
"type": string,
"state": string
}
]
Examples:
@@ -58,32 +76,9 @@ Examples:
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"job": integer,
"unit": string,
"type": string,
"state": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -100,5 +95,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,30 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.systemctl_ls
jc - JSON CLI output utility systemctl-ls Parser
jc - JSON CLI output utility `systemctl list-sockets` command output parser
Usage:
Usage (cli):
specify --systemctl-ls as the first argument if the piped input is coming from systemctl list-sockets
$ systemctl list-sockets | jc --systemctl-ls
Compatibility:
or
'linux'
$ jc systemctl list-sockets
Usage (module):
import jc.parsers.systemctl_ls
result = jc.parsers.systemctl_ls.parse(systemctl_ls_command_output)
Schema:
[
{
"listen": string,
"unit": string,
"activates": string
}
]
Examples:
@@ -31,33 +48,12 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"listen": string,
"unit": string,
"activates": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -74,5 +70,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,29 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.systemctl_luf
jc - JSON CLI output utility systemctl-luf Parser
jc - JSON CLI output utility `systemctl list-unit-files` command output parser
Usage:
Usage (cli):
specify --systemctl-luf as the first argument if the piped input is coming from systemctl list-unit-files
$ systemctl list-unit-files | jc --systemctl-luf
Compatibility:
or
'linux'
$ jc systemctl list-unit-files
Usage (module):
import jc.parsers.systemctl_luf
result = jc.parsers.systemctl_luf.parse(systemctl_luf_command_output)
Schema:
[
{
"unit_file": string,
"state": string
}
]
Examples:
@@ -28,32 +44,12 @@ Examples:
...
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"unit_file": string,
"state": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -70,5 +66,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

232
docs/parsers/systeminfo.md Normal file
View File

@@ -0,0 +1,232 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.systeminfo
jc - JSON CLI output utility `systeminfo` command output parser
Blank or missing elements are set to `null`.
The `original_install_date_epoch` and `system_boot_time_epoch` calculated timestamp fields are naive (i.e. based on the local time of the system the parser is run on)
The `original_install_date_epoch_utc` and `system_boot_time_epoch_utc` calculated timestamp fields are timezone-aware and are only available if the timezone field is UTC.
Usage (cli):
$ systeminfo | jc --systeminfo
Usage (module):
import jc.parsers.systeminfo
result = jc.parsers.systeminfo.parse(systeminfo_command_output)
Schema:
{
"host_name": string,
"os_name": string,
"os_version": string,
"os_manufacturer": string,
"os_configuration": string,
"os_build_type": string,
"registered_owner": string,
"registered_organization": string,
"product_id": string,
"original_install_date": string,
"original_install_date_epoch": integer, # naive timestamp
"original_install_date_epoch_utc": integer, # timezone-aware timestamp
"system_boot_time": string,
"system_boot_time_epoch": integer, # naive timestamp
"system_boot_time_epoch_utc": integer, # timezone-aware timestamp
"system_manufacturer": string,
"system_model": string,
"system_type": string,
"processors": [
string
],
"bios_version": string,
"windows_directory": string,
"system_directory": string,
"boot_device": string,
"system_locale": string,
"input_locale": string,
"time_zone": string,
"total_physical_memory_mb": string,
"available_physical_memory_mb": integer,
"virtual_memory_max_size_mb": integer,
"virtual_memory_available_mb": integer,
"virtual_memory_in_use_mb": integer,
"page_file_locations": string,
"domain": string,
"logon_server": string,
"hotfixs": [
string
],
"network_cards": [
{
"name": string,
"connection_name": string,
"status": string,
"dhcp_enabled": boolean,
"dhcp_server": string,
"ip_addresses": [
string
]
}
],
"hyperv_requirements": {
"vm_monitor_mode_extensions": boolean,
"virtualization_enabled_in_firmware": boolean,
"second_level_address_translation": boolean,
"data_execution_prevention_available": boolean
}
}
Examples:
$ systeminfo | jc --systeminfo -p
{
"host_name": "TESTLAPTOP",
"os_name": "Microsoft Windows 10 Enterprise",
"os_version": "10.0.17134 N/A Build 17134",
"os_manufacturer": "Microsoft Corporation",
"os_configuration": "Member Workstation",
"os_build_type": "Multiprocessor Free",
"registered_owner": "Test, Inc.",
"registered_organization": "Test, Inc.",
"product_id": "11111-11111-11111-AA111",
"original_install_date": "3/26/2019, 3:51:30 PM",
"system_boot_time": "3/30/2021, 6:13:59 AM",
"system_manufacturer": "Dell Inc.",
"system_model": "Precision 5530",
"system_type": "x64-based PC",
"processors": [
"Intel64 Family 6 Model 158 Stepping 10 GenuineIntel ~2592 Mhz"
],
"bios_version": "Dell Inc. 1.16.2, 4/21/2020",
"windows_directory": "C:\WINDOWS",
"system_directory": "C:\WINDOWS\system32",
"boot_device": "\Device\HarddiskVolume2",
"system_locale": "en-us;English (United States)",
"input_locale": "en-us;English (United States)",
"time_zone": "(UTC+00:00) UTC",
"total_physical_memory_mb": 32503,
"available_physical_memory_mb": 19743,
"virtual_memory_max_size_mb": 37367,
"virtual_memory_available_mb": 22266,
"virtual_memory_in_use_mb": 15101,
"page_file_locations": "C:\pagefile.sys",
"domain": "test.com",
"logon_server": "\\TESTDC01",
"hotfixs": [
"KB2693643",
"KB4601054"
],
"network_cards": [
{
"name": "Intel(R) Wireless-AC 9260 160MHz",
"connection_name": "Wi-Fi",
"status": null,
"dhcp_enabled": true,
"dhcp_server": "192.168.2.1",
"ip_addresses": [
"192.168.2.219"
]
}
],
"hyperv_requirements": {
"vm_monitor_mode_extensions": true,
"virtualization_enabled_in_firmware": true,
"second_level_address_translation": false,
"data_execution_prevention_available": true
},
"original_install_date_epoch": 1553640690,
"original_install_date_epoch_utc": 1553615490,
"system_boot_time_epoch": 1617110039,
"system_boot_time_epoch_utc": 1617084839
}
$ systeminfo | jc --systeminfo -p -r
{
"host_name": "TESTLAPTOP",
"os_name": "Microsoft Windows 10 Enterprise",
"os_version": "10.0.17134 N/A Build 17134",
"os_manufacturer": "Microsoft Corporation",
"os_configuration": "Member Workstation",
"os_build_type": "Multiprocessor Free",
"registered_owner": "Test, Inc.",
"registered_organization": "Test, Inc.",
"product_id": "11111-11111-11111-AA111",
"original_install_date": "3/26/2019, 3:51:30 PM",
"system_boot_time": "3/30/2021, 6:13:59 AM",
"system_manufacturer": "Dell Inc.",
"system_model": "Precision 5530",
"system_type": "x64-based PC",
"processors": [
"Intel64 Family 6 Model 158 Stepping 10 GenuineIntel ~2592 Mhz"
],
"bios_version": "Dell Inc. 1.16.2, 4/21/2020",
"windows_directory": "C:\WINDOWS",
"system_directory": "C:\WINDOWS\system32",
"boot_device": "\Device\HarddiskVolume2",
"system_locale": "en-us;English (United States)",
"input_locale": "en-us;English (United States)",
"time_zone": "(UTC+00:00) UTC",
"total_physical_memory_mb": "32,503 MB",
"available_physical_memory_mb": "19,743 MB",
"virtual_memory_max_size_mb": "37,367 MB",
"virtual_memory_available_mb": "22,266 MB",
"virtual_memory_in_use_mb": "15,101 MB",
"page_file_locations": "C:\pagefile.sys",
"domain": "test.com",
"logon_server": "\\TESTDC01",
"hotfixs": [
"KB2693643",
"KB4601054"
],
"network_cards": [
{
"name": "Intel(R) Wireless-AC 9260 160MHz",
"connection_name": "Wi-Fi",
"status": "",
"dhcp_enabled": "Yes",
"dhcp_server": "192.168.2.1",
"ip_addresses": [
"192.168.2.219"
]
}
],
"hyperv_requirements": {
"vm_monitor_mode_extensions": "Yes",
"virtualization_enabled_in_firmware": "Yes",
"second_level_address_translation": "No",
"data_execution_prevention_available": "Yes"
}
}
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: win32
Version 1.0 by Jon Smith (jon@rebelliondefense.com)

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

@@ -0,0 +1,151 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.time
jc - JSON CLI output utility `/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`.
Alternatively, the output from `/usr/bin/time` can be redirected to `STDOUT` so `jc` can receive it.
Note: `/usr/bin/time` is similar but different from the Bash builtin `time` command.
Usage (cli):
$ /usr/bin/time -o timefile.out sleep 2.5; cat timefile.out | jc --time -p
Usage (module):
import jc.parsers.time
result = jc.parsers.time.parse(time_command_output)
Schema:
Source: https://www.freebsd.org/cgi/man.cgi?query=getrusage
https://man7.org/linux/man-pages/man1/time.1.html
{
"real_time": float,
"user_time": float,
"system_time": float,
"elapsed_time": string,
"elapsed_time_hours": integer,
"elapsed_time_minutes": integer,
"elapsed_time_seconds": integer,
"elapsed_time_centiseconds": integer,
"elapsed_time_total_seconds": float,
"cpu_percent": integer, # null if ?
"average_shared_text_size": integer,
"average_unshared_data_size": integer,
"average_unshared_stack_size": integer,
"average_shared_memory_size": integer,
"maximum_resident_set_size": integer,
"block_input_operations": integer, # aka File system inputs
"block_output_operations": integer, # aka File system outputs
"major_pagefaults": integer,
"minor_pagefaults": integer,
"swaps": integer,
"page_reclaims": integer,
"page_faults": integer,
"messages_sent": integer,
"messages_received": integer,
"signals_received": integer,
"voluntary_context_switches": integer,
"involuntary_context_switches": integer
"command_being_timed": string,
"average_stack_size": integer,
"average_total_size": integer,
"average_resident_set_size": integer,
"signals_delivered": integer,
"page_size": integer,
"exit_status": integer
}
Examples:
$ /usr/bin/time --verbose -o timefile.out sleep 2.5; cat timefile.out | jc --time -p
{
"command_being_timed": "sleep 2.5",
"user_time": 0.0,
"system_time": 0.0,
"cpu_percent": 0,
"elapsed_time": "0:02.50",
"average_shared_text_size": 0,
"average_unshared_data_size": 0,
"average_stack_size": 0,
"average_total_size": 0,
"maximum_resident_set_size": 2084,
"average_resident_set_size": 0,
"major_pagefaults": 0,
"minor_pagefaults": 72,
"voluntary_context_switches": 2,
"involuntary_context_switches": 1,
"swaps": 0,
"block_input_operations": 0,
"block_output_operations": 0,
"messages_sent": 0,
"messages_received": 0,
"signals_delivered": 0,
"page_size": 4096,
"exit_status": 0,
"elapsed_time_hours": 0,
"elapsed_time_minutes": 0,
"elapsed_time_seconds": 2,
"elapsed_time_centiseconds": 50,
"elapsed_time_total_seconds": 2.5
}
$ /usr/bin/time --verbose -o timefile.out sleep 2.5; cat timefile.out | jc --time -p -r
{
"command_being_timed": ""sleep 2.5"",
"user_time": "0.00",
"system_time": "0.00",
"cpu_percent": "0",
"elapsed_time": "0:02.50",
"average_shared_text_size": "0",
"average_unshared_data_size": "0",
"average_stack_size": "0",
"average_total_size": "0",
"maximum_resident_set_size": "2084",
"average_resident_set_size": "0",
"major_pagefaults": "0",
"minor_pagefaults": "72",
"voluntary_context_switches": "2",
"involuntary_context_switches": "0",
"swaps": "0",
"block_input_operations": "0",
"block_output_operations": "0",
"messages_sent": "0",
"messages_received": "0",
"signals_delivered": "0",
"page_size": "4096",
"exit_status": "0"
}
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -0,0 +1,91 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.timedatectl
jc - JSON CLI output utility `timedatectl` command output parser
The `epoch_utc` calculated timestamp field is timezone-aware and is only available if the `universal_time` field is available.
Usage (cli):
$ timedatectl | jc --timedatectl
or
$ jc timedatectl
Usage (module):
import jc.parsers.timedatectl
result = jc.parsers.timedatectl.parse(timedatectl_command_output)
Schema:
{
"local_time": string,
"universal_time": string,
"epoch_utc": integer, # timezone-aware timestamp
"rtc_time": string,
"time_zone": string,
"ntp_enabled": boolean,
"ntp_synchronized": boolean,
"system_clock_synchronized": boolean,
"systemd-timesyncd.service_active": boolean,
"rtc_in_local_tz": boolean,
"dst_active": boolean
}
Examples:
$ timedatectl | jc --timedatectl -p
{
"local_time": "Tue 2020-03-10 17:53:21 PDT",
"universal_time": "Wed 2020-03-11 00:53:21 UTC",
"rtc_time": "Wed 2020-03-11 00:53:21",
"time_zone": "America/Los_Angeles (PDT, -0700)",
"ntp_enabled": true,
"ntp_synchronized": true,
"rtc_in_local_tz": false,
"dst_active": true,
"epoch_utc": 1583888001
}
$ timedatectl | jc --timedatectl -p -r
{
"local_time": "Tue 2020-03-10 17:53:21 PDT",
"universal_time": "Wed 2020-03-11 00:53:21 UTC",
"rtc_time": "Wed 2020-03-11 00:53:21",
"time_zone": "America/Los_Angeles (PDT, -0700)",
"ntp_enabled": "yes",
"ntp_synchronized": "yes",
"rtc_in_local_tz": "no",
"dst_active": "yes"
}
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

159
docs/parsers/tracepath.md Normal file
View File

@@ -0,0 +1,159 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.tracepath
jc - JSON CLI output utility `tracepath` command output parser
Supports `tracepath` and `tracepath6` output.
Usage (cli):
$ tracepath 1.2.3.4 | jc --tracepath
or
$ jc tracepath 1.2.3.4
Usage (module):
import jc.parsers.tracepath
result = jc.parsers.tracepath.parse(tracepath_command_output)
Schema:
{
"pmtu": integer,
"forward_hops": integer,
"return_hops": integer,
"hops": [
{
"ttl": integer,
"guess": boolean,
"host": string,
"reply_ms": float,
"pmtu": integer,
"asymmetric_difference": integer,
"reached": boolean
}
]
}
Examples:
$ tracepath6 3ffe:2400:0:109::2 | jc --tracepath -p
{
"pmtu": 1480,
"forward_hops": 2,
"return_hops": 2,
"hops": [
{
"ttl": 1,
"guess": true,
"host": "[LOCALHOST]",
"reply_ms": null,
"pmtu": 1500,
"asymmetric_difference": null,
"reached": false
},
{
"ttl": 1,
"guess": false,
"host": "dust.inr.ac.ru",
"reply_ms": 0.411,
"pmtu": null,
"asymmetric_difference": null,
"reached": false
},
{
"ttl": 2,
"guess": false,
"host": "dust.inr.ac.ru",
"reply_ms": 0.39,
"pmtu": 1480,
"asymmetric_difference": 1,
"reached": false
},
{
"ttl": 2,
"guess": false,
"host": "3ffe:2400:0:109::2",
"reply_ms": 463.514,
"pmtu": null,
"asymmetric_difference": null,
"reached": true
}
]
}
$ tracepath6 3ffe:2400:0:109::2 | jc --tracepath -p -r
{
"pmtu": "1480",
"forward_hops": "2",
"return_hops": "2",
"hops": [
{
"ttl": "1",
"guess": true,
"host": "[LOCALHOST]",
"reply_ms": null,
"pmtu": "1500",
"asymmetric_difference": null,
"reached": false
},
{
"ttl": "1",
"guess": false,
"host": "dust.inr.ac.ru",
"reply_ms": "0.411",
"pmtu": null,
"asymmetric_difference": null,
"reached": false
},
{
"ttl": "2",
"guess": false,
"host": "dust.inr.ac.ru",
"reply_ms": "0.390",
"pmtu": "1480",
"asymmetric_difference": "1",
"reached": false
},
{
"ttl": "2",
"guess": false,
"host": "3ffe:2400:0:109::2",
"reply_ms": "463.514",
"pmtu": null,
"asymmetric_difference": null,
"reached": true
}
]
}
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

145
docs/parsers/traceroute.md Normal file
View File

@@ -0,0 +1,145 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.traceroute
jc - JSON CLI output utility `traceroute` command output parser
Supports `traceroute` and `traceroute6` output.
Note: On some operating systems you will need to redirect `STDERR` to `STDOUT` for destination info since the header line is sent to `STDERR`. A warning message will be printed to `STDERR` if the header row is not found.
e.g. `$ traceroute 8.8.8.8 2>&1 | jc --traceroute`
Usage (cli):
$ traceroute 1.2.3.4 | jc --traceroute
or
$ jc traceroute 1.2.3.4
Usage (module):
import jc.parsers.traceroute
result = jc.parsers.traceroute.parse(traceroute_command_output)
Schema:
{
"destination_ip": string,
"destination_name": string,
"hops": [
{
"hop": integer,
"probes": [
{
"annotation": string,
"asn": integer,
"ip": string,
"name": string,
"rtt": float
}
]
}
]
}
Examples:
$ traceroute google.com | jc --traceroute -p
{
"destination_ip": "216.58.194.46",
"destination_name": "google.com",
"hops": [
{
"hop": 1,
"probes": [
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": 198.574
},
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": null
},
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": 198.65
}
]
},
...
]
}
$ traceroute google.com | jc --traceroute -p -r
{
"destination_ip": "216.58.194.46",
"destination_name": "google.com",
"hops": [
{
"hop": "1",
"probes": [
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": "198.574"
},
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": null
},
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": "198.650"
}
]
},
...
]
}
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, freebsd
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)

225
docs/parsers/ufw.md Normal file
View File

@@ -0,0 +1,225 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.ufw
jc - JSON CLI output utility `ufw status` command output parser
Usage (cli):
$ ufw status | jc --ufw
or
$ jc ufw status
Usage (module):
import jc.parsers.ufw
result = jc.parsers.ufw.parse(ufw_command_output)
Schema:
{
"status": string,
"logging": string,
"logging_level": string,
"default": string,
"new_profiles": string,
"rules": [
{
"action": string,
"action_direction": string, # null if blank
"index": integer, # null if blank
"network_protocol": string,
"to_ip": string,
"to_ip_prefix": integer,
"to_interface": string,
"to_transport": string,
"to_ports": [
integer
],
"to_port_ranges": [
{
"start": integer,
"end": integer
}
],
"to_service": string, # null if any to ports or port_ranges are set
"from_ip": string,
"from_ip_prefix": integer,
"from_interface": string,
"from_transport": string,
"from_ports": [
integer
],
"from_port_ranges": [
{
"start": integer,
"end": integer
}
],
"from_service": string, # null if any from ports or port_ranges are set
"comment": string # null if no comment
}
]
}
Examples:
$ ufw status verbose | jc --ufw -p
{
"status": "active",
"logging": "on",
"logging_level": "low",
"default": "deny (incoming), allow (outgoing), disabled (routed)",
"new_profiles": "skip",
"rules": [
{
"action": "ALLOW",
"action_direction": "IN",
"index": null,
"network_protocol": "ipv4",
"to_interface": "any",
"to_transport": "any",
"to_service": null,
"to_ports": [
22
],
"to_ip": "0.0.0.0",
"to_ip_prefix": 0,
"comment": null,
"from_ip": "0.0.0.0",
"from_ip_prefix": 0,
"from_interface": "any",
"from_transport": "any",
"from_port_ranges": [
{
"start": 0,
"end": 65535
}
],
"from_service": null
},
{
"action": "ALLOW",
"action_direction": "IN",
"index": null,
"network_protocol": "ipv4",
"to_interface": "any",
"to_transport": "tcp",
"to_service": null,
"to_ports": [
80,
443
],
"to_ip": "0.0.0.0",
"to_ip_prefix": 0,
"comment": null,
"from_ip": "0.0.0.0",
"from_ip_prefix": 0,
"from_interface": "any",
"from_transport": "any",
"from_port_ranges": [
{
"start": 0,
"end": 65535
}
],
"from_service": null
},
...
]
}
$ ufw status verbose | jc --ufw -p -r
{
"status": "active",
"logging": "on",
"logging_level": "low",
"default": "deny (incoming), allow (outgoing), disabled (routed)",
"new_profiles": "skip",
"rules": [
{
"action": "ALLOW",
"action_direction": "IN",
"index": null,
"network_protocol": "ipv4",
"to_interface": "any",
"to_transport": "any",
"to_service": null,
"to_ports": [
"22"
],
"to_ip": "0.0.0.0",
"to_ip_prefix": "0",
"comment": null,
"from_ip": "0.0.0.0",
"from_ip_prefix": "0",
"from_interface": "any",
"from_transport": "any",
"from_port_ranges": [
{
"start": "0",
"end": "65535"
}
],
"from_service": null
},
{
"action": "ALLOW",
"action_direction": "IN",
"index": null,
"network_protocol": "ipv4",
"to_interface": "any",
"to_transport": "tcp",
"to_service": null,
"to_ports": [
"80",
"443"
],
"to_ip": "0.0.0.0",
"to_ip_prefix": "0",
"comment": null,
"from_ip": "0.0.0.0",
"from_ip_prefix": "0",
"from_interface": "any",
"from_transport": "any",
"from_port_ranges": [
{
"start": "0",
"end": "65535"
}
],
"from_service": null
},
...
]
}
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

158
docs/parsers/ufw_appinfo.md Normal file
View File

@@ -0,0 +1,158 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.ufw_appinfo
jc - JSON CLI output utility `ufw app info [application]` command output parser
Supports individual apps via `ufw app info [application]` and all apps list via `ufw app info all`.
Because `ufw` application definitions allow overlapping ports and port ranges, this parser preserves that behavior, but also provides `normalized` lists and ranges that remove duplicate ports and merge overlapping ranges.
Usage (cli):
$ ufw app info OpenSSH | jc --ufw-appinfo
or
$ jc ufw app info OpenSSH
Usage (module):
import jc.parsers.ufw_appinfo
result = jc.parsers.ufw_appinfo.parse(ufw_appinfo_command_output)
Schema:
[
{
"profile": string,
"title": string,
"description": string,
"tcp_list": [
integer
],
"tcp_ranges": [
{
"start": integer, # 'any' is converted to start/end: 0/65535
"end": integer
}
],
"udp_list": [
integer
],
"udp_ranges": [
{
"start": integer, # 'any' is converted to start/end: 0/65535
"end": integer
}
],
"normalized_tcp_list": [
integers # duplicates and overlapping are removed
],
"normalized_tcp_ranges": [
{
"start": integer, # 'any' is converted to start/end: 0/65535
"end": integers # overlapping are merged
}
],
"normalized_udp_list": [
integers # duplicates and overlapping are removed
],
"normalized_udp_ranges": [
{
"start": integer, # 'any' is converted to start/end: 0/65535
"end": integers # overlapping are merged
}
]
}
]
Examples:
$ ufw app info MSN | jc --ufw-appinfo -p
[
{
"profile": "MSN",
"title": "MSN Chat",
"description": "MSN chat protocol (with file transfer and voice)",
"tcp_list": [
1863,
6901
],
"udp_list": [
1863,
6901
],
"tcp_ranges": [
{
"start": 6891,
"end": 6900
}
],
"normalized_tcp_list": [
1863,
6901
],
"normalized_tcp_ranges": [
{
"start": 6891,
"end": 6900
}
],
"normalized_udp_list": [
1863,
6901
]
}
]
$ ufw app info MSN | jc --ufw-appinfo -p -r
[
{
"profile": "MSN",
"title": "MSN Chat",
"description": "MSN chat protocol (with file transfer and voice)",
"tcp_list": [
"1863",
"6901"
],
"udp_list": [
"1863",
"6901"
],
"tcp_ranges": [
{
"start": "6891",
"end": "6900"
}
]
}
]
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,17 +1,35 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.uname
jc - JSON CLI output utility uname Parser
jc - JSON CLI output utility `uname -a` command output parser
Usage:
Note: Must use `uname -a`
specify --uname as the first argument if the piped input is coming from uname
Usage (cli):
Limitations:
$ uname -a | jc --uname
must use 'uname -a'
or
Compatibility:
$ jc uname -a
'linux', 'darwin'
Usage (module):
import jc.parsers.uname
result = jc.parsers.uname.parse(uname_command_output)
Schema:
{
"kernel_name": string,
"node_name": string,
"kernel_release": string,
"operating_system": string,
"hardware_platform": string,
"processor": string,
"machine": string,
"kernel_version": string
}
Example:
@@ -27,36 +45,12 @@ Example:
"kernel_version": "#74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019"
}
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
Dictionary. Structured data with the following schema:
{
"kernel_name": string,
"node_name": string,
"kernel_release": string,
"operating_system": string,
"hardware_platform": string,
"processor": string,
"machine": string,
"kernel_version": string
}
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -75,3 +69,7 @@ Returns:
Dictionary. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, freebsd
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

222
docs/parsers/upower.md Normal file
View File

@@ -0,0 +1,222 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.upower
jc - JSON CLI output utility `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)
The `updated_epoch_utc` calculated timestamp field is timezone-aware and is only available if the timezone field is UTC.
Usage (cli):
$ upower -d | jc --upower
or
$ jc upower -d
Usage (module):
import jc.parsers.upower
result = jc.parsers.upower.parse(upower_command_output)
Schema:
[
{
"type": string,
"device_name": string,
"native_path": string,
"power_supply": boolean,
"updated": string,
"updated_epoch": integer, # null if date-time conversion fails
"updated_epoch_utc": integer, # null if date-time conversion fails
"updated_seconds_ago": integer,
"has_history": boolean,
"has_statistics": boolean,
"detail": {
"type": string,
"warning_level": string, # null if none
"online": boolean,
"icon_name": string
"present": boolean,
"rechargeable": boolean,
"state": string,
"energy": float,
"energy_unit": string,
"energy_empty": float,
"energy_empty_unit": string,
"energy_full": float,
"energy_full_unit": string,
"energy_full_design": float,
"energy_full_design_unit": string,
"energy_rate": float,
"energy_rate_unit": string,
"voltage": float,
"voltage_unit": string,
"time_to_full": float,
"time_to_full_unit": string,
"percentage": float,
"capacity": float,
"technology": string
},
"history_charge": [
{
"time": integer,
"percent_charged": float,
"status": string
}
],
"history_rate":[
{
"time": integer,
"percent_charged": float,
"status": string
}
],
"daemon_version": string,
"on_battery": boolean,
"lid_is_closed": boolean,
"lid_is_present": boolean,
"critical_action": string
}
]
Examples:
$ upower -i /org/freedesktop/UPower/devices/battery | jc --upower -p
[
{
"native_path": "/sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0",
"vendor": "NOTEBOOK",
"model": "BAT",
"serial": "0001",
"power_supply": true,
"updated": "Thu 11 Mar 2021 06:28:08 PM UTC",
"has_history": true,
"has_statistics": true,
"detail": {
"type": "battery",
"present": true,
"rechargeable": true,
"state": "charging",
"energy": 22.3998,
"energy_empty": 0.0,
"energy_full": 52.6473,
"energy_full_design": 62.16,
"energy_rate": 31.6905,
"voltage": 12.191,
"time_to_full": 57.3,
"percentage": 42.5469,
"capacity": 84.6964,
"technology": "lithium-ion",
"energy_unit": "Wh",
"energy_empty_unit": "Wh",
"energy_full_unit": "Wh",
"energy_full_design_unit": "Wh",
"energy_rate_unit": "W",
"voltage_unit": "V",
"time_to_full_unit": "minutes"
},
"history_charge": [
{
"time": 1328809335,
"percent_charged": 42.547,
"status": "charging"
},
{
"time": 1328809305,
"percent_charged": 42.02,
"status": "charging"
}
],
"history_rate": [
{
"time": 1328809335,
"percent_charged": 31.691,
"status": "charging"
}
],
"updated_seconds_ago": 441975,
"updated_epoch": 1615516088,
"updated_epoch_utc": 1615487288
}
]
$ upower -i /org/freedesktop/UPower/devices/battery | jc --upower -p -r
[
{
"native_path": "/sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0",
"vendor": "NOTEBOOK",
"model": "BAT",
"serial": "0001",
"power_supply": "yes",
"updated": "Thu 11 Mar 2021 06:28:08 PM UTC (441975 seconds ago)",
"has_history": "yes",
"has_statistics": "yes",
"detail": {
"type": "battery",
"present": "yes",
"rechargeable": "yes",
"state": "charging",
"energy": "22.3998 Wh",
"energy_empty": "0 Wh",
"energy_full": "52.6473 Wh",
"energy_full_design": "62.16 Wh",
"energy_rate": "31.6905 W",
"voltage": "12.191 V",
"time_to_full": "57.3 minutes",
"percentage": "42.5469%",
"capacity": "84.6964%",
"technology": "lithium-ion"
},
"history_charge": [
{
"time": "1328809335",
"percent_charged": "42.547",
"status": "charging"
},
{
"time": "1328809305",
"percent_charged": "42.020",
"status": "charging"
}
],
"history_rate": [
{
"time": "1328809335",
"percent_charged": "31.691",
"status": "charging"
}
]
}
]
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,64 +1,74 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.uptime
jc - JSON CLI output utility uptime Parser
jc - JSON CLI output utility `uptime` command output parser
Usage:
Usage (cli):
specify --uptime as the first argument if the piped input is coming from uptime
$ uptime | jc --uptime
Compatibility:
or
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
$ jc uptime
Usage (module):
import jc.parsers.uptime
result = jc.parsers.uptime.parse(uptime_command_output)
Schema:
{
"time": string,
"time_hour": integer,
"time_minute": integer,
"time_second": integer, # null if not displayed
"uptime": string,
"uptime_days": integer,
"uptime_hours": integer,
"uptime_minutes": integer,
"uptime_total_seconds": integer,
"users": integer,
"load_1m": float,
"load_5m": float,
"load_15m": float
}
Example:
$ uptime | jc --uptime -p
{
"time": "11:30:44",
"uptime": "1 day, 21:17",
"users": 1,
"load_1m": 0.01,
"load_5m": 0.04,
"load_15m": 0.05
"time": "11:35",
"uptime": "3 days, 4:03",
"users": 5,
"load_1m": 1.88,
"load_5m": 2.0,
"load_15m": 1.94,
"time_hour": 11,
"time_minute": 35,
"time_second": null,
"uptime_days": 3,
"uptime_hours": 4,
"uptime_minutes": 3,
"uptime_total_seconds": 273780
}
$ uptime | jc --uptime -p -r
{
"time": "11:31:09",
"uptime": "1 day, 21:17",
"users": "1",
"load_1m": "0.00",
"load_5m": "0.04",
"load_15m": "0.05"
"time": "11:36",
"uptime": "3 days, 4:04",
"users": "5",
"load_1m": "1.88",
"load_5m": "1.99",
"load_15m": "1.94"
}
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
Dictionary. Structured data with the following schema:
{
"time": string,
"uptime": string,
"users": integer,
"load_1m": float,
"load_5m": float,
"load_15m": float
}
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -77,3 +87,7 @@ Returns:
Dictionary. Raw or processed structured data
## Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,35 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.w
jc - JSON CLI output utility w Parser
jc - JSON CLI output utility `w` command output parser
Usage:
Usage (cli):
specify --w as the first argument if the piped input is coming from w
$ w | jc --w
Compatibility:
or
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
$ jc w
Usage (module):
import jc.parsers.w
result = jc.parsers.w.parse(w_command_output)
Schema:
[
{
"user": string, # '-' = null
"tty": string, # '-' = null
"from": string, # '-' = null
"login_at": string, # '-' = null
"idle": string, # '-' = null
"jcpu": string,
"pcpu": string,
"what": string # '-' = null
}
]
Examples:
@@ -79,38 +101,12 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"user": string, # '-'' = null
"tty": string, # '-'' = null
"from": string, # '-'' = null
"login_at": string, # '-'' = null
"idle": string, # '-'' = null
"jcpu": string,
"pcpu": string,
"what": string # '-'' = null
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -127,5 +123,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

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

@@ -0,0 +1,82 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.wc
jc - JSON CLI output utility `wc` command output parser
Usage (cli):
$ wc file.txt | jc --wc
or
$ jc wc file.txt
Usage (module):
import jc.parsers.wc
result = jc.parsers.wc.parse(wc_command_output)
Schema:
[
{
"filename": string,
"lines": integer,
"words": integer,
"characters": integer
}
]
Examples:
$ wc * | jc --wc -p
[
{
"filename": "airport-I.json",
"lines": 1,
"words": 30,
"characters": 307
},
{
"filename": "airport-I.out",
"lines": 15,
"words": 33,
"characters": 348
},
{
"filename": "airport-s.json",
"lines": 1,
"words": 202,
"characters": 2152
},
...
]
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,15 +1,41 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.who
jc - JSON CLI output utility who Parser
jc - JSON CLI output utility `who` command output parser
Usage:
Accepts any of the following who options (or no options): `-aTH`
specify --who as the first argument if the piped input is coming from who
The `epoch` calculated timestamp field is naive (i.e. based on the local time of the system the parser is run on)
accepts any of the following who options (or no options): -aTH
Usage (cli):
Compatibility:
$ who | jc --who
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
or
$ jc who
Usage (module):
import jc.parsers.who
result = jc.parsers.who.parse(who_command_output)
Schema:
[
{
"user": string,
"event": string,
"writeable_tty": string,
"tty": string,
"time": string,
"epoch": integer, # naive timestamp. null if time cannot be converted
"idle": string,
"pid": integer,
"from": string,
"comment": string
}
]
Examples:
@@ -18,7 +44,8 @@ Examples:
{
"event": "reboot",
"time": "Feb 7 23:31",
"pid": 1
"pid": 1,
"epoch": null
},
{
"user": "joeuser",
@@ -26,7 +53,8 @@ Examples:
"tty": "console",
"time": "Feb 7 23:32",
"idle": "old",
"pid": 105
"pid": 105,
"epoch": null
},
{
"user": "joeuser",
@@ -35,7 +63,8 @@ Examples:
"time": "Feb 13 16:44",
"idle": ".",
"pid": 51217,
"comment": "term=0 exit=0"
"comment": "term=0 exit=0",
"epoch": null
},
{
"user": "joeuser",
@@ -43,7 +72,8 @@ Examples:
"tty": "ttys003",
"time": "Feb 28 08:59",
"idle": "01:36",
"pid": 41402
"pid": 41402,
"epoch": null
},
{
"user": "joeuser",
@@ -52,7 +82,8 @@ Examples:
"time": "Mar 1 16:35",
"idle": ".",
"pid": 15679,
"from": "192.168.1.5"
"from": "192.168.1.5",
"epoch": null
}
]
@@ -99,39 +130,12 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"user": string,
"event": string,
"writeable_tty": string,
"tty": string,
"time": string,
"idle": string,
"pid": integer,
"from": string,
"comment": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -148,5 +152,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,26 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.xml
jc - JSON CLI output utility XML Parser
jc - JSON CLI output utility `XML` file parser
Usage:
Usage (cli):
specify --xml as the first argument if the piped input is coming from an XML file
$ cat foo.xml | jc --xml
Compatibility:
Usage (module):
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
import jc.parsers.xml
result = jc.parsers.xml.parse(xml_file_output)
Schema:
XML Document converted to a Dictionary
See https://github.com/martinblech/xmltodict for details
{
"key1": string/object,
"key2": string/object
}
Examples:
@@ -55,30 +68,12 @@ Examples:
...
}
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
Dictionary representing an XML document:
{
XML Document converted to a Dictionary
See https://github.com/martinblech/xmltodict for details
}
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -97,3 +92,7 @@ Returns:
Dictionary. Raw or processed structured data.
## Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,13 +1,28 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.yaml
jc - JSON CLI output utility YAML Parser
jc - JSON CLI output utility `YAML` file parser
Usage:
Usage (cli):
specify --yaml as the first argument if the piped input is coming from a YAML file
$ cat foo.yaml | jc --yaml
Compatibility:
Usage (module):
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
import jc.parsers.yaml
result = jc.parsers.yaml.parse(yaml_file_output)
Schema:
YAML Document converted to a Dictionary
See https://pypi.org/project/ruamel.yaml for details
[
{
"key1": string/int/float/boolean/null/array/object,
"key2": string/int/float/boolean/null/array/object
}
]
Examples:
@@ -67,32 +82,12 @@ Examples:
}
]
## info
```python
info(self, /, *args, **kwargs)
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Each dictionary represents a YAML document:
[
{
YAML Document converted to a Dictionary
See https://pypi.org/project/ruamel.yaml for details
}
]
Provides parser metadata (version, author, etc.)
## parse
```python
@@ -109,5 +104,9 @@ Parameters:
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries representing the YAML documents.
## Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@@ -1,3 +1,4 @@
# jc
JC - JSON CLI output utility
@@ -5,64 +6,83 @@ JC - JSON CLI output utility
This package serializes the output of many standard unix command line tools to JSON format.
For documentation on each parser, see the [documentation site](https://kellyjonbrazil.github.io/jc/).
CLI Example:
$ ls -l /usr/bin | jc --ls -p
$ dig example.com | jc --dig -p
[
{
"filename": "apropos",
"link_to": "whatis",
"flags": "lrwxrwxrwx.",
"links": 1,
"owner": "root",
"group": "root",
"size": 6,
"date": "Aug 15 10:53"
},
{
"filename": "ar",
"flags": "-rwxr-xr-x.",
"links": 1,
"owner": "root",
"group": "root",
"size": 62744,
"date": "Aug 8 16:14"
},
{
"filename": "arch",
"flags": "-rwxr-xr-x.",
"links": 1,
"owner": "root",
"group": "root",
"size": 33080,
"date": "Aug 19 23:25"
},
...
"id": 2951,
"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": [
{
"name": "example.com.",
"class": "IN",
"type": "A",
"ttl": 39302,
"data": "93.184.216.34"
}
],
"query_time": 49,
"server": "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
"when": "Fri Apr 16 16:05:10 PDT 2021",
"rcvd": 56,
"when_epoch": 1618614310,
"when_epoch_utc": null
}
]
Module Example:
>>> import jc.parsers.ls
>>> import jc.parsers.dig
>>>
>>> data='''-rwxr-xr-x 1 root wheel 23648 May 3 22:26 cat
... -rwxr-xr-x 1 root wheel 30016 May 3 22:26 chmod
... -rwxr-xr-x 1 root wheel 29024 May 3 22:26 cp
... -rwxr-xr-x 1 root wheel 375824 May 3 22:26 csh
... -rwxr-xr-x 1 root wheel 28608 May 3 22:26 date
... -rwxr-xr-x 1 root wheel 32000 May 3 22:26 dd
... -rwxr-xr-x 1 root wheel 23392 May 3 22:26 df
... -rwxr-xr-x 1 root wheel 18128 May 3 22:26 echo'''
>>> data = '''; <<>> DiG 9.10.6 <<>> example.com
... ;; global options: +cmd
... ;; Got answer:
... ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64612
... ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
...
... ;; OPT PSEUDOSECTION:
... ; EDNS: version: 0, flags:; udp: 4096
... ;; QUESTION SECTION:
... ;example.com. IN A
...
... ;; ANSWER SECTION:
... example.com. 29658 IN A 93.184.216.34
...
... ;; Query time: 52 msec
... ;; SERVER: 2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)
... ;; WHEN: Fri Apr 16 16:13:00 PDT 2021
... ;; MSG SIZE rcvd: 56'''
>>>
>>> jc.parsers.ls.parse(data)
[{'filename': 'cat', 'flags': '-rwxr-xr-x', 'links': 1, 'owner': 'root', 'group': 'wheel', 'size': 23648,
'date': 'May 3 22:26'}, {'filename': 'chmod', 'flags': '-rwxr-xr-x', 'links': 1, 'owner': 'root',
'group': 'wheel', 'size': 30016, 'date': 'May 3 22:26'}, {'filename': 'cp', 'flags': '-rwxr-xr-x',
'links': 1, 'owner': 'root', 'group': 'wheel', 'size': 29024, 'date': 'May 3 22:26'}, {'filename': 'csh',
'flags': '-rwxr-xr-x', 'links': 1, 'owner': 'root', 'group': 'wheel', 'size': 375824, 'date': 'May 3
22:26'}, {'filename': 'date', 'flags': '-rwxr-xr-x', 'links': 1, 'owner': 'root', 'group': 'wheel',
'size': 28608, 'date': 'May 3 22:26'}, {'filename': 'dd', 'flags': '-rwxr-xr-x', 'links': 1, 'owner':
'root', 'group': 'wheel', 'size': 32000, 'date': 'May 3 22:26'}, {'filename': 'df', 'flags':
'-rwxr-xr-x', 'links': 1, 'owner': 'root', 'group': 'wheel', 'size': 23392, 'date': 'May 3 22:26'},
{'filename': 'echo', 'flags': '-rwxr-xr-x', 'links': 1, 'owner': 'root', 'group': 'wheel', 'size': 18128,
'date': 'May 3 22:26'}]
>>> jc.parsers.dig.parse(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': [{'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}]

View File

@@ -1,5 +1,7 @@
# utils
jc - JSON CLI output utility utils
## warning_message
```python
warning_message(message)
@@ -13,7 +15,8 @@ Parameters:
Returns:
no return, just prints output to STDERR
None - just prints output to STDERR
## error_message
```python
@@ -28,7 +31,8 @@ Parameters:
Returns:
no return, just prints output to STDERR
None - just prints output to STDERR
## compatibility
```python
@@ -46,5 +50,88 @@ Parameters:
Returns:
no return, just prints output to STDERR
None - just prints output to STDERR
## has_data
```python
has_data(data)
```
Checks if the input contains data. If there are any non-whitespace characters then return True, else return False
Parameters:
data: (string) input to check whether it contains data
Returns:
Boolean True if input string (data) contains non-whitespace characters, otherwise False
## convert_to_int
```python
convert_to_int(value)
```
Converts string and float input to int. Strips all non-numeric characters from strings.
Parameters:
value: (string/integer/float) Input value
Returns:
integer/None Integer if successful conversion, otherwise None
## convert_to_float
```python
convert_to_float(value)
```
Converts string and int input to float. Strips all non-numeric characters from strings.
Parameters:
value: (string) Input value
Returns:
float/None Float if successful conversion, otherwise None
## convert_to_bool
```python
convert_to_bool(value)
```
Converts string, integer, or float input to boolean by checking for 'truthy' values
Parameters:
value: (string/integer/float) Input value
Returns:
True/False False unless a 'truthy' number or string is found ('y', 'yes', 'true', '1', 1, -1, etc.)
## timestamp
```python
timestamp(datetime_string)
```
Input a date-time text string of several formats and convert to a naive or timezone-aware epoch timestamp in UTC
Parameters:
datetime_string: (str) a string representation of a date-time in several supported formats
Attributes:
string (str) the input datetime string
format (int) the format rule that was used to decode the datetime string
naive (int) timestamp based on locally configured timezone. None if conversion fails
utc (int) aware timestamp only if UTC timezone detected in datetime string. None if conversion fails

View File

@@ -4,66 +4,86 @@
This package serializes the output of many standard unix command line tools to JSON format.
For documentation on each parser, see the [documentation site](https://kellyjonbrazil.github.io/jc/).
CLI Example:
$ ls -l /usr/bin | jc --ls -p
$ dig example.com | jc --dig -p
[
{
"filename": "apropos",
"link_to": "whatis",
"flags": "lrwxrwxrwx.",
"links": 1,
"owner": "root",
"group": "root",
"size": 6,
"date": "Aug 15 10:53"
},
{
"filename": "ar",
"flags": "-rwxr-xr-x.",
"links": 1,
"owner": "root",
"group": "root",
"size": 62744,
"date": "Aug 8 16:14"
},
{
"filename": "arch",
"flags": "-rwxr-xr-x.",
"links": 1,
"owner": "root",
"group": "root",
"size": 33080,
"date": "Aug 19 23:25"
},
...
"id": 2951,
"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": [
{
"name": "example.com.",
"class": "IN",
"type": "A",
"ttl": 39302,
"data": "93.184.216.34"
}
],
"query_time": 49,
"server": "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
"when": "Fri Apr 16 16:05:10 PDT 2021",
"rcvd": 56,
"when_epoch": 1618614310,
"when_epoch_utc": null
}
]
Module Example:
>>> import jc.parsers.ls
>>>
>>> data='''-rwxr-xr-x 1 root wheel 23648 May 3 22:26 cat
... -rwxr-xr-x 1 root wheel 30016 May 3 22:26 chmod
... -rwxr-xr-x 1 root wheel 29024 May 3 22:26 cp
... -rwxr-xr-x 1 root wheel 375824 May 3 22:26 csh
... -rwxr-xr-x 1 root wheel 28608 May 3 22:26 date
... -rwxr-xr-x 1 root wheel 32000 May 3 22:26 dd
... -rwxr-xr-x 1 root wheel 23392 May 3 22:26 df
... -rwxr-xr-x 1 root wheel 18128 May 3 22:26 echo'''
>>> import jc.parsers.dig
>>>
>>> jc.parsers.ls.parse(data)
[{'filename': 'cat', 'flags': '-rwxr-xr-x', 'links': 1, 'owner': 'root', 'group': 'wheel', 'size': 23648,
'date': 'May 3 22:26'}, {'filename': 'chmod', 'flags': '-rwxr-xr-x', 'links': 1, 'owner': 'root',
'group': 'wheel', 'size': 30016, 'date': 'May 3 22:26'}, {'filename': 'cp', 'flags': '-rwxr-xr-x',
'links': 1, 'owner': 'root', 'group': 'wheel', 'size': 29024, 'date': 'May 3 22:26'}, {'filename': 'csh',
'flags': '-rwxr-xr-x', 'links': 1, 'owner': 'root', 'group': 'wheel', 'size': 375824, 'date': 'May 3
22:26'}, {'filename': 'date', 'flags': '-rwxr-xr-x', 'links': 1, 'owner': 'root', 'group': 'wheel',
'size': 28608, 'date': 'May 3 22:26'}, {'filename': 'dd', 'flags': '-rwxr-xr-x', 'links': 1, 'owner':
'root', 'group': 'wheel', 'size': 32000, 'date': 'May 3 22:26'}, {'filename': 'df', 'flags':
'-rwxr-xr-x', 'links': 1, 'owner': 'root', 'group': 'wheel', 'size': 23392, 'date': 'May 3 22:26'},
{'filename': 'echo', 'flags': '-rwxr-xr-x', 'links': 1, 'owner': 'root', 'group': 'wheel', 'size': 18128,
'date': 'May 3 22:26'}]
>>> data = '''; <<>> DiG 9.10.6 <<>> example.com
... ;; global options: +cmd
... ;; Got answer:
... ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64612
... ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
...
... ;; OPT PSEUDOSECTION:
... ; EDNS: version: 0, flags:; udp: 4096
... ;; QUESTION SECTION:
... ;example.com. IN A
...
... ;; ANSWER SECTION:
... example.com. 29658 IN A 93.184.216.34
...
... ;; Query time: 52 msec
... ;; SERVER: 2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)
... ;; WHEN: Fri Apr 16 16:13:00 PDT 2021
... ;; MSG SIZE rcvd: 56'''
>>>
>>> jc.parsers.dig.parse(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': [{'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}]
"""
name = 'jc'
__version__ = '1.15.3'

611
jc/appdirs.py Normal file
View File

@@ -0,0 +1,611 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2005-2010 ActiveState Software Inc.
# Copyright (c) 2013 Eddy Petrișor
'''
# This is the MIT license
Copyright (c) 2010 ActiveState Software Inc.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'''
"""Utilities for determining application-specific dirs.
See <https://github.com/ActiveState/appdirs> for details and usage.
"""
# Dev Notes:
# - MSDN on where to store app data files:
# http://support.microsoft.com/default.aspx?scid=kb;en-us;310294#XSLTH3194121123120121120120
# - Mac OS X: http://developer.apple.com/documentation/MacOSX/Conceptual/BPFileSystem/index.html
# - XDG spec for Un*x: https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
__version__ = "1.4.4"
__version_info__ = tuple(int(segment) for segment in __version__.split("."))
import sys
import os
PY3 = sys.version_info[0] == 3
if PY3:
unicode = str
if sys.platform.startswith('java'):
import platform
os_name = platform.java_ver()[3][0]
if os_name.startswith('Windows'): # "Windows XP", "Windows 7", etc.
system = 'win32'
elif os_name.startswith('Mac'): # "Mac OS X", etc.
system = 'darwin'
else: # "Linux", "SunOS", "FreeBSD", etc.
# Setting this to "linux2" is not ideal, but only Windows or Mac
# are actually checked for and the rest of the module expects
# *sys.platform* style strings.
system = 'linux2'
else:
system = sys.platform
def user_data_dir(appname=None, appauthor=None, version=None, roaming=False):
r"""Return full path to the user-specific data dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
it is the owning company name. This falls back to appname. You may
pass False to disable it.
"version" is an optional version path element to append to the
path. You might want to use this if you want multiple versions
of your app to be able to run independently. If used, this
would typically be "<major>.<minor>".
Only applied when appname is present.
"roaming" (boolean, default False) can be set True to use the Windows
roaming appdata directory. That means that for users on a Windows
network setup for roaming profiles, this user data will be
sync'd on login. See
<http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>
for a discussion of issues.
Typical user data directories are:
Mac OS X: ~/Library/Application Support/<AppName>
Unix: ~/.local/share/<AppName> # or in $XDG_DATA_HOME, if defined
Win XP (not roaming): C:\Documents and Settings\<username>\Application Data\<AppAuthor>\<AppName>
Win XP (roaming): C:\Documents and Settings\<username>\Local Settings\Application Data\<AppAuthor>\<AppName>
Win 7 (not roaming): C:\Users\<username>\AppData\Local\<AppAuthor>\<AppName>
Win 7 (roaming): C:\Users\<username>\AppData\Roaming\<AppAuthor>\<AppName>
For Unix, we follow the XDG spec and support $XDG_DATA_HOME.
That means, by default "~/.local/share/<AppName>".
"""
if system == "win32":
if appauthor is None:
appauthor = appname
const = roaming and "CSIDL_APPDATA" or "CSIDL_LOCAL_APPDATA"
path = os.path.normpath(_get_win_folder(const))
if appname:
if appauthor is not False:
path = os.path.join(path, appauthor, appname)
else:
path = os.path.join(path, appname)
elif system == 'darwin':
path = os.path.expanduser('~/Library/Application Support/')
if appname:
path = os.path.join(path, appname)
else:
path = os.getenv('XDG_DATA_HOME', os.path.expanduser("~/.local/share"))
if appname:
path = os.path.join(path, appname)
if appname and version:
path = os.path.join(path, version)
return path
def site_data_dir(appname=None, appauthor=None, version=None, multipath=False):
r"""Return full path to the user-shared data dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
it is the owning company name. This falls back to appname. You may
pass False to disable it.
"version" is an optional version path element to append to the
path. You might want to use this if you want multiple versions
of your app to be able to run independently. If used, this
would typically be "<major>.<minor>".
Only applied when appname is present.
"multipath" is an optional parameter only applicable to *nix
which indicates that the entire list of data dirs should be
returned. By default, the first item from XDG_DATA_DIRS is
returned, or '/usr/local/share/<AppName>',
if XDG_DATA_DIRS is not set
Typical site data directories are:
Mac OS X: /Library/Application Support/<AppName>
Unix: /usr/local/share/<AppName> or /usr/share/<AppName>
Win XP: C:\Documents and Settings\All Users\Application Data\<AppAuthor>\<AppName>
Vista: (Fail! "C:\ProgramData" is a hidden *system* directory on Vista.)
Win 7: C:\ProgramData\<AppAuthor>\<AppName> # Hidden, but writeable on Win 7.
For Unix, this is using the $XDG_DATA_DIRS[0] default.
WARNING: Do not use this on Windows. See the Vista-Fail note above for why.
"""
if system == "win32":
if appauthor is None:
appauthor = appname
path = os.path.normpath(_get_win_folder("CSIDL_COMMON_APPDATA"))
if appname:
if appauthor is not False:
path = os.path.join(path, appauthor, appname)
else:
path = os.path.join(path, appname)
elif system == 'darwin':
path = os.path.expanduser('/Library/Application Support')
if appname:
path = os.path.join(path, appname)
else:
# XDG default for $XDG_DATA_DIRS
# only first, if multipath is False
path = os.getenv('XDG_DATA_DIRS',
os.pathsep.join(['/usr/local/share', '/usr/share']))
pathlist = [os.path.expanduser(x.rstrip(os.sep)) for x in path.split(os.pathsep)]
if appname:
if version:
appname = os.path.join(appname, version)
pathlist = [os.sep.join([x, appname]) for x in pathlist]
if multipath:
path = os.pathsep.join(pathlist)
else:
path = pathlist[0]
return path
if appname and version:
path = os.path.join(path, version)
return path
def user_config_dir(appname=None, appauthor=None, version=None, roaming=False):
r"""Return full path to the user-specific config dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
it is the owning company name. This falls back to appname. You may
pass False to disable it.
"version" is an optional version path element to append to the
path. You might want to use this if you want multiple versions
of your app to be able to run independently. If used, this
would typically be "<major>.<minor>".
Only applied when appname is present.
"roaming" (boolean, default False) can be set True to use the Windows
roaming appdata directory. That means that for users on a Windows
network setup for roaming profiles, this user data will be
sync'd on login. See
<http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>
for a discussion of issues.
Typical user config directories are:
Mac OS X: ~/Library/Preferences/<AppName>
Unix: ~/.config/<AppName> # or in $XDG_CONFIG_HOME, if defined
Win *: same as user_data_dir
For Unix, we follow the XDG spec and support $XDG_CONFIG_HOME.
That means, by default "~/.config/<AppName>".
"""
if system == "win32":
path = user_data_dir(appname, appauthor, None, roaming)
elif system == 'darwin':
path = os.path.expanduser('~/Library/Preferences/')
if appname:
path = os.path.join(path, appname)
else:
path = os.getenv('XDG_CONFIG_HOME', os.path.expanduser("~/.config"))
if appname:
path = os.path.join(path, appname)
if appname and version:
path = os.path.join(path, version)
return path
def site_config_dir(appname=None, appauthor=None, version=None, multipath=False):
r"""Return full path to the user-shared data dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
it is the owning company name. This falls back to appname. You may
pass False to disable it.
"version" is an optional version path element to append to the
path. You might want to use this if you want multiple versions
of your app to be able to run independently. If used, this
would typically be "<major>.<minor>".
Only applied when appname is present.
"multipath" is an optional parameter only applicable to *nix
which indicates that the entire list of config dirs should be
returned. By default, the first item from XDG_CONFIG_DIRS is
returned, or '/etc/xdg/<AppName>', if XDG_CONFIG_DIRS is not set
Typical site config directories are:
Mac OS X: same as site_data_dir
Unix: /etc/xdg/<AppName> or $XDG_CONFIG_DIRS[i]/<AppName> for each value in
$XDG_CONFIG_DIRS
Win *: same as site_data_dir
Vista: (Fail! "C:\ProgramData" is a hidden *system* directory on Vista.)
For Unix, this is using the $XDG_CONFIG_DIRS[0] default, if multipath=False
WARNING: Do not use this on Windows. See the Vista-Fail note above for why.
"""
if system == 'win32':
path = site_data_dir(appname, appauthor)
if appname and version:
path = os.path.join(path, version)
elif system == 'darwin':
path = os.path.expanduser('/Library/Preferences')
if appname:
path = os.path.join(path, appname)
else:
# XDG default for $XDG_CONFIG_DIRS
# only first, if multipath is False
path = os.getenv('XDG_CONFIG_DIRS', '/etc/xdg')
pathlist = [os.path.expanduser(x.rstrip(os.sep)) for x in path.split(os.pathsep)]
if appname:
if version:
appname = os.path.join(appname, version)
pathlist = [os.sep.join([x, appname]) for x in pathlist]
if multipath:
path = os.pathsep.join(pathlist)
else:
path = pathlist[0]
return path
def user_cache_dir(appname=None, appauthor=None, version=None, opinion=True):
r"""Return full path to the user-specific cache dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
it is the owning company name. This falls back to appname. You may
pass False to disable it.
"version" is an optional version path element to append to the
path. You might want to use this if you want multiple versions
of your app to be able to run independently. If used, this
would typically be "<major>.<minor>".
Only applied when appname is present.
"opinion" (boolean) can be False to disable the appending of
"Cache" to the base app data dir for Windows. See
discussion below.
Typical user cache directories are:
Mac OS X: ~/Library/Caches/<AppName>
Unix: ~/.cache/<AppName> (XDG default)
Win XP: C:\Documents and Settings\<username>\Local Settings\Application Data\<AppAuthor>\<AppName>\Cache
Vista: C:\Users\<username>\AppData\Local\<AppAuthor>\<AppName>\Cache
On Windows the only suggestion in the MSDN docs is that local settings go in
the `CSIDL_LOCAL_APPDATA` directory. This is identical to the non-roaming
app data dir (the default returned by `user_data_dir` above). Apps typically
put cache data somewhere *under* the given dir here. Some examples:
...\Mozilla\Firefox\Profiles\<ProfileName>\Cache
...\Acme\SuperApp\Cache\1.0
OPINION: This function appends "Cache" to the `CSIDL_LOCAL_APPDATA` value.
This can be disabled with the `opinion=False` option.
"""
if system == "win32":
if appauthor is None:
appauthor = appname
path = os.path.normpath(_get_win_folder("CSIDL_LOCAL_APPDATA"))
if appname:
if appauthor is not False:
path = os.path.join(path, appauthor, appname)
else:
path = os.path.join(path, appname)
if opinion:
path = os.path.join(path, "Cache")
elif system == 'darwin':
path = os.path.expanduser('~/Library/Caches')
if appname:
path = os.path.join(path, appname)
else:
path = os.getenv('XDG_CACHE_HOME', os.path.expanduser('~/.cache'))
if appname:
path = os.path.join(path, appname)
if appname and version:
path = os.path.join(path, version)
return path
def user_state_dir(appname=None, appauthor=None, version=None, roaming=False):
r"""Return full path to the user-specific state dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
it is the owning company name. This falls back to appname. You may
pass False to disable it.
"version" is an optional version path element to append to the
path. You might want to use this if you want multiple versions
of your app to be able to run independently. If used, this
would typically be "<major>.<minor>".
Only applied when appname is present.
"roaming" (boolean, default False) can be set True to use the Windows
roaming appdata directory. That means that for users on a Windows
network setup for roaming profiles, this user data will be
sync'd on login. See
<http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>
for a discussion of issues.
Typical user state directories are:
Mac OS X: same as user_data_dir
Unix: ~/.local/state/<AppName> # or in $XDG_STATE_HOME, if defined
Win *: same as user_data_dir
For Unix, we follow this Debian proposal <https://wiki.debian.org/XDGBaseDirectorySpecification#state>
to extend the XDG spec and support $XDG_STATE_HOME.
That means, by default "~/.local/state/<AppName>".
"""
if system in ["win32", "darwin"]:
path = user_data_dir(appname, appauthor, None, roaming)
else:
path = os.getenv('XDG_STATE_HOME', os.path.expanduser("~/.local/state"))
if appname:
path = os.path.join(path, appname)
if appname and version:
path = os.path.join(path, version)
return path
def user_log_dir(appname=None, appauthor=None, version=None, opinion=True):
r"""Return full path to the user-specific log dir for this application.
"appname" is the name of application.
If None, just the system directory is returned.
"appauthor" (only used on Windows) is the name of the
appauthor or distributing body for this application. Typically
it is the owning company name. This falls back to appname. You may
pass False to disable it.
"version" is an optional version path element to append to the
path. You might want to use this if you want multiple versions
of your app to be able to run independently. If used, this
would typically be "<major>.<minor>".
Only applied when appname is present.
"opinion" (boolean) can be False to disable the appending of
"Logs" to the base app data dir for Windows, and "log" to the
base cache dir for Unix. See discussion below.
Typical user log directories are:
Mac OS X: ~/Library/Logs/<AppName>
Unix: ~/.cache/<AppName>/log # or under $XDG_CACHE_HOME if defined
Win XP: C:\Documents and Settings\<username>\Local Settings\Application Data\<AppAuthor>\<AppName>\Logs
Vista: C:\Users\<username>\AppData\Local\<AppAuthor>\<AppName>\Logs
On Windows the only suggestion in the MSDN docs is that local settings
go in the `CSIDL_LOCAL_APPDATA` directory. (Note: I'm interested in
examples of what some windows apps use for a logs dir.)
OPINION: This function appends "Logs" to the `CSIDL_LOCAL_APPDATA`
value for Windows and appends "log" to the user cache dir for Unix.
This can be disabled with the `opinion=False` option.
"""
if system == "darwin":
path = os.path.join(
os.path.expanduser('~/Library/Logs'),
appname)
elif system == "win32":
path = user_data_dir(appname, appauthor, version)
version = False
if opinion:
path = os.path.join(path, "Logs")
else:
path = user_cache_dir(appname, appauthor, version)
version = False
if opinion:
path = os.path.join(path, "log")
if appname and version:
path = os.path.join(path, version)
return path
class AppDirs(object):
"""Convenience wrapper for getting application dirs."""
def __init__(self, appname=None, appauthor=None, version=None,
roaming=False, multipath=False):
self.appname = appname
self.appauthor = appauthor
self.version = version
self.roaming = roaming
self.multipath = multipath
@property
def user_data_dir(self):
return user_data_dir(self.appname, self.appauthor,
version=self.version, roaming=self.roaming)
@property
def site_data_dir(self):
return site_data_dir(self.appname, self.appauthor,
version=self.version, multipath=self.multipath)
@property
def user_config_dir(self):
return user_config_dir(self.appname, self.appauthor,
version=self.version, roaming=self.roaming)
@property
def site_config_dir(self):
return site_config_dir(self.appname, self.appauthor,
version=self.version, multipath=self.multipath)
@property
def user_cache_dir(self):
return user_cache_dir(self.appname, self.appauthor,
version=self.version)
@property
def user_state_dir(self):
return user_state_dir(self.appname, self.appauthor,
version=self.version)
@property
def user_log_dir(self):
return user_log_dir(self.appname, self.appauthor,
version=self.version)
#---- internal support stuff
def _get_win_folder_from_registry(csidl_name):
"""This is a fallback technique at best. I'm not sure if using the
registry for this guarantees us the correct answer for all CSIDL_*
names.
"""
if PY3:
import winreg as _winreg
else:
import _winreg
shell_folder_name = {
"CSIDL_APPDATA": "AppData",
"CSIDL_COMMON_APPDATA": "Common AppData",
"CSIDL_LOCAL_APPDATA": "Local AppData",
}[csidl_name]
key = _winreg.OpenKey(
_winreg.HKEY_CURRENT_USER,
r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
)
dir, type = _winreg.QueryValueEx(key, shell_folder_name)
return dir
def _get_win_folder_with_ctypes(csidl_name):
import ctypes
csidl_const = {
"CSIDL_APPDATA": 26,
"CSIDL_COMMON_APPDATA": 35,
"CSIDL_LOCAL_APPDATA": 28,
}[csidl_name]
buf = ctypes.create_unicode_buffer(1024)
ctypes.windll.shell32.SHGetFolderPathW(None, csidl_const, None, 0, buf)
# Downgrade to short path name if have highbit chars. See
# <http://bugs.activestate.com/show_bug.cgi?id=85099>.
has_high_char = False
for c in buf:
if ord(c) > 255:
has_high_char = True
break
if has_high_char:
buf2 = ctypes.create_unicode_buffer(1024)
if ctypes.windll.kernel32.GetShortPathNameW(buf.value, buf2, 1024):
buf = buf2
return buf.value
def _get_win_folder_with_jna(csidl_name):
import array
from com.sun import jna
from com.sun.jna.platform import win32
buf_size = win32.WinDef.MAX_PATH * 2
buf = array.zeros('c', buf_size)
shell = win32.Shell32.INSTANCE
shell.SHGetFolderPath(None, getattr(win32.ShlObj, csidl_name), None, win32.ShlObj.SHGFP_TYPE_CURRENT, buf)
dir = jna.Native.toString(buf.tostring()).rstrip("\0")
# Downgrade to short path name if have highbit chars. See
# <http://bugs.activestate.com/show_bug.cgi?id=85099>.
has_high_char = False
for c in dir:
if ord(c) > 255:
has_high_char = True
break
if has_high_char:
buf = array.zeros('c', buf_size)
kernel = win32.Kernel32.INSTANCE
if kernel.GetShortPathName(dir, buf, buf_size):
dir = jna.Native.toString(buf.tostring()).rstrip("\0")
return dir
if system == "win32":
try:
from ctypes import windll
except ImportError:
try:
import com.sun.jna
except ImportError:
_get_win_folder = _get_win_folder_from_registry
else:
_get_win_folder = _get_win_folder_with_jna
else:
_get_win_folder = _get_win_folder_with_ctypes
#---- self test code
if __name__ == "__main__":
appname = "MyApp"
appauthor = "MyCompany"
props = ("user_data_dir",
"user_config_dir",
"user_cache_dir",
"user_state_dir",
"user_log_dir",
"site_data_dir",
"site_config_dir")
print("-- app dirs %s --" % __version__)
print("-- app dirs (with optional 'version')")
dirs = AppDirs(appname, appauthor, version="1.0")
for prop in props:
print("%s: %s" % (prop, getattr(dirs, prop)))
print("\n-- app dirs (without optional 'version')")
dirs = AppDirs(appname, appauthor)
for prop in props:
print("%s: %s" % (prop, getattr(dirs, prop)))
print("\n-- app dirs (without optional 'appauthor')")
dirs = AppDirs(appname)
for prop in props:
print("%s: %s" % (prop, getattr(dirs, prop)))
print("\n-- app dirs (with disabled 'appauthor')")
dirs = AppDirs(appname, appauthor=False)
for prop in props:
print("%s: %s" % (prop, getattr(dirs, prop)))

364
jc/cli.py
View File

@@ -1,47 +1,79 @@
#!/usr/bin/env python3
"""jc - JSON CLI output utility
JC cli module
"""
import sys
import os
import os.path
import re
import shlex
import importlib
import textwrap
import signal
import json
import jc.utils
import jc
import jc.appdirs as appdirs
# make pygments import optional
try:
import pygments
from pygments import highlight
from pygments.style import Style
from pygments.token import (Name, Number, String, Keyword)
from pygments.lexers import JsonLexer
from pygments.formatters import Terminal256Formatter
pygments_installed = True
except Exception:
pygments_installed = False
class info():
version = '1.8.1'
description = 'jc cli output JSON conversion tool'
version = jc.__version__
description = 'JSON CLI output utility'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
website = 'https://github.com/kellyjonbrazil/jc'
copyright = '© 2019-2021 Kelly Brazil'
license = 'MIT License'
__version__ = info.version
parsers = [
'acpi',
'airport',
'airport-s',
'arp',
'blkid',
'cksum',
'crontab',
'crontab-u',
'csv',
'date',
'df',
'dig',
'dir',
'dmidecode',
'dpkg-l',
'du',
'env',
'file',
'finger',
'free',
'fstab',
'group',
'gshadow',
'hash',
'hashsum',
'hciconfig',
'history',
'hosts',
'id',
'ifconfig',
'ini',
'iptables',
'iw-scan',
'jobs',
'kv',
'last',
'ls',
'lsblk',
@@ -49,55 +81,181 @@ parsers = [
'lsof',
'mount',
'netstat',
'ntpq',
'passwd',
'ping',
'pip-list',
'pip-show',
'ps',
'route',
'rpm-qi',
'shadow',
'ss',
'stat',
'sysctl',
'systemctl',
'systemctl-lj',
'systemctl-ls',
'systemctl-luf',
'systeminfo',
'time',
'timedatectl',
'tracepath',
'traceroute',
'ufw',
'ufw-appinfo',
'uname',
'upower',
'uptime',
'w',
'wc',
'who',
'xml',
'yaml'
]
# List of custom or override parsers.
# Allow any <user_data_dir>/jc/jcparsers/*.py
local_parsers = []
data_dir = appdirs.user_data_dir('jc', 'jc')
local_parsers_dir = os.path.join(data_dir, 'jcparsers')
if os.path.isdir(local_parsers_dir):
sys.path.append(data_dir)
for name in os.listdir(local_parsers_dir):
if re.match(r'\w+\.py', name) and os.path.isfile(os.path.join(local_parsers_dir, name)):
plugin_name = name[0:-3]
local_parsers.append(plugin_name)
if plugin_name not in parsers:
parsers.append(plugin_name)
# We only support 2.3.0+, pygments changed color names in 2.4.0.
# startswith is sufficient and avoids potential exceptions from split and int.
if pygments_installed:
if pygments.__version__.startswith('2.3.'):
PYGMENT_COLOR = {
'black': '#ansiblack',
'red': '#ansidarkred',
'green': '#ansidarkgreen',
'yellow': '#ansibrown',
'blue': '#ansidarkblue',
'magenta': '#ansipurple',
'cyan': '#ansiteal',
'gray': '#ansilightgray',
'brightblack': '#ansidarkgray',
'brightred': '#ansired',
'brightgreen': '#ansigreen',
'brightyellow': '#ansiyellow',
'brightblue': '#ansiblue',
'brightmagenta': '#ansifuchsia',
'brightcyan': '#ansiturquoise',
'white': '#ansiwhite',
}
else:
PYGMENT_COLOR = {
'black': 'ansiblack',
'red': 'ansired',
'green': 'ansigreen',
'yellow': 'ansiyellow',
'blue': 'ansiblue',
'magenta': 'ansimagenta',
'cyan': 'ansicyan',
'gray': 'ansigray',
'brightblack': 'ansibrightblack',
'brightred': 'ansibrightred',
'brightgreen': 'ansibrightgreen',
'brightyellow': 'ansibrightyellow',
'brightblue': 'ansibrightblue',
'brightmagenta': 'ansibrightmagenta',
'brightcyan': 'ansibrightcyan',
'white': 'ansiwhite',
}
def set_env_colors(env_colors=None):
"""
Return a dictionary to be used in Pygments custom style class.
Grab custom colors from JC_COLORS environment variable. JC_COLORS env variable takes 4 comma
separated string values and should be in the format of:
JC_COLORS=<keyname_color>,<keyword_color>,<number_color>,<string_color>
Where colors are: black, red, green, yellow, blue, magenta, cyan, gray, brightblack, brightred,
brightgreen, brightyellow, brightblue, brightmagenta, brightcyan, white, default
Default colors:
JC_COLORS=blue,brightblack,magenta,green
or
JC_COLORS=default,default,default,default
"""
input_error = False
if env_colors:
color_list = env_colors.split(',')
else:
color_list = ['default', 'default', 'default', 'default']
if len(color_list) != 4:
input_error = True
for color in color_list:
if color != 'default' and color not in PYGMENT_COLOR:
input_error = True
# if there is an issue with the env variable, just set all colors to default and move on
if input_error:
jc.utils.warning_message('could not parse JC_COLORS environment variable')
color_list = ['default', 'default', 'default', 'default']
# Try the color set in the JC_COLORS env variable first. If it is set to default, then fall back to default colors
return {
Name.Tag: f'bold {PYGMENT_COLOR[color_list[0]]}' if color_list[0] != 'default' else f"bold {PYGMENT_COLOR['blue']}", # key names
Keyword: PYGMENT_COLOR[color_list[1]] if color_list[1] != 'default' else PYGMENT_COLOR['brightblack'], # true, false, null
Number: PYGMENT_COLOR[color_list[2]] if color_list[2] != 'default' else PYGMENT_COLOR['magenta'], # numbers
String: PYGMENT_COLOR[color_list[3]] if color_list[3] != 'default' else PYGMENT_COLOR['green'] # strings
}
def piped_output():
"""Return False if stdout is a TTY. True if output is being piped to another program"""
if sys.stdout.isatty():
return False
else:
return True
def ctrlc(signum, frame):
"""exit with error on SIGINT"""
"""Exit with error on SIGINT"""
sys.exit(1)
def parser_shortname(parser_argument):
"""short name of the parser with dashes and no -- prefix"""
"""Return short name of the parser with dashes and no -- prefix"""
return parser_argument[2:]
def parser_argument(parser):
"""short name of the parser with dashes and with -- prefix"""
"""Return short name of the parser with dashes and with -- prefix"""
return f'--{parser}'
def parser_mod_shortname(parser):
"""short name of the parser's module name (no -- prefix and dashes converted to underscores)"""
"""Return short name of the parser's module name (no -- prefix and dashes converted to underscores)"""
return parser.replace('--', '').replace('-', '_')
def parser_module(parser):
"""import the module just in time and return the module object"""
importlib.import_module('jc.parsers.' + parser_mod_shortname(parser))
return getattr(jc.parsers, parser_mod_shortname(parser))
"""Import the module just in time and return the module object"""
shortname = parser_mod_shortname(parser)
path = ('jcparsers.' if shortname in local_parsers else 'jc.parsers.')
return importlib.import_module(path + shortname)
def parsers_text(indent=0, pad=0):
"""return the argument and description information from each parser"""
"""Return the argument and description information from each parser"""
ptext = ''
for parser in parsers:
parser_arg = parser_argument(parser)
@@ -115,7 +273,7 @@ def parsers_text(indent=0, pad=0):
def about_jc():
"""return jc info and the contents of each parser.info as a dictionary"""
"""Return jc info and the contents of each parser.info as a dictionary"""
parser_list = []
for parser in parsers:
@@ -139,17 +297,20 @@ def about_jc():
'description': info.description,
'author': info.author,
'author_email': info.author_email,
'website': info.website,
'copyright': info.copyright,
'license': info.license,
'parser_count': len(parser_list),
'parsers': parser_list
}
def helptext(message):
"""return the help text with the list of parsers"""
def helptext():
"""Return the help text with the list of parsers"""
parsers_string = parsers_text(indent=12, pad=17)
helptext_string = f'''
jc: {message}
helptext_string = f'''\
jc converts the output of many commands and file-types to JSON
Usage: COMMAND | jc PARSER [OPTIONS]
@@ -161,31 +322,82 @@ def helptext(message):
{parsers_string}
Options:
-a about jc
-d debug - show trace messages
-d debug (-dd for verbose debug)
-h help (-h --parser_name for parser documentation)
-m monochrome output
-p pretty print output
-q quiet - suppress warnings
-q quiet - suppress parser warnings
-r raw JSON output
-v version info
Example:
ls -al | jc --ls -p
Examples:
Standard Syntax:
$ dig www.google.com | jc --dig -p
or using the magic syntax:
Magic Syntax:
$ jc -p dig www.google.com
jc -p ls -al
Parser Documentation:
$ jc -h --dig
'''
print(textwrap.dedent(helptext_string), file=sys.stderr)
return textwrap.dedent(helptext_string)
def json_out(data, pretty=False):
if pretty:
print(json.dumps(data, indent=2))
def help_doc(options):
"""
Returns the parser documentation if a parser is found in the arguments, otherwise
the general help text is returned.
"""
for arg in options:
parser_name = parser_shortname(arg)
if parser_name in parsers:
# load parser module just in time so we don't need to load all modules
parser = parser_module(arg)
compatible = ', '.join(parser.info.compatible)
doc_text = f'''{parser.__doc__}
Compatibility: {compatible}
Version {parser.info.version} by {parser.info.author} ({parser.info.author_email})
'''
return doc_text
return helptext()
def versiontext():
"""Return the version text"""
versiontext_string = f'''\
jc version {info.version}
{info.website}
{info.copyright}'''
return textwrap.dedent(versiontext_string)
def json_out(data, pretty=False, env_colors=None, mono=False, piped_out=False):
"""Return a JSON formatted string. String may include color codes or be pretty printed."""
if not mono and not piped_out:
# set colors
class JcStyle(Style):
styles = set_env_colors(env_colors)
if pretty:
return str(highlight(json.dumps(data, indent=2, ensure_ascii=False),
JsonLexer(), Terminal256Formatter(style=JcStyle))[0:-1])
else:
return str(highlight(json.dumps(data, separators=(',', ':'), ensure_ascii=False),
JsonLexer(), Terminal256Formatter(style=JcStyle))[0:-1])
else:
print(json.dumps(data))
if pretty:
return json.dumps(data, indent=2, ensure_ascii=False)
else:
return json.dumps(data, separators=(',', ':'), ensure_ascii=False)
def generate_magic_command(args):
"""
Returns a tuple with a boolean and a command, where the boolean signifies that
Return a tuple with a boolean and a command, where the boolean signifies that
the command is valid, and the command is either a command string or None.
"""
@@ -194,25 +406,27 @@ def generate_magic_command(args):
return False, None
# correctly parse escape characters and spaces with shlex
args_given = " ".join(map(shlex.quote, args[1:])).split()
args_given = ' '.join(map(shlex.quote, args[1:])).split()
options = []
# find the options
popped = 0
for i, arg in enumerate(args_given):
for arg in list(args_given):
# parser found - use standard syntax
if arg.startswith('--'):
return False, None
# option found - populate option list
elif arg.startswith('-'):
options.append(args_given.pop(i - popped)[1:])
popped += 1
options.extend(args_given.pop(0)[1:])
# command found if iterator didn't already stop - stop iterating
else:
break
# if -h, -a, or -v found in options, then bail out
if 'h' in options or 'a' in options or 'v' in options:
return False, None
# all options popped and no command found - for case like 'jc -a'
if len(args_given) == 0:
return False, None
@@ -220,7 +434,7 @@ def generate_magic_command(args):
magic_dict = {}
parser_info = about_jc()['parsers']
# Create a dictionary of magic_commands to their respective parsers.
# create a dictionary of magic_commands to their respective parsers.
for entry in parser_info:
# Update the dict with all of the magic commands for this parser, if they exist.
magic_dict.update({mc: entry['argument'] for mc in entry.get('magic_commands', [])})
@@ -229,7 +443,7 @@ def generate_magic_command(args):
one_word_command = args_given[0]
two_word_command = ' '.join(args_given[0:2])
# Try to get a parser for two_word_command, otherwise get one for one_word_command
# try to get a parser for two_word_command, otherwise get one for one_word_command
found_parser = magic_dict.get(two_word_command, magic_dict.get(one_word_command))
# construct a new command line using the standard syntax: COMMAND | jc --PARSER -OPTIONS
@@ -242,24 +456,35 @@ def generate_magic_command(args):
def magic():
"""Runs the command generated by generate_magic_command() to support magic syntax"""
valid_command, run_command = generate_magic_command(sys.argv)
if valid_command:
os.system(run_command)
exit()
sys.exit(0)
elif run_command is None:
return
else:
helptext(f'parser not found for "{run_command}"')
jc.utils.error_message(f'parser not found for "{run_command}". Use "jc -h" for help.')
sys.exit(1)
def main():
import jc.utils
# break on ctrl-c keyboard interrupt
signal.signal(signal.SIGINT, ctrlc)
# break on pipe error. need try/except for windows compatibility
try:
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
except AttributeError:
pass
# try magic syntax first: e.g. jc -p ls -al
magic()
jc_colors = os.getenv('JC_COLORS')
options = []
# options
@@ -267,54 +492,69 @@ def main():
if opt.startswith('-') and not opt.startswith('--'):
options.extend(opt[1:])
about = 'a' in options
debug = 'd' in options
verbose_debug = True if options.count('d') > 1 else False
mono = 'm' in options
help_me = 'h' in options
pretty = 'p' in options
quiet = 'q' in options
raw = 'r' in options
version_info = 'v' in options
if 'a' in options:
json_out(about_jc(), pretty=pretty)
exit()
if not pygments_installed:
mono = True
if about:
print(json_out(about_jc(), pretty=pretty, env_colors=jc_colors, mono=mono, piped_out=piped_output()))
sys.exit(0)
if help_me:
print(help_doc(sys.argv))
sys.exit(0)
if version_info:
print(versiontext())
sys.exit(0)
if verbose_debug:
import jc.tracebackplus
jc.tracebackplus.enable(context=11)
if sys.stdin.isatty():
helptext('missing piped data')
jc.utils.error_message('Missing piped data. Use "jc -h" for help.')
sys.exit(1)
data = sys.stdin.read()
found = False
if debug:
for arg in sys.argv:
parser_name = parser_shortname(arg)
for arg in sys.argv:
parser_name = parser_shortname(arg)
if parser_name in parsers:
# load parser module just in time so we don't need to load all modules
parser = parser_module(arg)
if parser_name in parsers:
# load parser module just in time so we don't need to load all modules
parser = parser_module(arg)
try:
result = parser.parse(data, raw=raw, quiet=quiet)
found = True
break
else:
for arg in sys.argv:
parser_name = parser_shortname(arg)
if parser_name in parsers:
# load parser module just in time so we don't need to load all modules
parser = parser_module(arg)
try:
result = parser.parse(data, raw=raw, quiet=quiet)
found = True
break
except Exception:
except Exception:
if debug:
raise
else:
import jc.utils
jc.utils.error_message(
f'{parser_name} parser could not parse the input data. Did you use the correct parser?\n For details use the -d option.')
f'{parser_name} parser could not parse the input data. Did you use the correct parser?\n'
' For details use the -d or -dd option. Use "jc -h" for help.')
sys.exit(1)
if not found:
helptext('missing or incorrect arguments')
jc.utils.error_message('Missing or incorrect arguments. Use "jc -h" for help.')
sys.exit(1)
json_out(result, pretty=pretty)
print(json_out(result, pretty=pretty, env_colors=jc_colors, mono=mono, piped_out=piped_output()))
if __name__ == '__main__':

BIN
jc/man/jc.1.gz Normal file

Binary file not shown.

389
jc/parsers/acpi.py Normal file
View File

@@ -0,0 +1,389 @@
"""jc - JSON CLI output utility `acpi` command output parser
Usage (cli):
$ acpi -V | jc --acpi
or
$ jc acpi -V
Usage (module):
import jc.parsers.acpi
result = jc.parsers.acpi.parse(acpi_command_output)
Schema:
[
{
"type": string,
"id": integer,
"state": string,
"charge_percent": integer,
"until_charged": string,
"until_charged_hours": integer,
"until_charged_minuts": integer,
"until_charged_seconds": integer,
"until_charged_total_seconds": integer,
"charge_remaining": string,
"charge_remaining_hours": integer,
"charge_remaining_minutes": integer,
"charge_remaining_seconds": integer,
"charge_remaining_total_seconds": integer,
"design_capacity_mah": integer,
"last_full_capacity": integer,
"last_full_capacity_percent": integer,
"on-line": boolean,
"mode": string,
"temperature": float,
"temperature_unit": string,
"trip_points": [
{
"id": integer,
"switches_to_mode": string,
"temperature": float,
"temperature_unit": string
}
],
"messages": [
string
]
}
]
Examples:
$ acpi -V | jc --acpi -p
[
{
"type": "Battery",
"id": 0,
"state": "Charging",
"charge_percent": 71,
"until_charged": "00:29:20",
"design_capacity_mah": 2110,
"last_full_capacity": 2271,
"last_full_capacity_percent": 100,
"until_charged_hours": 0,
"until_charged_minutes": 29,
"until_charged_seconds": 20,
"until_charged_total_seconds": 1760
},
{
"type": "Adapter",
"id": 0,
"on-line": true
},
{
"type": "Thermal",
"id": 0,
"mode": "ok",
"temperature": 46.0,
"temperature_unit": "C",
"trip_points": [
{
"id": 0,
"switches_to_mode": "critical",
"temperature": 127.0,
"temperature_unit": "C"
},
{
"id": 1,
"switches_to_mode": "hot",
"temperature": 127.0,
"temperature_unit": "C"
}
]
},
{
"type": "Cooling",
"id": 0,
"messages": [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": 1,
"messages": [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": 2,
"messages": [
"x86_pkg_temp no state information available"
]
},
{
"type": "Cooling",
"id": 3,
"messages": [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": 4,
"messages": [
"intel_powerclamp no state information available"
]
},
{
"type": "Cooling",
"id": 5,
"messages": [
"Processor 0 of 10"
]
}
]
$ acpi -V | jc --acpi -p -r
[
{
"type": "Battery",
"id": "0",
"state": "Charging",
"charge_percent": "71",
"until_charged": "00:29:20",
"design_capacity_mah": "2110",
"last_full_capacity": "2271",
"last_full_capacity_percent": "100"
},
{
"type": "Adapter",
"id": "0",
"on-line": true
},
{
"type": "Thermal",
"id": "0",
"mode": "ok",
"temperature": "46.0",
"temperature_unit": "C",
"trip_points": [
{
"id": "0",
"switches_to_mode": "critical",
"temperature": "127.0",
"temperature_unit": "C"
},
{
"id": "1",
"switches_to_mode": "hot",
"temperature": "127.0",
"temperature_unit": "C"
}
]
},
{
"type": "Cooling",
"id": "0",
"messages": [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": "1",
"messages": [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": "2",
"messages": [
"x86_pkg_temp no state information available"
]
},
{
"type": "Cooling",
"id": "3",
"messages": [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": "4",
"messages": [
"intel_powerclamp no state information available"
]
},
{
"type": "Cooling",
"id": "5",
"messages": [
"Processor 0 of 10"
]
}
]
"""
import jc.utils
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.2'
description = '`acpi` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
compatible = ['linux']
magic_commands = ['acpi']
__version__ = info.version
def _process(proc_data):
"""
Final processing to conform to the schema.
Parameters:
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of Dictionaries. Structured data to conform to the schema.
"""
int_list = ['id', 'charge_percent', 'design_capacity_mah', 'last_full_capacity', 'last_full_capacity_percent']
float_list = ['temperature']
for entry in proc_data:
for key in entry:
if key in int_list:
entry[key] = jc.utils.convert_to_int(entry[key])
if key in float_list:
entry[key] = jc.utils.convert_to_float(entry[key])
if 'trip_points' in entry:
for tp in entry['trip_points']:
for key in tp:
if key in int_list:
tp[key] = jc.utils.convert_to_int(tp[key])
if key in float_list:
tp[key] = jc.utils.convert_to_float(tp[key])
for entry in proc_data:
if 'until_charged' in entry:
entry['until_charged_hours'] = int(entry['until_charged'].split(':')[0])
entry['until_charged_minutes'] = int(entry['until_charged'].split(':')[1])
entry['until_charged_seconds'] = int(entry['until_charged'].split(':')[2])
entry['until_charged_total_seconds'] = (entry['until_charged_hours'] * 3600) + \
(entry['until_charged_minutes'] * 60) + entry['until_charged_seconds']
if 'charge_remaining' in entry:
entry['charge_remaining_hours'] = int(entry['charge_remaining'].split(':')[0])
entry['charge_remaining_minutes'] = int(entry['charge_remaining'].split(':')[1])
entry['charge_remaining_seconds'] = int(entry['charge_remaining'].split(':')[2])
entry['charge_remaining_total_seconds'] = (entry['charge_remaining_hours'] * 3600) + \
(entry['charge_remaining_minutes'] * 60) + entry['charge_remaining_seconds']
return proc_data
def parse(data, raw=False, quiet=False):
"""
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
"""
if not quiet:
jc.utils.compatibility(__name__, info.compatible)
raw_output = []
output_line = {}
line_state = ''
last_line_state = ''
obj_type = ''
obj_id = ''
trip_points_list = []
trip_points_dict = {}
messages_list = []
if jc.utils.has_data(data):
for line in filter(None, data.splitlines()):
obj_type = line.split()[0]
obj_id = line.split()[1][:-1]
line_state = obj_type + obj_id
if line_state != last_line_state:
if output_line:
raw_output.append(output_line)
output_line = {}
trip_points_list = []
messages_list = []
if obj_type == 'Battery':
output_line['type'] = obj_type
output_line['id'] = obj_id
if 'Charging' in line or 'Discharging' in line or 'Full' in line:
output_line['state'] = line.split()[2][:-1]
output_line['charge_percent'] = line.split()[3].rstrip('%,')
if 'rate information unavailable' not in line:
if 'Charging' in line:
output_line['until_charged'] = line.split()[4]
if 'Discharging' in line:
output_line['charge_remaining'] = line.split()[4]
if 'design capacity' in line:
output_line['design_capacity_mah'] = line.split()[4]
output_line['last_full_capacity'] = line.split()[9]
output_line['last_full_capacity_percent'] = line.split()[-1][:-1]
if obj_type == 'Adapter':
output_line['type'] = obj_type
output_line['id'] = obj_id
if 'on-line' in line:
output_line['on-line'] = True
else:
output_line['on-line'] = False
if obj_type == 'Thermal':
output_line['type'] = obj_type
output_line['id'] = obj_id
if 'trip point' not in line:
output_line['mode'] = line.split()[2][:-1]
output_line['temperature'] = line.split()[3]
output_line['temperature_unit'] = line.split()[-1]
else:
trip_points_dict = {
"id": line.split()[4],
"switches_to_mode": line.split()[8],
"temperature": line.split()[11],
"temperature_unit": line.split()[-1]
}
trip_points_list.append(trip_points_dict)
output_line['trip_points'] = trip_points_list
if obj_type == 'Cooling':
output_line['type'] = obj_type
output_line['id'] = obj_id
messages_list.append(line.split(maxsplit=2)[2])
output_line['messages'] = messages_list
last_line_state = line_state
if output_line:
raw_output.append(output_line)
if raw:
return raw_output
else:
return _process(raw_output)

147
jc/parsers/airport.py Normal file
View File

@@ -0,0 +1,147 @@
"""jc - JSON CLI output utility `airport -I` command output parser
The `airport` program can be found at `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport`.
Usage (cli):
$ airport -I | jc --airport
or
$ jc airport -I
Usage (module):
import jc.parsers.airport
result = jc.parsers.airport.parse(airport_command_output)
Schema:
{
"agrctlrssi": integer,
"agrextrssi": integer,
"agrctlnoise": integer,
"agrextnoise": integer,
"state": string,
"op_mode": string,
"lasttxrate": integer,
"maxrate": integer,
"lastassocstatus": integer,
"802_11_auth": string,
"link_auth": string,
"bssid": string,
"ssid": string,
"mcs": integer,
"channel": string
}
Examples:
$ airport -I | jc --airport -p
{
"agrctlrssi": -66,
"agrextrssi": 0,
"agrctlnoise": -90,
"agrextnoise": 0,
"state": "running",
"op_mode": "station",
"lasttxrate": 195,
"maxrate": 867,
"lastassocstatus": 0,
"802_11_auth": "open",
"link_auth": "wpa2-psk",
"bssid": "3c:37:86:15:ad:f9",
"ssid": "SnazzleDazzle",
"mcs": 0,
"channel": "48,80"
}
$ airport -I | jc --airport -p -r
{
"agrctlrssi": "-66",
"agrextrssi": "0",
"agrctlnoise": "-90",
"agrextnoise": "0",
"state": "running",
"op_mode": "station",
"lasttxrate": "195",
"maxrate": "867",
"lastassocstatus": "0",
"802_11_auth": "open",
"link_auth": "wpa2-psk",
"bssid": "3c:37:86:15:ad:f9",
"ssid": "SnazzleDazzle",
"mcs": "0",
"channel": "48,80"
}
"""
import jc.utils
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.3'
description = '`airport -I` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
# details = 'enter any other details here'
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
compatible = ['darwin']
magic_commands = ['airport -I']
__version__ = info.version
def _process(proc_data):
"""
Final processing to conform to the schema.
Parameters:
proc_data: (Dictionary) raw structured data to process
Returns:
Dictionary. Structured data to conform to the schema.
"""
# integer changes
int_list = ['agrctlrssi', 'agrextrssi', 'agrctlnoise', 'agrextnoise',
'lasttxrate', 'maxrate', 'lastassocstatus', 'mcs']
for key in proc_data:
if key in int_list:
proc_data[key] = jc.utils.convert_to_int(proc_data[key])
return proc_data
def parse(data, raw=False, quiet=False):
"""
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.
"""
if not quiet:
jc.utils.compatibility(__name__, info.compatible)
raw_output = {}
if jc.utils.has_data(data):
for line in filter(None, data.splitlines()):
linedata = line.split(':', maxsplit=1)
raw_output[linedata[0].strip().lower().replace(' ', '_').replace('.', '_')] = linedata[1].strip()
if raw:
return raw_output
else:
return _process(raw_output)

187
jc/parsers/airport_s.py Normal file
View File

@@ -0,0 +1,187 @@
"""jc - JSON CLI output utility `airport -s` command output parser
The `airport` program can be found at `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport`.
Usage (cli):
$ airport -s | jc --airport-s
or
$ jc airport -s
Usage (module):
import jc.parsers.airport_s
result = jc.parsers.airport_s.parse(airport_s_command_output)
Schema:
[
{
"ssid": string,
"bssid": string,
"rssi": integer,
"channel": string,
"ht": boolean,
"cc": string,
"security": [
string,
]
}
]
Examples:
$ airport -s | jc --airport-s -p
[
{
"ssid": "DIRECT-4A-HP OfficeJet 3830",
"bssid": "00:67:eb:2a:a7:3b",
"rssi": -90,
"channel": "6",
"ht": true,
"cc": "--",
"security": [
"WPA2(PSK/AES/AES)"
]
},
{
"ssid": "Latitude38",
"bssid": "c0:ff:d5:d2:7a:f3",
"rssi": -85,
"channel": "11",
"ht": true,
"cc": "US",
"security": [
"WPA2(PSK/AES/AES)"
]
},
{
"ssid": "xfinitywifi",
"bssid": "6e:e3:0e:b8:45:99",
"rssi": -83,
"channel": "11",
"ht": true,
"cc": "US",
"security": [
"NONE"
]
},
...
]
$ airport -s | jc --airport -p -r
[
{
"ssid": "DIRECT-F3-HP ENVY 5660 series",
"bssid": "b0:5a:da:6f:0a:d4",
"rssi": "-93",
"channel": "1",
"ht": "Y",
"cc": "--",
"security": "WPA2(PSK/AES/AES)"
},
{
"ssid": "YouAreInfected-5",
"bssid": "5c:e3:0e:c2:85:da",
"rssi": "-85",
"channel": "36",
"ht": "Y",
"cc": "US",
"security": "WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP)"
},
{
"ssid": "YuanFamily",
"bssid": "5c:e3:0e:b8:5f:9a",
"rssi": "-84",
"channel": "11",
"ht": "Y",
"cc": "US",
"security": "WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP)"
},
...
]
"""
import jc.utils
import jc.parsers.universal
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.4'
description = '`airport -s` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
# details = 'enter any other details here'
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
compatible = ['darwin']
magic_commands = ['airport -s']
__version__ = info.version
def _process(proc_data):
"""
Final processing to conform to the schema.
Parameters:
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of Dictionaries. Structured data to conform to the schema.
"""
for entry in proc_data:
# convert integers and booleans
int_list = ['rssi']
bool_list = ['ht']
for key in entry:
if key in int_list:
entry[key] = jc.utils.convert_to_int(entry[key])
if key in bool_list:
entry[key] = jc.utils.convert_to_bool(entry[key])
if 'security' in entry:
entry['security'] = entry['security'].split()
return proc_data
def parse(data, raw=False, quiet=False):
"""
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
"""
if not quiet:
jc.utils.compatibility(__name__, info.compatible)
raw_output = []
cleandata = list(filter(None, data.splitlines()))
if jc.utils.has_data(data):
# fix headers
cleandata[0] = cleandata[0].lower()
cleandata[0] = cleandata[0].replace('-', '_')
cleandata[0] = cleandata[0].replace('security (auth/unicast/group)', 'security')
# parse the data
raw_output = jc.parsers.universal.sparse_table_parse(cleandata)
if raw:
return raw_output
else:
return _process(raw_output)

View File

@@ -1,16 +1,34 @@
"""jc - JSON CLI output utility arp Parser
"""jc - JSON CLI output utility `arp` command output parser
Usage:
Supports `arp` and `arp -a` output.
specify --arp as the first argument if the piped input is coming from:
Usage (cli):
arp
or
arp -a
$ arp | jc --arp
Compatibility:
or
'linux', 'aix', 'freebsd', 'darwin'
$ jc arp
Usage (module):
import jc.parsers.arp
result = jc.parsers.arp.parse(arp_command_output)
Schema:
[
{
"name": string,
"address": string,
"hwtype": string,
"hwaddress": string,
"flags_mask": string,
"iface": string,
"permanent": boolean,
"expires": integer
}
]
Examples:
@@ -58,6 +76,8 @@ Examples:
"hwtype": "ether",
"hwaddress": "00:50:56:f0:98:26",
"iface": "ens33"
"permanent": false,
"expires": 1182
},
{
"name": "gateway",
@@ -65,6 +85,8 @@ Examples:
"hwtype": "ether",
"hwaddress": "00:50:56:f7:4a:fc",
"iface": "ens33"
"permanent": false,
"expires": 110
}
]
@@ -76,6 +98,8 @@ Examples:
"hwtype": "ether",
"hwaddress": "00:50:56:fe:7a:b4",
"iface": "ens33"
"permanent": false,
"expires": "1182"
},
{
"name": "_gateway",
@@ -83,6 +107,8 @@ Examples:
"hwtype": "ether",
"hwaddress": "00:50:56:f7:4a:fc",
"iface": "ens33"
"permanent": false,
"expires": "110"
}
]
"""
@@ -91,8 +117,9 @@ import jc.parsers.universal
class info():
version = '1.1'
description = 'arp command parser'
"""Provides parser metadata (version, author, etc.)"""
version = '1.7'
description = '`arp` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -104,28 +131,17 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"name": string,
"address": string,
"hwtype": string,
"hwaddress": string,
"flags_mask": string,
"iface": string
}
]
List of Dictionaries. Structured data to conform to the schema:
"""
# in BSD style, change name to null if it is a question mark
@@ -133,6 +149,11 @@ def process(proc_data):
if 'name' in entry and entry['name'] == '?':
entry['name'] = None
int_list = ['expires']
for key in entry:
if key in int_list:
entry[key] = jc.utils.convert_to_int(entry[key])
return proc_data
@@ -148,64 +169,70 @@ def parse(data, raw=False, quiet=False):
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
"""
if not quiet:
jc.utils.compatibility(__name__, info.compatible)
cleandata = data.splitlines()
raw_output = []
cleandata = list(filter(None, data.splitlines()))
# remove final Entries row if -v was used
if cleandata[-1].find('Entries:') == 0:
cleandata.pop(-1)
if jc.utils.has_data(data):
# detect if osx style was used
if cleandata[0].find(' ifscope ') != -1:
raw_output = []
for line in cleandata:
line = line.split()
output_line = {}
output_line['name'] = line[0]
output_line['address'] = line[1].lstrip('(').rstrip(')')
output_line['hwtype'] = line[-1].lstrip('[').rstrip(']')
output_line['hwaddress'] = line[3]
output_line['iface'] = line[5]
raw_output.append(output_line)
# remove final Entries row if -v was used
if cleandata[-1].startswith('Entries:'):
cleandata.pop(-1)
if raw:
return raw_output
# detect if freebsd/osx style was used
if cleandata[0][-1] == ']':
for line in cleandata:
splitline = line.split()
output_line = {
'name': splitline[0],
'address': splitline[1].lstrip('(').rstrip(')'),
'hwtype': splitline[-1].lstrip('[').rstrip(']'),
'hwaddress': splitline[3],
'iface': splitline[5]
}
if 'permanent' in splitline:
output_line['permanent'] = True
else:
output_line['permanent'] = False
if 'expires' in splitline:
output_line['expires'] = splitline[-3]
raw_output.append(output_line)
if raw:
return raw_output
else:
return _process(raw_output)
# detect if linux style was used
elif cleandata[0].startswith('Address'):
# fix header row to change Flags Mask to flags_mask
cleandata[0] = cleandata[0].replace('Flags Mask', 'flags_mask')
cleandata[0] = cleandata[0].lower()
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
# otherwise, try bsd style
else:
return process(raw_output)
for line in cleandata:
line = line.split()
output_line = {
'name': line[0],
'address': line[1].lstrip('(').rstrip(')'),
'hwtype': line[4].lstrip('[').rstrip(']'),
'hwaddress': line[3],
'iface': line[6],
}
raw_output.append(output_line)
# detect if linux style was used
elif cleandata[0].find('Address') == 0:
# fix header row to change Flags Mask to flags_mask
cleandata[0] = cleandata[0].replace('Flags Mask', 'flags_mask')
cleandata[0] = cleandata[0].lower()
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
if raw:
return raw_output
else:
return process(raw_output)
# otherwise, try bsd style
if raw:
return raw_output
else:
raw_output = []
for line in cleandata:
line = line.split()
output_line = {
'name': line[0],
'address': line[1].lstrip('(').rstrip(')'),
'hwtype': line[4].lstrip('[').rstrip(']'),
'hwaddress': line[3],
'iface': line[6],
}
raw_output.append(output_line)
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@@ -1,12 +1,53 @@
"""jc - JSON CLI output utility blkid Parser
"""jc - JSON CLI output utility `blkid` command output parser
Usage:
Usage (cli):
specify --blkid as the first argument if the piped input is coming from blkid
$ blkid | jc --blkid
Compatibility:
or
'linux'
$ jc blkid
Usage (module):
import jc.parsers.blkid
result = jc.parsers.blkid.parse(blkid_command_output)
Schema:
[
{
"device": string,
"uuid": string,
"type": string,
"usage": string,
"part_entry_scheme": string,
"part_entry_type": string,
"part_entry_flags": string,
"part_entry_number": integer,
"part_entry_offset": integer,
"part_entry_size": integer,
"part_entry_disk": string,
"id_fs_uuid": string,
"id_fs_uuid_enc": string,
"id_fs_version": string,
"id_fs_type": string,
"id_fs_usage": string,
"id_part_entry_scheme": string,
"id_part_entry_type": string,
"id_part_entry_flags": string,
"id_part_entry_number": integer,
"id_part_entry_offset": integer,
"id_part_entry_size": integer,
"id_iolimit_minimum_io_size": integer,
"id_iolimit_physical_sector_size": integer,
"id_iolimit_logical_sector_size": integer,
"id_part_entry_disk": string,
"minimum_io_size": integer,
"physical_sector_size": integer,
"logical_sector_size": integer
}
]
Examples:
@@ -79,8 +120,9 @@ import jc.utils
class info():
version = '1.0'
description = 'blkid command parser'
"""Provides parser metadata (version, author, etc.)"""
version = '1.4'
description = '`blkid` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
# details = 'enter any other details here'
@@ -93,51 +135,17 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of dictionaries. Structured data with the following schema:
[
{
"device": string,
"uuid": string,
"type": string,
"usage": string,
"part_entry_scheme": string,
"part_entry_type": string,
"part_entry_flags": string,
"part_entry_number": integer,
"part_entry_offset": integer,
"part_entry_size": integer,
"part_entry_disk": string,
"id_fs_uuid": string,
"id_fs_uuid_enc": string,
"id_fs_version": string,
"id_fs_type": string,
"id_fs_usage": string,
"id_part_entry_scheme": string,
"id_part_entry_type": string,
"id_part_entry_flags": string,
"id_part_entry_number": integer,
"id_part_entry_offset": integer,
"id_part_entry_size": integer,
"id_iolimit_minimum_io_size": integer,
"id_iolimit_physical_sector_size": integer,
"id_iolimit_logical_sector_size": integer,
"id_part_entry_disk": string,
"minimum_io_size": integer,
"physical_sector_size": integer,
"logical_sector_size": integer
}
]
List of Dictionaries. Structured data to conform to the schema.
"""
for entry in proc_data:
if 'devname' in entry:
@@ -147,12 +155,9 @@ def process(proc_data):
'id_part_entry_offset', 'id_part_entry_size', 'minimum_io_size', 'physical_sector_size',
'logical_sector_size', 'id_iolimit_minimum_io_size', 'id_iolimit_physical_sector_size',
'id_iolimit_logical_sector_size']
for key in int_list:
if key in entry:
try:
entry[key] = int(entry[key])
except (ValueError):
entry[key] = None
for key in entry:
if key in int_list:
entry[key] = jc.utils.convert_to_int(entry[key])
return proc_data
@@ -169,14 +174,15 @@ def parse(data, raw=False, quiet=False):
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
"""
if not quiet:
jc.utils.compatibility(__name__, info.compatible)
raw_output = []
if data:
if jc.utils.has_data(data):
# if the first field is a device, use normal parsing:
if data.split(maxsplit=1)[0][-1] == ':':
linedata = data.splitlines()
@@ -215,4 +221,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

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

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

View File

@@ -1,12 +1,50 @@
"""jc - JSON CLI output utility crontab command and file Parser
"""jc - JSON CLI output utility `crontab -l` command output and crontab file parser
Usage:
Supports `crontab -l` command output and crontab files.
specify --crontab as the first argument if the piped input is coming from crontab -l or a crontab file
Usage (cli):
Compatibility:
$ crontab -l | jc --crontab
'linux', 'darwin', 'aix', 'freebsd'
or
$ jc crontab -l
Usage (module):
import jc.parsers.crontab
result = jc.parsers.crontab.parse(crontab_output)
Schema:
{
"variables": [
"name": string,
"value": string
],
"schedule": [
{
"occurrence" string,
"minute": [
string
],
"hour": [
string
],
"day_of_month": [
string
],
"month": [
string
],
"day_of_week": [
string
],
"occurrence": string,
"command": string
}
]
}
Examples:
@@ -132,8 +170,9 @@ import jc.parsers.universal
class info():
version = '1.1'
description = 'crontab command and file parser'
"""Provides parser metadata (version, author, etc.)"""
version = '1.5'
description = '`crontab` command and file parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
# details = 'enter any other details here'
@@ -146,47 +185,17 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
proc_data: (Dictionary) raw structured data to process
Returns:
Dictionary. Structured data with the following schema:
{
"variables": [
"name": string,
"value": string
],
"schedule": [
{
"occurrence" string,
"minute": [
string
],
"hour": [
string
],
"day_of_month": [
string
],
"month": [
string
],
"day_of_week": [
string
],
"occurrence": string,
"command": string
}
]
}
Dictionary. Structured data to conform to the schema.
"""
# put itmes in lists
try:
@@ -225,46 +234,48 @@ def parse(data, raw=False, quiet=False):
# Clear any blank lines
cleandata = list(filter(None, cleandata))
# Clear any commented lines
for i, line in reversed(list(enumerate(cleandata))):
if line.strip().find('#') == 0:
cleandata.pop(i)
if jc.utils.has_data(data):
# Pop any variable assignment lines
cron_var = []
for i, line in reversed(list(enumerate(cleandata))):
if line.find('=') != -1:
var_line = cleandata.pop(i)
var_name = var_line.split('=', maxsplit=1)[0].strip()
var_value = var_line.split('=', maxsplit=1)[1].strip()
cron_var.append({'name': var_name,
'value': var_value})
# Clear any commented lines
for i, line in reversed(list(enumerate(cleandata))):
if line.strip().startswith('#'):
cleandata.pop(i)
raw_output['variables'] = cron_var
# Pop any variable assignment lines
cron_var = []
for i, line in reversed(list(enumerate(cleandata))):
if '=' in line and not line.strip()[0].isdigit() and not line.strip()[0] == '@':
var_line = cleandata.pop(i)
var_name = var_line.split('=', maxsplit=1)[0].strip()
var_value = var_line.split('=', maxsplit=1)[1].strip()
cron_var.append({'name': var_name,
'value': var_value})
# Pop any shortcut lines
shortcut_list = []
for i, line in reversed(list(enumerate(cleandata))):
if line.strip().startswith('@'):
shortcut_line = cleandata.pop(i)
occurrence = shortcut_line.split(maxsplit=1)[0].strip().lstrip('@')
cmd = shortcut_line.split(maxsplit=1)[1].strip()
shortcut_list.append({'occurrence': occurrence,
'command': cmd})
raw_output['variables'] = cron_var
# Add header row for parsing
cleandata[:0] = ['minute hour day_of_month month day_of_week command']
# Pop any shortcut lines
shortcut_list = []
for i, line in reversed(list(enumerate(cleandata))):
if line.strip().startswith('@'):
shortcut_line = cleandata.pop(i)
occurrence = shortcut_line.split(maxsplit=1)[0].strip().lstrip('@')
cmd = shortcut_line.split(maxsplit=1)[1].strip()
shortcut_list.append({'occurrence': occurrence,
'command': cmd})
if len(cleandata) > 1:
cron_list = jc.parsers.universal.simple_table_parse(cleandata)
# Add header row for parsing
cleandata[:0] = ['minute hour day_of_month month day_of_week command']
raw_output['schedule'] = cron_list
if len(cleandata) > 1:
cron_list = jc.parsers.universal.simple_table_parse(cleandata)
# Add shortcut entries back in
for item in shortcut_list:
raw_output['schedule'].append(item)
raw_output['schedule'] = cron_list
# Add shortcut entries back in
for item in shortcut_list:
raw_output['schedule'].append(item)
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@@ -1,12 +1,47 @@
"""jc - JSON CLI output utility crontab file Parser
"""jc - JSON CLI output utility `crontab -l` command output and crontab file parser
Usage:
This version of the `crontab -l` parser supports output that contains user information for processes.
specify --crontab-u as the first argument if the piped input is coming from a crontab file with User specified
Usage (cli):
Compatibility:
$ crontab -l | jc --crontab-u
'linux', 'darwin', 'aix', 'freebsd'
Usage (module):
import jc.parsers.crontab_u
result = jc.parsers.crontab_u.parse(crontab_u_output)
Schema:
{
"variables": [
"name": string,
"value": string
],
"schedule": [
{
"occurrence" string,
"minute": [
string
],
"hour": [
string
],
"day_of_month": [
string
],
"month": [
string
],
"day_of_week": [
string
],
"occurrence": string,
"user": string,
"command": string
}
]
}
Examples:
@@ -125,16 +160,15 @@ Examples:
}
]
}
"""
import jc.utils
import jc.parsers.universal
class info():
version = '1.0'
description = 'crontab file parser with user support'
"""Provides parser metadata (version, author, etc.)"""
version = '1.6'
description = '`crontab` file parser with user support'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
# details = 'enter any other details here'
@@ -146,48 +180,17 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
proc_data: (Dictionary) raw structured data to process
Returns:
Dictionary. Structured data with the following schema:
{
"variables": [
"name": string,
"value": string
],
"schedule": [
{
"occurrence" string,
"minute": [
string
],
"hour": [
string
],
"day_of_month": [
string
],
"month": [
string
],
"day_of_week": [
string
],
"occurrence": string,
"user": string,
"command": string
}
]
}
Dictionary. Structured data to conform to the schema.
"""
# put itmes in lists
try:
@@ -226,48 +229,50 @@ def parse(data, raw=False, quiet=False):
# Clear any blank lines
cleandata = list(filter(None, cleandata))
# Clear any commented lines
for i, line in reversed(list(enumerate(cleandata))):
if line.strip().find('#') == 0:
cleandata.pop(i)
if jc.utils.has_data(data):
# Pop any variable assignment lines
cron_var = []
for i, line in reversed(list(enumerate(cleandata))):
if line.find('=') != -1:
var_line = cleandata.pop(i)
var_name = var_line.split('=', maxsplit=1)[0].strip()
var_value = var_line.split('=', maxsplit=1)[1].strip()
cron_var.append({'name': var_name,
'value': var_value})
# Clear any commented lines
for i, line in reversed(list(enumerate(cleandata))):
if line.strip().startswith('#'):
cleandata.pop(i)
raw_output['variables'] = cron_var
# Pop any variable assignment lines
cron_var = []
for i, line in reversed(list(enumerate(cleandata))):
if '=' in line and not line.strip()[0].isdigit() and not line.strip()[0] == '@':
var_line = cleandata.pop(i)
var_name = var_line.split('=', maxsplit=1)[0].strip()
var_value = var_line.split('=', maxsplit=1)[1].strip()
cron_var.append({'name': var_name,
'value': var_value})
# Pop any shortcut lines
shortcut_list = []
for i, line in reversed(list(enumerate(cleandata))):
if line.strip().startswith('@'):
shortcut_line = cleandata.pop(i)
occurrence = shortcut_line.split(maxsplit=1)[0].strip().lstrip('@')
usr = shortcut_line.split(maxsplit=2)[1].strip()
cmd = shortcut_line.split(maxsplit=2)[2].strip()
shortcut_list.append({'occurrence': occurrence,
'user': usr,
'command': cmd})
raw_output['variables'] = cron_var
# Add header row for parsing
cleandata[:0] = ['minute hour day_of_month month day_of_week user command']
# Pop any shortcut lines
shortcut_list = []
for i, line in reversed(list(enumerate(cleandata))):
if line.strip().startswith('@'):
shortcut_line = cleandata.pop(i)
occurrence = shortcut_line.split(maxsplit=1)[0].strip().lstrip('@')
usr = shortcut_line.split(maxsplit=2)[1].strip()
cmd = shortcut_line.split(maxsplit=2)[2].strip()
shortcut_list.append({'occurrence': occurrence,
'user': usr,
'command': cmd})
if len(cleandata) > 1:
cron_list = jc.parsers.universal.simple_table_parse(cleandata)
# Add header row for parsing
cleandata[:0] = ['minute hour day_of_month month day_of_week user command']
raw_output['schedule'] = cron_list
if len(cleandata) > 1:
cron_list = jc.parsers.universal.simple_table_parse(cleandata)
# Add shortcut entries back in
for item in shortcut_list:
raw_output['schedule'].append(item)
raw_output['schedule'] = cron_list
# Add shortcut entries back in
for item in shortcut_list:
raw_output['schedule'].append(item)
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@@ -1,15 +1,26 @@
"""jc - JSON CLI output utility csv Parser
"""jc - JSON CLI output utility `csv` file parser
Usage:
The `csv` parser will attempt to automatically detect the delimiter character. If the delimiter cannot be detected it will default to comma. The first row of the file must be a header row.
specify --csv as the first argument if the piped input is coming from a csv file.
the csv parser will attempt to automatically detect the delimiter character.
if the delimiter cannot be detected it will default to comma.
the first row of the file must be a header row.
Usage (cli):
Compatibility:
$ cat file.csv | jc --csv
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
Usage (module):
import jc.parsers.csv
result = jc.parsers.csv.parse(csv_output)
Schema:
csv file converted to a Dictionary: https://docs.python.org/3/library/csv.html
[
{
"column_name1": string,
"column_name2": string
}
]
Examples:
@@ -63,7 +74,8 @@ import csv
class info():
version = '1.0'
"""Provides parser metadata (version, author, etc.)"""
version = '1.2'
description = 'CSV file parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -76,24 +88,17 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of dictionaries. Each dictionary represents a row in the csv file:
[
{
csv file converted to a Dictionary
https://docs.python.org/3/library/csv.html
}
]
List of Dictionaries. Each Dictionary represents a row in the csv file.
"""
# No further processing
@@ -112,7 +117,7 @@ def parse(data, raw=False, quiet=False):
Returns:
List of dictionaries. Raw or processed structured data.
List of Dictionaries. Raw or processed structured data.
"""
if not quiet:
jc.utils.compatibility(__name__, info.compatible)
@@ -123,7 +128,8 @@ def parse(data, raw=False, quiet=False):
# Clear any blank lines
cleandata = list(filter(None, cleandata))
if cleandata:
if jc.utils.has_data(data):
dialect = None
try:
dialect = csv.Sniffer().sniff(data[:1024])
@@ -138,4 +144,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

191
jc/parsers/date.py Normal file
View File

@@ -0,0 +1,191 @@
"""jc - JSON CLI output utility `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)
The `epoch_utc` calculated timestamp field is timezone-aware and is only available if the timezone field is UTC.
Usage (cli):
$ date | jc --date
or
$ jc date
Usage (module):
import jc.parsers.date
result = jc.parsers.date.parse(date_command_output)
Schema:
{
"year": integer,
"month": string,
"month_num": integer,
"day": integer,
"weekday": string,
"weekday_num": integer,
"hour": integer,
"hour_24": integer,
"minute": integer,
"second": integer,
"period": string,
"timezone": string,
"utc_offset": string, # null if timezone field is not UTC
"day_of_year": integer,
"week_of_year": integer,
"iso": string,
"epoch": integer, # naive timestamp
"epoch_utc": integer, # timezone-aware timestamp. Only available if timezone field is UTC
"timezone_aware": boolean # if true, all fields are correctly based on UTC
}
Examples:
$ date | jc --date -p
{
"year": 2021,
"month": "Mar",
"month_num": 3,
"day": 25,
"weekday": "Thu",
"weekday_num": 4,
"hour": 2,
"hour_24": 2,
"minute": 2,
"second": 26,
"period": "AM",
"timezone": "UTC",
"utc_offset": "+0000",
"day_of_year": 84,
"week_of_year": 12,
"iso": "2021-03-25T02:02:26+00:00",
"epoch": 1616662946,
"epoch_utc": 1616637746,
"timezone_aware": true
}
"""
from datetime import datetime, timezone
import jc.utils
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '2.1'
description = '`date` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
compatible = ['linux', 'darwin', 'freebsd']
magic_commands = ['date']
__version__ = info.version
def _process(proc_data):
"""
Final processing to conform to the schema.
Parameters:
proc_data: (Dictionary) raw structured data to process
Returns:
Dictionary. Structured data to conform to the schema.
"""
# no further processing
return proc_data
def parse(data, raw=False, quiet=False):
"""
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.
"""
if not quiet:
jc.utils.compatibility(__name__, info.compatible)
raw_output = {}
if jc.utils.has_data(data):
# find the timezone no matter where it is in the string
# from https://www.timeanddate.com/time/zones/
tz_abbr = ['A', 'ACDT', 'ACST', 'ACT', 'ACWST', 'ADT', 'AEDT', 'AEST', 'AET', 'AFT', 'AKDT', 'AKST', 'ALMT',
'AMST', 'AMT', 'ANAST', 'ANAT', 'AQTT', 'ART', 'AST', 'AT', 'AWDT', 'AWST', 'AZOST', 'AZOT',
'AZST', 'AZT', 'AoE', 'B', 'BNT', 'BOT', 'BRST', 'BRT', 'BST', 'BTT', 'C', 'CAST', 'CAT', 'CCT',
'CDT', 'CEST', 'CET', 'CHADT', 'CHAST', 'CHOST', 'CHOT', 'CHUT', 'CIDST', 'CIST', 'CKT', 'CLST',
'CLT', 'COT', 'CST', 'CT', 'CVT', 'CXT', 'ChST', 'D', 'DAVT', 'DDUT', 'E', 'EASST', 'EAST',
'EAT', 'ECT', 'EDT', 'EEST', 'EET', 'EGST', 'EGT', 'EST', 'ET', 'F', 'FET', 'FJST', 'FJT', 'FKST',
'FKT', 'FNT', 'G', 'GALT', 'GAMT', 'GET', 'GFT', 'GILT', 'GMT', 'GST', 'GYT', 'H', 'HDT', 'HKT',
'HOVST', 'HOVT', 'HST', 'I', 'ICT', 'IDT', 'IOT', 'IRDT', 'IRKST', 'IRKT', 'IRST', 'IST', 'JST',
'K', 'KGT', 'KOST', 'KRAST', 'KRAT', 'KST', 'KUYT', 'L', 'LHDT', 'LHST', 'LINT', 'M', 'MAGST',
'MAGT', 'MART', 'MAWT', 'MDT', 'MHT', 'MMT', 'MSD', 'MSK', 'MST', 'MT', 'MUT', 'MVT', 'MYT', 'N',
'NCT', 'NDT', 'NFDT', 'NFT', 'NOVST', 'NOVT', 'NPT', 'NRT', 'NST', 'NUT', 'NZDT', 'NZST', 'O',
'OMSST', 'OMST', 'ORAT', 'P', 'PDT', 'PET', 'PETST', 'PETT', 'PGT', 'PHOT', 'PHT', 'PKT', 'PMDT',
'PMST', 'PONT', 'PST', 'PT', 'PWT', 'PYST', 'PYT', 'Q', 'QYZT', 'R', 'RET', 'ROTT', 'S', 'SAKT',
'SAMT', 'SAST', 'SBT', 'SCT', 'SGT', 'SRET', 'SRT', 'SST', 'SYOT', 'T', 'TAHT', 'TFT', 'TJT', 'TKT',
'TLT', 'TMT', 'TOST', 'TOT', 'TRT', 'TVT', 'U', 'ULAST', 'ULAT', 'UYST', 'UYT', 'UZT', 'V', 'VET',
'VLAST', 'VLAT', 'VOST', 'VUT', 'W', 'WAKT', 'WARST', 'WAST', 'WAT', 'WEST', 'WET', 'WFT', 'WGST',
'WGT', 'WIB', 'WIT', 'WITA', 'WST', 'WT', 'X', 'Y', 'YAKST', 'YAKT', 'YAPT', 'YEKST', 'YEKT', 'Z',
'UTC', 'UTC-1200', 'UTC-1100', 'UTC-1000', 'UTC-0930', 'UTC-0900', 'UTC-0800', 'UTC-0700', 'UTC-0600',
'UTC-0500', 'UTC-0400', 'UTC-0300', 'UTC-0230', 'UTC-0200', 'UTC-0100', 'UTC+0000', 'UTC-0000',
'UTC+0100', 'UTC+0200', 'UTC+0300', 'UTC+0400', 'UTC+0430', 'UTC+0500', 'UTC+0530', 'UTC+0545',
'UTC+0600', 'UTC+0630', 'UTC+0700', 'UTC+0800', 'UTC+0845', 'UTC+0900', 'UTC+1000', 'UTC+1030',
'UTC+1100', 'UTC+1200', 'UTC+1300', 'UTC+1345', 'UTC+1400']
tz = None
for term in data.replace('(', '').replace(')', '').split():
if term in tz_abbr:
tz = term
dt = None
dt_utc = None
timestamp = jc.utils.timestamp(data)
if timestamp.naive:
dt = datetime.fromtimestamp(timestamp.naive)
if timestamp.utc:
dt_utc = datetime.fromtimestamp(timestamp.utc, timezone.utc)
if dt_utc:
dt = dt_utc
raw_output = {
'year': dt.year,
'month': dt.strftime('%b'),
'month_num': dt.month,
'day': dt.day,
'weekday': dt.strftime('%a'),
'weekday_num': dt.isoweekday(),
'hour': int(dt.strftime('%I')),
'hour_24': dt.hour,
'minute': dt.minute,
'second': dt.second,
'period': dt.strftime('%p'),
'timezone': tz,
'utc_offset': dt.strftime('%z') or None,
'day_of_year': int(dt.strftime('%j')),
'week_of_year': int(dt.strftime('%W')),
'iso': dt.isoformat(),
'epoch': timestamp.naive,
'epoch_utc': timestamp.utc,
'timezone_aware': True if timestamp.utc else False
}
if raw:
return raw_output
else:
return _process(raw_output)

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