mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2026-04-03 17:44:07 +02:00
Compare commits
710 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2683dbb20a | ||
|
|
8b3228797e | ||
|
|
947b37397f | ||
|
|
f5f0e00e8d | ||
|
|
73ab7da665 | ||
|
|
6f00b6fd61 | ||
|
|
8ada8b79c1 | ||
|
|
cd293d4786 | ||
|
|
b7d59bdd85 | ||
|
|
894f599f79 | ||
|
|
29bb10b8ff | ||
|
|
7224c7183b | ||
|
|
81301357e4 | ||
|
|
ddca18f25a | ||
|
|
d1164290a6 | ||
|
|
3949edc169 | ||
|
|
a296ac2e8f | ||
|
|
551f4b097d | ||
|
|
8d42f747a7 | ||
|
|
163a76dd10 | ||
|
|
7389ed5d0c | ||
|
|
5905058e97 | ||
|
|
2a11fefe45 | ||
|
|
e27ed0743c | ||
|
|
9f6a788a98 | ||
|
|
a15d20b400 | ||
|
|
55ae836a43 | ||
|
|
c4fc5409e3 | ||
|
|
956ad75168 | ||
|
|
71494a53ca | ||
|
|
bc211b7c36 | ||
|
|
2eaef09770 | ||
|
|
641d63604b | ||
|
|
750a3906c7 | ||
|
|
bd8e69ce98 | ||
|
|
16b17dd7aa | ||
|
|
d5a6c22cc6 | ||
|
|
b2271713e1 | ||
|
|
f0b9662c5e | ||
|
|
720c6b5d42 | ||
|
|
c30d44ea13 | ||
|
|
b5788134b6 | ||
|
|
790103fb48 | ||
|
|
e56944dc24 | ||
|
|
ed04951ed7 | ||
|
|
84337fe3d1 | ||
|
|
da631c8b22 | ||
|
|
450d0d5ddf | ||
|
|
0ed47fc7ce | ||
|
|
d57a00e8be | ||
|
|
fa7721c31d | ||
|
|
0f72d46050 | ||
|
|
fe3b5bc2ed | ||
|
|
4f7f8dd82b | ||
|
|
81fb294859 | ||
|
|
c04fd5bbf9 | ||
|
|
d6ed5a0eba | ||
|
|
33b996f6be | ||
|
|
26d4bbe9a4 | ||
|
|
5abea6d0c5 | ||
|
|
afce7cdbd7 | ||
|
|
8c3cff59c6 | ||
|
|
bc15a636f1 | ||
|
|
1564533161 | ||
|
|
27fd6843cc | ||
|
|
8c8d5552c8 | ||
|
|
a7ee414c67 | ||
|
|
6573b355cc | ||
|
|
eaa36a6a31 | ||
|
|
8b1c4f923e | ||
|
|
89c36e4996 | ||
|
|
0ea5c9585a | ||
|
|
5fa2fe3992 | ||
|
|
014437298c | ||
|
|
04d91516e8 | ||
|
|
9b33a50bb0 | ||
|
|
b0e9d9fa9d | ||
|
|
991b612b62 | ||
|
|
855c9363a5 | ||
|
|
625544f53e | ||
|
|
f179da8cd1 | ||
|
|
eeee776555 | ||
|
|
d0bde14a2a | ||
|
|
69b0e407ad | ||
|
|
ad2b9ab76c | ||
|
|
32483de4f2 | ||
|
|
ec713cfa1b | ||
|
|
eac8c1c1a0 | ||
|
|
4e15ab7924 | ||
|
|
5882755e7c | ||
|
|
13388df603 | ||
|
|
430385fa63 | ||
|
|
7bfebdcfeb | ||
|
|
e472c3b140 | ||
|
|
43ac3d951c | ||
|
|
207fa232c3 | ||
|
|
667dc1976a | ||
|
|
7437750de5 | ||
|
|
aab47c9e80 | ||
|
|
f1ed803525 | ||
|
|
093c1703d7 | ||
|
|
1f2e16aeea | ||
|
|
6f89745a58 | ||
|
|
9b710b0b6f | ||
|
|
992120b861 | ||
|
|
229bef5f82 | ||
|
|
c8a4890fc7 | ||
|
|
10a9848ac8 | ||
|
|
95189e37ba | ||
|
|
fe1f09f08d | ||
|
|
6adfa15742 | ||
|
|
edef264f17 | ||
|
|
9911b3fc9d | ||
|
|
1675aa7a59 | ||
|
|
7fd67fda13 | ||
|
|
7583f315ce | ||
|
|
7fd70d2088 | ||
|
|
337ee73844 | ||
|
|
43702a260b | ||
|
|
40208a9f76 | ||
|
|
b958358389 | ||
|
|
c23aacedad | ||
|
|
4f148469d7 | ||
|
|
247c43278c | ||
|
|
45f45e0511 | ||
|
|
c0c469ae9b | ||
|
|
4b86fd8d8a | ||
|
|
8fba47f449 | ||
|
|
f9ae964280 | ||
|
|
ca95615d7f | ||
|
|
747b255e34 | ||
|
|
c0da9ebd6c | ||
|
|
5c40b38a05 | ||
|
|
7bc03dcf06 | ||
|
|
f62e6168fd | ||
|
|
39c1470ea6 | ||
|
|
e48b99f1c1 | ||
|
|
71ae545907 | ||
|
|
b9a5eda187 | ||
|
|
231a2039c2 | ||
|
|
a415bc23fa | ||
|
|
79add35fc1 | ||
|
|
901763fc39 | ||
|
|
1034cb1ea2 | ||
|
|
020093fd67 | ||
|
|
f17b3fbd32 | ||
|
|
15b58e3a6b | ||
|
|
da6c98826b | ||
|
|
26415e2978 | ||
|
|
d849bd3b66 | ||
|
|
5996192455 | ||
|
|
a38b6b5522 | ||
|
|
1d6bc40bff | ||
|
|
437fa62cb1 | ||
|
|
6cde26d9ed | ||
|
|
f6dd5a68cd | ||
|
|
b1507dc576 | ||
|
|
a5d5b1554f | ||
|
|
ec8efebc94 | ||
|
|
f86cbf5527 | ||
|
|
57142d899c | ||
|
|
504a04279e | ||
|
|
3b4ef4a814 | ||
|
|
a7e3d2fc86 | ||
|
|
776ee66bae | ||
|
|
9bf2cd0691 | ||
|
|
fec74cf305 | ||
|
|
d3d7fbca61 | ||
|
|
550862a415 | ||
|
|
1763b530da | ||
|
|
8307150cae | ||
|
|
d2223c45d1 | ||
|
|
472ee5e295 | ||
|
|
1d0aebd836 | ||
|
|
8240626043 | ||
|
|
2cd14235c8 | ||
|
|
f774513554 | ||
|
|
388da9f003 | ||
|
|
fa18243491 | ||
|
|
5df1c1702b | ||
|
|
b6557802f4 | ||
|
|
15e3a511b6 | ||
|
|
08fbde0e8f | ||
|
|
28ebb4e8dd | ||
|
|
04fda57cbe | ||
|
|
b24495136c | ||
|
|
7d3fa55571 | ||
|
|
a76b5db8db | ||
|
|
667dd01ac7 | ||
|
|
559bee962a | ||
|
|
9f977d06e0 | ||
|
|
f67a916940 | ||
|
|
8a1308948f | ||
|
|
4e130d11a3 | ||
|
|
51aa5b268f | ||
|
|
6869133f53 | ||
|
|
ad3d88e47f | ||
|
|
6d29f8ba74 | ||
|
|
c7cb89e91d | ||
|
|
27f5118abd | ||
|
|
ac5a6e516d | ||
|
|
5d5bfbc1d1 | ||
|
|
9f4ba80000 | ||
|
|
c21c334b73 | ||
|
|
14093d9d43 | ||
|
|
176ca2f75d | ||
|
|
cfb71c7dad | ||
|
|
722eab83b1 | ||
|
|
d30edb2dae | ||
|
|
cba461ce8a | ||
|
|
f876505e25 | ||
|
|
5b9fcd5852 | ||
|
|
8a122cd9e1 | ||
|
|
557e68225c | ||
|
|
dc0947b87e | ||
|
|
af2c06cd28 | ||
|
|
67a4c6f797 | ||
|
|
0d1c857410 | ||
|
|
c7684dc94d | ||
|
|
a247572f64 | ||
|
|
306111303a | ||
|
|
c12b48537a | ||
|
|
0bf69713ab | ||
|
|
c05f1475ed | ||
|
|
416c262f02 | ||
|
|
40a5976f11 | ||
|
|
dc582fbec8 | ||
|
|
7047f0a449 | ||
|
|
d7a884a567 | ||
|
|
28de57792c | ||
|
|
a230cdbd21 | ||
|
|
251a261679 | ||
|
|
3baef254fd | ||
|
|
9e69e928b2 | ||
|
|
6eb595d2ca | ||
|
|
acf07a5144 | ||
|
|
7f53c58057 | ||
|
|
a069dc4855 | ||
|
|
febf544202 | ||
|
|
f2dd7b8815 | ||
|
|
d758e37fe3 | ||
|
|
9bc02a5623 | ||
|
|
eb0ec265d0 | ||
|
|
1f236dc02a | ||
|
|
86c279cbb2 | ||
|
|
4a7f1bed3a | ||
|
|
a730ae18c8 | ||
|
|
930bf439c0 | ||
|
|
f5f3133b87 | ||
|
|
cbca96de84 | ||
|
|
4d8ae3f124 | ||
|
|
653127431d | ||
|
|
22acef3765 | ||
|
|
0d5bf11f0d | ||
|
|
a824ccaff3 | ||
|
|
97ac965ba5 | ||
|
|
3e7f284df5 | ||
|
|
5c749fe26f | ||
|
|
aa48b46f48 | ||
|
|
6eaa4ae176 | ||
|
|
60c330b342 | ||
|
|
fdeb994121 | ||
|
|
65ed92fe7b | ||
|
|
9c8730786b | ||
|
|
7608823ea7 | ||
|
|
4f8c1a2ca2 | ||
|
|
37489dd4e1 | ||
|
|
a53aa1d0b8 | ||
|
|
f7b64a5762 | ||
|
|
9b1fe0d9a4 | ||
|
|
b876645fc5 | ||
|
|
d9c0b8f8ad | ||
|
|
78d2b239c8 | ||
|
|
5a12d98893 | ||
|
|
621f11e6f9 | ||
|
|
8417f2fe4e | ||
|
|
3ef2a0a065 | ||
|
|
faec16d1f2 | ||
|
|
a4ef52b533 | ||
|
|
0b407123c2 | ||
|
|
98eedc69ec | ||
|
|
dd231ae293 | ||
|
|
ad6196ddab | ||
|
|
49ca0cecf4 | ||
|
|
148f2fb6db | ||
|
|
e04cd298fb | ||
|
|
5bb4e2b4b6 | ||
|
|
7b22db50d3 | ||
|
|
fecb2193ae | ||
|
|
46af3bd0c0 | ||
|
|
c245c89f82 | ||
|
|
a8f0cd9dae | ||
|
|
3101189d47 | ||
|
|
3f0b644b85 | ||
|
|
25c2c483f8 | ||
|
|
8bc2ea14a3 | ||
|
|
8d4f22d9a5 | ||
|
|
d2adc2630c | ||
|
|
727f2b589e | ||
|
|
abbfc92da0 | ||
|
|
73b7e71cad | ||
|
|
4825b16f07 | ||
|
|
d2013366cc | ||
|
|
96609a2c70 | ||
|
|
39306573da | ||
|
|
01e330aa97 | ||
|
|
f08a74097d | ||
|
|
79e37a7383 | ||
|
|
3eebb6ee19 | ||
|
|
096fffdb79 | ||
|
|
728d882ed0 | ||
|
|
b53e42aca6 | ||
|
|
477329ce5b | ||
|
|
283dc4efd5 | ||
|
|
d490bbcaa0 | ||
|
|
f49ddf8e5c | ||
|
|
e1e341652b | ||
|
|
ecda667549 | ||
|
|
a0d96a188a | ||
|
|
6c0f0cddfe | ||
|
|
c7173ecd89 | ||
|
|
e98240c905 | ||
|
|
6cb7e25974 | ||
|
|
c37980c05c | ||
|
|
b5943bd39d | ||
|
|
49a3a7db3b | ||
|
|
0c55240e9d | ||
|
|
f91988aed5 | ||
|
|
3c3ad9fc6a | ||
|
|
291ab79e22 | ||
|
|
e6d5892c14 | ||
|
|
dcca7a57d5 | ||
|
|
4ee8a69337 | ||
|
|
c0414e7db7 | ||
|
|
a419175fe6 | ||
|
|
cd6dead034 | ||
|
|
45342ea9fe | ||
|
|
585bf0e159 | ||
|
|
3a860b9bab | ||
|
|
269180df77 | ||
|
|
a1afed8d95 | ||
|
|
e39f150a21 | ||
|
|
e85f11c6fc | ||
|
|
49a9d7b07e | ||
|
|
a2ef9c429e | ||
|
|
d5e9074f1c | ||
|
|
774699f085 | ||
|
|
7138eef3d1 | ||
|
|
fad5e544aa | ||
|
|
64757e2cf5 | ||
|
|
e05be3f08b | ||
|
|
789f0735df | ||
|
|
34bc775317 | ||
|
|
38de059a1b | ||
|
|
304ae6268f | ||
|
|
978caf4522 | ||
|
|
17df5bfcfc | ||
|
|
5e6a5068cf | ||
|
|
619de68a61 | ||
|
|
6748c3cc91 | ||
|
|
0a462978b7 | ||
|
|
e66a82ff49 | ||
|
|
f3aa797d96 | ||
|
|
e5b478218c | ||
|
|
35e0e9c32a | ||
|
|
17c3c2f029 | ||
|
|
cf83e6398b | ||
|
|
94e061b881 | ||
|
|
720480e39c | ||
|
|
82a63fe159 | ||
|
|
9c1ec9940e | ||
|
|
f23f19da45 | ||
|
|
aea2e1b0a9 | ||
|
|
7d95d679bf | ||
|
|
b3b140066b | ||
|
|
b204c423c1 | ||
|
|
d451c309bb | ||
|
|
01d53da68e | ||
|
|
53dd05e52c | ||
|
|
ab564f5be8 | ||
|
|
00c39450f9 | ||
|
|
f611d08b50 | ||
|
|
90e79b7df3 | ||
|
|
4eb2d725d5 | ||
|
|
51ae5ebcac | ||
|
|
9ecbdb0916 | ||
|
|
b3a2886fd0 | ||
|
|
ceacec0f46 | ||
|
|
ff0f794b01 | ||
|
|
70fafbf3f8 | ||
|
|
5a248a8fc5 | ||
|
|
4a3a4e10df | ||
|
|
c27bd5ff39 | ||
|
|
f804c9627f | ||
|
|
3ab25d02f9 | ||
|
|
9e80fd2b97 | ||
|
|
ff9527a098 | ||
|
|
7dac2f8dc3 | ||
|
|
32e4d55e86 | ||
|
|
f9a9062147 | ||
|
|
89e5919796 | ||
|
|
e5f5b2591d | ||
|
|
77c667eec0 | ||
|
|
b257ce8c2f | ||
|
|
c693c868ca | ||
|
|
6f98b27a05 | ||
|
|
d7efd25d88 | ||
|
|
2cddb1f0bb | ||
|
|
ae1c331595 | ||
|
|
bc97052ed4 | ||
|
|
6c3e0e2aa0 | ||
|
|
dd052e0146 | ||
|
|
54e8f58145 | ||
|
|
def7aa5764 | ||
|
|
6986c74f6d | ||
|
|
b784db404d | ||
|
|
8aee4517bb | ||
|
|
a5fb8fbf94 | ||
|
|
b9365e2ac2 | ||
|
|
696338c1a3 | ||
|
|
4f0616190b | ||
|
|
3278cb0de3 | ||
|
|
4fc04256a5 | ||
|
|
e4ae0fea63 | ||
|
|
d3727ea090 | ||
|
|
0d13909cf6 | ||
|
|
c52ca20e28 | ||
|
|
21f27f26c8 | ||
|
|
5e7a87f397 | ||
|
|
845d763829 | ||
|
|
f5c7d52ec7 | ||
|
|
c3198a5874 | ||
|
|
bbd4afa735 | ||
|
|
ae754a84bf | ||
|
|
3389eb5deb | ||
|
|
01f2c1e71f | ||
|
|
8bfbf8f1bc | ||
|
|
f4242669ba | ||
|
|
bebd9331f1 | ||
|
|
ac61e9ad2c | ||
|
|
648ef4d8a9 | ||
|
|
727fc9a701 | ||
|
|
306512d6bb | ||
|
|
6afb1d389c | ||
|
|
9861983481 | ||
|
|
ca79053db0 | ||
|
|
29c263f878 | ||
|
|
128c3c170a | ||
|
|
a531ab8864 | ||
|
|
0c1be7cc11 | ||
|
|
e4222b45f5 | ||
|
|
ac32c69c31 | ||
|
|
cb2dfeac8d | ||
|
|
9a3602e70b | ||
|
|
a9f53ee258 | ||
|
|
6be3d3d982 | ||
|
|
e49df72083 | ||
|
|
7ede7be7bf | ||
|
|
4758e28a36 | ||
|
|
4a1ee151b3 | ||
|
|
8c8afc1a92 | ||
|
|
ed205f7720 | ||
|
|
d65f7ae992 | ||
|
|
e2ffef57b9 | ||
|
|
002caa9fb3 | ||
|
|
b7c6faf3da | ||
|
|
554ca61d17 | ||
|
|
7b9722d255 | ||
|
|
5505bde8ef | ||
|
|
dbcd9a4060 | ||
|
|
4bdeb2b3aa | ||
|
|
6ae1d03187 | ||
|
|
f75b06abe4 | ||
|
|
1923925710 | ||
|
|
2c5c57ae04 | ||
|
|
f4d11d697e | ||
|
|
7f409b7082 | ||
|
|
937fa5aad2 | ||
|
|
19dcef5135 | ||
|
|
3d01356461 | ||
|
|
2d6f666fa4 | ||
|
|
4dda895f12 | ||
|
|
52617b1722 | ||
|
|
961968a0fc | ||
|
|
f026a788e5 | ||
|
|
2f7c03eb35 | ||
|
|
3afaa48eee | ||
|
|
3201452564 | ||
|
|
7ee1e34fc7 | ||
|
|
67dbf05016 | ||
|
|
4ac9f2e3da | ||
|
|
3f5f6e39a7 | ||
|
|
4723db8e3c | ||
|
|
ca914ec77d | ||
|
|
dcc7f3f357 | ||
|
|
cbdc666236 | ||
|
|
184ef3a1fa | ||
|
|
c732f75944 | ||
|
|
7a1ae4f5fc | ||
|
|
d04bc3757c | ||
|
|
73e8391653 | ||
|
|
f6c1463c15 | ||
|
|
d392c7f901 | ||
|
|
d0387f5820 | ||
|
|
76f92908a3 | ||
|
|
1a115da67b | ||
|
|
f0a37ccf30 | ||
|
|
f331f53a53 | ||
|
|
8611aff06b | ||
|
|
2f3f78e8d3 | ||
|
|
d1e0ee6123 | ||
|
|
45314c9808 | ||
|
|
df00945b46 | ||
|
|
fda0050d86 | ||
|
|
a76d46f9ec | ||
|
|
6b069a82d0 | ||
|
|
6b793d0521 | ||
|
|
ce9103f7cc | ||
|
|
671d6dee36 | ||
|
|
49929c714c | ||
|
|
2986771f07 | ||
|
|
520082d963 | ||
|
|
021e296d45 | ||
|
|
42e56fbcea | ||
|
|
a5b62a4055 | ||
|
|
be98c9b7f6 | ||
|
|
aceeb84507 | ||
|
|
1391063217 | ||
|
|
52157addd0 | ||
|
|
ec0bc6615e | ||
|
|
2f80800e38 | ||
|
|
3959d3347c | ||
|
|
b57d25c69a | ||
|
|
63e43a7cab | ||
|
|
21719f9a26 | ||
|
|
96ec70de4f | ||
|
|
a15a1967dc | ||
|
|
a10d756629 | ||
|
|
0700dc7a64 | ||
|
|
ca654b2140 | ||
|
|
4ff3b87c1c | ||
|
|
ea244fb7a9 | ||
|
|
8061f30e6f | ||
|
|
8f3b12e81e | ||
|
|
d0694ce0db | ||
|
|
0cd4c4bc7f | ||
|
|
12f90c349c | ||
|
|
26b8a1f167 | ||
|
|
3abe382c06 | ||
|
|
1e2edc2c7b | ||
|
|
5fe032a674 | ||
|
|
e825c02df1 | ||
|
|
a4a4d170b5 | ||
|
|
d0fcd523cb | ||
|
|
f72b7dc75d | ||
|
|
4101dc6bf7 | ||
|
|
ea5011b616 | ||
|
|
d6de81747f | ||
|
|
38f04b1c96 | ||
|
|
84169e1a91 | ||
|
|
1f96586a5e | ||
|
|
681176e4c9 | ||
|
|
8bb2663522 | ||
|
|
663abf3139 | ||
|
|
f7ac41db95 | ||
|
|
5502cda9e5 | ||
|
|
a2b165565f | ||
|
|
b426369815 | ||
|
|
ac0840cc0a | ||
|
|
ee98ab0a4a | ||
|
|
2adec2c003 | ||
|
|
f19c9c71bf | ||
|
|
e93adf1884 | ||
|
|
254c4fc507 | ||
|
|
74d5f60d14 | ||
|
|
db7dc0634b | ||
|
|
e156b0db45 | ||
|
|
50adc05fbd | ||
|
|
446cac7c21 | ||
|
|
28ffe3076b | ||
|
|
d4d5e206ca | ||
|
|
42fbe40a4a | ||
|
|
27e4a120e2 | ||
|
|
b5d5b7c73a | ||
|
|
e7471556ba | ||
|
|
640a21341b | ||
|
|
f5befad3e4 | ||
|
|
f8223023c3 | ||
|
|
7028e87f9b | ||
|
|
590728f9c1 | ||
|
|
7cc147fe2d | ||
|
|
3cfb3965bb | ||
|
|
155d421322 | ||
|
|
d3e10bb87b | ||
|
|
fd5433ee62 | ||
|
|
4568f2d06e | ||
|
|
c36e513d1b | ||
|
|
8e089baf3f | ||
|
|
386f6c317e | ||
|
|
75cd84ce8a | ||
|
|
6fad44e35d | ||
|
|
1caac750da | ||
|
|
16370dcb3d | ||
|
|
c1302f2573 | ||
|
|
6f0ffe0955 | ||
|
|
1f89745fe7 | ||
|
|
a46ac18ef7 | ||
|
|
1a05f1c575 | ||
|
|
08f818aa42 | ||
|
|
b3896650c2 | ||
|
|
f285539526 | ||
|
|
a896dcdf3b | ||
|
|
0a187d4ed0 | ||
|
|
2d65bc57d5 | ||
|
|
ab63809fde | ||
|
|
6f04707dc6 | ||
|
|
d14a86a9b5 | ||
|
|
8e6a31d3da | ||
|
|
6e7b6afe87 | ||
|
|
027c231097 | ||
|
|
f1cf7d1f95 | ||
|
|
df611cc263 | ||
|
|
0f3143bbbb | ||
|
|
c280757b76 | ||
|
|
d30b9d84ef | ||
|
|
50ded1dbd9 | ||
|
|
e319aea5a4 | ||
|
|
ba86509c1d | ||
|
|
0a9279ae6b | ||
|
|
a13dde12af | ||
|
|
e2ed358de1 | ||
|
|
a2cd366621 | ||
|
|
15addd9bfc | ||
|
|
a4e34b0053 | ||
|
|
d09529ac30 | ||
|
|
553097b505 | ||
|
|
49c5568577 | ||
|
|
6962b9ee8a | ||
|
|
b4575a3f78 | ||
|
|
35b54d235d | ||
|
|
583a5757e4 | ||
|
|
f355333eee | ||
|
|
4d7df10960 | ||
|
|
66b2c28f4b | ||
|
|
299a9c6d88 | ||
|
|
bd391d979c | ||
|
|
7309bd2282 | ||
|
|
ce84c09d33 | ||
|
|
b4fffbb647 | ||
|
|
3701b4198a | ||
|
|
d4c34098fa | ||
|
|
b3c531193b | ||
|
|
1d0e07c77b | ||
|
|
06a322cf9c | ||
|
|
623d148712 | ||
|
|
647e83d043 | ||
|
|
91a5544644 | ||
|
|
a1190998ae | ||
|
|
097d7a1850 | ||
|
|
302bf72e72 | ||
|
|
2c42baf3a4 | ||
|
|
03feb89c84 | ||
|
|
9dd553192f | ||
|
|
fa3f02e9d1 | ||
|
|
0a9dde58c5 | ||
|
|
70cb4453be | ||
|
|
830674cc6f | ||
|
|
fb406b58a1 | ||
|
|
55b272e412 | ||
|
|
94f62a9bf3 | ||
|
|
8d19e4cb7b | ||
|
|
7e510d48e0 | ||
|
|
7b20cffb14 | ||
|
|
5c934c43c1 | ||
|
|
8609298449 | ||
|
|
72cb0dc10b | ||
|
|
7b22fa81de | ||
|
|
0b6a130779 | ||
|
|
fdcf4338e0 | ||
|
|
ee43037f48 | ||
|
|
26e365563c | ||
|
|
1b39586bb1 | ||
|
|
8bb3a6bea3 | ||
|
|
e6900e2000 | ||
|
|
0ee244756b | ||
|
|
6d5ac9abe6 | ||
|
|
44f6d9e132 | ||
|
|
360154559c | ||
|
|
78672bd7ad | ||
|
|
65d96e26b5 | ||
|
|
241d53af9a | ||
|
|
5563829df2 | ||
|
|
3a4a27e1f9 | ||
|
|
9c887a36a8 | ||
|
|
bc7973af36 | ||
|
|
32972d8fdb | ||
|
|
b128d9109c | ||
|
|
929d7273a4 | ||
|
|
2a40f84274 | ||
|
|
9ff6fa818f | ||
|
|
dac73a4bfe | ||
|
|
d7895547f7 | ||
|
|
b7d439cb87 | ||
|
|
7cc903a5f5 | ||
|
|
c495a8291b | ||
|
|
5e1d7d777c | ||
|
|
7edad3f676 | ||
|
|
f7331001d4 | ||
|
|
f8e09ae2ff | ||
|
|
433c7cc0f0 |
159
CHANGELOG
159
CHANGELOG
@@ -1,5 +1,114 @@
|
||||
jc changelog
|
||||
|
||||
20220723 v1.20.3
|
||||
- Add URL string parser
|
||||
- Add Email Address string parser
|
||||
- Add JWT string parser
|
||||
- Add ISO 8601 Datetime string parser
|
||||
- Add UNIX Epoch Timestamp string parser
|
||||
- Add M3U/M3U8 file parser
|
||||
- Add pager functionality to help (parser documentation only)
|
||||
- Minor parser performance optimizations
|
||||
|
||||
20220705 v1.20.2
|
||||
- Add `gpg --with-colons` parser tested on linux
|
||||
- Add DER and PEM encoded X.509 Certificate parser
|
||||
- Add Bash and Zsh completion scripts to DEB and RPM packages
|
||||
|
||||
20220615 v1.20.1
|
||||
- Add `postconf -M` parser tested on linux
|
||||
- Update `asciitable` and `asciitable-m` parsers to preserve case in key
|
||||
names when using the `-r` or `raw=True` options.
|
||||
- Add long options (e.g. `--help`, `--about`, `--pretty`, etc.)
|
||||
- Add shell completions for Bash and Zsh
|
||||
- Fix `id` parser for cases where the user or group name is not present
|
||||
|
||||
20220531 v1.20.0
|
||||
- Add YAML output option with `-y`
|
||||
- Add `top -b` standard and streaming parsers tested on linux
|
||||
- Add `plugin_parser_count`, `standard_parser_count`, and `streaming_parser_count`
|
||||
keys to `jc -a` output
|
||||
- Add `is_compatible` function to the `utils` module
|
||||
- Fix `pip-show` parser for packages with a multi-line license field
|
||||
- Fix ASCII Table parser for cases where centered headers cause mis-aligned fields
|
||||
|
||||
20220513 v1.19.0
|
||||
- Add `chage --list` command parser tested on linux
|
||||
- Add `git log` command streaming parser
|
||||
- Fix `git log` standard parser for corner-cases where hash values are in messages
|
||||
- Fix `df` command parser for rare instances when a newline is found at the end
|
||||
- Allow jc to pip install on unsupported python version 3.6
|
||||
- Fix `asciitable-m` parser to skip some rows that contain column separator
|
||||
characters in cell data. A warning message will be printed to STDERR
|
||||
unless `-q` or `quiet=True` is used.
|
||||
|
||||
20220427 v1.18.8
|
||||
- Fix `update-alternatives --query` parser for cases where `slaves` are not present
|
||||
- Fix UnicodeEncodeError on some systems where LANG=C is set and unicode
|
||||
characters are in the output
|
||||
- Update `history` parser: do not drop non-ASCII characters if the system
|
||||
is configured for UTF-8 encoding
|
||||
- Enhance "magic syntax" to always use UTF-8 encoding
|
||||
|
||||
20220425 v1.18.7
|
||||
- Add `git log` command parser
|
||||
- Add `update-alternatives --query` parser
|
||||
- Add `update-alternatives --get-selections` parser
|
||||
- Fix key/value and ini parsers to allow duplicate keys
|
||||
- Fix yaml file parser for files including timestamp objects
|
||||
- Update `xrandr` parser: add a 'rotation' field
|
||||
- Fix failing tests by moving template files
|
||||
- Add python interpreter version and path to -v and -a output
|
||||
|
||||
20220325 v1.18.6
|
||||
- Add `pidstat` command parser tested on linux
|
||||
- Add `pidstat` command streaming parser tested on linux
|
||||
- Add `mpstat` command parser tested on linux
|
||||
- Add `mpstat` command streaming parser tested on linux
|
||||
- Add single-line ASCII and Unicode table parser
|
||||
- Add multi-line ASCII and Unicode table parser
|
||||
- Add documentation option to `parser_info()` and `all_parser_info()`
|
||||
|
||||
20220305 v1.18.5
|
||||
- Fix date parser to ensure AM/PM period string is always uppercase
|
||||
|
||||
20220304 v1.18.4
|
||||
- Add nmcli command parser tested on linux
|
||||
- Enhance parse error messages at the cli
|
||||
- Add standard and streaming parser list functions to the public API
|
||||
- Enhance python developer documentation formatting
|
||||
|
||||
20220214 v1.18.3
|
||||
- Add rsync command and log file parser tested on linux and macOS
|
||||
- Add rsync command and log file streaming parser tested on linux and macOS
|
||||
- Add xrandr command parser tested on linux
|
||||
- Enhance timestamp performance with caching and format hints
|
||||
- Refactor ignore_exceptions functionality in streaming parsers
|
||||
- Fix man page in packages
|
||||
|
||||
20220127 v1.18.2
|
||||
- Fix for plugin parsers with underscores in the name
|
||||
- Add type hints to public API functions
|
||||
- Add plugin attribute to plugin parser metadata
|
||||
- Add C locale hint to parsing error messages
|
||||
- Refactor more cli code into lib
|
||||
|
||||
20220121 v1.18.1
|
||||
- Minor fix for MacOS binary
|
||||
|
||||
20220121 v1.18.0
|
||||
- Add high-level parse API for built-in and plugin parsers
|
||||
- Add python module developer documentation
|
||||
- Enhance magic syntax exception messages
|
||||
- Enhance documentation formatting
|
||||
|
||||
20220106 v1.17.7
|
||||
- Add stat command streaming parser tested on linux and macOS
|
||||
|
||||
20220103 v1.17.6
|
||||
- Add jar-manifest file parser (for MANIFEST.MF files)
|
||||
- Fix CSV parsers for some files that include doublequotes
|
||||
|
||||
20211221 v1.17.5
|
||||
- Add zipinfo parser tested on linux and macOS
|
||||
|
||||
@@ -312,16 +421,16 @@ jc changelog
|
||||
- Add axfr support for dig command parser
|
||||
|
||||
20200312 v1.9.2
|
||||
- Updated arp parser to fix OSX detection for some edge cases
|
||||
- Update arp parser to fix OSX detection for some edge cases
|
||||
|
||||
20200312 v1.9.1
|
||||
- Updated file command parser to make filename splitting more robust
|
||||
- Update file command parser to make filename splitting more robust
|
||||
|
||||
20200311 v1.9.0
|
||||
- Added ntpq command parser
|
||||
- Added timedatectl status command parser
|
||||
- Added airport -I and airport -s command parser
|
||||
- Added file command parser
|
||||
- Add ntpq command parser
|
||||
- Add timedatectl status command parser
|
||||
- Add airport -I and airport -s command parser
|
||||
- Add file command parser
|
||||
- Optimized history command parser by https://github.com/philippeitis
|
||||
- Magic syntax fix for certain edge cases
|
||||
|
||||
@@ -329,23 +438,23 @@ jc changelog
|
||||
- CLI optimizations by https://github.com/philippeitis
|
||||
- Refactored magic syntax function and added tests (https://github.com/philippeitis)
|
||||
- Github actions for CI testing on multiple platforms by https://github.com/philippeitis
|
||||
- Updated ls parser to fix parsing error in OSX with -lR when there are empty folders
|
||||
- Update ls parser to fix parsing error in OSX with -lR when there are empty folders
|
||||
|
||||
20200303 v1.8.0
|
||||
- Added blkid command parser
|
||||
- Added last and lastb command parser
|
||||
- Added who command parser
|
||||
- Added CSV file parser
|
||||
- Added /etc/passwd file parser
|
||||
- Added /etc/shadow file parser
|
||||
- Added /etc/group file parser
|
||||
- Added /etc/gshadow file parser
|
||||
- Add blkid command parser
|
||||
- Add last and lastb command parser
|
||||
- Add who command parser
|
||||
- Add CSV file parser
|
||||
- Add /etc/passwd file parser
|
||||
- Add /etc/shadow file parser
|
||||
- Add /etc/group file parser
|
||||
- Add /etc/gshadow file parser
|
||||
|
||||
20200227 v1.7.5
|
||||
- Updated ls parser to support filenames with newline characters
|
||||
- Update ls parser to support filenames with newline characters
|
||||
|
||||
20200219 v1.7.4
|
||||
- Updated ls parser to support multiple directories, globbing, and -R (recursive)
|
||||
- Update ls parser to support multiple directories, globbing, and -R (recursive)
|
||||
|
||||
20200211 v1.7.3
|
||||
- Add alternative 'magic' syntax: e.g. `jc ls -al`
|
||||
@@ -362,8 +471,8 @@ jc changelog
|
||||
- Add crontab file parser with user support (tested on linux)
|
||||
- Add __version__ variable to parser modules
|
||||
- Add exit code on error
|
||||
- Updated history parser to output "line" as an integer
|
||||
- Updated compatibility list for some parsers
|
||||
- Update history parser to output "line" as an integer
|
||||
- Update compatibility list for some parsers
|
||||
- Bugfix in crontab file parser: header insertion was clobbering first row
|
||||
- Just-in-time loading of parser modules instead of loading all at start
|
||||
|
||||
@@ -376,7 +485,7 @@ jc changelog
|
||||
- Add tests for ls, dig, ps, w, uptime on OSX
|
||||
- Add about option
|
||||
- Add universal parsers to refactor repetitive code
|
||||
- Updated ifconfig parser to output 'state' as an array
|
||||
- Update ifconfig parser to output 'state' as an array
|
||||
|
||||
20191117 v1.5.1
|
||||
- Add ss parser
|
||||
@@ -389,11 +498,11 @@ jc changelog
|
||||
- Add -d option to debug parsing issues
|
||||
- Add compatibility warnings to stderr
|
||||
- Add documentation
|
||||
- Updated iptables parser to allow --line-numbers option
|
||||
- Updated lsblk parser to allow parsing of added columns
|
||||
- Updated mount parser: changed 'access' field name to 'options'
|
||||
- Updated netstat parser to allow parsing of unix sockets and raw network connections
|
||||
- Updated w parser to fix unaligned data where blanks are possible
|
||||
- Update iptables parser to allow --line-numbers option
|
||||
- Update lsblk parser to allow parsing of added columns
|
||||
- Update mount parser: changed 'access' field name to 'options'
|
||||
- Update netstat parser to allow parsing of unix sockets and raw network connections
|
||||
- Update w parser to fix unaligned data where blanks are possible
|
||||
- Clean up code and reorganize package
|
||||
|
||||
20191031 v1.1.1
|
||||
|
||||
763
EXAMPLES.md
763
EXAMPLES.md
@@ -265,6 +265,21 @@ blkid -o udev -ip /dev/sda2 | jc --blkid -p # or: jc -p blkid -o udev
|
||||
}
|
||||
]
|
||||
```
|
||||
### chage --list
|
||||
```bash
|
||||
chage --list joeuser | jc --chage -p # or: jc -p chage --list joeuser
|
||||
```
|
||||
```json
|
||||
{
|
||||
"password_last_changed": "never",
|
||||
"password_expires": "never",
|
||||
"password_inactive": "never",
|
||||
"account_expires": "never",
|
||||
"min_days_between_password_change": 0,
|
||||
"max_days_between_password_change": 99999,
|
||||
"warning_days_before_password_expires": 7
|
||||
}
|
||||
```
|
||||
### cksum
|
||||
```bash
|
||||
cksum * | jc --cksum -p # or: jc -p cksum *
|
||||
@@ -907,6 +922,18 @@ du /usr | jc --du -p # or: jc -p du /usr
|
||||
}
|
||||
]
|
||||
```
|
||||
### Email Address string
|
||||
```bash
|
||||
echo 'joe.user@gmail.com' | jc --email-address -p
|
||||
```
|
||||
```json
|
||||
{
|
||||
"username": "joe.user",
|
||||
"domain": "gmail.com",
|
||||
"local": "joe.user",
|
||||
"local_plus_suffix": null
|
||||
}
|
||||
```
|
||||
### env
|
||||
```bash
|
||||
env | jc --env -p # or: jc -p env
|
||||
@@ -1059,6 +1086,84 @@ cat /etc/fstab | jc --fstab -p
|
||||
}
|
||||
]
|
||||
```
|
||||
### git log
|
||||
```bash
|
||||
git log --stat | jc --git-log -p or: jc -p git log --stat
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"commit": "728d882ed007b3c8b785018874a0eb06e1143b66",
|
||||
"author": "Kelly Brazil",
|
||||
"author_email": "kellyjonbrazil@gmail.com",
|
||||
"date": "Wed Apr 20 09:50:19 2022 -0400",
|
||||
"stats": {
|
||||
"files_changed": 2,
|
||||
"insertions": 90,
|
||||
"deletions": 12,
|
||||
"files": [
|
||||
"docs/parsers/git_log.md",
|
||||
"jc/parsers/git_log.py"
|
||||
]
|
||||
},
|
||||
"message": "add timestamp docs and examples",
|
||||
"epoch": 1650462619,
|
||||
"epoch_utc": null
|
||||
},
|
||||
{
|
||||
"commit": "b53e42aca623181aa9bc72194e6eeef1e9a3a237",
|
||||
"author": "Kelly Brazil",
|
||||
"author_email": "kellyjonbrazil@gmail.com",
|
||||
"date": "Wed Apr 20 09:44:42 2022 -0400",
|
||||
"stats": {
|
||||
"files_changed": 5,
|
||||
"insertions": 29,
|
||||
"deletions": 6,
|
||||
"files": [
|
||||
"docs/parsers/git_log.md",
|
||||
"docs/utils.md",
|
||||
"jc/parsers/git_log.py",
|
||||
"jc/utils.py",
|
||||
"man/jc.1"
|
||||
]
|
||||
},
|
||||
"message": "add calculated timestamp",
|
||||
"epoch": 1650462282,
|
||||
"epoch_utc": null
|
||||
}
|
||||
]
|
||||
```
|
||||
### gpg --with-colons
|
||||
```bash
|
||||
gpg --with-colons --show-keys file.gpg | jc --gpg -p # or jc -p gpg --with-colons --show-keys file.gpg
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"type": "pub",
|
||||
"validity": "f",
|
||||
"key_length": "1024",
|
||||
"pub_key_alg": "17",
|
||||
"key_id": "6C7EE1B8621CC013",
|
||||
"creation_date": "899817715",
|
||||
"expiration_date": "1055898235",
|
||||
"certsn_uidhash_trustinfo": null,
|
||||
"owner_trust": "m",
|
||||
"user_id": null,
|
||||
"signature_class": null,
|
||||
"key_capabilities": "scESC",
|
||||
"cert_fingerprint_other": null,
|
||||
"flag": null,
|
||||
"token_sn": null,
|
||||
"hash_alg": null,
|
||||
"curve_name": null,
|
||||
"compliance_flags": null,
|
||||
"last_update_date": null,
|
||||
"origin": null,
|
||||
"comment": null
|
||||
}
|
||||
]
|
||||
```
|
||||
### /etc/group file
|
||||
```bash
|
||||
cat /etc/group | jc --group -p
|
||||
@@ -1622,6 +1727,31 @@ iptables --line-numbers -v -L -t nat | jc --iptables -p # or: jc -p ip
|
||||
}
|
||||
]
|
||||
```
|
||||
### ISO Datetime string
|
||||
```bash
|
||||
echo "2022-07-20T14:52:45Z" | jc --iso-datetime -p
|
||||
```
|
||||
```json
|
||||
{
|
||||
"year": 2022,
|
||||
"month": "Jul",
|
||||
"month_num": 7,
|
||||
"day": 20,
|
||||
"weekday": "Wed",
|
||||
"weekday_num": 3,
|
||||
"hour": 2,
|
||||
"hour_24": 14,
|
||||
"minute": 52,
|
||||
"second": 45,
|
||||
"microsecond": 0,
|
||||
"period": "PM",
|
||||
"utc_offset": "+0000",
|
||||
"day_of_year": 201,
|
||||
"week_of_year": 29,
|
||||
"iso": "2022-07-20T14:52:45+00:00",
|
||||
"timestamp": 1658328765
|
||||
}
|
||||
```
|
||||
### iw dev `device` scan
|
||||
```bash
|
||||
iw dev wlan0 scan | jc --iw-scan -p # or: jc -p iw dev wlan0 scan
|
||||
@@ -1713,6 +1843,27 @@ iw dev wlan0 scan | jc --iw-scan -p # or: jc -p iw dev wlan0 scan
|
||||
}
|
||||
]
|
||||
```
|
||||
### jar-manifest
|
||||
```bash
|
||||
cat MANIFEST.MF | jc --jar-manifest -p
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"Import_Package": "com.conversantmedia.util.concurrent;resolution:=optional,com.fasterxml.jackson.annotation;version=\"[2.12,3)\";resolution:=optional,com.fasterxml.jackson.core;version=\"[2.12,3)\";resolution:=optional,com.fasterxml.jackson.core.type;version=\"[2.12,3)\";resolution:=optional,com.fasterxml.jackson.cor...",
|
||||
"Export_Package": "org.apache.logging.log4j.core;uses:=\"org.apache.logging.log4j,org.apache.logging.log4j.core.config,org.apache.logging.log4j.core.impl,org.apache.logging.log4j.core.layout,org.apache.logging.log4j.core.time,org.apache.logging.log4j.message,org.apache.logging.log4j.spi,org.apache.logging.log4j.status...",
|
||||
"Manifest_Version": "1.0",
|
||||
"Bundle_License": "https://www.apache.org/licenses/LICENSE-2.0.txt",
|
||||
"Bundle_SymbolicName": "org.apache.logging.log4j.core",
|
||||
"Built_By": "matt",
|
||||
"Bnd_LastModified": "1639373735804",
|
||||
"Implementation_Vendor_Id": "org.apache.logging.log4j",
|
||||
"Specification_Title": "Apache Log4j Core",
|
||||
"Log4jReleaseManager": "Matt Sicker",
|
||||
...
|
||||
}
|
||||
]
|
||||
```
|
||||
### jobs
|
||||
```bash
|
||||
jobs -l | jc --jobs -p
|
||||
@@ -1747,6 +1898,24 @@ jobs -l | jc --jobs -p
|
||||
}
|
||||
]
|
||||
```
|
||||
### JWT string
|
||||
```bash
|
||||
echo 'eyJhbGciOiJIUzI1N...' | jc --jwt -p
|
||||
```
|
||||
```json
|
||||
{
|
||||
"header": {
|
||||
"alg": "HS256",
|
||||
"typ": "JWT"
|
||||
},
|
||||
"payload": {
|
||||
"sub": "1234567890",
|
||||
"name": "John Doe",
|
||||
"iat": 1516239022
|
||||
},
|
||||
"signature": "49:f9:4a:c7:04:49:48:c7:8a:28:5d:90:4f:87:f0:a4:c7..."
|
||||
}
|
||||
```
|
||||
### Key/Value files
|
||||
```bash
|
||||
cat keyvalue.txt
|
||||
@@ -2083,6 +2252,24 @@ lsusb -v | jc --lsusb -p # or: jc -p lsusb -v
|
||||
}
|
||||
]
|
||||
```
|
||||
### M3U and M3U8 files
|
||||
```bash
|
||||
cat playlist.m3u | jc --m3u -p
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"runtime": 105,
|
||||
"display": "Example artist - Example title",
|
||||
"path": "C:\\Files\\My Music\\Example.mp3"
|
||||
},
|
||||
{
|
||||
"runtime": 321,
|
||||
"display": "Example Artist2 - Example title2",
|
||||
"path": "C:\\Files\\My Music\\Favorites\\Example2.ogg"
|
||||
}
|
||||
]
|
||||
```
|
||||
### mount
|
||||
```bash
|
||||
mount | jc --mount -p # or: jc -p mount
|
||||
@@ -2128,6 +2315,29 @@ mount | jc --mount -p # or: jc -p mount
|
||||
}
|
||||
]
|
||||
```
|
||||
### mpstat
|
||||
```bash
|
||||
mpstat | jc --mpstat -p # or jc -p mpstat
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"cpu": "all",
|
||||
"percent_usr": 12.94,
|
||||
"percent_nice": 0.0,
|
||||
"percent_sys": 26.42,
|
||||
"percent_iowait": 0.43,
|
||||
"percent_irq": 0.0,
|
||||
"percent_soft": 0.16,
|
||||
"percent_steal": 0.0,
|
||||
"percent_guest": 0.0,
|
||||
"percent_gnice": 0.0,
|
||||
"percent_idle": 60.05,
|
||||
"type": "cpu",
|
||||
"time": "01:58:14 PM"
|
||||
}
|
||||
]
|
||||
```
|
||||
### netstat
|
||||
```bash
|
||||
netstat -apee | jc --netstat -p # or: jc -p netstat -apee
|
||||
@@ -2366,6 +2576,47 @@ netstat -i | jc --netstat -p # or: jc -p netstat -i
|
||||
}
|
||||
]
|
||||
```
|
||||
### nmcli
|
||||
```bash
|
||||
nmcli connection show ens33 | jc --nmcli -p # or jc -p nmcli connection show ens33
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"connection_id": "ens33",
|
||||
"connection_uuid": "d92ece08-9e02-47d5-b2d2-92c80e155744",
|
||||
"connection_stable_id": null,
|
||||
"connection_type": "802-3-ethernet",
|
||||
"connection_interface_name": "ens33",
|
||||
"connection_autoconnect": "yes",
|
||||
"ip4_address_1": "192.168.71.180/24",
|
||||
"ip4_gateway": "192.168.71.2",
|
||||
"ip4_route_1": {
|
||||
"dst": "0.0.0.0/0",
|
||||
"nh": "192.168.71.2",
|
||||
"mt": 100
|
||||
},
|
||||
"ip4_route_2": {
|
||||
"dst": "192.168.71.0/24",
|
||||
"nh": "0.0.0.0",
|
||||
"mt": 100
|
||||
},
|
||||
"ip4_dns_1": "192.168.71.2",
|
||||
"ip4_domain_1": "localdomain",
|
||||
"dhcp4_option_1": {
|
||||
"name": "broadcast_address",
|
||||
"value": "192.168.71.255"
|
||||
},
|
||||
"ip6_address_1": "fe80::c1cb:715d:bc3e:b8a0/64",
|
||||
"ip6_gateway": null,
|
||||
"ip6_route_1": {
|
||||
"dst": "fe80::/64",
|
||||
"nh": "::",
|
||||
"mt": 100
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
### ntpq
|
||||
```bash
|
||||
ntpq -p | jc --ntpq -p # or: jc -p ntpq -p
|
||||
@@ -2435,6 +2686,47 @@ cat /etc/passwd | jc --passwd -p
|
||||
}
|
||||
]
|
||||
```
|
||||
### pidstat
|
||||
```bash
|
||||
pidstat -hl | jc --pidstat -p # or jc -p pidstat -hl
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"time": 1646859134,
|
||||
"uid": 0,
|
||||
"pid": 1,
|
||||
"percent_usr": 0.0,
|
||||
"percent_system": 0.03,
|
||||
"percent_guest": 0.0,
|
||||
"percent_cpu": 0.03,
|
||||
"cpu": 0,
|
||||
"command": "/usr/lib/systemd/systemd --switched-root --system..."
|
||||
},
|
||||
{
|
||||
"time": 1646859134,
|
||||
"uid": 0,
|
||||
"pid": 6,
|
||||
"percent_usr": 0.0,
|
||||
"percent_system": 0.0,
|
||||
"percent_guest": 0.0,
|
||||
"percent_cpu": 0.0,
|
||||
"cpu": 0,
|
||||
"command": "ksoftirqd/0"
|
||||
},
|
||||
{
|
||||
"time": 1646859134,
|
||||
"uid": 0,
|
||||
"pid": 2263,
|
||||
"percent_usr": 0.0,
|
||||
"percent_system": 0.0,
|
||||
"percent_guest": 0.0,
|
||||
"percent_cpu": 0.0,
|
||||
"cpu": 0,
|
||||
"command": "kworker/0:0"
|
||||
}
|
||||
]
|
||||
```
|
||||
### ping
|
||||
```bash
|
||||
ping 8.8.8.8 -c 3 | jc --ping -p # or: jc -p ping 8.8.8.8 -c 3
|
||||
@@ -2540,6 +2832,36 @@ pip show wrapt wheel | jc --pip-show -p # or: jc -p pip show wrapt whe
|
||||
}
|
||||
]
|
||||
```
|
||||
### postconf -M
|
||||
```bash
|
||||
postconf -M | jc --postconf -p # or jc -p postconf -M
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"service_name": "smtp",
|
||||
"service_type": "inet",
|
||||
"private": false,
|
||||
"unprivileged": null,
|
||||
"chroot": true,
|
||||
"wake_up_time": null,
|
||||
"process_limit": null,
|
||||
"command": "smtpd",
|
||||
"no_wake_up_before_first_use": null
|
||||
},
|
||||
{
|
||||
"service_name": "pickup",
|
||||
"service_type": "unix",
|
||||
"private": false,
|
||||
"unprivileged": null,
|
||||
"chroot": true,
|
||||
"wake_up_time": 60,
|
||||
"process_limit": 1,
|
||||
"command": "pickup",
|
||||
"no_wake_up_before_first_use": false
|
||||
}
|
||||
]
|
||||
```
|
||||
### ps
|
||||
```bash
|
||||
ps -ef | jc --ps -p # or: jc -p ps -ef
|
||||
@@ -2722,6 +3044,39 @@ rpm_qia | jc --rpm_qi -p # or: jc -p rpm -qia
|
||||
}
|
||||
]
|
||||
```
|
||||
### rsync
|
||||
```bash
|
||||
rsync -i -a source/ dest | jc --rsync -p # or jc -p rsync -i -a source/ dest
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"summary": {
|
||||
"sent": 1708,
|
||||
"received": 8209,
|
||||
"bytes_sec": 19834.0,
|
||||
"total_size": 235,
|
||||
"speedup": 0.02
|
||||
},
|
||||
"files": [
|
||||
{
|
||||
"filename": "./",
|
||||
"metadata": ".d..t......",
|
||||
"update_type": "not updated",
|
||||
"file_type": "directory",
|
||||
"checksum_or_value_different": false,
|
||||
"size_different": false,
|
||||
"modification_time_different": true,
|
||||
"permissions_different": false,
|
||||
"owner_different": false,
|
||||
"group_different": false,
|
||||
"acl_different": false,
|
||||
"extended_attribute_different": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
### sfdisk
|
||||
```bash
|
||||
sfdisk -l | jc --sfdisk -p # or jc -p sfdisk -l
|
||||
@@ -3244,6 +3599,146 @@ timedatectl | jc --timedatectl -p # or: jc -p timedatectl
|
||||
"epoch_utc": 1583888001
|
||||
}
|
||||
```
|
||||
### Timestamp strings (UNIX Epoch)
|
||||
```bash
|
||||
echo '1658599410' | jc --timestamp -p
|
||||
```
|
||||
```json
|
||||
{
|
||||
"naive": {
|
||||
"year": 2022,
|
||||
"month": "Jul",
|
||||
"month_num": 7,
|
||||
"day": 23,
|
||||
"weekday": "Sat",
|
||||
"weekday_num": 6,
|
||||
"hour": 11,
|
||||
"hour_24": 11,
|
||||
"minute": 3,
|
||||
"second": 30,
|
||||
"period": "AM",
|
||||
"day_of_year": 204,
|
||||
"week_of_year": 29,
|
||||
"iso": "2022-07-23T11:03:30"
|
||||
},
|
||||
"utc": {
|
||||
"year": 2022,
|
||||
"month": "Jul",
|
||||
"month_num": 7,
|
||||
"day": 23,
|
||||
"weekday": "Sat",
|
||||
"weekday_num": 6,
|
||||
"hour": 6,
|
||||
"hour_24": 18,
|
||||
"minute": 3,
|
||||
"second": 30,
|
||||
"period": "PM",
|
||||
"utc_offset": "+0000",
|
||||
"day_of_year": 204,
|
||||
"week_of_year": 29,
|
||||
"iso": "2022-07-23T18:03:30+00:00"
|
||||
}
|
||||
}
|
||||
```
|
||||
### tob -b
|
||||
```bash
|
||||
top -b -n 1 | jc --top -p # or jc -p tob -b -n 1
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"time": "11:20:43",
|
||||
"uptime": 118,
|
||||
"users": 2,
|
||||
"load_1m": 0.0,
|
||||
"load_5m": 0.01,
|
||||
"load_15m": 0.05,
|
||||
"tasks_total": 108,
|
||||
"tasks_running": 2,
|
||||
"tasks_sleeping": 106,
|
||||
"tasks_stopped": 0,
|
||||
"tasks_zombie": 0,
|
||||
"cpu_user": 5.6,
|
||||
"cpu_sys": 11.1,
|
||||
"cpu_nice": 0.0,
|
||||
"cpu_idle": 83.3,
|
||||
"cpu_wait": 0.0,
|
||||
"cpu_hardware": 0.0,
|
||||
"cpu_software": 0.0,
|
||||
"cpu_steal": 0.0,
|
||||
"mem_total": 3.7,
|
||||
"mem_free": 3.3,
|
||||
"mem_used": 0.2,
|
||||
"mem_buff_cache": 0.2,
|
||||
"swap_total": 2.0,
|
||||
"swap_free": 2.0,
|
||||
"swap_used": 0.0,
|
||||
"mem_available": 3.3,
|
||||
"processes": [
|
||||
{
|
||||
"pid": 2225,
|
||||
"user": "kbrazil",
|
||||
"priority": 20,
|
||||
"nice": 0,
|
||||
"virtual_mem": 158.1,
|
||||
"resident_mem": 2.2,
|
||||
"shared_mem": 1.6,
|
||||
"status": "running",
|
||||
"percent_cpu": 12.5,
|
||||
"percent_mem": 0.1,
|
||||
"time_hundredths": "0:00.02",
|
||||
"command": "top",
|
||||
"parent_pid": 1884,
|
||||
"uid": 1000,
|
||||
"real_uid": 1000,
|
||||
"real_user": "kbrazil",
|
||||
"saved_uid": 1000,
|
||||
"saved_user": "kbrazil",
|
||||
"gid": 1000,
|
||||
"group": "kbrazil",
|
||||
"pgrp": 2225,
|
||||
"tty": "pts/0",
|
||||
"tty_process_gid": 2225,
|
||||
"session_id": 1884,
|
||||
"thread_count": 1,
|
||||
"last_used_processor": 0,
|
||||
"time": "0:00",
|
||||
"swap": 0.0,
|
||||
"code": 0.1,
|
||||
"data": 1.0,
|
||||
"major_page_fault_count": 0,
|
||||
"minor_page_fault_count": 736,
|
||||
"dirty_pages_count": 0,
|
||||
"sleeping_in_function": null,
|
||||
"flags": "..4.2...",
|
||||
"cgroups": "1:name=systemd:/user.slice/user-1000.+",
|
||||
"supplementary_gids": [
|
||||
10,
|
||||
1000
|
||||
],
|
||||
"supplementary_groups": [
|
||||
"wheel",
|
||||
"kbrazil"
|
||||
],
|
||||
"thread_gid": 2225,
|
||||
"environment_variables": [
|
||||
"XDG_SESSION_ID=2",
|
||||
"HOSTNAME=localhost"
|
||||
],
|
||||
"major_page_fault_count_delta": 0,
|
||||
"minor_page_fault_count_delta": 4,
|
||||
"used": 2.2,
|
||||
"ipc_namespace_inode": 4026531839,
|
||||
"mount_namespace_inode": 4026531840,
|
||||
"net_namespace_inode": 4026531956,
|
||||
"pid_namespace_inode": 4026531836,
|
||||
"user_namespace_inode": 4026531837,
|
||||
"nts_namespace_inode": 4026531838
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
### tracepath
|
||||
```bash
|
||||
tracepath6 3ffe:2400:0:109::2 | jc --tracepath -p
|
||||
@@ -3486,6 +3981,69 @@ uname -a | jc --uname -p # or: jc -p uname -a
|
||||
"kernel_version": "#74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019"
|
||||
}
|
||||
```
|
||||
### update-alternatives --get-selections
|
||||
```bash
|
||||
update-alternatives --get-selections | jc --update-alt-gs -p # or: jc -p update-alternatives --get-selections
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"name": "arptables",
|
||||
"status": "auto",
|
||||
"current": "/usr/sbin/arptables-nft"
|
||||
},
|
||||
{
|
||||
"name": "awk",
|
||||
"status": "auto",
|
||||
"current": "/usr/bin/gawk"
|
||||
}
|
||||
]
|
||||
```
|
||||
### update-alternatives --query
|
||||
```bash
|
||||
update-alternatives --query editor | jc --update-alt-q -p # or: jc -p update-alternatives --query editor
|
||||
```
|
||||
```json
|
||||
{
|
||||
"name": "editor",
|
||||
"link": "/usr/bin/editor",
|
||||
"slaves": [
|
||||
{
|
||||
"name": "editor.1.gz",
|
||||
"path": "/usr/share/man/man1/editor.1.gz"
|
||||
},
|
||||
{
|
||||
"name": "editor.da.1.gz",
|
||||
"path": "/usr/share/man/da/man1/editor.1.gz"
|
||||
}
|
||||
],
|
||||
"status": "auto",
|
||||
"best": "/bin/nano",
|
||||
"value": "/bin/nano",
|
||||
"alternatives": [
|
||||
{
|
||||
"name": "/bin/ed",
|
||||
"priority": -100,
|
||||
"slaves": [
|
||||
{
|
||||
"name": "editor.1.gz",
|
||||
"path": "/usr/share/man/man1/ed.1.gz"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "/bin/nano",
|
||||
"priority": 40,
|
||||
"slaves": [
|
||||
{
|
||||
"name": "editor.1.gz",
|
||||
"path": "/usr/share/man/man1/nano.1.gz"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
### upower
|
||||
```bash
|
||||
upower -i /org/freedesktop/UPower/devices/battery | jc --upower -p # or jc -p upower -i /org/freedesktop/UPower/devices/battery
|
||||
@@ -3570,6 +4128,70 @@ uptime | jc --uptime -p # or: jc -p uptime
|
||||
"uptime_total_seconds": 273780
|
||||
}
|
||||
```
|
||||
### URL string
|
||||
```bash
|
||||
echo "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag" \\
|
||||
| jc --url -p
|
||||
```
|
||||
```json
|
||||
{
|
||||
"url": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag",
|
||||
"scheme": "http",
|
||||
"netloc": "example.com",
|
||||
"path": "/test/path",
|
||||
"path_list": [
|
||||
"test",
|
||||
"path"
|
||||
],
|
||||
"query": "q1=foo&q1=bar&q2=baz",
|
||||
"query_obj": {
|
||||
"q1": [
|
||||
"foo",
|
||||
"bar"
|
||||
],
|
||||
"q2": [
|
||||
"baz"
|
||||
]
|
||||
},
|
||||
"fragment": "frag",
|
||||
"username": null,
|
||||
"password": null,
|
||||
"hostname": "example.com",
|
||||
"port": null,
|
||||
"encoded": {
|
||||
"url": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag",
|
||||
"scheme": "http",
|
||||
"netloc": "example.com",
|
||||
"path": "/test/path",
|
||||
"path_list": [
|
||||
"test",
|
||||
"path"
|
||||
],
|
||||
"query": "q1=foo&q1=bar&q2=baz",
|
||||
"fragment": "frag",
|
||||
"username": null,
|
||||
"password": null,
|
||||
"hostname": "example.com",
|
||||
"port": null
|
||||
},
|
||||
"decoded": {
|
||||
"url": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag",
|
||||
"scheme": "http",
|
||||
"netloc": "example.com",
|
||||
"path": "/test/path",
|
||||
"path_list": [
|
||||
"test",
|
||||
"path"
|
||||
],
|
||||
"query": "q1=foo&q1=bar&q2=baz",
|
||||
"fragment": "frag",
|
||||
"username": null,
|
||||
"password": null,
|
||||
"hostname": "example.com",
|
||||
"port": null
|
||||
}
|
||||
}
|
||||
```
|
||||
### w
|
||||
```bash
|
||||
w | jc --w -p # or: jc -p w
|
||||
@@ -3678,6 +4300,85 @@ who -a | jc --who -p # or: jc -p who -a
|
||||
}
|
||||
]
|
||||
```
|
||||
### X.509 PEM and DER certificate files
|
||||
```bash
|
||||
cat entrust.pem | jc --x509-cert -p
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"tbs_certificate": {
|
||||
"version": "v3",
|
||||
"serial_number": "a6:8b:79:29:00:00:00:00:50:d0:91:f9",
|
||||
"signature": {
|
||||
"algorithm": "sha384_ecdsa",
|
||||
"parameters": null
|
||||
},
|
||||
"issuer": {
|
||||
"country_name": "US",
|
||||
"organization_name": "Entrust, Inc.",
|
||||
"organizational_unit_name": [
|
||||
"See www.entrust.net/legal-terms",
|
||||
"(c) 2012 Entrust, Inc. - for authorized use only"
|
||||
],
|
||||
"common_name": "Entrust Root Certification Authority - EC1"
|
||||
},
|
||||
"validity": {
|
||||
"not_before": 1355844336,
|
||||
"not_after": 2144764536,
|
||||
"not_before_iso": "2012-12-18T15:25:36+00:00",
|
||||
"not_after_iso": "2037-12-18T15:55:36+00:00"
|
||||
},
|
||||
"subject": {
|
||||
"country_name": "US",
|
||||
"organization_name": "Entrust, Inc.",
|
||||
"organizational_unit_name": [
|
||||
"See www.entrust.net/legal-terms",
|
||||
"(c) 2012 Entrust, Inc. - for authorized use only"
|
||||
],
|
||||
"common_name": "Entrust Root Certification Authority - EC1"
|
||||
},
|
||||
"subject_public_key_info": {
|
||||
"algorithm": {
|
||||
"algorithm": "ec",
|
||||
"parameters": "secp384r1"
|
||||
},
|
||||
"public_key": "04:84:13:c9:d0:ba:6d:41:7b:e2:6c:d0:eb:55:5f:66:02:1a:24:f4:5b:89:69:47:e3:b8:c2:7d:f1:f2:02:c5:9f:a0:f6:5b:d5:8b:06:19:86:4f:53:10:6d:07:24:27:a1:a0:f8:d5:47:19:61:4c:7d:ca:93:27:ea:74:0c:ef:6f:96:09:fe:63:ec:70:5d:36:ad:67:77:ae:c9:9d:7c:55:44:3a:a2:63:51:1f:f5:e3:62:d4:a9:47:07:3e:cc:20"
|
||||
},
|
||||
"issuer_unique_id": null,
|
||||
"subject_unique_id": null,
|
||||
"extensions": [
|
||||
{
|
||||
"extn_id": "key_usage",
|
||||
"critical": true,
|
||||
"extn_value": [
|
||||
"key_cert_sign",
|
||||
"crl_sign"
|
||||
]
|
||||
},
|
||||
{
|
||||
"extn_id": "basic_constraints",
|
||||
"critical": true,
|
||||
"extn_value": {
|
||||
"ca": true,
|
||||
"path_len_constraint": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"extn_id": "key_identifier",
|
||||
"critical": false,
|
||||
"extn_value": "b7:63:e7:1a:dd:8d:e9:08:a6:55:83:a4:e0:6a:50:41:65:11:42:49"
|
||||
}
|
||||
]
|
||||
},
|
||||
"signature_algorithm": {
|
||||
"algorithm": "sha384_ecdsa",
|
||||
"parameters": null
|
||||
},
|
||||
"signature_value": "30:64:02:30:61:79:d8:e5:42:47:df:1c:ae:53:99:17:b6:6f:1c:7d:e1:bf:11:94:d1:03:88:75:e4:8d:89:a4:8a:77:46:de:6d:61:ef:02:f5:fb:b5:df:cc:fe:4e:ff:fe:a9:e6:a7:02:30:5b:99:d7:85:37:06:b5:7b:08:fd:eb:27:8b:4a:94:f9:e1:fa:a7:8e:26:08:e8:7c:92:68:6d:73:d8:6f:26:ac:21:02:b8:99:b7:26:41:5b:25:60:ae:d0:48:1a:ee:06"
|
||||
}
|
||||
]
|
||||
```
|
||||
### XML files
|
||||
```bash
|
||||
cat cd_catalog.xml
|
||||
@@ -3730,6 +4431,68 @@ cat cd_catalog.xml | jc --xml -p
|
||||
}
|
||||
}
|
||||
```
|
||||
### xrandr
|
||||
```bash
|
||||
$ xrandr | jc --xrandr -p # or jc -p xrandr
|
||||
```
|
||||
```json
|
||||
{
|
||||
"screens": [
|
||||
{
|
||||
"screen_number": 0,
|
||||
"minimum_width": 8,
|
||||
"minimum_height": 8,
|
||||
"current_width": 1920,
|
||||
"current_height": 1080,
|
||||
"maximum_width": 32767,
|
||||
"maximum_height": 32767,
|
||||
"associated_device": {
|
||||
"associated_modes": [
|
||||
{
|
||||
"resolution_width": 1920,
|
||||
"resolution_height": 1080,
|
||||
"is_high_resolution": false,
|
||||
"frequencies": [
|
||||
{
|
||||
"frequency": 60.03,
|
||||
"is_current": true,
|
||||
"is_preferred": true
|
||||
},
|
||||
{
|
||||
"frequency": 59.93,
|
||||
"is_current": false,
|
||||
"is_preferred": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"resolution_width": 1680,
|
||||
"resolution_height": 1050,
|
||||
"is_high_resolution": false,
|
||||
"frequencies": [
|
||||
{
|
||||
"frequency": 59.88,
|
||||
"is_current": false,
|
||||
"is_preferred": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"is_connected": true,
|
||||
"is_primary": true,
|
||||
"device_name": "eDP1",
|
||||
"resolution_width": 1920,
|
||||
"resolution_height": 1080,
|
||||
"offset_width": 0,
|
||||
"offset_height": 0,
|
||||
"dimension_width": 310,
|
||||
"dimension_height": 170
|
||||
}
|
||||
}
|
||||
],
|
||||
"unassociated_devices": []
|
||||
}
|
||||
```
|
||||
### YAML files
|
||||
```bash
|
||||
cat istio.yaml
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
include jc/man/jc.1.gz
|
||||
include man/jc.1
|
||||
include CHANGELOG
|
||||
|
||||
500
README.md
500
README.md
@@ -1,60 +1,85 @@
|
||||

|
||||

|
||||
[](https://github.com/kellyjonbrazil/jc/actions)
|
||||
[](https://pypi.org/project/jc/)
|
||||
|
||||
> Check out the `jc` Python [package documentation](https://github.com/kellyjonbrazil/jc/tree/master/docs) for developers
|
||||
|
||||
> Try the `jc` [web demo](https://jc-web-demo.herokuapp.com/)
|
||||
|
||||
> JC is [now available](https://galaxy.ansible.com/community/general) as an Ansible filter plugin in the `community.general` collection. See this [blog post](https://blog.kellybrazil.com/2020/08/30/parsing-command-output-in-ansible-with-jc/) for an example.
|
||||
> JC is [now available](https://galaxy.ansible.com/community/general) as an
|
||||
Ansible filter plugin in the `community.general` collection. See this
|
||||
[blog post](https://blog.kellybrazil.com/2020/08/30/parsing-command-output-in-ansible-with-jc/)
|
||||
for an example.
|
||||
|
||||
# JC
|
||||
JSON CLI output utility
|
||||
JSON Convert
|
||||
|
||||
`jc` JSONifies the output of many CLI tools and file-types for easier parsing in scripts. See the [**Parsers**](#parsers) section for supported commands and file-types.
|
||||
`jc` JSONifies the output of many CLI tools and file-types for easier parsing in
|
||||
scripts. See the [**Parsers**](#parsers) section for supported commands and
|
||||
file-types.
|
||||
```bash
|
||||
dig example.com | jc --dig
|
||||
```
|
||||
```json
|
||||
[{"id":38052,"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":
|
||||
39049,"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:09:00 PDT 2021","rcvd":56,"when_epoch":1618614540,"when_epoch_utc":null}]
|
||||
[{"id":38052,"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":39049,"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:09:00 PDT 2021","rcvd":56,"when_epoch":1618614540,
|
||||
"when_epoch_utc":null}]
|
||||
```
|
||||
This allows further command-line processing of output with tools like `jq` or [`jello`](https://github.com/kellyjonbrazil/jello) by piping commands:
|
||||
|
||||
This allows further command-line processing of output with tools like `jq`
|
||||
or [`jello`](https://github.com/kellyjonbrazil/jello) by piping commands:
|
||||
```bash
|
||||
$ dig example.com | jc --dig | jq -r '.[].answer[].data'
|
||||
93.184.216.34
|
||||
```
|
||||
|
||||
or using the alternative "magic" syntax:
|
||||
|
||||
```bash
|
||||
$ jc dig example.com | jq -r '.[].answer[].data'
|
||||
93.184.216.34
|
||||
```
|
||||
The `jc` parsers can also be used as python modules. In this case the output will be a python dictionary, or list of dictionaries, instead of JSON:
|
||||
|
||||
`jc` can also be used as a python library. In this case the output will be
|
||||
a python dictionary, a list of dictionaries, or even a
|
||||
[lazy iterable of dictionaries](#using-streaming-parsers-as-python-modules)
|
||||
instead of JSON:
|
||||
```python
|
||||
>>> import subprocess
|
||||
>>> import jc.parsers.dig
|
||||
>>>
|
||||
>>> cmd_output = subprocess.check_output(['dig', 'example.com'], text=True)
|
||||
>>> data = jc.parsers.dig.parse(cmd_output)
|
||||
>>> import jc
|
||||
>>>
|
||||
>>> 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}]
|
||||
>>> cmd_output = subprocess.check_output(['dig', 'example.com'], text=True)
|
||||
>>> data = jc.parse('dig', cmd_output)
|
||||
>>>
|
||||
>>> data[0]['answer']
|
||||
[{'name': 'example.com.', 'class': 'IN', 'type': 'A', 'ttl': 29658, 'data':
|
||||
'93.184.216.34'}]
|
||||
```
|
||||
Two representations of the data are available. The default representation uses a strict schema per parser and converts known numbers to int/float JSON values. Certain known values of `None` are converted to JSON `null`, known boolean values are converted, and, in some cases, additional semantic context fields are added.
|
||||
|
||||
To access the raw, pre-processed JSON, use the `-r` cli option or the `raw=True` function parameter in `parse()`.
|
||||
> For `jc` Python package documentation, use `help('jc')`, `help('jc.lib')`, or
|
||||
see the [online documentation](https://github.com/kellyjonbrazil/jc/tree/master/docs).
|
||||
|
||||
Schemas for each parser can be found at the documentation link beside each [**Parser**](#parsers) below.
|
||||
Two representations of the data are available. The default representation uses a
|
||||
strict schema per parser and converts known numbers to int/float JSON values.
|
||||
Certain known values of `None` are converted to JSON `null`, known boolean
|
||||
values are converted, and, in some cases, additional semantic context fields are
|
||||
added.
|
||||
|
||||
To access the raw, pre-processed JSON, use the `-r` cli option or the `raw=True`
|
||||
function parameter in `parse()`.
|
||||
|
||||
Schemas for each parser can be found at the documentation link beside each
|
||||
[**Parser**](#parsers) below.
|
||||
|
||||
Release notes can be found [here](https://blog.kellybrazil.com/category/jc-news/).
|
||||
|
||||
## Why Would Anyone Do This!?
|
||||
For more information on the motivations for this project, please see my blog post on [Bringing the Unix Philosophy to the 21st Century](https://blog.kellybrazil.com/2019/11/26/bringing-the-unix-philosophy-to-the-21st-century/).
|
||||
For more information on the motivations for this project, please see my blog
|
||||
post on [Bringing the Unix Philosophy to the 21st Century](https://blog.kellybrazil.com/2019/11/26/bringing-the-unix-philosophy-to-the-21st-century/) and my [interview with Console](https://console.substack.com/p/console-89).
|
||||
|
||||
See also:
|
||||
- [libxo on FreeBSD](http://juniper.github.io/libxo/libxo-manual.html)
|
||||
@@ -70,144 +95,199 @@ Use Cases:
|
||||
- [Nornir command output parsing](https://blog.kellybrazil.com/2020/12/09/parsing-command-output-in-nornir-with-jc/)
|
||||
|
||||
## Installation
|
||||
There are several ways to get `jc`. You can install via `pip`, OS package repositories, via DEB/RPM/MSI packaged binaries for linux and Windows, or by downloading the correct binary for your architecture and running it anywhere on your filesystem.
|
||||
There are several ways to get `jc`. You can install via `pip`, OS package
|
||||
[repositories](https://repology.org/project/jc/versions), or by downloading the
|
||||
correct [binary](https://github.com/kellyjonbrazil/jc/releases) for your
|
||||
architecture and running it anywhere on your filesystem.
|
||||
|
||||
### Pip (macOS, linux, unix, Windows)
|
||||
[](https://pypi.org/project/jc/)
|
||||
```bash
|
||||
pip3 install jc
|
||||
```
|
||||
|
||||
### OS Package Repositories
|
||||
|
||||
| OS | Command |
|
||||
|-----------------------|-------------------------------------------------------------------------------|
|
||||
| Debian/Ubuntu linux | `apt-get install jc` |
|
||||
| Fedora linux | `dnf install jc` |
|
||||
| openSUSE linux | `zypper install jc` |
|
||||
| Arch linux | `pacman -S jc` |
|
||||
| NixOS linux | `nix-env -iA nixpkgs.jc` or `nix-env -iA nixos.jc` |
|
||||
| Guix System linux | `guix install jc` |
|
||||
| macOS | `brew install jc` |
|
||||
| FreeBSD | `portsnap fetch update && cd /usr/ports/textproc/py-jc && make install clean` |
|
||||
| Ansible filter plugin | `ansible-galaxy collection install community.general` |
|
||||
| OS | Command |
|
||||
|--------------------------------------|-------------------------------------------------------------------------------|
|
||||
| Debian/Ubuntu linux | `apt-get install jc` |
|
||||
| Fedora linux | `dnf install jc` |
|
||||
| openSUSE linux | `zypper install jc` |
|
||||
| Archlinux Community Repository | `paru -S jc` or `aura -S jc` or `yay -S jc` |
|
||||
| NixOS linux | `nix-env -iA nixpkgs.jc` or `nix-env -iA nixos.jc` |
|
||||
| Guix System linux | `guix install jc` |
|
||||
| Gentoo Linux | `emerge dev-python/jc` |
|
||||
| macOS | `brew install jc` |
|
||||
| FreeBSD | `portsnap fetch update && cd /usr/ports/textproc/py-jc && make install clean` |
|
||||
| Ansible filter plugin | `ansible-galaxy collection install community.general` |
|
||||
|
||||
> For more packages and binaries, see the [jc packaging](https://kellyjonbrazil.github.io/jc-packaging/) site.
|
||||
> For more OS Packages, see https://repology.org/project/jc/versions.
|
||||
|
||||
### Binaries
|
||||
For precompiled binaries, see [Releases](https://github.com/kellyjonbrazil/jc/releases)
|
||||
on Github.
|
||||
|
||||
## Usage
|
||||
`jc` accepts piped input from `STDIN` and outputs a JSON representation of the previous command's output to `STDOUT`.
|
||||
`jc` accepts piped input from `STDIN` and outputs a JSON representation of the
|
||||
previous command's output to `STDOUT`.
|
||||
```bash
|
||||
COMMAND | jc PARSER [OPTIONS]
|
||||
```
|
||||
Alternatively, the "magic" syntax can be used by prepending `jc` to the command to be converted. Options can be passed to `jc` immediately before the command is given. (Note: command aliases and shell builtins are not supported)
|
||||
|
||||
Alternatively, the "magic" syntax can be used by prepending `jc` to the command
|
||||
to be converted. Options can be passed to `jc` immediately before the command is
|
||||
given. (Note: command aliases and shell builtins are not supported)
|
||||
```bash
|
||||
jc [OPTIONS] COMMAND
|
||||
```
|
||||
The JSON output can be compact (default) or pretty formatted with the `-p` option.
|
||||
|
||||
The JSON output can be compact (default) or pretty formatted with the `-p`
|
||||
option.
|
||||
|
||||
### Parsers
|
||||
|
||||
- `--acpi` enables the `acpi` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/acpi))
|
||||
- `--airport` enables the `airport -I` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/airport))
|
||||
- `--airport-s` enables the `airport -s` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/airport_s))
|
||||
- `--arp` enables the `arp` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/arp))
|
||||
- `--blkid` enables the `blkid` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/blkid))
|
||||
- `--cksum` enables the `cksum` and `sum` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/cksum))
|
||||
- `--crontab` enables the `crontab` command and file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/crontab))
|
||||
- `--crontab-u` enables the `crontab` file parser with user support ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/crontab_u))
|
||||
- `--csv` enables the CSV file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/csv))
|
||||
- `--csv-s` enables the CSV file streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/csv_s))
|
||||
- `--date` enables the `date` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/date))
|
||||
- `--df` enables the `df` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/df))
|
||||
- `--dig` enables the `dig` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/dig))
|
||||
- `--dir` enables the `dir` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/dir))
|
||||
- `--dmidecode` enables the `dmidecode` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/dmidecode))
|
||||
- `--dpkg-l` enables the `dpkg -l` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/dpkg_l))
|
||||
- `--du` enables the `du` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/du))
|
||||
- `--env` enables the `env` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/env))
|
||||
- `--file` enables the `file` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/file))
|
||||
- `--finger` enables the `finger` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/finger))
|
||||
- `--free` enables the `free` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/free))
|
||||
- `--fstab` enables the `/etc/fstab` file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/fstab))
|
||||
- `--group` enables the `/etc/group` file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/group))
|
||||
- `--gshadow` enables the `/etc/gshadow` file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/gshadow))
|
||||
- `--hash` enables the `hash` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/hash))
|
||||
- `--hashsum` enables the hashsum command parser (`md5sum`, `shasum`, etc.) ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/hashsum))
|
||||
- `--hciconfig` enables the `hciconfig` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/hciconfig))
|
||||
- `--history` enables the `history` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/history))
|
||||
- `--hosts` enables the `/etc/hosts` file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/hosts))
|
||||
- `--id` enables the `id` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/id))
|
||||
- `--ifconfig` enables the `ifconfig` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ifconfig))
|
||||
- `--ini` enables the INI file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ini))
|
||||
- `--iostat` enables the `iostat` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat))
|
||||
- `--iostat-s` enables the `iostat` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat_s))
|
||||
- `--iptables` enables the `iptables` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/iptables))
|
||||
- `--iw-scan` enables the `iw dev [device] scan` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/iw_scan))
|
||||
- `--jobs` enables the `jobs` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/jobs))
|
||||
- `--kv` enables the Key/Value file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/kv))
|
||||
- `--last` enables the `last` and `lastb` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/last))
|
||||
- `--ls` enables the `ls` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ls))
|
||||
- `--ls-s` enables the `ls` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ls_s))
|
||||
- `--lsblk` enables the `lsblk` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/lsblk))
|
||||
- `--lsmod` enables the `lsmod` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/lsmod))
|
||||
- `--lsof` enables the `lsof` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/lsof))
|
||||
- `--lsusb` enables the `lsusb` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/lsusb))
|
||||
- `--mount` enables the `mount` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/mount))
|
||||
- `--netstat` enables the `netstat` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/netstat))
|
||||
- `--ntpq` enables the `ntpq -p` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ntpq))
|
||||
- `--passwd` enables the `/etc/passwd` file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/passwd))
|
||||
- `--ping` enables the `ping` and `ping6` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ping))
|
||||
- `--ping-s` enables the `ping` and `ping6` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ping_s))
|
||||
- `--pip-list` enables the `pip list` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/pip_list))
|
||||
- `--pip-show` enables the `pip show` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/pip_show))
|
||||
- `--ps` enables the `ps` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ps))
|
||||
- `--route` enables the `route` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/route))
|
||||
- `--rpm-qi` enables the `rpm -qi` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/rpm_qi))
|
||||
- `--sfdisk` enables the `sfdisk` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/sfdisk))
|
||||
- `--shadow` enables the `/etc/shadow` file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/shadow))
|
||||
- `--ss` enables the `ss` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ss))
|
||||
- `--stat` enables the `stat` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/stat))
|
||||
- `--sysctl` enables the `sysctl` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/sysctl))
|
||||
- `--systemctl` enables the `systemctl` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl))
|
||||
- `--systemctl-lj` enables the `systemctl list-jobs` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl_lj))
|
||||
- `--systemctl-ls` enables the `systemctl list-sockets` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl_ls))
|
||||
- `--systemctl-luf` enables the `systemctl list-unit-files` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl_luf))
|
||||
- `--systeminfo` enables the `systeminfo` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/systeminfo))
|
||||
- `--time` enables the `/usr/bin/time` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/time))
|
||||
- `--timedatectl` enables the `timedatectl status` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/timedatectl))
|
||||
- `--tracepath` enables the `tracepath` and `tracepath6` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/tracepath))
|
||||
- `--traceroute` enables the `traceroute` and `traceroute6` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/traceroute))
|
||||
- `--ufw` enables the `ufw status` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw))
|
||||
- `--ufw-appinfo` enables the `ufw app info [application]` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw_appinfo))
|
||||
- `--uname` enables the `uname -a` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/uname))
|
||||
- `--upower` enables the `upower` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/upower))
|
||||
- `--uptime` enables the `uptime` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/uptime))
|
||||
- `--vmstat` enables the `vmstat` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/vmstat))
|
||||
- `--vmstat-s` enables the `vmstat` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/vmstat_s))
|
||||
- `--w` enables the `w` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/w))
|
||||
- `--wc` enables the `wc` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/wc))
|
||||
- `--who` enables the `who` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/who))
|
||||
- `--xml` enables the XML file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/xml))
|
||||
- `--yaml` enables the YAML file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/yaml))
|
||||
- `--zipinfo` enables the `zipinfo` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/zipinfo))
|
||||
| Argument | Command or Filetype | Documentation |
|
||||
|-------------------|---------------------------------------------------------|----------------------------------------------------------------------------|
|
||||
| ` --acpi` | `acpi` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/acpi) |
|
||||
| ` --airport` | `airport -I` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/airport) |
|
||||
| ` --airport-s` | `airport -s` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/airport_s) |
|
||||
| ` --arp` | `arp` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/arp) |
|
||||
| ` --asciitable` | ASCII and Unicode table parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/asciitable) |
|
||||
| ` --asciitable-m` | multi-line ASCII and Unicode table parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/asciitable_m) |
|
||||
| ` --blkid` | `blkid` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/blkid) |
|
||||
| ` --chage` | `chage --list` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/chage) |
|
||||
| ` --cksum` | `cksum` and `sum` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/cksum) |
|
||||
| ` --crontab` | `crontab` command and file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/crontab) |
|
||||
| ` --crontab-u` | `crontab` file parser with user support | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/crontab_u) |
|
||||
| ` --csv` | CSV file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/csv) |
|
||||
| ` --csv-s` | CSV file streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/csv_s) |
|
||||
| ` --date` | `date` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/date) |
|
||||
| ` --df` | `df` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/df) |
|
||||
| ` --dig` | `dig` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/dig) |
|
||||
| ` --dir` | `dir` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/dir) |
|
||||
| ` --dmidecode` | `dmidecode` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/dmidecode) |
|
||||
| ` --dpkg-l` | `dpkg -l` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/dpkg_l) |
|
||||
| ` --du` | `du` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/du) |
|
||||
| `--email-address` | Email Address string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/email_address) |
|
||||
| ` --env` | `env` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/env) |
|
||||
| ` --file` | `file` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/file) |
|
||||
| ` --finger` | `finger` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/finger) |
|
||||
| ` --free` | `free` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/free) |
|
||||
| ` --fstab` | `/etc/fstab` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/fstab) |
|
||||
| ` --git-log` | `git log` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/git_log) |
|
||||
| ` --git-log-s` | `git log` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/git_log_s) |
|
||||
| ` --gpg` | `gpg --with-colons` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/gpg) |
|
||||
| ` --group` | `/etc/group` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/group) |
|
||||
| ` --gshadow` | `/etc/gshadow` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/gshadow) |
|
||||
| ` --hash` | `hash` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/hash) |
|
||||
| ` --hashsum` | hashsum command parser (`md5sum`, `shasum`, etc.) | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/hashsum) |
|
||||
| ` --hciconfig` | `hciconfig` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/hciconfig) |
|
||||
| ` --history` | `history` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/history) |
|
||||
| ` --hosts` | `/etc/hosts` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/hosts) |
|
||||
| ` --id` | `id` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/id) |
|
||||
| ` --ifconfig` | `ifconfig` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ifconfig) |
|
||||
| ` --ini` | INI file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ini) |
|
||||
| ` --iostat` | `iostat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat) |
|
||||
| ` --iostat-s` | `iostat` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat_s) |
|
||||
| ` --iptables` | `iptables` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iptables) |
|
||||
| ` --iso-datetime` | ISO 8601 Datetime string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iso_datetime) |
|
||||
| ` --iw-scan` | `iw dev [device] scan` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iw_scan) |
|
||||
| ` --jar-manifest` | MANIFEST.MF file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/jar_manifest) |
|
||||
| ` --jobs` | `jobs` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/jobs) |
|
||||
| ` --jwt` | JWT string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/jwt) |
|
||||
| ` --kv` | Key/Value file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/kv) |
|
||||
| ` --last` | `last` and `lastb` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/last) |
|
||||
| ` --ls` | `ls` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ls) |
|
||||
| ` --ls-s` | `ls` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ls_s) |
|
||||
| ` --lsblk` | `lsblk` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsblk) |
|
||||
| ` --lsmod` | `lsmod` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsmod) |
|
||||
| ` --lsof` | `lsof` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsof) |
|
||||
| ` --lsusb` | `lsusb` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsusb) |
|
||||
| ` --m3u` | M3U and M3U8 file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/m3u) |
|
||||
| ` --mount` | `mount` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/mount) |
|
||||
| ` --mpstat` | `mpstat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/mpstat) |
|
||||
| ` --mpstat-s` | `mpstat` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/mpstat_s) |
|
||||
| ` --netstat` | `netstat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/netstat) |
|
||||
| ` --nmcli` | `nmcli` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/nmcli) |
|
||||
| ` --ntpq` | `ntpq -p` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ntpq) |
|
||||
| ` --passwd` | `/etc/passwd` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/passwd) |
|
||||
| ` --pidstat` | `pidstat -h` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pidstat) |
|
||||
| ` --pidstat-s` | `pidstat -h` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pidstat_s) |
|
||||
| ` --ping` | `ping` and `ping6` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ping) |
|
||||
| ` --ping-s` | `ping` and `ping6` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ping_s) |
|
||||
| ` --pip-list` | `pip list` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pip_list) |
|
||||
| ` --pip-show` | `pip show` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pip_show) |
|
||||
| ` --postconf` | `postconf -M` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/postconf) |
|
||||
| ` --ps` | `ps` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ps) |
|
||||
| ` --route` | `route` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/route) |
|
||||
| ` --rpm-qi` | `rpm -qi` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/rpm_qi) |
|
||||
| ` --rsync` | `rsync` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/rsync) |
|
||||
| ` --rsync-s` | `rsync` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/rsync_s) |
|
||||
| ` --sfdisk` | `sfdisk` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/sfdisk) |
|
||||
| ` --shadow` | `/etc/shadow` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/shadow) |
|
||||
| ` --ss` | `ss` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ss) |
|
||||
| ` --stat` | `stat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/stat) |
|
||||
| ` --stat-s` | `stat` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/stat_s) |
|
||||
| ` --sysctl` | `sysctl` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/sysctl) |
|
||||
| ` --systemctl` | `systemctl` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl) |
|
||||
| ` --systemctl-lj` | `systemctl list-jobs` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl_lj) |
|
||||
| ` --systemctl-ls` | `systemctl list-sockets` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl_ls) |
|
||||
| `--systemctl-luf` | `systemctl list-unit-files` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/systemctl_luf) |
|
||||
| ` --systeminfo` | `systeminfo` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/systeminfo) |
|
||||
| ` --time` | `/usr/bin/time` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/time) |
|
||||
| ` --timedatectl` | `timedatectl status` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/timedatectl) |
|
||||
| ` --timestamp` | UNIX Epoch Timestamp string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/timestamp) |
|
||||
| ` --top` | `top -b` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/top) |
|
||||
| ` --top-s` | `top -b` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/top_s) |
|
||||
| ` --tracepath` | `tracepath` and `tracepath6` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/tracepath) |
|
||||
| ` --traceroute` | `traceroute` and `traceroute6` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/traceroute) |
|
||||
| ` --ufw` | `ufw status` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw) |
|
||||
| ` --ufw-appinfo` | `ufw app info [application]` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw_appinfo) |
|
||||
| ` --uname` | `uname -a` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/uname) |
|
||||
| `--update-alt-gs` | `update-alternatives --get-selections` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/update_alt_gs) |
|
||||
| ` --update-alt-q` | `update-alternatives --query` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/update_alt_q) |
|
||||
| ` --upower` | `upower` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/upower) |
|
||||
| ` --uptime` | `uptime` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/uptime) |
|
||||
| ` --url` | URL string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/url) |
|
||||
| ` --vmstat` | `vmstat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/vmstat) |
|
||||
| ` --vmstat-s` | `vmstat` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/vmstat_s) |
|
||||
| ` --w` | `w` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/w) |
|
||||
| ` --wc` | `wc` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/wc) |
|
||||
| ` --who` | `who` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/who) |
|
||||
| ` --x509-cert` | X.509 PEM and DER certificate file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/x509_cert) |
|
||||
| ` --xml` | XML file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/xml) |
|
||||
| ` --xrandr` | `xrandr` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/xrandr) |
|
||||
| ` --yaml` | YAML file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/yaml) |
|
||||
| ` --zipinfo` | `zipinfo` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/zipinfo) |
|
||||
|
||||
### Options
|
||||
- `-a` about `jc`. Prints information about `jc` and the parsers (in JSON, of course!)
|
||||
- `-C` force color output even when using pipes (overrides `-m` and the `NO_COLOR` env variable)
|
||||
- `-d` debug mode. Prints trace messages if parsing issues are encountered (use `-dd` for verbose debugging)
|
||||
- `-h` help. Use `jc -h --parser_name` for parser documentation
|
||||
- `-m` monochrome JSON output
|
||||
- `-p` pretty format the JSON output
|
||||
- `-q` quiet mode. Suppresses parser warning messages (use `-qq` to ignore streaming parser errors)
|
||||
- `-r` raw output. Provides a more literal JSON output, typically with string values and no additional semantic processing
|
||||
- `-u` unbuffer output
|
||||
- `-v` version information
|
||||
|
||||
| Short | Long | Description |
|
||||
|-------|-----------------|---------------------------------------------------------------------------------------------------------------------|
|
||||
| `-a` | `--about` | About `jc`. Prints information about `jc` and the parsers (in JSON or YAML, of course!) |
|
||||
| `-C` | `--force-color` | Force color output even when using pipes (overrides `-m` and the `NO_COLOR` env variable) |
|
||||
| `-d` | `--debug` | Debug mode. Prints trace messages if parsing issues are encountered (use`-dd` for verbose debugging) |
|
||||
| `-h` | `--help` | Help. Use `jc -h --parser_name` for parser documentation |
|
||||
| `-m` | `--monochrome` | Monochrome output |
|
||||
| `-p` | `--pretty` | Pretty format the JSON output |
|
||||
| `-q` | `--quiet` | Quiet mode. Suppresses parser warning messages (use `-qq` to ignore streaming parser errors) |
|
||||
| `-r` | `--raw` | Raw output. Provides more literal output, typically with string values and no additional semantic processing |
|
||||
| `-u` | `--unbuffer` | Unbuffer output |
|
||||
| `-v` | `--version` | Version information |
|
||||
| `-y` | `--yaml-out` | YAML output |
|
||||
| `-B` | `--bash-comp` | Generate Bash shell completion script ([more info](https://github.com/kellyjonbrazil/jc/wiki/Shell-Completions)) |
|
||||
| `-Z` | `--zsh-comp` | Generate Zsh shell completion script ([more info](https://github.com/kellyjonbrazil/jc/wiki/Shell-Completions)) |
|
||||
|
||||
### Exit Codes
|
||||
Any fatal errors within `jc` will generate an exit code of `100`, otherwise the exit code will be `0`. When using the "magic" syntax (e.g. `jc ifconfig eth0`), `jc` will store the exit code of the program being parsed and add it to the `jc` exit code. This way it is easier to determine if an error was from the parsed program or `jc`.
|
||||
Any fatal errors within `jc` will generate an exit code of `100`, otherwise the
|
||||
exit code will be `0`. When using the "magic" syntax (e.g. `jc ifconfig eth0`),
|
||||
`jc` will store the exit code of the program being parsed and add it to the `jc`
|
||||
exit code. This way it is easier to determine if an error was from the parsed
|
||||
program or `jc`.
|
||||
|
||||
Consider the following examples using `ifconfig`:
|
||||
|
||||
| `ifconfig` exit code | `jc` exit code | Combined exit code | Interpretation |
|
||||
| `ifconfig` exit code | `jc` exit code | Combined exit code | Interpretation |
|
||||
|----------------------|----------------|--------------------|------------------------------------|
|
||||
| `0` | `0` | `0` | No errors |
|
||||
| `1` | `0` | `1` | Error in `ifconfig` |
|
||||
@@ -216,11 +296,16 @@ Consider the following examples using `ifconfig`:
|
||||
|
||||
|
||||
### Setting Custom Colors via Environment Variable
|
||||
You can specify custom colors via the `JC_COLORS` environment variable. The `JC_COLORS` environment variable takes four comma separated string values in the following format:
|
||||
You can specify custom colors via the `JC_COLORS` environment variable. The
|
||||
`JC_COLORS` environment variable takes four comma separated string values in
|
||||
the following format:
|
||||
```bash
|
||||
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`, or `default`
|
||||
|
||||
Where colors are: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`,
|
||||
`gray`, `brightblack`, `brightred`, `brightgreen`, `brightyellow`, `brightblue`,
|
||||
`brightmagenta`, `brightcyan`, `white`, or `default`
|
||||
|
||||
For example, to set to the default colors:
|
||||
```bash
|
||||
@@ -232,16 +317,33 @@ JC_COLORS=default,default,default,default
|
||||
```
|
||||
|
||||
### Disable Colors via Environment Variable
|
||||
You can set the [`NO_COLOR`](http://no-color.org/) environment variable to any value to disable color output in `jc`. Note that using the `-C` option to force color output will override both the `NO_COLOR` environment variable and the `-m` option.
|
||||
You can set the [`NO_COLOR`](http://no-color.org/) environment variable to any
|
||||
value to disable color output in `jc`. Note that using the `-C` option to force
|
||||
color output will override both the `NO_COLOR` environment variable and the `-m`
|
||||
option.
|
||||
|
||||
### Streaming Parsers
|
||||
Most parsers load all of the data from STDIN, parse it, then output the entire JSON document serially. There are some streaming parsers (e.g. `ls-s` and `ping-s`) that immediately start processing and outputing the data line-by-line as [JSON Lines](https://jsonlines.org/) (aka [NDJSON](http://ndjson.org/)) while it is being received from STDIN. This can significantly reduce the amount of memory required to parse large amounts of command output (e.g. `ls -lR /`) and can sometimes process the data more quickly. Streaming parsers have slightly different behavior than standard parsers as outlined below.
|
||||
Most parsers load all of the data from `STDIN`, parse it, then output the entire
|
||||
JSON document serially. There are some streaming parsers (e.g. `ls-s` and
|
||||
`ping-s`) that immediately start processing and outputing the data line-by-line
|
||||
as [JSON Lines](https://jsonlines.org/) (aka [NDJSON](http://ndjson.org/)) while
|
||||
it is being received from `STDIN`. This can significantly reduce the amount of
|
||||
memory required to parse large amounts of command output (e.g. `ls -lR /`) and
|
||||
can sometimes process the data more quickly. Streaming parsers have slightly
|
||||
different behavior than standard parsers as outlined below.
|
||||
|
||||
> Note: Streaming parsers cannot be used with the "magic" syntax
|
||||
|
||||
#### Ignoring Errors
|
||||
|
||||
You may want to ignore parsing errors when using streaming parsers since these may be used in long-lived processing pipelines and errors can break the pipe. To ignore parsing errors, use the `-qq` cli option or the `ignore_exceptions=True` argument with the `parse()` function. This will add a `_jc_meta` object to the JSON output with a `success` attribute. If `success` is `true`, then there were no issues parsing the line. If `success` is `false`, then a parsing issue was found and `error` and `line` fields will be added to include a short error description and the contents of the unparsable line, respectively:
|
||||
You may want to ignore parsing errors when using streaming parsers since these
|
||||
may be used in long-lived processing pipelines and errors can break the pipe. To
|
||||
ignore parsing errors, use the `-qq` cli option or the `ignore_exceptions=True`
|
||||
argument with the `parse()` function. This will add a `_jc_meta` object to the
|
||||
JSON output with a `success` attribute. If `success` is `true`, then there were
|
||||
no issues parsing the line. If `success` is `false`, then a parsing issue was
|
||||
found and `error` and `line` fields will be added to include a short error
|
||||
description and the contents of the unparsable line, respectively:
|
||||
|
||||
Successfully parsed line with `-qq` option:
|
||||
```json
|
||||
@@ -252,6 +354,7 @@ Successfully parsed line with `-qq` option:
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Unsuccessfully parsed line with `-qq` option:
|
||||
```json
|
||||
{
|
||||
@@ -265,74 +368,125 @@ Unsuccessfully parsed line with `-qq` option:
|
||||
|
||||
#### Unbuffering Output
|
||||
|
||||
Most operating systems will buffer output that is being piped from process to process. The buffer is usually around 4KB. When viewing the output in the terminal the OS buffer is not engaged so output is immediately displayed on the screen. When piping multiple processes together, though, it may seem as if the output is hanging when the input data is very slow (e.g. `ping`):
|
||||
Most operating systems will buffer output that is being piped from process to
|
||||
process. The buffer is usually around 4KB. When viewing the output in the
|
||||
terminal the OS buffer is not engaged so output is immediately displayed on the
|
||||
screen. When piping multiple processes together, though, it may seem as if the
|
||||
output is hanging when the input data is very slow (e.g. `ping`):
|
||||
```
|
||||
$ ping 1.1.1.1 | jc --ping-s | jq
|
||||
<slow output>
|
||||
```
|
||||
This is because the OS engages the 4KB buffer between `jc` and `jq` in this example. To display the data on the terminal in realtime, you can disable the buffer with the `-u` (unbuffer) cli option:
|
||||
|
||||
This is because the OS engages the 4KB buffer between `jc` and `jq` in this
|
||||
example. To display the data on the terminal in realtime, you can disable the
|
||||
buffer with the `-u` (unbuffer) cli option:
|
||||
```
|
||||
$ ping 1.1.1.1 | jc --ping-s -u | jq
|
||||
{"type":"reply","pattern":null,"timestamp":null,"bytes":"64","response_ip":"1.1.1.1","icmp_seq":"1","ttl":"128","time_ms":"24.6","duplicate":false}
|
||||
{"type":"reply","pattern":null,"timestamp":null,"bytes":"64","response_ip":"1.1.1.1","icmp_seq":"2","ttl":"128","time_ms":"26.8","duplicate":false}
|
||||
{"type":"reply","pattern":null,"timestamp":null,"bytes":"64","respons...}
|
||||
{"type":"reply","pattern":null,"timestamp":null,"bytes":"64","respons...}
|
||||
...
|
||||
```
|
||||
|
||||
> Note: Unbuffered output can be slower for large data streams.
|
||||
|
||||
#### Using Streaming Parsers as Python Modules
|
||||
|
||||
Streaming parsers accept any iterable object and return a generator iterator object allowing lazy processing of the data. The input data should iterate on lines of string data. Examples of good input data are `sys.stdin` or `str.splitlines()`.
|
||||
Streaming parsers accept any iterable object and return an iterable object
|
||||
allowing lazy processing of the data. The input data should iterate on lines
|
||||
of string data. Examples of good input data are `sys.stdin` or
|
||||
`str.splitlines()`.
|
||||
|
||||
To use the generator object in your code, simply loop through it or use the [next()](https://docs.python.org/3/library/functions.html#next) builtin function:
|
||||
To use the returned iterable object in your code, simply loop through it or
|
||||
use the [next()](https://docs.python.org/3/library/functions.html#next)
|
||||
builtin function:
|
||||
```python
|
||||
import jc.parsers.ls_s
|
||||
import jc
|
||||
|
||||
result = jc.parsers.ls_s.parse(ls_command_output.splitlines())
|
||||
result = jc.parse('ls_s', ls_command_output.splitlines())
|
||||
for item in result:
|
||||
print(item["filename"])
|
||||
```
|
||||
|
||||
### Custom Parsers
|
||||
Custom local parser plugins may be placed in a `jc/jcparsers` folder in your local **"App data directory"**:
|
||||
Custom local parser plugins may be placed in a `jc/jcparsers` folder in your
|
||||
local **"App data directory"**:
|
||||
|
||||
- Linux/unix: `$HOME/.local/share/jc/jcparsers`
|
||||
- macOS: `$HOME/Library/Application Support/jc/jcparsers`
|
||||
- Windows: `$LOCALAPPDATA\jc\jc\jcparsers`
|
||||
|
||||
Local parser plugins are standard python module files. Use the [`jc/parsers/foo.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo.py) or [`jc/parsers/foo_s.py (streaming)`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo_s.py) parser as a template and simply place a `.py` file in the `jcparsers` subfolder.
|
||||
Local parser plugins are standard python module files. Use the
|
||||
[`jc/parsers/foo.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo.py)
|
||||
or [`jc/parsers/foo_s.py (streaming)`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo_s.py)
|
||||
parser as a template and simply place a `.py` file in the `jcparsers` subfolder.
|
||||
|
||||
Local plugin filenames must be valid python module names, therefore must consist entirely of alphanumerics and start with a letter. Local plugins may override default parsers.
|
||||
Local plugin filenames must be valid python module names and therefore must
|
||||
start with a letter and consist entirely of alphanumerics and underscores.
|
||||
Local plugins may override default parsers.
|
||||
|
||||
> Note: The application data directory follows the [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)
|
||||
> Note: The application data directory follows the
|
||||
[XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)
|
||||
|
||||
### Caveats
|
||||
|
||||
#### Locale
|
||||
|
||||
For best results set the `LANG` locale environment variable to `C` or `en_US.UTF-8`. For example, either by setting directly on the command-line:
|
||||
For best results set the `LANG` locale environment variable to `C` or
|
||||
`en_US.UTF-8`. For example, either by setting directly on the command-line:
|
||||
```
|
||||
$ LANG=C date | jc --date
|
||||
```
|
||||
|
||||
or by exporting to the environment before running commands:
|
||||
```
|
||||
$ export LANG=C
|
||||
```
|
||||
|
||||
On some older systems UTF-8 output will be downgraded to ASCII with `\\u`
|
||||
escape sequences if the `C` locale does not support UTF-8 encoding.
|
||||
|
||||
#### Timezones
|
||||
|
||||
Some parsers have calculated epoch timestamp fields added to the output. Unless a timestamp field name has a `_utc` suffix it is considered naive. (i.e. based on the local timezone of the system the `jc` parser was run on).
|
||||
Some parsers have calculated epoch timestamp fields added to the output. Unless
|
||||
a timestamp field name has a `_utc` suffix it is considered naive. (i.e. based
|
||||
on the local timezone of the system the `jc` parser was run on).
|
||||
|
||||
If a UTC timezone can be detected in the text of the command output, the timestamp will be timezone aware and have a `_utc` suffix on the key name. (e.g. `epoch_utc`) No other timezones are supported for aware timestamps.
|
||||
If a UTC timezone can be detected in the text of the command output, the
|
||||
timestamp will be timezone aware and have a `_utc` suffix on the key name.
|
||||
(e.g. `epoch_utc`) No other timezones are supported for aware timestamps.
|
||||
|
||||
## Use In Other Shells
|
||||
`jc` can be used in most any shell. Some modern shells have JSON deserialization
|
||||
and filtering capabilities built-in which makes using `jc` even more convenient.
|
||||
|
||||
For example, the following is possible in [NGS](https://ngs-lang.org/)
|
||||
(Next Generation Shell):
|
||||
```bash
|
||||
myvar = ``jc dig www.google.com``[0].answer[0].data
|
||||
```
|
||||
This runs `jc`, parses the output JSON, and assigs the resulting data structure
|
||||
to a variable in a single line of code.
|
||||
|
||||
For more examples of how to use `jc` in other shells, see this
|
||||
[wiki page](https://github.com/kellyjonbrazil/jc/wiki/Using-jc-With-Different-Shells).
|
||||
|
||||
## Compatibility
|
||||
Some parsers like `dig`, `xml`, `csv`, etc. will work on any platform. Other parsers that convert platform-specific output will generate a warning message if they are run on an unsupported platform. To see all parser information, including compatibility, run `jc -ap`.
|
||||
Some parsers like `dig`, `xml`, `csv`, etc. will work on any platform. Other
|
||||
parsers that convert platform-specific output will generate a warning message if
|
||||
they are run on an unsupported platform. To see all parser information,
|
||||
including compatibility, run `jc -ap`.
|
||||
|
||||
You may still use a parser on an unsupported platform - for example, you may want to parse a file with linux `lsof` output on an macOS or Windows laptop. In that case you can suppress the warning message with the `-q` cli option or the `quiet=True` function parameter in `parse()`:
|
||||
You may still use a parser on an unsupported platform - for example, you may
|
||||
want to parse a file with linux `lsof` output on an macOS or Windows laptop. In
|
||||
that case you can suppress the warning message with the `-q` cli option or the
|
||||
`quiet=True` function parameter in `parse()`:
|
||||
|
||||
macOS:
|
||||
```bash
|
||||
cat lsof.out | jc --lsof -q
|
||||
```
|
||||
|
||||
or Windows:
|
||||
```bash
|
||||
type lsof.out | jc --lsof -q
|
||||
@@ -352,22 +506,31 @@ Tested on:
|
||||
- Windows 2019 Server
|
||||
|
||||
## Contributions
|
||||
Feel free to add/improve code or parsers! You can use the [`jc/parsers/foo.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo.py) or [`jc/parsers/foo_s.py (streaming)`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo_s.py) parsers as a template and submit your parser with a pull request.
|
||||
Feel free to add/improve code or parsers! You can use the
|
||||
[`jc/parsers/foo.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo.py)
|
||||
or [`jc/parsers/foo_s.py (streaming)`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo_s.py) parsers as a template and submit your parser with a pull
|
||||
request.
|
||||
|
||||
Please see the [Contributing Guidelines](https://github.com/kellyjonbrazil/jc/blob/master/CONTRIBUTING.md) for more information.
|
||||
|
||||
## Acknowledgments
|
||||
- Local parser plugin feature contributed by [Dean Serenevy](https://github.com/duelafn)
|
||||
- CI automation and code optimizations by [philippeitis](https://github.com/philippeitis)
|
||||
- [`ifconfig-parser`](https://github.com/KnightWhoSayNi/ifconfig-parser) module by KnightWhoSayNi
|
||||
- [`ifconfig-parser`](https://github.com/KnightWhoSayNi/ifconfig-parser) module
|
||||
by KnightWhoSayNi
|
||||
- [`xmltodict`](https://github.com/martinblech/xmltodict) module by Martín Blech
|
||||
- [`ruamel.yaml`](https://pypi.org/project/ruamel.yaml) module by Anthon van der Neut
|
||||
- [`ruamel.yaml`](https://pypi.org/project/ruamel.yaml) module by Anthon van
|
||||
der Neut
|
||||
- [`trparse`](https://github.com/lbenitez000/trparse) module by Luis Benitez
|
||||
- Parsing [code](https://gist.github.com/cahna/43a1a3ff4d075bcd71f9d7120037a501) from Conor Heine adapted for some parsers
|
||||
- Parsing [code](https://gist.github.com/cahna/43a1a3ff4d075bcd71f9d7120037a501)
|
||||
from Conor Heine adapted for some parsers
|
||||
- Excellent constructive feedback from [Ilya Sher](https://github.com/ilyash-b)
|
||||
|
||||
## Examples
|
||||
Here are some examples of `jc` output. For more examples, see [here](https://kellyjonbrazil.github.io/jc/EXAMPLES) or the parser documentation.
|
||||
Here are some examples of `jc` output. For more examples, see
|
||||
[here](https://kellyjonbrazil.github.io/jc/EXAMPLES) or the parser
|
||||
documentation.
|
||||
|
||||
### arp
|
||||
```bash
|
||||
arp | jc --arp -p # or: jc -p arp
|
||||
@@ -775,7 +938,7 @@ ps axu | jc --ps -p # or: jc -p ps axu
|
||||
"stat": "Ss",
|
||||
"start": "Nov09",
|
||||
"time": "0:08",
|
||||
"command": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
||||
"command": "/usr/lib/systemd/systemd --switched-root --system --deseria..."
|
||||
},
|
||||
{
|
||||
"user": "root",
|
||||
@@ -807,7 +970,8 @@ ps axu | jc --ps -p # or: jc -p ps axu
|
||||
```
|
||||
### traceroute
|
||||
```bash
|
||||
traceroute -m 2 8.8.8.8 | jc --traceroute -p # or: jc -p traceroute -m 2 8.8.8.8
|
||||
traceroute -m 2 8.8.8.8 | jc --traceroute -p
|
||||
# or: jc -p traceroute -m 2 8.8.8.8
|
||||
```
|
||||
```json
|
||||
{
|
||||
@@ -1006,4 +1170,4 @@ cat istio.yaml | jc --yaml -p
|
||||
]
|
||||
```
|
||||
|
||||
© 2019-2021 Kelly Brazil
|
||||
© 2019-2022 Kelly Brazil
|
||||
@@ -1 +1,2 @@
|
||||
theme: jekyll-theme-cayman
|
||||
theme: jekyll-theme-cayman
|
||||
markdown: GFM
|
||||
|
||||
9
build-completions.py
Executable file
9
build-completions.py
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
# build Bash and Zsh completion scripts and add to the completions folder
|
||||
from jc.shell_completions import bash_completion, zsh_completion
|
||||
|
||||
with open('completions/jc_bash_completion.sh', 'w') as f:
|
||||
print(bash_completion(), file=f)
|
||||
|
||||
with open('completions/jc_zsh_completion.sh', 'w') as f:
|
||||
print(zsh_completion(), file=f)
|
||||
84
completions/jc_bash_completion.sh
Normal file
84
completions/jc_bash_completion.sh
Normal file
@@ -0,0 +1,84 @@
|
||||
_jc()
|
||||
{
|
||||
local cur prev words cword jc_commands jc_parsers jc_options \
|
||||
jc_about_options jc_about_mod_options jc_help_options jc_special_options
|
||||
|
||||
jc_commands=(acpi airport arp blkid chage cksum crontab date df dig dmidecode dpkg du env file finger free git gpg hciconfig id ifconfig iostat iptables iw jobs last lastb ls lsblk lsmod lsof lsusb md5 md5sum mount mpstat netstat nmcli ntpq pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss stat sum sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 ufw uname update-alternatives upower uptime vdir vmstat w wc who xrandr zipinfo)
|
||||
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --chage --cksum --crontab --crontab-u --csv --csv-s --date --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --finger --free --fstab --git-log --git-log-s --gpg --group --gshadow --hash --hashsum --hciconfig --history --hosts --id --ifconfig --ini --iostat --iostat-s --iptables --iso-datetime --iw-scan --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsblk --lsmod --lsof --lsusb --m3u --mount --mpstat --mpstat-s --netstat --nmcli --ntpq --passwd --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --postconf --ps --route --rpm-qi --rsync --rsync-s --sfdisk --shadow --ss --stat --stat-s --sysctl --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --top --top-s --tracepath --traceroute --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --vmstat --vmstat-s --w --wc --who --x509-cert --xml --xrandr --yaml --zipinfo)
|
||||
jc_options=(--force-color -C --debug -d --monochrome -m --pretty -p --quiet -q --raw -r --unbuffer -u --yaml-out -y)
|
||||
jc_about_options=(--about -a)
|
||||
jc_about_mod_options=(--pretty -p --yaml-out -y --monochrome -m --force-color -C)
|
||||
jc_help_options=(--help -h)
|
||||
jc_special_options=(--version -v --bash-comp -B --zsh-comp -Z)
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev words cword
|
||||
|
||||
# if jc_about_options are found anywhere in the line, then only complete from jc_about_mod_options
|
||||
for i in "${words[@]::${#words[@]}-1}"; do
|
||||
if [[ " ${jc_about_options[*]} " =~ " ${i} " ]]; then
|
||||
COMPREPLY=( $( compgen -W "${jc_about_mod_options[*]}" \
|
||||
-- "${cur}" ) )
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# if jc_help_options and a parser are found anywhere in the line, then no more completions
|
||||
if
|
||||
(
|
||||
for i in "${words[@]::${#words[@]}-1}"; do
|
||||
if [[ " ${jc_help_options[*]} " =~ " ${i} " ]]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
) && (
|
||||
for i in "${words[@]::${#words[@]}-1}"; do
|
||||
if [[ " ${jc_parsers[*]} " =~ " ${i} " ]]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
); then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# if jc_help_options are found anywhere in the line, then only complete with parsers
|
||||
for i in "${words[@]::${#words[@]}-1}"; do
|
||||
if [[ " ${jc_help_options[*]} " =~ " ${i} " ]]; then
|
||||
COMPREPLY=( $( compgen -W "${jc_parsers[*]}" \
|
||||
-- "${cur}" ) )
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# if special options are found anywhere in the line, then no more completions
|
||||
for i in "${words[@]::${#words[@]}-1}"; do
|
||||
if [[ " ${jc_special_options[*]} " =~ " ${i} " ]]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# if magic command is found anywhere in the line, use called command's autocompletion
|
||||
for i in "${words[@]::${#words[@]}-1}"; do
|
||||
if [[ " ${jc_commands[*]} " =~ " ${i} " ]]; then
|
||||
_command
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# if a parser arg is found anywhere in the line, only show options and help options
|
||||
for i in "${words[@]::${#words[@]}-1}"; do
|
||||
if [[ " ${jc_parsers[*]} " =~ " ${i} " ]]; then
|
||||
COMPREPLY=( $( compgen -W "${jc_options[*]} ${jc_help_options[*]}" \
|
||||
-- "${cur}" ) )
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# default completion
|
||||
COMPREPLY=( $( compgen -W "${jc_options[*]} ${jc_about_options[*]} ${jc_help_options[*]} ${jc_special_options[*]} ${jc_parsers[*]} ${jc_commands[*]}" \
|
||||
-- "${cur}" ) )
|
||||
} &&
|
||||
complete -F _jc jc
|
||||
|
||||
331
completions/jc_zsh_completion.sh
Normal file
331
completions/jc_zsh_completion.sh
Normal file
@@ -0,0 +1,331 @@
|
||||
#compdef jc
|
||||
|
||||
_jc() {
|
||||
local -a jc_commands jc_commands_describe \
|
||||
jc_parsers jc_parsers_describe \
|
||||
jc_options jc_options_describe \
|
||||
jc_about_options jc_about_options_describe \
|
||||
jc_about_mod_options jc_about_mod_options_describe \
|
||||
jc_help_options jc_help_options_describe \
|
||||
jc_special_options jc_special_options_describe
|
||||
|
||||
jc_commands=(acpi airport arp blkid chage cksum crontab date df dig dmidecode dpkg du env file finger free git gpg hciconfig id ifconfig iostat iptables iw jobs last lastb ls lsblk lsmod lsof lsusb md5 md5sum mount mpstat netstat nmcli ntpq pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss stat sum sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 ufw uname update-alternatives upower uptime vdir vmstat w wc who xrandr zipinfo)
|
||||
jc_commands_describe=(
|
||||
'acpi:run "acpi" command with magic syntax.'
|
||||
'airport:run "airport" command with magic syntax.'
|
||||
'arp:run "arp" command with magic syntax.'
|
||||
'blkid:run "blkid" command with magic syntax.'
|
||||
'chage:run "chage" command with magic syntax.'
|
||||
'cksum:run "cksum" command with magic syntax.'
|
||||
'crontab:run "crontab" command with magic syntax.'
|
||||
'date:run "date" command with magic syntax.'
|
||||
'df:run "df" command with magic syntax.'
|
||||
'dig:run "dig" command with magic syntax.'
|
||||
'dmidecode:run "dmidecode" command with magic syntax.'
|
||||
'dpkg:run "dpkg" command with magic syntax.'
|
||||
'du:run "du" command with magic syntax.'
|
||||
'env:run "env" command with magic syntax.'
|
||||
'file:run "file" command with magic syntax.'
|
||||
'finger:run "finger" command with magic syntax.'
|
||||
'free:run "free" command with magic syntax.'
|
||||
'git:run "git" command with magic syntax.'
|
||||
'gpg:run "gpg" command with magic syntax.'
|
||||
'hciconfig:run "hciconfig" command with magic syntax.'
|
||||
'id:run "id" command with magic syntax.'
|
||||
'ifconfig:run "ifconfig" command with magic syntax.'
|
||||
'iostat:run "iostat" command with magic syntax.'
|
||||
'iptables:run "iptables" command with magic syntax.'
|
||||
'iw:run "iw" command with magic syntax.'
|
||||
'jobs:run "jobs" command with magic syntax.'
|
||||
'last:run "last" command with magic syntax.'
|
||||
'lastb:run "lastb" command with magic syntax.'
|
||||
'ls:run "ls" command with magic syntax.'
|
||||
'lsblk:run "lsblk" command with magic syntax.'
|
||||
'lsmod:run "lsmod" command with magic syntax.'
|
||||
'lsof:run "lsof" command with magic syntax.'
|
||||
'lsusb:run "lsusb" command with magic syntax.'
|
||||
'md5:run "md5" command with magic syntax.'
|
||||
'md5sum:run "md5sum" command with magic syntax.'
|
||||
'mount:run "mount" command with magic syntax.'
|
||||
'mpstat:run "mpstat" command with magic syntax.'
|
||||
'netstat:run "netstat" command with magic syntax.'
|
||||
'nmcli:run "nmcli" command with magic syntax.'
|
||||
'ntpq:run "ntpq" command with magic syntax.'
|
||||
'pidstat:run "pidstat" command with magic syntax.'
|
||||
'ping:run "ping" command with magic syntax.'
|
||||
'ping6:run "ping6" command with magic syntax.'
|
||||
'pip:run "pip" command with magic syntax.'
|
||||
'pip3:run "pip3" command with magic syntax.'
|
||||
'postconf:run "postconf" command with magic syntax.'
|
||||
'printenv:run "printenv" command with magic syntax.'
|
||||
'ps:run "ps" command with magic syntax.'
|
||||
'route:run "route" command with magic syntax.'
|
||||
'rpm:run "rpm" command with magic syntax.'
|
||||
'rsync:run "rsync" command with magic syntax.'
|
||||
'sfdisk:run "sfdisk" command with magic syntax.'
|
||||
'sha1sum:run "sha1sum" command with magic syntax.'
|
||||
'sha224sum:run "sha224sum" command with magic syntax.'
|
||||
'sha256sum:run "sha256sum" command with magic syntax.'
|
||||
'sha384sum:run "sha384sum" command with magic syntax.'
|
||||
'sha512sum:run "sha512sum" command with magic syntax.'
|
||||
'shasum:run "shasum" command with magic syntax.'
|
||||
'ss:run "ss" command with magic syntax.'
|
||||
'stat:run "stat" command with magic syntax.'
|
||||
'sum:run "sum" command with magic syntax.'
|
||||
'sysctl:run "sysctl" command with magic syntax.'
|
||||
'systemctl:run "systemctl" command with magic syntax.'
|
||||
'systeminfo:run "systeminfo" command with magic syntax.'
|
||||
'timedatectl:run "timedatectl" command with magic syntax.'
|
||||
'top:run "top" command with magic syntax.'
|
||||
'tracepath:run "tracepath" command with magic syntax.'
|
||||
'tracepath6:run "tracepath6" command with magic syntax.'
|
||||
'traceroute:run "traceroute" command with magic syntax.'
|
||||
'traceroute6:run "traceroute6" command with magic syntax.'
|
||||
'ufw:run "ufw" command with magic syntax.'
|
||||
'uname:run "uname" command with magic syntax.'
|
||||
'update-alternatives:run "update-alternatives" command with magic syntax.'
|
||||
'upower:run "upower" command with magic syntax.'
|
||||
'uptime:run "uptime" command with magic syntax.'
|
||||
'vdir:run "vdir" command with magic syntax.'
|
||||
'vmstat:run "vmstat" command with magic syntax.'
|
||||
'w:run "w" command with magic syntax.'
|
||||
'wc:run "wc" command with magic syntax.'
|
||||
'who:run "who" command with magic syntax.'
|
||||
'xrandr:run "xrandr" command with magic syntax.'
|
||||
'zipinfo:run "zipinfo" command with magic syntax.'
|
||||
)
|
||||
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --chage --cksum --crontab --crontab-u --csv --csv-s --date --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --finger --free --fstab --git-log --git-log-s --gpg --group --gshadow --hash --hashsum --hciconfig --history --hosts --id --ifconfig --ini --iostat --iostat-s --iptables --iso-datetime --iw-scan --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsblk --lsmod --lsof --lsusb --m3u --mount --mpstat --mpstat-s --netstat --nmcli --ntpq --passwd --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --postconf --ps --route --rpm-qi --rsync --rsync-s --sfdisk --shadow --ss --stat --stat-s --sysctl --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --top --top-s --tracepath --traceroute --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --vmstat --vmstat-s --w --wc --who --x509-cert --xml --xrandr --yaml --zipinfo)
|
||||
jc_parsers_describe=(
|
||||
'--acpi:`acpi` command parser'
|
||||
'--airport:`airport -I` command parser'
|
||||
'--airport-s:`airport -s` command parser'
|
||||
'--arp:`arp` command parser'
|
||||
'--asciitable:ASCII and Unicode table parser'
|
||||
'--asciitable-m:multi-line ASCII and Unicode table parser'
|
||||
'--blkid:`blkid` command parser'
|
||||
'--chage:`chage --list` command parser'
|
||||
'--cksum:`cksum` and `sum` command parser'
|
||||
'--crontab:`crontab` command and file parser'
|
||||
'--crontab-u:`crontab` file parser with user support'
|
||||
'--csv:CSV file parser'
|
||||
'--csv-s:CSV file streaming parser'
|
||||
'--date:`date` command parser'
|
||||
'--df:`df` command parser'
|
||||
'--dig:`dig` command parser'
|
||||
'--dir:`dir` command parser'
|
||||
'--dmidecode:`dmidecode` command parser'
|
||||
'--dpkg-l:`dpkg -l` command parser'
|
||||
'--du:`du` command parser'
|
||||
'--email-address:Email Address string parser'
|
||||
'--env:`env` command parser'
|
||||
'--file:`file` command parser'
|
||||
'--finger:`finger` command parser'
|
||||
'--free:`free` command parser'
|
||||
'--fstab:`/etc/fstab` file parser'
|
||||
'--git-log:`git log` command parser'
|
||||
'--git-log-s:`git log` command streaming parser'
|
||||
'--gpg:`gpg --with-colons` command parser'
|
||||
'--group:`/etc/group` file parser'
|
||||
'--gshadow:`/etc/gshadow` file parser'
|
||||
'--hash:`hash` command parser'
|
||||
'--hashsum:hashsum command parser (`md5sum`, `shasum`, etc.)'
|
||||
'--hciconfig:`hciconfig` command parser'
|
||||
'--history:`history` command parser'
|
||||
'--hosts:`/etc/hosts` file parser'
|
||||
'--id:`id` command parser'
|
||||
'--ifconfig:`ifconfig` command parser'
|
||||
'--ini:INI file parser'
|
||||
'--iostat:`iostat` command parser'
|
||||
'--iostat-s:`iostat` command streaming parser'
|
||||
'--iptables:`iptables` command parser'
|
||||
'--iso-datetime:ISO 8601 Datetime string parser'
|
||||
'--iw-scan:`iw dev [device] scan` command parser'
|
||||
'--jar-manifest:MANIFEST.MF file parser'
|
||||
'--jobs:`jobs` command parser'
|
||||
'--jwt:JWT string parser'
|
||||
'--kv:Key/Value file parser'
|
||||
'--last:`last` and `lastb` command parser'
|
||||
'--ls:`ls` command parser'
|
||||
'--ls-s:`ls` command streaming parser'
|
||||
'--lsblk:`lsblk` command parser'
|
||||
'--lsmod:`lsmod` command parser'
|
||||
'--lsof:`lsof` command parser'
|
||||
'--lsusb:`lsusb` command parser'
|
||||
'--m3u:M3U and M3U8 file parser'
|
||||
'--mount:`mount` command parser'
|
||||
'--mpstat:`mpstat` command parser'
|
||||
'--mpstat-s:`mpstat` command streaming parser'
|
||||
'--netstat:`netstat` command parser'
|
||||
'--nmcli:`nmcli` command parser'
|
||||
'--ntpq:`ntpq -p` command parser'
|
||||
'--passwd:`/etc/passwd` file parser'
|
||||
'--pidstat:`pidstat -h` command parser'
|
||||
'--pidstat-s:`pidstat -h` command streaming parser'
|
||||
'--ping:`ping` and `ping6` command parser'
|
||||
'--ping-s:`ping` and `ping6` command streaming parser'
|
||||
'--pip-list:`pip list` command parser'
|
||||
'--pip-show:`pip show` command parser'
|
||||
'--postconf:`postconf -M` command parser'
|
||||
'--ps:`ps` command parser'
|
||||
'--route:`route` command parser'
|
||||
'--rpm-qi:`rpm -qi` command parser'
|
||||
'--rsync:`rsync` command parser'
|
||||
'--rsync-s:`rsync` command streaming parser'
|
||||
'--sfdisk:`sfdisk` command parser'
|
||||
'--shadow:`/etc/shadow` file parser'
|
||||
'--ss:`ss` command parser'
|
||||
'--stat:`stat` command parser'
|
||||
'--stat-s:`stat` command streaming parser'
|
||||
'--sysctl:`sysctl` command parser'
|
||||
'--systemctl:`systemctl` command parser'
|
||||
'--systemctl-lj:`systemctl list-jobs` command parser'
|
||||
'--systemctl-ls:`systemctl list-sockets` command parser'
|
||||
'--systemctl-luf:`systemctl list-unit-files` command parser'
|
||||
'--systeminfo:`systeminfo` command parser'
|
||||
'--time:`/usr/bin/time` command parser'
|
||||
'--timedatectl:`timedatectl status` command parser'
|
||||
'--timestamp:UNIX Epoch Timestamp string parser'
|
||||
'--top:`top -b` command parser'
|
||||
'--top-s:`top -b` command streaming parser'
|
||||
'--tracepath:`tracepath` and `tracepath6` command parser'
|
||||
'--traceroute:`traceroute` and `traceroute6` command parser'
|
||||
'--ufw:`ufw status` command parser'
|
||||
'--ufw-appinfo:`ufw app info [application]` command parser'
|
||||
'--uname:`uname -a` command parser'
|
||||
'--update-alt-gs:`update-alternatives --get-selections` command parser'
|
||||
'--update-alt-q:`update-alternatives --query` command parser'
|
||||
'--upower:`upower` command parser'
|
||||
'--uptime:`uptime` command parser'
|
||||
'--url:URL string parser'
|
||||
'--vmstat:`vmstat` command parser'
|
||||
'--vmstat-s:`vmstat` command streaming parser'
|
||||
'--w:`w` command parser'
|
||||
'--wc:`wc` command parser'
|
||||
'--who:`who` command parser'
|
||||
'--x509-cert:X.509 PEM and DER certificate file parser'
|
||||
'--xml:XML file parser'
|
||||
'--xrandr:`xrandr` command parser'
|
||||
'--yaml:YAML file parser'
|
||||
'--zipinfo:`zipinfo` command parser'
|
||||
)
|
||||
jc_options=(--force-color -C --debug -d --monochrome -m --pretty -p --quiet -q --raw -r --unbuffer -u --yaml-out -y)
|
||||
jc_options_describe=(
|
||||
'--force-color:force color output even when using pipes (overrides -m)'
|
||||
'-C:force color output even when using pipes (overrides -m)'
|
||||
'--debug:debug (double for verbose debug)'
|
||||
'-d:debug (double for verbose debug)'
|
||||
'--monochrome:monochrome output'
|
||||
'-m:monochrome output'
|
||||
'--pretty:pretty print output'
|
||||
'-p:pretty print output'
|
||||
'--quiet:suppress warnings (double to ignore streaming errors)'
|
||||
'-q:suppress warnings (double to ignore streaming errors)'
|
||||
'--raw:raw output'
|
||||
'-r:raw output'
|
||||
'--unbuffer:unbuffer output'
|
||||
'-u:unbuffer output'
|
||||
'--yaml-out:YAML output'
|
||||
'-y:YAML output'
|
||||
)
|
||||
jc_about_options=(--about -a)
|
||||
jc_about_options_describe=(
|
||||
'--about:about jc'
|
||||
'-a:about jc'
|
||||
)
|
||||
jc_about_mod_options=(--pretty -p --yaml-out -y --monochrome -m --force-color -C)
|
||||
jc_about_mod_options_describe=(
|
||||
'--pretty:pretty print output'
|
||||
'-p:pretty print output'
|
||||
'--yaml-out:YAML output'
|
||||
'-y:YAML output'
|
||||
'--monochrome:monochrome output'
|
||||
'-m:monochrome output'
|
||||
'--force-color:force color output even when using pipes (overrides -m)'
|
||||
'-C:force color output even when using pipes (overrides -m)'
|
||||
)
|
||||
jc_help_options=(--help -h)
|
||||
jc_help_options_describe=(
|
||||
'--help:help (--help --parser_name for parser documentation)'
|
||||
'-h:help (--help --parser_name for parser documentation)'
|
||||
)
|
||||
jc_special_options=(--version -v --bash-comp -B --zsh-comp -Z)
|
||||
jc_special_options_describe=(
|
||||
'--version:version info'
|
||||
'-v:version info'
|
||||
'--bash-comp:gen Bash completion: jc -B > /etc/bash_completion.d/jc'
|
||||
'-B:gen Bash completion: jc -B > /etc/bash_completion.d/jc'
|
||||
'--zsh-comp:gen Zsh completion: jc -Z > "${fpath[1]}/_jc"'
|
||||
'-Z:gen Zsh completion: jc -Z > "${fpath[1]}/_jc"'
|
||||
)
|
||||
|
||||
# if jc_about_options are found anywhere in the line, then only complete from jc_about_mod_options
|
||||
for i in ${words:0:-1}; do
|
||||
if (( $jc_about_options[(Ie)${i}] )); then
|
||||
_describe 'commands' jc_about_mod_options_describe
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# if jc_help_options and a parser are found anywhere in the line, then no more completions
|
||||
if
|
||||
(
|
||||
for i in ${words:0:-1}; do
|
||||
if (( $jc_help_options[(Ie)${i}] )); then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
) && (
|
||||
for i in ${words:0:-1}; do
|
||||
if (( $jc_parsers[(Ie)${i}] )); then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
); then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# if jc_help_options are found anywhere in the line, then only complete with parsers
|
||||
for i in ${words:0:-1}; do
|
||||
if (( $jc_help_options[(Ie)${i}] )); then
|
||||
_describe 'commands' jc_parsers_describe
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# if special options are found anywhere in the line, then no more completions
|
||||
for i in ${words:0:-1}; do
|
||||
if (( $jc_special_options[(Ie)${i}] )); then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# if magic command is found anywhere in the line, use called command's autocompletion
|
||||
for i in ${words:0:-1}; do
|
||||
if (( $jc_commands[(Ie)${i}] )); then
|
||||
# hack to remove options between jc and the magic command
|
||||
shift $(( ${#words} - 2 )) words
|
||||
words[1,0]=(jc)
|
||||
CURRENT=${#words}
|
||||
|
||||
# run the magic command's completions
|
||||
_arguments '*::arguments:_normal'
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# if a parser arg is found anywhere in the line, only show options and help options
|
||||
for i in ${words:0:-1}; do
|
||||
if (( $jc_parsers[(Ie)${i}] )); then
|
||||
_describe 'commands' jc_options_describe -- jc_help_options_describe
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# default completion
|
||||
_describe 'commands' jc_options_describe -- jc_about_options_describe -- jc_help_options_describe -- jc_special_options_describe -- jc_parsers_describe -- jc_commands_describe
|
||||
}
|
||||
|
||||
_jc
|
||||
|
||||
117
docgen.sh
117
docgen.sh
@@ -1,26 +1,119 @@
|
||||
#!/bin/bash
|
||||
# Generate docs.md
|
||||
# requires pydoc-markdown 2.1.0.post1
|
||||
# requires pydoc-markdown 4.6.1
|
||||
readme_config=$(cat <<'EOF'
|
||||
{
|
||||
"processors": [
|
||||
{
|
||||
"type": "filter"
|
||||
},
|
||||
{
|
||||
"type": "pydocmd"
|
||||
}
|
||||
],
|
||||
"renderer": {
|
||||
"type": "markdown",
|
||||
"header_level_by_type": {
|
||||
"Module": 1,
|
||||
"Class": 3,
|
||||
"Method": 3,
|
||||
"Function": 3,
|
||||
"Variable": 3
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
)
|
||||
|
||||
toc_config=$(cat <<'EOF'
|
||||
{
|
||||
"processors": [
|
||||
{
|
||||
"type": "filter"
|
||||
},
|
||||
{
|
||||
"type": "pydocmd"
|
||||
}
|
||||
],
|
||||
"renderer": {
|
||||
"type": "markdown",
|
||||
"render_toc": true,
|
||||
"header_level_by_type": {
|
||||
"Module": 1,
|
||||
"Class": 3,
|
||||
"Method": 3,
|
||||
"Function": 3,
|
||||
"Variable": 3
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
)
|
||||
|
||||
parser_config=$(cat <<'EOF'
|
||||
{
|
||||
"processors": [
|
||||
{
|
||||
"type": "filter",
|
||||
"expression": "not name == \"info\" and not name.startswith(\"_\") and default()"
|
||||
},
|
||||
{
|
||||
"type": "pydocmd"
|
||||
}
|
||||
],
|
||||
"renderer": {
|
||||
"type": "markdown",
|
||||
"header_level_by_type": {
|
||||
"Module": 1,
|
||||
"Class": 3,
|
||||
"Method": 3,
|
||||
"Function": 3,
|
||||
"Variable": 3
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
)
|
||||
|
||||
cd jc
|
||||
echo Building docs for: package
|
||||
pydocmd simple jc+ > ../docs/readme.md
|
||||
echo Building docs for: utils
|
||||
pydocmd simple utils+ > ../docs/utils.md
|
||||
(
|
||||
echo Building docs for: package
|
||||
pydoc-markdown -m jc "${readme_config}" > ../docs/readme.md; echo "+++ package docs complete"
|
||||
) &
|
||||
|
||||
(
|
||||
echo Building docs for: lib
|
||||
pydoc-markdown -m jc.lib "${toc_config}" > ../docs/lib.md; echo "+++ lib docs complete"
|
||||
) &
|
||||
|
||||
(
|
||||
echo Building docs for: utils
|
||||
pydoc-markdown -m jc.utils "${toc_config}" > ../docs/utils.md; echo "+++ utils docs complete"
|
||||
) &
|
||||
|
||||
(
|
||||
echo Building docs for: streaming
|
||||
pydoc-markdown -m jc.streaming "${toc_config}" > ../docs/streaming.md; echo "+++ streaming docs complete"
|
||||
) &
|
||||
|
||||
(
|
||||
echo Building docs for: universal parser
|
||||
pydoc-markdown -m jc.parsers.universal "${toc_config}" > ../docs/parsers/universal.md; echo "+++ universal parser docs complete"
|
||||
) &
|
||||
|
||||
# a bit of inception here... jc is being used to help
|
||||
# automate the generation of its own documentation. :)
|
||||
|
||||
# pull jc parser objects into a bash array from jq
|
||||
# filter out any plugin parsers
|
||||
parsers=()
|
||||
while read -r value
|
||||
do
|
||||
parsers+=("$value")
|
||||
done < <(jc -a | jq -c '.parsers[]')
|
||||
done < <(jc -a | jq -c '.parsers[] | select(.plugin != true)')
|
||||
|
||||
# iterate over the bash array
|
||||
for parser in "${parsers[@]}"
|
||||
do
|
||||
do (
|
||||
parser_name=$(jq -r '.name' <<< "$parser")
|
||||
compatible=$(jq -r '.compatible | join(", ")' <<< "$parser")
|
||||
version=$(jq -r '.version' <<< "$parser")
|
||||
@@ -29,9 +122,13 @@ do
|
||||
|
||||
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
|
||||
pydoc-markdown -m jc.parsers."${parser_name}" "${parser_config}" >> ../docs/parsers/"${parser_name}".md
|
||||
echo "### Parser Information" >> ../docs/parsers/"${parser_name}".md
|
||||
echo "Compatibility: ${compatible}" >> ../docs/parsers/"${parser_name}".md
|
||||
echo >> ../docs/parsers/"${parser_name}".md
|
||||
echo "Version ${version} by ${author} (${author_email})" >> ../docs/parsers/"${parser_name}".md
|
||||
echo "+++ ${parser_name} docs complete"
|
||||
) &
|
||||
done
|
||||
wait
|
||||
echo "Document Generation Complete"
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
theme: jekyll-theme-cayman
|
||||
176
docs/lib.md
Normal file
176
docs/lib.md
Normal file
@@ -0,0 +1,176 @@
|
||||
# Table of Contents
|
||||
|
||||
* [jc.lib](#jc.lib)
|
||||
* [parse](#jc.lib.parse)
|
||||
* [parser\_mod\_list](#jc.lib.parser_mod_list)
|
||||
* [plugin\_parser\_mod\_list](#jc.lib.plugin_parser_mod_list)
|
||||
* [standard\_parser\_mod\_list](#jc.lib.standard_parser_mod_list)
|
||||
* [streaming\_parser\_mod\_list](#jc.lib.streaming_parser_mod_list)
|
||||
* [parser\_info](#jc.lib.parser_info)
|
||||
* [all\_parser\_info](#jc.lib.all_parser_info)
|
||||
* [get\_help](#jc.lib.get_help)
|
||||
|
||||
<a id="jc.lib"></a>
|
||||
|
||||
# jc.lib
|
||||
|
||||
jc - JSON Convert lib module
|
||||
|
||||
<a id="jc.lib.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(parser_mod_name: str,
|
||||
data: Union[str, bytes, Iterable[str]],
|
||||
quiet: bool = False,
|
||||
raw: bool = False,
|
||||
ignore_exceptions: bool = None,
|
||||
**kwargs) -> Union[Dict, List[Dict], Iterator[Dict]]
|
||||
```
|
||||
|
||||
Parse the string data using the supplied parser module.
|
||||
|
||||
This function provides a high-level API to simplify parser use. This
|
||||
function will call built-in parsers and custom plugin parsers.
|
||||
|
||||
Example:
|
||||
|
||||
>>> import jc
|
||||
>>> jc.parse('date', 'Tue Jan 18 10:23:07 PST 2022')
|
||||
{'year': 2022, 'month': 'Jan', 'month_num': 1, 'day'...}
|
||||
|
||||
To get a list of available parser module names, use `parser_mod_list()`.
|
||||
|
||||
You can also use the lower-level parser modules directly:
|
||||
|
||||
>>> import jc.parsers.date
|
||||
>>> jc.parsers.date.parse('Tue Jan 18 10:23:07 PST 2022')
|
||||
|
||||
Though, accessing plugin parsers directly is a bit more cumbersome, so
|
||||
this higher-level API is recommended. Here is how you can access plugin
|
||||
parsers without this API:
|
||||
|
||||
>>> import os
|
||||
>>> import sys
|
||||
>>> import jc.appdirs
|
||||
>>> data_dir = jc.appdirs.user_data_dir('jc', 'jc')
|
||||
>>> local_parsers_dir = os.path.join(data_dir, 'jcparsers')
|
||||
>>> sys.path.append(local_parsers_dir)
|
||||
>>> import my_custom_parser
|
||||
>>> my_custom_parser.parse('command_data')
|
||||
|
||||
Parameters:
|
||||
|
||||
parser_mod_name: (string) name of the parser module. This
|
||||
function will accept module_name,
|
||||
cli-name, and --argument-name
|
||||
variants of the module name.
|
||||
|
||||
data: (string or data to parse (string or bytes for
|
||||
bytes or standard parsers, iterable of
|
||||
iterable) strings for streaming parsers)
|
||||
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||
(streaming parsers only)
|
||||
|
||||
Returns:
|
||||
|
||||
Standard Parsers: Dictionary or List of Dictionaries
|
||||
Streaming Parsers: Generator Object containing Dictionaries
|
||||
|
||||
<a id="jc.lib.parser_mod_list"></a>
|
||||
|
||||
### parser\_mod\_list
|
||||
|
||||
```python
|
||||
def parser_mod_list() -> List[str]
|
||||
```
|
||||
|
||||
Returns a list of all available parser module names.
|
||||
|
||||
<a id="jc.lib.plugin_parser_mod_list"></a>
|
||||
|
||||
### plugin\_parser\_mod\_list
|
||||
|
||||
```python
|
||||
def plugin_parser_mod_list() -> List[str]
|
||||
```
|
||||
|
||||
Returns a list of plugin parser module names. This function is a
|
||||
subset of `parser_mod_list()`.
|
||||
|
||||
<a id="jc.lib.standard_parser_mod_list"></a>
|
||||
|
||||
### standard\_parser\_mod\_list
|
||||
|
||||
```python
|
||||
def standard_parser_mod_list() -> List[str]
|
||||
```
|
||||
|
||||
Returns a list of standard parser module names. This function is a
|
||||
subset of `parser_mod_list()` and does not contain any streaming
|
||||
parsers.
|
||||
|
||||
<a id="jc.lib.streaming_parser_mod_list"></a>
|
||||
|
||||
### streaming\_parser\_mod\_list
|
||||
|
||||
```python
|
||||
def streaming_parser_mod_list() -> List[str]
|
||||
```
|
||||
|
||||
Returns a list of streaming parser module names. This function is a
|
||||
subset of `parser_mod_list()`.
|
||||
|
||||
<a id="jc.lib.parser_info"></a>
|
||||
|
||||
### parser\_info
|
||||
|
||||
```python
|
||||
def parser_info(parser_mod_name: str, documentation: bool = False) -> Dict
|
||||
```
|
||||
|
||||
Returns a dictionary that includes the parser module metadata.
|
||||
|
||||
Parameters:
|
||||
|
||||
parser_mod_name: (string) name of the parser module. This
|
||||
function will accept module_name,
|
||||
cli-name, and --argument-name
|
||||
variants of the module name.
|
||||
|
||||
documentation: (boolean) include parser docstring if True
|
||||
|
||||
<a id="jc.lib.all_parser_info"></a>
|
||||
|
||||
### all\_parser\_info
|
||||
|
||||
```python
|
||||
def all_parser_info(documentation: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Returns a list of dictionaries that includes metadata for all parser
|
||||
modules.
|
||||
|
||||
Parameters:
|
||||
|
||||
documentation: (boolean) include parser docstrings if True
|
||||
|
||||
<a id="jc.lib.get_help"></a>
|
||||
|
||||
### get\_help
|
||||
|
||||
```python
|
||||
def get_help(parser_mod_name: str) -> None
|
||||
```
|
||||
|
||||
Show help screen for the selected parser.
|
||||
|
||||
This function will accept **module_name**, **cli-name**, and
|
||||
**--argument-name** variants of the module name string.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.acpi"></a>
|
||||
|
||||
# jc.parsers.acpi
|
||||
jc - JSON CLI output utility `acpi` command output parser
|
||||
|
||||
jc - JSON Convert `acpi` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,8 +15,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.acpi
|
||||
result = jc.parsers.acpi.parse(acpi_command_output)
|
||||
import jc
|
||||
result = jc.parse('acpi', acpi_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -225,16 +227,12 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.acpi.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -242,14 +240,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.airport"></a>
|
||||
|
||||
# jc.parsers.airport
|
||||
jc - JSON CLI output utility `airport -I` command output parser
|
||||
|
||||
jc - JSON Convert `airport -I` command output parser
|
||||
|
||||
The `airport` program can be found at `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport`.
|
||||
|
||||
@@ -15,8 +17,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.airport
|
||||
result = jc.parsers.airport.parse(airport_command_output)
|
||||
import jc
|
||||
result = jc.parse('airport', airport_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -78,16 +80,12 @@ Examples:
|
||||
"channel": "48,80"
|
||||
}
|
||||
|
||||
<a id="jc.parsers.airport.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -95,14 +93,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: darwin
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.airport_s"></a>
|
||||
|
||||
# jc.parsers.airport_s
|
||||
jc - JSON CLI output utility `airport -s` command output parser
|
||||
# jc.parsers.airport\_s
|
||||
|
||||
jc - JSON Convert `airport -s` command output parser
|
||||
|
||||
The `airport` program can be found at `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport`.
|
||||
|
||||
@@ -15,8 +17,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.airport_s
|
||||
result = jc.parsers.airport_s.parse(airport_s_command_output)
|
||||
import jc
|
||||
result = jc.parse('airport_s', airport_s_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -106,16 +108,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.airport_s.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -123,14 +121,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: darwin
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.arp"></a>
|
||||
|
||||
# jc.parsers.arp
|
||||
jc - JSON CLI output utility `arp` command output parser
|
||||
|
||||
jc - JSON Convert `arp` command output parser
|
||||
|
||||
Supports `arp` and `arp -a` output.
|
||||
|
||||
@@ -15,8 +17,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.arp
|
||||
result = jc.parsers.arp.parse(arp_command_output)
|
||||
import jc
|
||||
result = jc.parse('arp', arp_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -115,16 +117,12 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.arp.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -132,14 +130,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, aix, freebsd, darwin
|
||||
|
||||
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.10 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
147
docs/parsers/asciitable.md
Normal file
147
docs/parsers/asciitable.md
Normal file
@@ -0,0 +1,147 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.asciitable"></a>
|
||||
|
||||
# jc.parsers.asciitable
|
||||
|
||||
jc - JSON Convert `asciitable` parser
|
||||
|
||||
This parser converts ASCII and Unicode text tables with single-line rows.
|
||||
|
||||
Column headers must be at least two spaces apart from each other and must
|
||||
be unique. For best results, column headers should be left-justified. If
|
||||
column separators are present, then non-left-justified headers will be fixed
|
||||
automatically.
|
||||
|
||||
Row separators are optional and are ignored. Each non-row-separator line is
|
||||
considered a separate row in the table.
|
||||
|
||||
For example:
|
||||
|
||||
╒══════════╤═════════╤════════╕
|
||||
│ foo │ bar │ baz │
|
||||
╞══════════╪═════════╪════════╡
|
||||
│ good day │ │ 12345 │
|
||||
├──────────┼─────────┼────────┤
|
||||
│ hi there │ abc def │ 3.14 │
|
||||
╘══════════╧═════════╧════════╛
|
||||
|
||||
or
|
||||
|
||||
+-----------------------------+
|
||||
| foo bar baz |
|
||||
+-----------------------------+
|
||||
| good day 12345 |
|
||||
| hi there abc def 3.14 |
|
||||
+-----------------------------+
|
||||
|
||||
or
|
||||
|
||||
| foo | bar | baz |
|
||||
|----------|---------|--------|
|
||||
| good day | | 12345 |
|
||||
| hi there | abc def | 3.14 |
|
||||
|
||||
or
|
||||
|
||||
foo bar baz
|
||||
--------- -------- ------
|
||||
good day 12345
|
||||
hi there abc def 3.14
|
||||
|
||||
or
|
||||
|
||||
foo bar baz
|
||||
good day 12345
|
||||
hi there abc def 3.14
|
||||
|
||||
etc...
|
||||
|
||||
Headers (keys) are converted to snake-case. All values are returned as
|
||||
strings, except empty strings, which are converted to None/null.
|
||||
|
||||
> Note: To preserve the case of the keys use the `-r` cli option or
|
||||
> `raw=True` argument in `parse()`.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat table.txt | jc --asciitable
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('asciitable', asciitable_string)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"column_name1": string, # empty string is null
|
||||
"column_name2": string # empty string is null
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ echo '
|
||||
> ╒══════════╤═════════╤════════╕
|
||||
> │ foo │ bar │ baz │
|
||||
> ╞══════════╪═════════╪════════╡
|
||||
> │ good day │ │ 12345 │
|
||||
> ├──────────┼─────────┼────────┤
|
||||
> │ hi there │ abc def │ 3.14 │
|
||||
> ╘══════════╧═════════╧════════╛' | jc --asciitable -p
|
||||
[
|
||||
{
|
||||
"foo": "good day",
|
||||
"bar": null,
|
||||
"baz": "12345"
|
||||
},
|
||||
{
|
||||
"foo": "hi there",
|
||||
"bar": "abc def",
|
||||
"baz": "3.14"
|
||||
}
|
||||
]
|
||||
|
||||
$ echo '
|
||||
> foo bar baz
|
||||
> --------- -------- ------
|
||||
> good day 12345
|
||||
> hi there abc def 3.14' | jc --asciitable -p
|
||||
[
|
||||
{
|
||||
"foo": "good day",
|
||||
"bar": null,
|
||||
"baz": "12345"
|
||||
},
|
||||
{
|
||||
"foo": "hi there",
|
||||
"bar": "abc def",
|
||||
"baz": "3.14"
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.asciitable.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
132
docs/parsers/asciitable_m.md
Normal file
132
docs/parsers/asciitable_m.md
Normal file
@@ -0,0 +1,132 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.asciitable_m"></a>
|
||||
|
||||
# jc.parsers.asciitable\_m
|
||||
|
||||
jc - JSON Convert `asciitable-m` parser
|
||||
|
||||
This parser converts various styles of ASCII and Unicode text tables with
|
||||
multi-line rows. Tables must have a header row and separator line between
|
||||
rows.
|
||||
|
||||
For example:
|
||||
|
||||
╒══════════╤═════════╤════════╕
|
||||
│ foo │ bar baz │ fiz │
|
||||
│ │ │ buz │
|
||||
╞══════════╪═════════╪════════╡
|
||||
│ good day │ 12345 │ │
|
||||
│ mate │ │ │
|
||||
├──────────┼─────────┼────────┤
|
||||
│ hi there │ abc def │ 3.14 │
|
||||
│ │ │ │
|
||||
╘══════════╧═════════╧════════╛
|
||||
|
||||
Cells with multiple lines within rows will be joined with a newline
|
||||
character ('\\n').
|
||||
|
||||
Headers (keys) are converted to snake-case and newlines between multi-line
|
||||
headers are joined with an underscore. All values are returned as strings,
|
||||
except empty strings, which are converted to None/null.
|
||||
|
||||
> Note: To preserve the case of the keys use the `-r` cli option or
|
||||
> `raw=True` argument in `parse()`.
|
||||
|
||||
> Note: table column separator characters (e.g. `|`) cannot be present
|
||||
> inside the cell data. If detected, a warning message will be printed to
|
||||
> `STDERR` and the line will be skipped. The warning message can be
|
||||
> suppressed by using the `-q` command option or by setting `quiet=True` in
|
||||
> `parse()`.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat table.txt | jc --asciitable-m
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('asciitable_m', asciitable-string)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"column_name1": string, # empty string is null
|
||||
"column_name2": string # empty string is null
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ echo '
|
||||
> +----------+---------+--------+
|
||||
> | foo | bar | baz |
|
||||
> | | | buz |
|
||||
> +==========+=========+========+
|
||||
> | good day | 12345 | |
|
||||
> | mate | | |
|
||||
> +----------+---------+--------+
|
||||
> | hi there | abc def | 3.14 |
|
||||
> | | | |
|
||||
> +==========+=========+========+' | jc --asciitable-m -p
|
||||
[
|
||||
{
|
||||
"foo": "good day\\nmate",
|
||||
"bar": "12345",
|
||||
"baz_buz": null
|
||||
},
|
||||
{
|
||||
"foo": "hi there",
|
||||
"bar": "abc def",
|
||||
"baz_buz": "3.14"
|
||||
}
|
||||
]
|
||||
|
||||
$ echo '
|
||||
> ╒══════════╤═════════╤════════╕
|
||||
> │ foo │ bar │ baz │
|
||||
> │ │ │ buz │
|
||||
> ╞══════════╪═════════╪════════╡
|
||||
> │ good day │ 12345 │ │
|
||||
> │ mate │ │ │
|
||||
> ├──────────┼─────────┼────────┤
|
||||
> │ hi there │ abc def │ 3.14 │
|
||||
> │ │ │ │
|
||||
> ╘══════════╧═════════╧════════╛' | jc --asciitable-m -p
|
||||
[
|
||||
{
|
||||
"foo": "good day\\nmate",
|
||||
"bar": "12345",
|
||||
"baz_buz": null
|
||||
},
|
||||
{
|
||||
"foo": "hi there",
|
||||
"bar": "abc def",
|
||||
"baz_buz": "3.14"
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.asciitable_m.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.blkid"></a>
|
||||
|
||||
# jc.parsers.blkid
|
||||
jc - JSON CLI output utility `blkid` command output parser
|
||||
|
||||
jc - JSON Convert `blkid` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,8 +15,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.blkid
|
||||
result = jc.parsers.blkid.parse(blkid_command_output)
|
||||
import jc
|
||||
result = jc.parse('blkid', blkid_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -83,7 +85,7 @@ Examples:
|
||||
{
|
||||
"id_fs_uuid": "3klkIj-w1kk-DkJi-0XBJ-y3i7-i2Ac-vHqWBM",
|
||||
"id_fs_uuid_enc": "3klkIj-w1kk-DkJi-0XBJ-y3i7-i2Ac-vHqWBM",
|
||||
"id_fs_version": "LVM2\x20001",
|
||||
"id_fs_version": "LVM2\\x20001",
|
||||
"id_fs_type": "LVM2_member",
|
||||
"id_fs_usage": "raid",
|
||||
"id_iolimit_minimum_io_size": 512,
|
||||
@@ -118,16 +120,12 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.blkid.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -135,14 +133,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
82
docs/parsers/chage.md
Normal file
82
docs/parsers/chage.md
Normal file
@@ -0,0 +1,82 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.chage"></a>
|
||||
|
||||
# jc.parsers.chage
|
||||
|
||||
jc - JSON Convert `chage --list` command output parser
|
||||
|
||||
Supports `chage -l <username>` or `chage --list <username>`
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ chage -l johndoe | jc --chage
|
||||
|
||||
or
|
||||
|
||||
$ jc chage -l johndoe
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('chage', chage_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"password_last_changed": string,
|
||||
"password_expires": string,
|
||||
"password_inactive": string,
|
||||
"account_expires": string,
|
||||
"min_days_between_password_change": integer,
|
||||
"max_days_between_password_change": integer,
|
||||
"warning_days_before_password_expires": integer
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ chage --list joeuser | jc --chage -p
|
||||
{
|
||||
"password_last_changed": "never",
|
||||
"password_expires": "never",
|
||||
"password_inactive": "never",
|
||||
"account_expires": "never",
|
||||
"min_days_between_password_change": 0,
|
||||
"max_days_between_password_change": 99999,
|
||||
"warning_days_before_password_expires": 7
|
||||
}
|
||||
|
||||
$ chage --list joeuser | jc --chage -p -r
|
||||
{
|
||||
"password_last_changed": "never",
|
||||
"password_expires": "never",
|
||||
"password_inactive": "never",
|
||||
"account_expires": "never",
|
||||
"min_days_between_password_change": "0",
|
||||
"max_days_between_password_change": "99999",
|
||||
"warning_days_before_password_expires": "7"
|
||||
}
|
||||
|
||||
<a id="jc.parsers.chage.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> Dict
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.cksum"></a>
|
||||
|
||||
# jc.parsers.cksum
|
||||
jc - JSON CLI output utility `cksum` command output parser
|
||||
|
||||
jc - JSON Convert `cksum` command output parser
|
||||
|
||||
This parser works with the following checksum calculation utilities:
|
||||
- `sum`
|
||||
@@ -17,8 +19,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.cksum
|
||||
result = jc.parsers.cksum.parse(cksum_command_output)
|
||||
import jc
|
||||
result = jc.parse('cksum', cksum_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -52,16 +54,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.cksum.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -69,14 +67,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.crontab"></a>
|
||||
|
||||
# jc.parsers.crontab
|
||||
jc - JSON CLI output utility `crontab -l` command output and crontab file parser
|
||||
|
||||
jc - JSON Convert `crontab -l` command output and crontab
|
||||
file parser
|
||||
|
||||
Supports `crontab -l` command output and crontab files.
|
||||
|
||||
@@ -15,8 +18,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.crontab
|
||||
result = jc.parsers.crontab.parse(crontab_output)
|
||||
import jc
|
||||
result = jc.parse('crontab', crontab_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -170,16 +173,12 @@ Examples:
|
||||
]
|
||||
}
|
||||
|
||||
<a id="jc.parsers.crontab.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -187,14 +186,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, aix, freebsd
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.crontab_u"></a>
|
||||
|
||||
# jc.parsers.crontab_u
|
||||
jc - JSON CLI output utility `crontab -l` command output and crontab file parser
|
||||
# jc.parsers.crontab\_u
|
||||
|
||||
This version of the `crontab -l` parser supports output that contains user information for processes.
|
||||
jc - JSON Convert `crontab -l` command output and crontab
|
||||
file parser
|
||||
|
||||
This version of the `crontab -l` parser supports output that contains user
|
||||
information for processes.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -11,8 +15,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.crontab_u
|
||||
result = jc.parsers.crontab_u.parse(crontab_u_output)
|
||||
import jc
|
||||
result = jc.parse('crontab_u', crontab_u_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -55,7 +59,7 @@ Examples:
|
||||
"variables": [
|
||||
{
|
||||
"name": "PATH",
|
||||
"value": "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
|
||||
"value": "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sb..."
|
||||
},
|
||||
{
|
||||
"name": "SHELL",
|
||||
@@ -80,7 +84,7 @@ Examples:
|
||||
"*"
|
||||
],
|
||||
"user": "root",
|
||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )"
|
||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
||||
},
|
||||
{
|
||||
"minute": [
|
||||
@@ -99,7 +103,7 @@ Examples:
|
||||
"7"
|
||||
],
|
||||
"user": "root",
|
||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )"
|
||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
||||
},
|
||||
{
|
||||
"minute": [
|
||||
@@ -118,7 +122,7 @@ Examples:
|
||||
"*"
|
||||
],
|
||||
"user": "root",
|
||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )"
|
||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -128,7 +132,7 @@ Examples:
|
||||
"variables": [
|
||||
{
|
||||
"name": "PATH",
|
||||
"value": "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
|
||||
"value": "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/..."
|
||||
},
|
||||
{
|
||||
"name": "SHELL",
|
||||
@@ -143,7 +147,7 @@ Examples:
|
||||
"month": "*",
|
||||
"day_of_week": "*",
|
||||
"user": "root",
|
||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )"
|
||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
||||
},
|
||||
{
|
||||
"minute": "47",
|
||||
@@ -152,7 +156,7 @@ Examples:
|
||||
"month": "*",
|
||||
"day_of_week": "7",
|
||||
"user": "root",
|
||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )"
|
||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
||||
},
|
||||
{
|
||||
"minute": "52",
|
||||
@@ -161,21 +165,17 @@ Examples:
|
||||
"month": "*",
|
||||
"day_of_week": "*",
|
||||
"user": "root",
|
||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )"
|
||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
<a id="jc.parsers.crontab_u.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -183,14 +183,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, aix, freebsd
|
||||
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.csv"></a>
|
||||
|
||||
# jc.parsers.csv
|
||||
jc - JSON CLI output utility `csv` file parser
|
||||
|
||||
The `csv` parser will attempt to automatically detect the delimiter character. If the delimiter cannot be detected it will default to comma. The first row of the file must be a header row.
|
||||
jc - JSON Convert `csv` file parser
|
||||
|
||||
The `csv` parser will attempt to automatically detect the delimiter
|
||||
character. If the delimiter cannot be detected it will default to comma.
|
||||
The first row of the file must be a header row.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -11,12 +15,13 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.csv
|
||||
result = jc.parsers.csv.parse(csv_output)
|
||||
import jc
|
||||
result = jc.parse('csv', csv_output)
|
||||
|
||||
Schema:
|
||||
|
||||
csv file converted to a Dictionary: https://docs.python.org/3/library/csv.html
|
||||
CSV file converted to a Dictionary:
|
||||
https://docs.python.org/3/library/csv.html
|
||||
|
||||
[
|
||||
{
|
||||
@@ -28,7 +33,7 @@ Schema:
|
||||
Examples:
|
||||
|
||||
$ cat homes.csv
|
||||
"Sell", "List", "Living", "Rooms", "Beds", "Baths", "Age", "Acres", "Taxes"
|
||||
"Sell", "List", "Living", "Rooms", "Beds", "Baths", "Age", "Acres"...
|
||||
142, 160, 28, 10, 5, 3, 60, 0.28, 3167
|
||||
175, 180, 18, 8, 4, 1, 12, 0.43, 4033
|
||||
129, 132, 13, 6, 3, 1, 41, 0.33, 1471
|
||||
@@ -72,16 +77,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.csv.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -89,14 +90,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.csv_s"></a>
|
||||
|
||||
# jc.parsers.csv_s
|
||||
jc - JSON CLI output utility `csv` file streaming parser
|
||||
# jc.parsers.csv\_s
|
||||
|
||||
> This streaming parser outputs JSON Lines
|
||||
jc - JSON Convert `csv` file streaming parser
|
||||
|
||||
The `csv` streaming parser will attempt to automatically detect the delimiter character. If the delimiter cannot be detected it will default to comma. The first row of the file must be a header row.
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
Note: The first 100 rows are read into memory to enable delimiter detection, then the rest of the rows are loaded lazily.
|
||||
The `csv` streaming parser will attempt to automatically detect the
|
||||
delimiter character. If the delimiter cannot be detected it will default
|
||||
to comma. The first row of the file must be a header row.
|
||||
|
||||
> Note: The first 100 rows are read into memory to enable delimiter
|
||||
> detection, then the rest of the rows are loaded lazily.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -15,71 +21,69 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.csv_s
|
||||
result = jc.parsers.csv_s.parse(csv_output.splitlines()) # result is an iterable object
|
||||
import jc
|
||||
|
||||
result = jc.parse('csv_s', csv_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
Schema:
|
||||
|
||||
csv file converted to a Dictionary: https://docs.python.org/3/library/csv.html
|
||||
CSV file converted to a Dictionary:
|
||||
https://docs.python.org/3/library/csv.html
|
||||
|
||||
{
|
||||
"column_name1": string,
|
||||
"column_name2": string,
|
||||
"_jc_meta": # This object only exists if using -qq or ignore_exceptions=True
|
||||
{
|
||||
"success": boolean, # true if successfully parsed, false if error
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # false if error parsing
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat homes.csv
|
||||
"Sell", "List", "Living", "Rooms", "Beds", "Baths", "Age", "Acres", "Taxes"
|
||||
"Sell", "List", "Living", "Rooms", "Beds", "Baths", "Age", "Acres"...
|
||||
142, 160, 28, 10, 5, 3, 60, 0.28, 3167
|
||||
175, 180, 18, 8, 4, 1, 12, 0.43, 4033
|
||||
129, 132, 13, 6, 3, 1, 41, 0.33, 1471
|
||||
...
|
||||
|
||||
$ cat homes.csv | jc --csv-s
|
||||
{"Sell":"142","List":"160","Living":"28","Rooms":"10","Beds":"5","Baths":"3","Age":"60","Acres":"0.28","Taxes":"3167"}
|
||||
{"Sell":"175","List":"180","Living":"18","Rooms":"8","Beds":"4","Baths":"1","Age":"12","Acres":"0.43","Taxes":"4033"}
|
||||
{"Sell":"129","List":"132","Living":"13","Rooms":"6","Beds":"3","Baths":"1","Age":"41","Acres":"0.33","Taxes":"1471"}
|
||||
{"Sell":"142","List":"160","Living":"28","Rooms":"10","Beds":"5"...}
|
||||
{"Sell":"175","List":"180","Living":"18","Rooms":"8","Beds":"4"...}
|
||||
{"Sell":"129","List":"132","Living":"13","Rooms":"6","Beds":"3"...}
|
||||
...
|
||||
|
||||
<a id="jc.parsers.csv_s.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||
@add_jc_meta
|
||||
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterator object.
|
||||
Main text parsing generator function. Returns an iterable object.
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (iterable) line-based text data to parse (e.g. sys.stdin or str.splitlines())
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
data: (iterable) line-based text data to parse
|
||||
(e.g. sys.stdin or str.splitlines())
|
||||
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||
|
||||
Yields:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
Returns:
|
||||
|
||||
Iterator object
|
||||
Iterable of Dictionaries
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.date"></a>
|
||||
|
||||
# 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)
|
||||
jc - JSON Convert `date` command output parser
|
||||
|
||||
The `epoch_utc` calculated timestamp field is timezone-aware and is only available if the timezone field is UTC.
|
||||
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):
|
||||
|
||||
@@ -17,8 +21,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.date
|
||||
result = jc.parsers.date.parse(date_command_output)
|
||||
import jc
|
||||
result = jc.parse('date', date_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -35,15 +39,19 @@ Schema:
|
||||
"second": integer,
|
||||
"period": string,
|
||||
"timezone": string,
|
||||
"utc_offset": string, # null if timezone field is not UTC
|
||||
"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
|
||||
"epoch": integer, # [0]
|
||||
"epoch_utc": integer, # [1]
|
||||
"timezone_aware": boolean # [2]
|
||||
}
|
||||
|
||||
[0] naive timestamp
|
||||
[1] timezone-aware timestamp. Only available if timezone field is UTC
|
||||
[2] if true, all fields are correctly based on UTC
|
||||
|
||||
Examples:
|
||||
|
||||
$ date | jc --date -p
|
||||
@@ -69,16 +77,12 @@ Examples:
|
||||
"timezone_aware": true
|
||||
}
|
||||
|
||||
<a id="jc.parsers.date.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -86,14 +90,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 2.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 2.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.df"></a>
|
||||
|
||||
# jc.parsers.df
|
||||
jc - JSON CLI output utility `df` command output parser
|
||||
|
||||
jc - JSON Convert `df` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,8 +15,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.df
|
||||
result = jc.parsers.df.parse(df_command_output)
|
||||
import jc
|
||||
result = jc.parse('df', df_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -95,16 +97,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.df.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -112,14 +110,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.11 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.dig"></a>
|
||||
|
||||
# jc.parsers.dig
|
||||
jc - JSON CLI output utility `dig` command output parser
|
||||
|
||||
jc - JSON Convert `dig` command output parser
|
||||
|
||||
Options supported:
|
||||
- `+noall +answer` options are supported in cases where only the answer information is desired.
|
||||
- `+noall +answer` options are supported in cases where only the answer
|
||||
information is desired.
|
||||
- `+axfr` option is supported on its own
|
||||
|
||||
The `when_epoch` calculated timestamp field is naive (i.e. based on the local time of the system the parser is run on)
|
||||
The `when_epoch` calculated timestamp field is naive. (i.e. based on the
|
||||
local time of the system the parser is run on)
|
||||
|
||||
The `when_epoch_utc` calculated timestamp field is timezone-aware and is only available if the timezone field is UTC.
|
||||
The `when_epoch_utc` calculated timestamp field is timezone-aware and is
|
||||
only available if the timezone field is UTC.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -21,8 +26,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.dig
|
||||
result = jc.parsers.dig.parse(dig_command_output)
|
||||
import jc
|
||||
result = jc.parse('dig', dig_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -93,13 +98,16 @@ Schema:
|
||||
"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
|
||||
"when_epoch": integer, # [0]
|
||||
"when_epoch_utc": integer, # [1]
|
||||
"rcvd": integer
|
||||
"size": string
|
||||
}
|
||||
]
|
||||
|
||||
[0] naive timestamp if "when" field is parsable, else null
|
||||
[1] timezone aware timestamp availabe for UTC, else null
|
||||
|
||||
Examples:
|
||||
|
||||
$ dig example.com | jc --dig -p
|
||||
@@ -314,16 +322,12 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.dig.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -331,14 +335,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, aix, freebsd, darwin, win32, cygwin
|
||||
|
||||
Version 2.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 2.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.dir"></a>
|
||||
|
||||
# jc.parsers.dir
|
||||
jc - JSON CLI output utility `dir` command output parser
|
||||
|
||||
jc - JSON Convert `dir` command output parser
|
||||
|
||||
Options supported:
|
||||
- `/T timefield`
|
||||
@@ -9,18 +11,20 @@ Options supported:
|
||||
- `/C, /-C`
|
||||
- `/S`
|
||||
|
||||
The "Magic" syntax is not supported since the `dir` command is a shell builtin.
|
||||
The "Magic" syntax is not supported since the `dir` command is a shell
|
||||
builtin.
|
||||
|
||||
The `epoch` calculated timestamp field is naive (i.e. based on the local time of the system the parser is run on)
|
||||
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
|
||||
C:\> dir | jc --dir
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.dir
|
||||
result = jc.parsers.dir.parse(dir_command_output)
|
||||
import jc
|
||||
result = jc.parse('dir', dir_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -38,7 +42,7 @@ Schema:
|
||||
|
||||
Examples:
|
||||
|
||||
C:> dir | jc --dir -p
|
||||
C:\> dir | jc --dir -p
|
||||
[
|
||||
{
|
||||
"date": "03/24/2021",
|
||||
@@ -46,7 +50,7 @@ Examples:
|
||||
"dir": true,
|
||||
"size": null,
|
||||
"filename": ".",
|
||||
"parent": "C:\Program Files\Internet Explorer",
|
||||
"parent": "C:\\Program Files\\Internet Explorer",
|
||||
"epoch": 1616624100
|
||||
},
|
||||
{
|
||||
@@ -55,7 +59,7 @@ Examples:
|
||||
"dir": true,
|
||||
"size": null,
|
||||
"filename": "..",
|
||||
"parent": "C:\Program Files\Internet Explorer",
|
||||
"parent": "C:\\Program Files\\Internet Explorer",
|
||||
"epoch": 1616624100
|
||||
},
|
||||
{
|
||||
@@ -64,7 +68,7 @@ Examples:
|
||||
"dir": true,
|
||||
"size": null,
|
||||
"filename": "en-US",
|
||||
"parent": "C:\Program Files\Internet Explorer",
|
||||
"parent": "C:\\Program Files\\Internet Explorer",
|
||||
"epoch": 1575715740
|
||||
},
|
||||
{
|
||||
@@ -73,13 +77,13 @@ Examples:
|
||||
"dir": false,
|
||||
"size": 54784,
|
||||
"filename": "ExtExport.exe",
|
||||
"parent": "C:\Program Files\Internet Explorer",
|
||||
"parent": "C:\\Program Files\\Internet Explorer",
|
||||
"epoch": 1575713340
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
C:> dir | jc --dir -p -r
|
||||
C:\> dir | jc --dir -p -r
|
||||
[
|
||||
{
|
||||
"date": "03/24/2021",
|
||||
@@ -87,7 +91,7 @@ Examples:
|
||||
"dir": true,
|
||||
"size": null,
|
||||
"filename": ".",
|
||||
"parent": "C:\Program Files\Internet Explorer"
|
||||
"parent": "C:\\Program Files\\Internet Explorer"
|
||||
},
|
||||
{
|
||||
"date": "03/24/2021",
|
||||
@@ -95,7 +99,7 @@ Examples:
|
||||
"dir": true,
|
||||
"size": null,
|
||||
"filename": "..",
|
||||
"parent": "C:\Program Files\Internet Explorer"
|
||||
"parent": "C:\\Program Files\\Internet Explorer"
|
||||
},
|
||||
{
|
||||
"date": "12/07/2019",
|
||||
@@ -103,7 +107,7 @@ Examples:
|
||||
"dir": true,
|
||||
"size": null,
|
||||
"filename": "en-US",
|
||||
"parent": "C:\Program Files\Internet Explorer"
|
||||
"parent": "C:\\Program Files\\Internet Explorer"
|
||||
},
|
||||
{
|
||||
"date": "12/07/2019",
|
||||
@@ -111,21 +115,17 @@ Examples:
|
||||
"dir": false,
|
||||
"size": "54,784",
|
||||
"filename": "ExtExport.exe",
|
||||
"parent": "C:\Program Files\Internet Explorer"
|
||||
"parent": "C:\\Program Files\\Internet Explorer"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.dir.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -133,14 +133,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: win32
|
||||
|
||||
Version 1.4 by Rasheed Elsaleh (rasheed@rebelliondefense.com)
|
||||
Version 1.6 by Rasheed Elsaleh (rasheed@rebelliondefense.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.dmidecode"></a>
|
||||
|
||||
# jc.parsers.dmidecode
|
||||
jc - JSON CLI output utility `dmidecode` command output parser
|
||||
|
||||
jc - JSON Convert `dmidecode` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,8 +15,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.dmidecode
|
||||
result = jc.parsers.dmidecode.parse(dmidecode_command_output)
|
||||
import jc
|
||||
result = jc.parse('dmidecode', dmidecode_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -24,7 +26,7 @@ Schema:
|
||||
"type": integer,
|
||||
"bytes": integer,
|
||||
"description": string,
|
||||
"values": { (null if empty)
|
||||
"values": { # null if empty
|
||||
"lowercase_no_spaces_keys": string,
|
||||
"multiline_key_values": [
|
||||
string,
|
||||
@@ -123,16 +125,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.dmidecode.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -140,14 +138,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.dpkg_l"></a>
|
||||
|
||||
# jc.parsers.dpkg_l
|
||||
jc - JSON CLI output utility `dpkg -l` command output parser
|
||||
# jc.parsers.dpkg\_l
|
||||
|
||||
Set the `COLUMNS` environment variable to a large value to avoid field truncation. For example:
|
||||
jc - JSON Convert `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
|
||||
|
||||
@@ -17,8 +20,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.dpkg_l
|
||||
result = jc.parsers.dpkg_l.parse(dpkg_command_output)
|
||||
import jc
|
||||
result = jc.parse('dpkg_l', dpkg_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -72,7 +75,7 @@ Examples:
|
||||
"name": "acpid",
|
||||
"version": "1:2.0.28-1ubuntu1",
|
||||
"architecture": "amd64",
|
||||
"description": "Advanced Configuration and Power Interface event daemon",
|
||||
"description": "Advanced Configuration and Power Interface...",
|
||||
"desired": "remove",
|
||||
"status": "half installed"
|
||||
},
|
||||
@@ -116,7 +119,7 @@ Examples:
|
||||
"name": "acpid",
|
||||
"version": "1:2.0.28-1ubuntu1",
|
||||
"architecture": "amd64",
|
||||
"description": "Advanced Configuration and Power Interface event daemon"
|
||||
"description": "Advanced Configuration and Power Interface..."
|
||||
},
|
||||
{
|
||||
"codes": "pn",
|
||||
@@ -128,16 +131,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.dpkg_l.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -145,14 +144,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.du"></a>
|
||||
|
||||
# jc.parsers.du
|
||||
jc - JSON CLI output utility `du` command output parser
|
||||
|
||||
jc - JSON Convert `du` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,8 +15,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.du
|
||||
result = jc.parsers.du.parse(du_command_output)
|
||||
import jc
|
||||
result = jc.parse('du', du_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -35,23 +37,23 @@ Examples:
|
||||
},
|
||||
{
|
||||
"size": 56,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/_CodeSignature"
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||
},
|
||||
{
|
||||
"size": 0,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local/standalone"
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||
},
|
||||
{
|
||||
"size": 0,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local"
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||
},
|
||||
{
|
||||
"size": 0,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr"
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||
},
|
||||
{
|
||||
"size": 1008,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/dfu"
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||
},
|
||||
...
|
||||
]
|
||||
@@ -64,37 +66,33 @@ Examples:
|
||||
},
|
||||
{
|
||||
"size": "56",
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/_CodeSignature"
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||
},
|
||||
{
|
||||
"size": "0",
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local/standalone"
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||
},
|
||||
{
|
||||
"size": "0",
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local"
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||
},
|
||||
{
|
||||
"size": "0",
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr"
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||
},
|
||||
{
|
||||
"size": "1008",
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/dfu"
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.du.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -102,14 +100,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, aix, freebsd
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
67
docs/parsers/email_address.md
Normal file
67
docs/parsers/email_address.md
Normal file
@@ -0,0 +1,67 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.email_address"></a>
|
||||
|
||||
# jc.parsers.email\_address
|
||||
|
||||
jc - JSON Convert Email Address string parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ echo "username@example.com" | jc --email-address
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('email_address', email_address_string)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"username": string,
|
||||
"domain": string,
|
||||
"local": string,
|
||||
"local_plus_suffix": string or null
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ echo 'joe.user@gmail.com' | jc --email-address -p
|
||||
{
|
||||
"username": "joe.user",
|
||||
"domain": "gmail.com",
|
||||
"local": "joe.user",
|
||||
"local_plus_suffix": null
|
||||
}
|
||||
|
||||
$ echo 'joe.user+spam@gmail.com' | jc --email-address -p
|
||||
{
|
||||
"username": "joe.user",
|
||||
"domain": "gmail.com",
|
||||
"local": "joe.user+spam",
|
||||
"local_plus_suffix": "spam"
|
||||
}
|
||||
|
||||
<a id="jc.parsers.email_address.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> Dict
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -1,9 +1,14 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.env"></a>
|
||||
|
||||
# jc.parsers.env
|
||||
jc - JSON CLI output utility `env` and `printenv` command output parser
|
||||
|
||||
This parser will output a list of dictionaries each containing `name` and `value` keys. If you would like a simple dictionary output, then use the `-r` command-line option or the `raw=True` argument in the `parse()` function.
|
||||
jc - JSON Convert `env` and `printenv` command output parser
|
||||
|
||||
This parser will output a list of dictionaries each containing `name` and
|
||||
`value` keys. If you would like a simple dictionary output, then use the
|
||||
`-r` command-line option or the `raw=True` argument in the `parse()`
|
||||
function.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -15,8 +20,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.env
|
||||
result = jc.parsers.env.parse(env_command_output)
|
||||
import jc
|
||||
result = jc.parse('env', env_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -67,16 +72,12 @@ Examples:
|
||||
"_": "/usr/bin/env"
|
||||
}
|
||||
|
||||
<a id="jc.parsers.env.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -84,7 +85,7 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
@@ -92,7 +93,7 @@ Returns:
|
||||
Dictionary of raw structured data or
|
||||
List of Dictionaries of processed structured data
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.file"></a>
|
||||
|
||||
# jc.parsers.file
|
||||
jc - JSON CLI output utility `file` command output parser
|
||||
|
||||
jc - JSON Convert `file` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,15 +15,15 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.file
|
||||
result = jc.parsers.file.parse(file_command_output)
|
||||
import jc
|
||||
result = jc.parse('file', file_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"filename": string,
|
||||
"type ": string
|
||||
"type": string
|
||||
}
|
||||
]
|
||||
|
||||
@@ -51,25 +53,21 @@ Examples:
|
||||
},
|
||||
{
|
||||
"filename": "cd_catalog.xml",
|
||||
"type": "XML 1.0 document text, ASCII text, with CRLF line terminators"
|
||||
"type": "XML 1.0 document text, ASCII text, with CRLF line ..."
|
||||
},
|
||||
{
|
||||
"filename": "centosserial.sh",
|
||||
"type": "Bourne-Again shell script text executable, UTF-8 Unicode text"
|
||||
"type": "Bourne-Again shell script text executable, UTF-8 ..."
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.file.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -77,14 +75,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, aix, freebsd, darwin
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.finger"></a>
|
||||
|
||||
# jc.parsers.finger
|
||||
jc - JSON CLI output utility `finger` command output parser
|
||||
|
||||
jc - JSON Convert `finger` command output parser
|
||||
|
||||
Supports `-s` output option. Does not support the `-l` detail option.
|
||||
|
||||
@@ -15,8 +17,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.finger
|
||||
result = jc.parsers.finger.parse(finger_command_output)
|
||||
import jc
|
||||
result = jc.parse('finger', finger_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -88,16 +90,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.finger.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -105,14 +103,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, freebsd
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.free"></a>
|
||||
|
||||
# jc.parsers.free
|
||||
jc - JSON CLI output utility `free` command output parser
|
||||
|
||||
jc - JSON Convert `free` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,8 +15,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.free
|
||||
result = jc.parsers.free.parse(free_command_output)
|
||||
import jc
|
||||
result = jc.parse('free', free_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -70,16 +72,12 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.free.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -87,14 +85,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.fstab"></a>
|
||||
|
||||
# jc.parsers.fstab
|
||||
jc - JSON CLI output utility `fstab` file parser
|
||||
|
||||
jc - JSON Convert `fstab` file parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -9,8 +11,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.fstab
|
||||
result = jc.parsers.fstab.parse(fstab_command_output)
|
||||
import jc
|
||||
result = jc.parse('fstab', fstab_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -83,16 +85,12 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.fstab.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -100,14 +98,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, freebsd
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
175
docs/parsers/git_log.md
Normal file
175
docs/parsers/git_log.md
Normal file
@@ -0,0 +1,175 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.git_log"></a>
|
||||
|
||||
# jc.parsers.git\_log
|
||||
|
||||
jc - JSON Convert `git log` command output parser
|
||||
|
||||
Can be used with the following format options:
|
||||
- `oneline`
|
||||
- `short`
|
||||
- `medium`
|
||||
- `full`
|
||||
- `fuller`
|
||||
|
||||
Additional options supported:
|
||||
- `--stat`
|
||||
- `--shortstat`
|
||||
|
||||
The `epoch` calculated timestamp field is naive. (i.e. based on the
|
||||
local time of the system the parser is run on)
|
||||
|
||||
The `epoch_utc` calculated timestamp field is timezone-aware and is
|
||||
only available if the timezone field is UTC.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ git log | jc --git-log
|
||||
|
||||
or
|
||||
|
||||
$ jc git log
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('git_log', git_log_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"commit": string,
|
||||
"author": string,
|
||||
"author_email": string,
|
||||
"date": string,
|
||||
"epoch": integer, # [0]
|
||||
"epoch_utc": integer, # [1]
|
||||
"commit_by": string,
|
||||
"commit_by_email": string,
|
||||
"commit_by_date": string,
|
||||
"message": string,
|
||||
"stats" : {
|
||||
"files_changed": integer,
|
||||
"insertions": integer,
|
||||
"deletions": integer,
|
||||
"files": [
|
||||
string
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
[0] naive timestamp if "date" field is parsable, else null
|
||||
[1] timezone aware timestamp availabe for UTC, else null
|
||||
|
||||
Examples:
|
||||
|
||||
$ git log --stat | jc --git-log -p
|
||||
[
|
||||
{
|
||||
"commit": "728d882ed007b3c8b785018874a0eb06e1143b66",
|
||||
"author": "Kelly Brazil",
|
||||
"author_email": "kellyjonbrazil@gmail.com",
|
||||
"date": "Wed Apr 20 09:50:19 2022 -0400",
|
||||
"stats": {
|
||||
"files_changed": 2,
|
||||
"insertions": 90,
|
||||
"deletions": 12,
|
||||
"files": [
|
||||
"docs/parsers/git_log.md",
|
||||
"jc/parsers/git_log.py"
|
||||
]
|
||||
},
|
||||
"message": "add timestamp docs and examples",
|
||||
"epoch": 1650462619,
|
||||
"epoch_utc": null
|
||||
},
|
||||
{
|
||||
"commit": "b53e42aca623181aa9bc72194e6eeef1e9a3a237",
|
||||
"author": "Kelly Brazil",
|
||||
"author_email": "kellyjonbrazil@gmail.com",
|
||||
"date": "Wed Apr 20 09:44:42 2022 -0400",
|
||||
"stats": {
|
||||
"files_changed": 5,
|
||||
"insertions": 29,
|
||||
"deletions": 6,
|
||||
"files": [
|
||||
"docs/parsers/git_log.md",
|
||||
"docs/utils.md",
|
||||
"jc/parsers/git_log.py",
|
||||
"jc/utils.py",
|
||||
"man/jc.1"
|
||||
]
|
||||
},
|
||||
"message": "add calculated timestamp",
|
||||
"epoch": 1650462282,
|
||||
"epoch_utc": null
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ git log --stat | jc --git-log -p -r
|
||||
[
|
||||
{
|
||||
"commit": "728d882ed007b3c8b785018874a0eb06e1143b66",
|
||||
"author": "Kelly Brazil",
|
||||
"author_email": "kellyjonbrazil@gmail.com",
|
||||
"date": "Wed Apr 20 09:50:19 2022 -0400",
|
||||
"stats": {
|
||||
"files_changed": "2",
|
||||
"insertions": "90",
|
||||
"deletions": "12",
|
||||
"files": [
|
||||
"docs/parsers/git_log.md",
|
||||
"jc/parsers/git_log.py"
|
||||
]
|
||||
},
|
||||
"message": "add timestamp docs and examples"
|
||||
},
|
||||
{
|
||||
"commit": "b53e42aca623181aa9bc72194e6eeef1e9a3a237",
|
||||
"author": "Kelly Brazil",
|
||||
"author_email": "kellyjonbrazil@gmail.com",
|
||||
"date": "Wed Apr 20 09:44:42 2022 -0400",
|
||||
"stats": {
|
||||
"files_changed": "5",
|
||||
"insertions": "29",
|
||||
"deletions": "6",
|
||||
"files": [
|
||||
"docs/parsers/git_log.md",
|
||||
"docs/utils.md",
|
||||
"jc/parsers/git_log.py",
|
||||
"jc/utils.py",
|
||||
"man/jc.1"
|
||||
]
|
||||
},
|
||||
"message": "add calculated timestamp"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.git_log.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
111
docs/parsers/git_log_s.md
Normal file
111
docs/parsers/git_log_s.md
Normal file
@@ -0,0 +1,111 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.git_log_s"></a>
|
||||
|
||||
# jc.parsers.git\_log\_s
|
||||
|
||||
jc - JSON Convert `git log` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
Can be used with the following format options:
|
||||
- `oneline`
|
||||
- `short`
|
||||
- `medium`
|
||||
- `full`
|
||||
- `fuller`
|
||||
|
||||
Additional options supported:
|
||||
- `--stat`
|
||||
- `--shortstat`
|
||||
|
||||
The `epoch` calculated timestamp field is naive. (i.e. based on the
|
||||
local time of the system the parser is run on)
|
||||
|
||||
The `epoch_utc` calculated timestamp field is timezone-aware and is
|
||||
only available if the timezone field is UTC.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ git log | jc --git-log-s
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
|
||||
result = jc.parse('git_log_s', git_log_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"commit": string,
|
||||
"author": string,
|
||||
"author_email": string,
|
||||
"date": string,
|
||||
"epoch": integer, # [0]
|
||||
"epoch_utc": integer, # [1]
|
||||
"commit_by": string,
|
||||
"commit_by_email": string,
|
||||
"commit_by_date": string,
|
||||
"message": string,
|
||||
"stats" : {
|
||||
"files_changed": integer,
|
||||
"insertions": integer,
|
||||
"deletions": integer,
|
||||
"files": [
|
||||
string
|
||||
]
|
||||
}
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # false if error parsing
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
}
|
||||
|
||||
[0] naive timestamp if "date" field is parsable, else null
|
||||
[1] timezone aware timestamp availabe for UTC, else null
|
||||
|
||||
Examples:
|
||||
|
||||
$ git log | jc --git-log-s
|
||||
{"commit":"a730ae18c8e81c5261db132df73cd74f272a0a26","author":"Kelly...}
|
||||
{"commit":"930bf439c06c48a952baec05a9896c8d92b7693e","author":"Kelly...}
|
||||
...
|
||||
|
||||
<a id="jc.parsers.git_log_s.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
@add_jc_meta
|
||||
def parse(data: Iterable[str],
|
||||
raw: bool = False,
|
||||
quiet: bool = False,
|
||||
ignore_exceptions: bool = False) -> Union[Iterable[Dict], tuple]
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterable object.
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (iterable) line-based text data to parse
|
||||
(e.g. sys.stdin or str.splitlines())
|
||||
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||
|
||||
|
||||
Returns:
|
||||
|
||||
Iterable of Dictionaries
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
145
docs/parsers/gpg.md
Normal file
145
docs/parsers/gpg.md
Normal file
@@ -0,0 +1,145 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.gpg"></a>
|
||||
|
||||
# jc.parsers.gpg
|
||||
|
||||
jc - JSON Convert `gpg --with-colons` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ gpg --with-colons --show-keys file.gpg | jc --gpg
|
||||
|
||||
or
|
||||
|
||||
$ jc gpg --with-colons --show-keys file.gpg
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('gpg', gpg_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
Field definitions from https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob_plain;f=doc/DETAILS
|
||||
|
||||
> Note: Number values are not converted to integers because many field
|
||||
> specifications are overloaded and future augmentations are implied in the
|
||||
> documentation.
|
||||
|
||||
[
|
||||
{
|
||||
"type": string,
|
||||
"validity": string,
|
||||
"key_length": string,
|
||||
"pub_key_alg": string,
|
||||
"key_id": string,
|
||||
"creation_date": string,
|
||||
"expiration_date": string,
|
||||
"certsn_uidhash_trustinfo": string,
|
||||
"owner_trust": string,
|
||||
"user_id": string,
|
||||
"signature_class": string,
|
||||
"key_capabilities": string,
|
||||
"cert_fingerprint_other": string,
|
||||
"flag": string,
|
||||
"token_sn": string,
|
||||
"hash_alg": string,
|
||||
"curve_name": string,
|
||||
"compliance_flags": string,
|
||||
"last_update_date": string,
|
||||
"origin": string,
|
||||
"comment": string,
|
||||
"index": string, # [0]
|
||||
"bits": string, # [0]
|
||||
"value": string, # [0]
|
||||
"version": string, # [1], [4]
|
||||
"signature_count": string, # [1]
|
||||
"encryption_count": string, # [1]
|
||||
"policy": string, # [1]
|
||||
"signature_first_seen": string, # [1]
|
||||
"signature_most_recent_seen": string, # [1]
|
||||
"encryption_first_done": string, # [1]
|
||||
"encryption_most_recent_done": string, # [1]
|
||||
"staleness_reason": string, # [2]
|
||||
"trust_model": string, # [2]
|
||||
"trust_db_created": string, # [2]
|
||||
"trust_db_expires": string, # [2]
|
||||
"marginally_trusted_users": string, # [2]
|
||||
"completely_trusted_users": string, # [2]
|
||||
"cert_chain_max_depth": string, # [2]
|
||||
"subpacket_number": string, # [3]
|
||||
"hex_flags": string, # [3]
|
||||
"subpacket_length": string, # [3]
|
||||
"subpacket_data": string, # [3]
|
||||
"pubkey": string, # [4]
|
||||
"cipher": string, # [4]
|
||||
"digest": string, # [4]
|
||||
"compress": string, # [4]
|
||||
"group": string, # [4]
|
||||
"members": string, # [4]
|
||||
"curve_names": string, # [4]
|
||||
}
|
||||
]
|
||||
|
||||
All blank values are converted to null/None.
|
||||
|
||||
[0] for 'pkd' type
|
||||
[1] for 'tfs' type
|
||||
[2] for 'tru' type
|
||||
[3] for 'skp' type
|
||||
[4] for 'cfg' type
|
||||
|
||||
Examples:
|
||||
|
||||
$ gpg --with-colons --show-keys file.gpg | jc --gpg -p
|
||||
[
|
||||
{
|
||||
"type": "pub",
|
||||
"validity": "f",
|
||||
"key_length": "1024",
|
||||
"pub_key_alg": "17",
|
||||
"key_id": "6C7EE1B8621CC013",
|
||||
"creation_date": "899817715",
|
||||
"expiration_date": "1055898235",
|
||||
"certsn_uidhash_trustinfo": null,
|
||||
"owner_trust": "m",
|
||||
"user_id": null,
|
||||
"signature_class": null,
|
||||
"key_capabilities": "scESC",
|
||||
"cert_fingerprint_other": null,
|
||||
"flag": null,
|
||||
"token_sn": null,
|
||||
"hash_alg": null,
|
||||
"curve_name": null,
|
||||
"compliance_flags": null,
|
||||
"last_update_date": null,
|
||||
"origin": null,
|
||||
"comment": null
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.gpg.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.group"></a>
|
||||
|
||||
# jc.parsers.group
|
||||
jc - JSON CLI output utility `/etc/group` file parser
|
||||
|
||||
jc - JSON Convert `/etc/group` file parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -9,8 +11,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.group
|
||||
result = jc.parsers.group.parse(group_file_output)
|
||||
import jc
|
||||
result = jc.parse('group', group_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -107,16 +109,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.group.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -124,14 +122,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, aix, freebsd
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.gshadow"></a>
|
||||
|
||||
# jc.parsers.gshadow
|
||||
jc - JSON CLI output utility `/etc/gshadow` file parser
|
||||
|
||||
jc - JSON Convert `/etc/gshadow` file parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -9,8 +11,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.gshadow
|
||||
result = jc.parsers.gshadow.parse(gshadow_file_output)
|
||||
import jc
|
||||
result = jc.parse('gshadow', gshadow_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -75,16 +77,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.gshadow.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -92,14 +90,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, aix, freebsd
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.hash"></a>
|
||||
|
||||
# jc.parsers.hash
|
||||
jc - JSON CLI output utility `hash` command output parser
|
||||
|
||||
jc - JSON Convert `hash` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -9,8 +11,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.hash
|
||||
result = jc.parsers.hash.parse(hash_command_output)
|
||||
import jc
|
||||
result = jc.parse('hash', hash_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -35,16 +37,12 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.hash.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -52,14 +50,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.hashsum"></a>
|
||||
|
||||
# jc.parsers.hashsum
|
||||
jc - JSON CLI output utility `hash sum` command output parser
|
||||
|
||||
jc - JSON Convert `hash sum` command output parser
|
||||
|
||||
This parser works with the following hash calculation utilities:
|
||||
- `md5`
|
||||
@@ -23,8 +25,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.hashsum
|
||||
result = jc.parsers.hashsum.parse(md5sum_command_output)
|
||||
import jc
|
||||
result = jc.parse('hashsum', md5sum_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -66,16 +68,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.hashsum.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -83,14 +81,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.hciconfig"></a>
|
||||
|
||||
# jc.parsers.hciconfig
|
||||
jc - JSON CLI output utility `hciconfig` command output parser
|
||||
|
||||
jc - JSON Convert `hciconfig` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,8 +15,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.hciconfig
|
||||
result = jc.parsers.hciconfig.parse(hciconfig_command_output)
|
||||
import jc
|
||||
result = jc.parse('hciconfig', hciconfig_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -315,16 +317,12 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.hciconfig.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -332,14 +330,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.history"></a>
|
||||
|
||||
# jc.parsers.history
|
||||
jc - JSON CLI output utility `history` command output parser
|
||||
|
||||
This parser will output a list of dictionaries each containing `line` and `command` keys. If you would like a simple dictionary output, then use the `-r` command-line option or the `raw=True` argument in the `parse()` function.
|
||||
jc - JSON Convert `history` command output parser
|
||||
|
||||
The "Magic" syntax is not supported since the `history` command is a shell builtin.
|
||||
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.
|
||||
|
||||
The "Magic" syntax is not supported since the `history` command is a shell
|
||||
builtin.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,8 +19,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.history
|
||||
result = jc.parsers.history.parse(history_command_output)
|
||||
import jc
|
||||
result = jc.parse('history', history_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -39,7 +45,7 @@ Examples:
|
||||
},
|
||||
{
|
||||
"line": 120,
|
||||
"command": "echo "hello""
|
||||
"command": "echo \"hello\""
|
||||
},
|
||||
{
|
||||
"line": 121,
|
||||
@@ -52,21 +58,17 @@ Examples:
|
||||
{
|
||||
"118": "sleep 100",
|
||||
"119": "ls /bin",
|
||||
"120": "echo "hello"",
|
||||
"120": "echo \"hello\"",
|
||||
"121": "docker images",
|
||||
...
|
||||
}
|
||||
|
||||
<a id="jc.parsers.history.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -74,7 +76,7 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
@@ -82,7 +84,7 @@ Returns:
|
||||
Dictionary of raw structured data or
|
||||
List of Dictionaries of processed structured data
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.hosts"></a>
|
||||
|
||||
# jc.parsers.hosts
|
||||
jc - JSON CLI output utility `/etc/hosts` file parser
|
||||
|
||||
jc - JSON Convert `/etc/hosts` file parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -9,8 +11,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.hosts
|
||||
result = jc.parsers.hosts.parse(hosts_file_output)
|
||||
import jc
|
||||
result = jc.parse('hosts', hosts_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -72,16 +74,12 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.hosts.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -89,14 +87,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.id"></a>
|
||||
|
||||
# jc.parsers.id
|
||||
jc - JSON CLI output utility `id` command output parser
|
||||
|
||||
jc - JSON Convert `id` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,8 +15,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.id
|
||||
result = jc.parsers.id.parse(id_command_output)
|
||||
import jc
|
||||
result = jc.parse('id', id_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -103,16 +105,12 @@ Examples:
|
||||
}
|
||||
}
|
||||
|
||||
<a id="jc.parsers.id.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -120,14 +118,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, aix, freebsd
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.ifconfig"></a>
|
||||
|
||||
# jc.parsers.ifconfig
|
||||
jc - JSON CLI output utility `ifconfig` command output parser
|
||||
|
||||
Note: No `ifconfig` options are supported.
|
||||
jc - JSON Convert `ifconfig` command output parser
|
||||
|
||||
> Note: No `ifconfig` options are supported.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -15,8 +17,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.ifconfig
|
||||
result = jc.parsers.ifconfig.parse(ifconfig_command_output)
|
||||
import jc
|
||||
result = jc.parse('ifconfig', ifconfig_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -184,16 +186,12 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.ifconfig.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -201,14 +199,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, aix, freebsd, darwin
|
||||
|
||||
Version 1.11 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.12 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.ini"></a>
|
||||
|
||||
# jc.parsers.ini
|
||||
jc - JSON CLI output utility `INI` file parser
|
||||
|
||||
Parses standard `INI` files and files containing simple key/value pairs. Delimiter can be `=` or `:`. Missing values are supported. Comment prefix can be `#` or `;`. Comments must be on their own line.
|
||||
jc - JSON Convert `INI` file parser
|
||||
|
||||
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()`.
|
||||
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.
|
||||
- If duplicate keys are found, only the last value will be used.
|
||||
|
||||
> Note: Values starting and ending with double or single quotation marks
|
||||
> will have the marks removed. If you would like to keep the quotation
|
||||
> marks, use the `-r` command-line argument or the `raw=True` argument in
|
||||
> `parse()`.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,16 +22,13 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.ini
|
||||
result = jc.parsers.ini.parse(ini_file_output)
|
||||
import jc
|
||||
result = jc.parse('ini', 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.
|
||||
ini or key/value document converted to a dictionary - see the configparser
|
||||
standard library documentation for more details.
|
||||
|
||||
{
|
||||
"key1": string,
|
||||
@@ -63,16 +69,12 @@ Examples:
|
||||
}
|
||||
}
|
||||
|
||||
<a id="jc.parsers.ini.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -80,14 +82,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary representing the ini file
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.iostat"></a>
|
||||
|
||||
# jc.parsers.iostat
|
||||
jc - JSON CLI output utility `iostat` command output parser
|
||||
|
||||
Note: `iostat` version 11 and higher include a JSON output option
|
||||
jc - JSON Convert `iostat` command output parser
|
||||
|
||||
> Note: `iostat` version 11 and higher include a JSON output option
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -15,8 +17,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.iostat
|
||||
result = jc.parsers.iostat.parse(iostat_command_output)
|
||||
import jc
|
||||
result = jc.parse('iostat', iostat_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -157,16 +159,12 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.iostat.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -174,14 +172,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,20 +1,31 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.iostat_s"></a>
|
||||
|
||||
# jc.parsers.iostat_s
|
||||
jc - JSON CLI output utility `iostat` command output streaming parser
|
||||
# jc.parsers.iostat\_s
|
||||
|
||||
> This streaming parser outputs JSON Lines
|
||||
jc - JSON Convert `iostat` command output streaming parser
|
||||
|
||||
Note: `iostat` version 11 and higher include a JSON output option
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
> Note: `iostat` version 11 and higher include a JSON output option
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ iostat | jc --iostat-s
|
||||
|
||||
> Note: When piping `jc` converted `iostat` output to other processes it may
|
||||
> appear the output is hanging due to the OS pipe buffers. This is because
|
||||
> `iostat` output is too small to quickly fill up the buffer. Use the `-u`
|
||||
> option to unbuffer the `jc` output if you would like immediate output. See
|
||||
> the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
|
||||
> for more information.
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.iostat_s
|
||||
result = jc.parsers.iostat_s.parse(iostat_command_output.splitlines()) # result is an iterable object
|
||||
import jc
|
||||
|
||||
result = jc.parse('iostat_s', iostat_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
@@ -71,56 +82,52 @@ Schema:
|
||||
"percent_util": float,
|
||||
"percent_rrqm": float,
|
||||
"percent_wrqm": float,
|
||||
"_jc_meta": # This object only exists if using -qq or ignore_exceptions=True
|
||||
{
|
||||
"success": boolean, # true if successfully parsed, false if error
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # false if error parsing
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ iostat | jc --iostat-s
|
||||
{"percent_user":0.14,"percent_nice":0.0,"percent_system":0.16,"percent_iowait":0.0,"percent_steal":0.0,"percent_idle":99.7,"type":"cpu"}
|
||||
{"device":"sda","tps":0.24,"kb_read_s":5.28,"kb_wrtn_s":1.1,"kb_read":203305,"kb_wrtn":42368,"type":"device"}
|
||||
{"percent_user":0.14,"percent_nice":0.0,"percent_system":0.16,...}
|
||||
{"device":"sda","tps":0.24,"kb_read_s":5.28,"kb_wrtn_s":1.1...}
|
||||
...
|
||||
|
||||
$ iostat | jc --iostat-s -r
|
||||
{"percent_user":"0.14","percent_nice":"0.00","percent_system":"0.16","percent_iowait":"0.00","percent_steal":"0.00","percent_idle":"99.70","type":"cpu"}
|
||||
{"device":"sda","tps":"0.24","kb_read_s":"5.28","kb_wrtn_s":"1.10","kb_read":"203305","kb_wrtn":"42368","type":"device"}
|
||||
{"percent_user":"0.14","percent_nice":"0.00","percent_system":"0.16"...}
|
||||
{"device":"sda","tps":"0.24","kb_read_s":"5.28","kb_wrtn_s":"1.10"...}
|
||||
...
|
||||
|
||||
<a id="jc.parsers.iostat_s.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||
@add_jc_meta
|
||||
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterator object.
|
||||
Main text parsing generator function. Returns an iterable object.
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (iterable) line-based text data to parse (e.g. sys.stdin or str.splitlines())
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
data: (iterable) line-based text data to parse
|
||||
(e.g. sys.stdin or str.splitlines())
|
||||
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||
|
||||
Yields:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
Returns:
|
||||
|
||||
Iterator object
|
||||
Iterable of Dictionaries
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.iptables"></a>
|
||||
|
||||
# jc.parsers.iptables
|
||||
jc - JSON CLI output utility `ipables` command output parser
|
||||
|
||||
jc - JSON Convert `iptables` command output parser
|
||||
|
||||
Supports `-vLn` and `--line-numbers` for all tables.
|
||||
|
||||
@@ -15,8 +17,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.iptables
|
||||
result = jc.parsers.iptables.parse(iptables_command_output)
|
||||
import jc
|
||||
result = jc.parse('iptables', iptables_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -161,16 +163,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.iptables.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -178,14 +176,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
91
docs/parsers/iso_datetime.md
Normal file
91
docs/parsers/iso_datetime.md
Normal file
@@ -0,0 +1,91 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.iso_datetime"></a>
|
||||
|
||||
# jc.parsers.iso\_datetime
|
||||
|
||||
jc - JSON Convert ISO 8601 Datetime string parser
|
||||
|
||||
This parser supports standard ISO 8601 strings that include both date and
|
||||
time. If no timezone or offset information is available in the sring, then
|
||||
UTC timezone is used.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ echo "2022-07-20T14:52:45Z" | jc --iso-datetime
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('iso_datetime', iso_8601_string)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"year": integer,
|
||||
"month": string,
|
||||
"month_num": integer,
|
||||
"day": integer,
|
||||
"weekday": string,
|
||||
"weekday_num": integer,
|
||||
"hour": integer,
|
||||
"hour_24": integer,
|
||||
"minute": integer,
|
||||
"second": integer,
|
||||
"microsecond": integer,
|
||||
"period": string,
|
||||
"utc_offset": string,
|
||||
"day_of_year": integer,
|
||||
"week_of_year": integer,
|
||||
"iso": string,
|
||||
"timestamp": integer # [0]
|
||||
}
|
||||
|
||||
[0] timezone aware UNIX timestamp expressed in UTC
|
||||
|
||||
Examples:
|
||||
|
||||
$ echo "2022-07-20T14:52:45Z" | jc --iso-datetime -p
|
||||
{
|
||||
"year": 2022,
|
||||
"month": "Jul",
|
||||
"month_num": 7,
|
||||
"day": 20,
|
||||
"weekday": "Wed",
|
||||
"weekday_num": 3,
|
||||
"hour": 2,
|
||||
"hour_24": 14,
|
||||
"minute": 52,
|
||||
"second": 45,
|
||||
"microsecond": 0,
|
||||
"period": "PM",
|
||||
"utc_offset": "+0000",
|
||||
"day_of_year": 201,
|
||||
"week_of_year": 29,
|
||||
"iso": "2022-07-20T14:52:45+00:00",
|
||||
"timestamp": 1658328765
|
||||
}
|
||||
|
||||
<a id="jc.parsers.iso_datetime.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, aix, freebsd, darwin, win32, cygwin
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -1,9 +1,12 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.iw_scan"></a>
|
||||
|
||||
# jc.parsers.iw_scan
|
||||
jc - JSON CLI output utility `iw dev <device> scan` command output parser
|
||||
# jc.parsers.iw\_scan
|
||||
|
||||
This parser is considered beta quality. Not all fields are parsed and there are not enough samples to test.
|
||||
jc - JSON Convert `iw dev <device> scan` command output parser
|
||||
|
||||
This parser is considered beta quality. Not all fields are parsed and there
|
||||
are not enough samples to test.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -15,14 +18,14 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.iw-scan
|
||||
result = jc.parsers.iw-scan.parse(iw-scan_command_output)
|
||||
import jc
|
||||
result = jc.parse('iw_scan', iw_scan_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"foo": string/integer/float, # best guess based on value
|
||||
"foo": string/integer/float, # best guess based on value
|
||||
"bar": string/integer/float,
|
||||
"baz": string/integer/float
|
||||
}
|
||||
@@ -118,16 +121,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.iw_scan.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -135,14 +134,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 0.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
103
docs/parsers/jar_manifest.md
Normal file
103
docs/parsers/jar_manifest.md
Normal file
@@ -0,0 +1,103 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.jar_manifest"></a>
|
||||
|
||||
# jc.parsers.jar\_manifest
|
||||
|
||||
jc - JSON Convert `MANIFEST.MF` file parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat MANIFEST.MF | jc --jar-manifest
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('jar_manifest', jar_manifest_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"key1": string,
|
||||
"key2": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat MANIFEST.MF | jc --jar-manifest -p
|
||||
$ unzip -c log4j-core-2.16.0.jar META-INF/MANIFEST.MF | \\
|
||||
jc --jar-manifest -p
|
||||
$ unzip -c 'apache-log4j-2.16.0-bin/*.jar' META-INF/MANIFEST.MF | \\
|
||||
jc --jar-manifest -p
|
||||
|
||||
$ cat MANIFEST.MF | jc --jar-manifest -p
|
||||
[
|
||||
{
|
||||
"Import_Package": "com.conversantmedia.util.concurrent;resoluti...",
|
||||
"Export_Package": "org.apache.logging.log4j.core;uses:=\"org.ap...",
|
||||
"Manifest_Version": "1.0",
|
||||
"Bundle_License": "https://www.apache.org/licenses/LICENSE-2.0.txt",
|
||||
"Bundle_SymbolicName": "org.apache.logging.log4j.core",
|
||||
"Built_By": "matt",
|
||||
"Bnd_LastModified": "1639373735804",
|
||||
"Implementation_Vendor_Id": "org.apache.logging.log4j",
|
||||
"Specification_Title": "Apache Log4j Core",
|
||||
"Log4jReleaseManager": "Matt Sicker",
|
||||
...
|
||||
}
|
||||
]
|
||||
|
||||
$ unzip -c 'apache-log4j-2.16.0-bin/*.jar' META-INF/MANIFEST.MF | \\
|
||||
jc --jar-manifest -p
|
||||
[
|
||||
...
|
||||
{
|
||||
"Archive": "apache-log4j-2.16.0-bin/log4j-spring-boot-2.16.0-so...",
|
||||
"Manifest_Version": "1.0",
|
||||
"Built_By": "matt",
|
||||
"Created_By": "Apache Maven 3.8.4",
|
||||
"Build_Jdk": "1.8.0_312"
|
||||
},
|
||||
{
|
||||
"Archive": "apache-log4j-2.16.0-bin/log4j-spring-boot-2.16.0-ja...",
|
||||
"Manifest_Version": "1.0",
|
||||
"Built_By": "matt",
|
||||
"Created_By": "Apache Maven 3.8.4",
|
||||
"Build_Jdk": "1.8.0_312"
|
||||
},
|
||||
{
|
||||
"Bundle_SymbolicName": "org.apache.logging.log4j.spring-cloud-c...",
|
||||
"Export_Package": "org.apache.logging.log4j.spring.cloud.config...",
|
||||
"Archive": "apache-log4j-2.16.0-bin/log4j-spring-cloud-config-c...",
|
||||
"Manifest_Version": "1.0",
|
||||
"Bundle_License": "https://www.apache.org/licenses/LICENSE-2.0.txt",
|
||||
...
|
||||
}
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.jar_manifest.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 0.01 by Matt J (https://github.com/listuser)
|
||||
@@ -1,11 +1,14 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.jobs"></a>
|
||||
|
||||
# jc.parsers.jobs
|
||||
jc - JSON CLI output utility `jobs` command output parser
|
||||
|
||||
jc - JSON Convert `jobs` command output parser
|
||||
|
||||
Also supports the `-l` option.
|
||||
|
||||
The "Magic" syntax is not supported since the `jobs` command is a shell builtin.
|
||||
The "Magic" syntax is not supported since the `jobs` command is a shell
|
||||
builtin.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,8 +16,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.jobs
|
||||
result = jc.parsers.jobs.parse(jobs_command_output)
|
||||
import jc
|
||||
result = jc.parse('jobs', jobs_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -90,16 +93,12 @@ Example:
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.jobs.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -107,14 +106,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
73
docs/parsers/jwt.md
Normal file
73
docs/parsers/jwt.md
Normal file
@@ -0,0 +1,73 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.jwt"></a>
|
||||
|
||||
# jc.parsers.jwt
|
||||
|
||||
jc - JSON Convert JWT string parser
|
||||
|
||||
> Note: `jc` will not check the integrity of the JWT payload.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ echo "eyJhbGciOiJIUzI1N..." | jc --jwt
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('jwt', jwt_string)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"header": {
|
||||
"alg": string,
|
||||
"typ": string
|
||||
},
|
||||
"payload": {
|
||||
<key name>: string/integer/float/boolean/null
|
||||
},
|
||||
"signature": string # [0]
|
||||
}
|
||||
|
||||
[0] in colon-delimited hex notation
|
||||
|
||||
Examples:
|
||||
|
||||
% echo 'eyJhbGciOiJIUzI1N...' | jc --jwt -p
|
||||
{
|
||||
"header": {
|
||||
"alg": "HS256",
|
||||
"typ": "JWT"
|
||||
},
|
||||
"payload": {
|
||||
"sub": "1234567890",
|
||||
"name": "John Doe",
|
||||
"iat": 1516239022
|
||||
},
|
||||
"signature": "49:f9:4a:c7:04:49:48:c7:8a:28:5d:90:4f:87:f0:a4:c7..."
|
||||
}
|
||||
|
||||
<a id="jc.parsers.jwt.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> Dict
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -1,11 +1,19 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.kv"></a>
|
||||
|
||||
# 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.
|
||||
jc - JSON Convert `Key/Value` file parser
|
||||
|
||||
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()`.
|
||||
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.
|
||||
- If duplicate keys are found, only the last value will be used.
|
||||
|
||||
> Note: Values starting and ending with quotation marks will have the marks
|
||||
> removed. If you would like to keep the quotation marks, use the `-r`
|
||||
> command-line argument or the `raw=True` argument in `parse()`.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,12 +21,13 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.kv
|
||||
result = jc.parsers.kv.parse(kv_file_output)
|
||||
import jc
|
||||
result = jc.parse('kv', kv_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
key/value document converted to a dictionary - see configparser standard library documentation for more details.
|
||||
key/value document converted to a dictionary - see the configparser standard
|
||||
library documentation for more details.
|
||||
|
||||
{
|
||||
"key1": string,
|
||||
@@ -46,16 +55,12 @@ Examples:
|
||||
"occupation": "Engineer"
|
||||
}
|
||||
|
||||
<a id="jc.parsers.kv.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -65,14 +70,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary representing the key/value file
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.last"></a>
|
||||
|
||||
# jc.parsers.last
|
||||
jc - JSON CLI output utility `last` and `lastb` command output parser
|
||||
|
||||
jc - JSON Convert `last` and `lastb` command output parser
|
||||
|
||||
Supports `-w` and `-F` options.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -17,8 +21,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.last
|
||||
result = jc.parsers.last.parse(last_command_output)
|
||||
import jc
|
||||
result = jc.parse('last', last_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -30,9 +34,9 @@ Schema:
|
||||
"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
|
||||
"login_epoch": integer, # (naive) available w/last -F option
|
||||
"logout_epoch": integer, # (naive) available w/last -F option
|
||||
"duration_seconds": integer # available w/last -F option
|
||||
}
|
||||
]
|
||||
|
||||
@@ -100,17 +104,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.last.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -118,14 +117,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, aix, freebsd
|
||||
|
||||
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.ls"></a>
|
||||
|
||||
# jc.parsers.ls
|
||||
jc - JSON CLI output utility `ls` and `vdir` command output parser
|
||||
|
||||
jc - JSON Convert `ls` and `vdir` command output parser
|
||||
|
||||
Options supported:
|
||||
- `lbaR1`
|
||||
- `--time-style=full-iso`
|
||||
|
||||
Note: The `-1`, `-l`, or `-b` option of `ls` should be used to correctly parse filenames that include newline characters. Since `ls` does not encode newlines in filenames when outputting to a pipe it will cause `jc` to see multiple files instead of a single file if `-1`, `-l`, or `-b` is not used. Alternatively, `vdir` can be used, which is the same as running `ls -lb`.
|
||||
> Note: The `-1`, `-l`, or `-b` option of `ls` should be used to correctly
|
||||
> parse filenames that include newline characters. Since `ls` does not
|
||||
> encode newlines in filenames when outputting to a pipe it will cause `jc`
|
||||
> to see multiple files instead of a single file if `-1`, `-l`, or `-b` is
|
||||
> not used. Alternatively, `vdir` can be used, which is the same as running
|
||||
> `ls -lb`.
|
||||
|
||||
The `epoch` calculated timestamp field is naive (i.e. based on the local time of the system the parser is run on)
|
||||
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.
|
||||
The `epoch_utc` calculated timestamp field is timezone-aware and is only
|
||||
available if the timezone field is UTC.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -23,8 +32,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.ls
|
||||
result = jc.parsers.ls.parse(ls_command_output)
|
||||
import jc
|
||||
result = jc.parse('ls', ls_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -38,11 +47,15 @@ Schema:
|
||||
"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
|
||||
"epoch": integer, # [0]
|
||||
"epoch_utc": integer # [1]
|
||||
}
|
||||
]
|
||||
|
||||
[0] naive timestamp if date field exists and can be converted.
|
||||
[1] timezone aware timestamp if date field is in UTC and can
|
||||
be converted.
|
||||
|
||||
Examples:
|
||||
|
||||
$ ls /usr/bin | jc --ls -p
|
||||
@@ -104,16 +117,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.ls.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -121,14 +130,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.10 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.12 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.ls_s"></a>
|
||||
|
||||
# jc.parsers.ls_s
|
||||
jc - JSON CLI output utility `ls` and `vdir` command output streaming parser
|
||||
# jc.parsers.ls\_s
|
||||
|
||||
> This streaming parser outputs JSON Lines
|
||||
jc - JSON Convert `ls` and `vdir` command output streaming parser
|
||||
|
||||
Requires the `-l` option to be used on `ls`. If there are newline characters in the filename, then make sure to use the `-b` option on `ls`.
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
The `jc` `-qq` option can be used to ignore parsing errors. (e.g. filenames with newline characters, but `-b` was not used)
|
||||
Requires the `-l` option to be used on `ls`. If there are newline characters
|
||||
in the filename, then make sure to use the `-b` option on `ls`.
|
||||
|
||||
The `epoch` calculated timestamp field is naive (i.e. based on the local time of the system the parser is run on)
|
||||
The `jc` `-qq` option can be used to ignore parsing errors. (e.g. filenames
|
||||
with newline characters, but `-b` was not used)
|
||||
|
||||
The `epoch_utc` calculated timestamp field is timezone-aware and is only available if the timezone field is UTC.
|
||||
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):
|
||||
|
||||
@@ -19,8 +26,9 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.ls_s
|
||||
result = jc.parsers.ls_s.parse(ls_command_output.splitlines()) # result is an iterable object
|
||||
import jc
|
||||
|
||||
result = jc.parse('ls_s', ls_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
@@ -35,60 +43,60 @@ Schema:
|
||||
"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
|
||||
"_jc_meta": # This object only exists if using -qq or ignore_exceptions=True
|
||||
{
|
||||
"success": boolean, # true if successfully parsed, false if error
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
"epoch": integer, # [0]
|
||||
"epoch_utc": integer, # [1]
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # false if error parsing
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
}
|
||||
|
||||
[0] naive timestamp if date field exists and can be converted.
|
||||
[1] timezone aware timestamp if date field is in UTC and can
|
||||
be converted
|
||||
|
||||
Examples:
|
||||
|
||||
$ ls -l /usr/bin | jc --ls-s
|
||||
{"filename":"2to3-","flags":"-rwxr-xr-x","links":4,"owner":"root","group":"wheel","size":925,"date":"Feb 22 2019"}
|
||||
{"filename":"2to3-2.7","link_to":"../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/2to3-2.7","flags":"lrwxr-xr-x","links":1,"owner":"root","group":"wheel","size":74,"date":"May 4 2019"}
|
||||
{"filename":"AssetCacheLocatorUtil","flags":"-rwxr-xr-x","links":1,"owner":"root","group":"wheel","size":55152,"date":"May 3 2019"}
|
||||
{"filename":"2to3-","flags":"-rwxr-xr-x","links":4,"owner":"root","...}
|
||||
{"filename":"2to3-2.7","link_to":"../../System/Library/Frameworks/P...}
|
||||
{"filename":"AssetCacheLocatorUtil","flags":"-rwxr-xr-x","links":1,...}
|
||||
...
|
||||
|
||||
$ ls -l /usr/bin | jc --ls-s -r
|
||||
{"filename":"2to3-","flags":"-rwxr-xr-x","links":"4","owner":"root","group":"wheel","size":"925","date":"Feb 22 2019"}
|
||||
{"filename":"2to3-2.7","link_to":"../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/2to3-2.7","flags":"lrwxr-xr-x","links":"1","owner":"root","group":"wheel","size":"74","date":"May 4 2019"}
|
||||
{"filename":"AssetCacheLocatorUtil","flags":"-rwxr-xr-x","links":"1","owner":"root","group":"wheel","size":"55152","date":"May 3 2019"}
|
||||
{"filename":"2to3-","flags":"-rwxr-xr-x","links":"4","owner":"roo"..."}
|
||||
{"filename":"2to3-2.7","link_to":"../../System/Library/Frameworks/P...}
|
||||
{"filename":"AssetCacheLocatorUtil","flags":"-rwxr-xr-x","links":"1...}
|
||||
...
|
||||
|
||||
<a id="jc.parsers.ls_s.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||
@add_jc_meta
|
||||
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterator object.
|
||||
Main text parsing generator function. Returns an iterable object.
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (iterable) line-based text data to parse (e.g. sys.stdin or str.splitlines())
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
data: (iterable) line-based text data to parse
|
||||
(e.g. sys.stdin or str.splitlines())
|
||||
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||
|
||||
Yields:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
Returns:
|
||||
|
||||
Iterator object
|
||||
Iterable of Dictionaries
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 0.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.lsblk"></a>
|
||||
|
||||
# jc.parsers.lsblk
|
||||
jc - JSON CLI output utility `lsblk` command output parser
|
||||
|
||||
jc - JSON Convert `lsblk` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,8 +15,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.lsblk
|
||||
result = jc.parsers.lsblk.parse(lsblk_command_output)
|
||||
import jc
|
||||
result = jc.parse('lsblk', lsblk_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -88,7 +90,10 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
$ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,PKNAME,HCTL,TRAN,REV,VENDOR | jc --lsblk -p
|
||||
$ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,\\
|
||||
STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,\\
|
||||
SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,\\
|
||||
PKNAME,HCTL,TRAN,REV,VENDOR | jc --lsblk -p
|
||||
[
|
||||
{
|
||||
"name": "sda",
|
||||
@@ -177,7 +182,10 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
$ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,PKNAME,HCTL,TRAN,REV,VENDOR | jc --lsblk -p -r
|
||||
$ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,\\
|
||||
STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,\\
|
||||
SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,\\
|
||||
PKNAME,HCTL,TRAN,REV,VENDOR | jc --lsblk -p -r
|
||||
[
|
||||
{
|
||||
"name": "sda",
|
||||
@@ -266,16 +274,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.lsblk.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -283,14 +287,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.lsmod"></a>
|
||||
|
||||
# jc.parsers.lsmod
|
||||
jc - JSON CLI output utility `lsmod` command output parser
|
||||
|
||||
jc - JSON Convert `lsmod` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,8 +15,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.lsmod
|
||||
result = jc.parsers.lsmod.parse(lsmod_command_output)
|
||||
import jc
|
||||
result = jc.parse('lsmod', lsmod_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -123,16 +125,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.lsmod.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -140,14 +138,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.lsof"></a>
|
||||
|
||||
# jc.parsers.lsof
|
||||
jc - JSON CLI output utility `lsof` command output parser
|
||||
|
||||
jc - JSON Convert `lsof` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,8 +15,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.lsof
|
||||
result = jc.parsers.lsof.parse(lsof_command_output)
|
||||
import jc
|
||||
result = jc.parse('lsof', lsof_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -117,16 +119,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.lsof.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -134,14 +132,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.lsusb"></a>
|
||||
|
||||
# jc.parsers.lsusb
|
||||
jc - JSON CLI output utility `lsusb` command output parser
|
||||
|
||||
jc - JSON Convert `lsusb` command output parser
|
||||
|
||||
Supports the `-v` option or no options.
|
||||
|
||||
@@ -15,13 +17,14 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.lsusb
|
||||
result = jc.parsers.lsusb.parse(lsusb_command_output)
|
||||
import jc
|
||||
result = jc.parse('lsusb', lsusb_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
Note: <item> object keynames are assigned directly from the lsusb output.
|
||||
If there are duplicate <item> names in a section, only the last one is converted.
|
||||
> Note: <item> object keynames are assigned directly from the lsusb
|
||||
> output. If there are duplicate <item> names in a section, only the
|
||||
> last one is converted.
|
||||
|
||||
[
|
||||
{
|
||||
@@ -258,16 +261,12 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.lsusb.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -275,14 +274,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
90
docs/parsers/m3u.md
Normal file
90
docs/parsers/m3u.md
Normal file
@@ -0,0 +1,90 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.m3u"></a>
|
||||
|
||||
# jc.parsers.m3u
|
||||
|
||||
jc - JSON Convert M3U and M3U8 file parser
|
||||
|
||||
This parser will make a best-effort to parse extended field information. If
|
||||
the extended fields cannot be successfully parsed, then an `unparsed_info`
|
||||
field will be added to the object. If not using `--quiet`, then a warning
|
||||
message also will be printed to `STDERR`.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat playlist.m3u | jc --m3u
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('m3u', m3u_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"runtime": integer,
|
||||
"display": string,
|
||||
"path": string,
|
||||
<extended fields>: string, # [0]
|
||||
"unparsed_info": string, # [1]
|
||||
}
|
||||
]
|
||||
|
||||
[0] Field names are pulled directly from the #EXTINF: line
|
||||
[1] Only added if the extended information cannot be parsed
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat playlist.m3u | jc --m3u -p
|
||||
[
|
||||
{
|
||||
"runtime": 105,
|
||||
"display": "Example artist - Example title",
|
||||
"path": "C:\\Files\\My Music\\Example.mp3"
|
||||
},
|
||||
{
|
||||
"runtime": 321,
|
||||
"display": "Example Artist2 - Example title2",
|
||||
"path": "C:\\Files\\My Music\\Favorites\\Example2.ogg"
|
||||
}
|
||||
]
|
||||
|
||||
$ cat playlist.m3u | jc --m3u -p -r
|
||||
[
|
||||
{
|
||||
"runtime": "105",
|
||||
"display": "Example artist - Example title",
|
||||
"path": "C:\\Files\\My Music\\Example.mp3"
|
||||
},
|
||||
{
|
||||
"runtime": "321",
|
||||
"display": "Example Artist2 - Example title2",
|
||||
"path": "C:\\Files\\My Music\\Favorites\\Example2.ogg"
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.m3u.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.mount"></a>
|
||||
|
||||
# jc.parsers.mount
|
||||
jc - JSON CLI output utility `mount` command output parser
|
||||
|
||||
jc - JSON Convert `mount` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,8 +15,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.mount
|
||||
result = jc.parsers.mount.parse(mount_command_output)
|
||||
import jc
|
||||
result = jc.parse('mount', mount_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -73,16 +75,12 @@ Example:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.mount.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -90,14 +88,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
140
docs/parsers/mpstat.md
Normal file
140
docs/parsers/mpstat.md
Normal file
@@ -0,0 +1,140 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.mpstat"></a>
|
||||
|
||||
# jc.parsers.mpstat
|
||||
|
||||
jc - JSON Convert `mpstat` command output parser
|
||||
|
||||
> Note: Latest versions of `mpstat` support JSON output (v11.5.1+)
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ mpstat | jc --mpstat
|
||||
|
||||
or
|
||||
|
||||
$ jc mpstat
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('mpstat', mpstat_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"type": string,
|
||||
"time": string,
|
||||
"cpu": string,
|
||||
"node": string,
|
||||
"average": boolean,
|
||||
"percent_usr": float,
|
||||
"percent_nice": float,
|
||||
"percent_sys": float,
|
||||
"percent_iowait": float,
|
||||
"percent_irq": float,
|
||||
"percent_soft": float,
|
||||
"percent_steal": float,
|
||||
"percent_guest": float,
|
||||
"percent_gnice": float,
|
||||
"percent_idle": float,
|
||||
"intr_s": float,
|
||||
"<x>_s": float, # <x> is an integer
|
||||
"nmi_s": float,
|
||||
"loc_s": float,
|
||||
"spu_s": float,
|
||||
"pmi_s": float,
|
||||
"iwi_s": float,
|
||||
"rtr_s": float,
|
||||
"res_s": float,
|
||||
"cal_s": float,
|
||||
"tlb_s": float,
|
||||
"trm_s": float,
|
||||
"thr_s": float,
|
||||
"dfr_s": float,
|
||||
"mce_s": float,
|
||||
"mcp_s": float,
|
||||
"err_s": float,
|
||||
"mis_s": float,
|
||||
"pin_s": float,
|
||||
"npi_s": float,
|
||||
"piw_s": float,
|
||||
"hi_s": float,
|
||||
"timer_s": float,
|
||||
"net_tx_s": float,
|
||||
"net_rx_s": float,
|
||||
"block_s": float,
|
||||
"irq_poll_s": float,
|
||||
"block_iopoll_s": float,
|
||||
"tasklet_s": float,
|
||||
"sched_s": float,
|
||||
"hrtimer_s": float,
|
||||
"rcu_s": float
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ mpstat | jc --mpstat -p
|
||||
[
|
||||
{
|
||||
"cpu": "all",
|
||||
"percent_usr": 12.94,
|
||||
"percent_nice": 0.0,
|
||||
"percent_sys": 26.42,
|
||||
"percent_iowait": 0.43,
|
||||
"percent_irq": 0.0,
|
||||
"percent_soft": 0.16,
|
||||
"percent_steal": 0.0,
|
||||
"percent_guest": 0.0,
|
||||
"percent_gnice": 0.0,
|
||||
"percent_idle": 60.05,
|
||||
"type": "cpu",
|
||||
"time": "01:58:14 PM"
|
||||
}
|
||||
]
|
||||
|
||||
$ mpstat | jc --mpstat -p -r
|
||||
[
|
||||
{
|
||||
"cpu": "all",
|
||||
"percent_usr": "12.94",
|
||||
"percent_nice": "0.00",
|
||||
"percent_sys": "26.42",
|
||||
"percent_iowait": "0.43",
|
||||
"percent_irq": "0.00",
|
||||
"percent_soft": "0.16",
|
||||
"percent_steal": "0.00",
|
||||
"percent_guest": "0.00",
|
||||
"percent_gnice": "0.00",
|
||||
"percent_idle": "60.05",
|
||||
"type": "cpu",
|
||||
"time": "01:58:14 PM"
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.mpstat.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
128
docs/parsers/mpstat_s.md
Normal file
128
docs/parsers/mpstat_s.md
Normal file
@@ -0,0 +1,128 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.mpstat_s"></a>
|
||||
|
||||
# jc.parsers.mpstat\_s
|
||||
|
||||
jc - JSON Convert `mpstat` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
> Note: Latest versions of `mpstat` support JSON output (v11.5.1+)
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ mpstat | jc --mpstat-s
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
|
||||
result = jc.parse('mpstat_s', mpstat_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"type": string,
|
||||
"time": string,
|
||||
"cpu": string,
|
||||
"node": string,
|
||||
"average": boolean,
|
||||
"percent_usr": float,
|
||||
"percent_nice": float,
|
||||
"percent_sys": float,
|
||||
"percent_iowait": float,
|
||||
"percent_irq": float,
|
||||
"percent_soft": float,
|
||||
"percent_steal": float,
|
||||
"percent_guest": float,
|
||||
"percent_gnice": float,
|
||||
"percent_idle": float,
|
||||
"intr_s": float,
|
||||
"<x>_s": float, # <x> is an integer
|
||||
"nmi_s": float,
|
||||
"loc_s": float,
|
||||
"spu_s": float,
|
||||
"pmi_s": float,
|
||||
"iwi_s": float,
|
||||
"rtr_s": float,
|
||||
"res_s": float,
|
||||
"cal_s": float,
|
||||
"tlb_s": float,
|
||||
"trm_s": float,
|
||||
"thr_s": float,
|
||||
"dfr_s": float,
|
||||
"mce_s": float,
|
||||
"mcp_s": float,
|
||||
"err_s": float,
|
||||
"mis_s": float,
|
||||
"pin_s": float,
|
||||
"npi_s": float,
|
||||
"piw_s": float,
|
||||
"hi_s": float,
|
||||
"timer_s": float,
|
||||
"net_tx_s": float,
|
||||
"net_rx_s": float,
|
||||
"block_s": float,
|
||||
"irq_poll_s": float,
|
||||
"block_iopoll_s": float,
|
||||
"tasklet_s": float,
|
||||
"sched_s": float,
|
||||
"hrtimer_s": float,
|
||||
"rcu_s": float,
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # false if error parsing
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ mpstat -A | jc --mpstat-s
|
||||
{"cpu":"all","percent_usr":0.22,"percent_nice":0.0,"percent_sys":...}
|
||||
{"cpu":"0","percent_usr":0.22,"percent_nice":0.0,"percent_sys":0....}
|
||||
{"cpu":"all","intr_s":37.61,"type":"interrupts","time":"03:15:06 PM"}
|
||||
...
|
||||
|
||||
$ mpstat -A | jc --mpstat-s -r
|
||||
{"cpu":"all","percent_usr":"0.22","percent_nice":"0.00","percent_...}
|
||||
{"cpu":"0","percent_usr":"0.22","percent_nice":"0.00","percent_sy...}
|
||||
{"cpu":"all","intr_s":"37.61","type":"interrupts","time":"03:15:06 PM"}
|
||||
...
|
||||
|
||||
<a id="jc.parsers.mpstat_s.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
@add_jc_meta
|
||||
def parse(data: Iterable[str],
|
||||
raw: bool = False,
|
||||
quiet: bool = False,
|
||||
ignore_exceptions: bool = False) -> Union[Iterable[Dict], tuple]
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterable object.
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (iterable) line-based text data to parse
|
||||
(e.g. sys.stdin or str.splitlines())
|
||||
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||
|
||||
Returns:
|
||||
|
||||
Iterable of Dictionaries
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -1,11 +1,14 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.netstat"></a>
|
||||
|
||||
# jc.parsers.netstat
|
||||
jc - JSON CLI output utility `netstat` command output parser
|
||||
|
||||
jc - JSON Convert `netstat` command output parser
|
||||
|
||||
Caveats:
|
||||
- Use of multiple `l` options is not supported on OSX (e.g. `netstat -rlll`)
|
||||
- Use of the `A` option is not supported on OSX when using the `r` option (e.g. `netstat -rA`)
|
||||
- Use of the `A` option is not supported on OSX when using the `r` option
|
||||
(e.g. `netstat -rA`)
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -17,8 +20,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.netstat
|
||||
result = jc.parsers.netstat.parse(netstat_command_output)
|
||||
import jc
|
||||
result = jc.parse('netstat', netstat_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -352,16 +355,12 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.netstat.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -369,14 +368,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.12 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.13 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
171
docs/parsers/nmcli.md
Normal file
171
docs/parsers/nmcli.md
Normal file
@@ -0,0 +1,171 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.nmcli"></a>
|
||||
|
||||
# jc.parsers.nmcli
|
||||
|
||||
jc - JSON Convert `nmcli` command output parser
|
||||
|
||||
Supports the following `nmcli` subcommands:
|
||||
- `nmcli general`
|
||||
- `nmcli general permissions`
|
||||
- `nmcli connection`
|
||||
- `nmcli connection show <device_name>`
|
||||
- `nmcli device`
|
||||
- `nmcli device show`
|
||||
- `nmcli device show <device_name>`
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ nmcli device show lo | jc --nmcli
|
||||
|
||||
or
|
||||
|
||||
$ jc nmcli device show lo
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('nmcli', nmcli_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
Because there are so many options, the schema is not strictly defined.
|
||||
Integer and Float value conversions are attempted and the original
|
||||
values are kept if they fail. If you don't want automatic conversion,
|
||||
then use the `-r` or `raw=True` option to disable it.
|
||||
|
||||
The structure is flat, for the most part, but there are a couple of
|
||||
"well-known" keys that are further parsed into objects for convenience.
|
||||
These are documented below.
|
||||
|
||||
[
|
||||
{
|
||||
"<key>": string/integer/float, # [0]
|
||||
"dhcp4_option_x": {
|
||||
"name": string,
|
||||
"value": string/integer/float,
|
||||
},
|
||||
"dhcp6_option_x": {
|
||||
"name": string,
|
||||
"value": string/integer/float,
|
||||
},
|
||||
"ip4_route_x": {
|
||||
"dst": string,
|
||||
"nh": string,
|
||||
"mt": integer
|
||||
},
|
||||
"ip6_route_x": {
|
||||
"dst": string,
|
||||
"nh": string,
|
||||
"mt": integer,
|
||||
"table": integer
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
[0] all values of `---` are converted to null
|
||||
|
||||
Examples:
|
||||
|
||||
$ nmcli connection show ens33 | jc --nmcli -p
|
||||
[
|
||||
{
|
||||
"connection_id": "ens33",
|
||||
"connection_uuid": "d92ece08-9e02-47d5-b2d2-92c80e155744",
|
||||
"connection_stable_id": null,
|
||||
"connection_type": "802-3-ethernet",
|
||||
"connection_interface_name": "ens33",
|
||||
"connection_autoconnect": "yes",
|
||||
...
|
||||
"ip4_address_1": "192.168.71.180/24",
|
||||
"ip4_gateway": "192.168.71.2",
|
||||
"ip4_route_1": {
|
||||
"dst": "0.0.0.0/0",
|
||||
"nh": "192.168.71.2",
|
||||
"mt": 100
|
||||
},
|
||||
"ip4_route_2": {
|
||||
"dst": "192.168.71.0/24",
|
||||
"nh": "0.0.0.0",
|
||||
"mt": 100
|
||||
},
|
||||
"ip4_dns_1": "192.168.71.2",
|
||||
"ip4_domain_1": "localdomain",
|
||||
"dhcp4_option_1": {
|
||||
"name": "broadcast_address",
|
||||
"value": "192.168.71.255"
|
||||
},
|
||||
...
|
||||
"ip6_address_1": "fe80::c1cb:715d:bc3e:b8a0/64",
|
||||
"ip6_gateway": null,
|
||||
"ip6_route_1": {
|
||||
"dst": "fe80::/64",
|
||||
"nh": "::",
|
||||
"mt": 100
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
$ nmcli connection show ens33 | jc --nmcli -p -r
|
||||
[
|
||||
{
|
||||
"connection_id": "ens33",
|
||||
"connection_uuid": "d92ece08-9e02-47d5-b2d2-92c80e155744",
|
||||
"connection_stable_id": null,
|
||||
"connection_type": "802-3-ethernet",
|
||||
"connection_interface_name": "ens33",
|
||||
"connection_autoconnect": "yes",
|
||||
...
|
||||
"ip4_address_1": "192.168.71.180/24",
|
||||
"ip4_gateway": "192.168.71.2",
|
||||
"ip4_route_1": {
|
||||
"dst": "0.0.0.0/0",
|
||||
"nh": "192.168.71.2",
|
||||
"mt": "100"
|
||||
},
|
||||
"ip4_route_2": {
|
||||
"dst": "192.168.71.0/24",
|
||||
"nh": "0.0.0.0",
|
||||
"mt": "100"
|
||||
},
|
||||
"ip4_dns_1": "192.168.71.2",
|
||||
"ip4_domain_1": "localdomain",
|
||||
"dhcp4_option_1": {
|
||||
"name": "broadcast_address",
|
||||
"value": "192.168.71.255"
|
||||
},
|
||||
...
|
||||
"ip6_address_1": "fe80::c1cb:715d:bc3e:b8a0/64",
|
||||
"ip6_gateway": null,
|
||||
"ip6_route_1": {
|
||||
"dst": "fe80::/64",
|
||||
"nh": "::",
|
||||
"mt": "100"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.nmcli.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.ntpq"></a>
|
||||
|
||||
# jc.parsers.ntpq
|
||||
jc - JSON CLI output utility `ntpq -p` command output parser
|
||||
|
||||
jc - JSON Convert `ntpq -p` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,8 +15,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.ntpq
|
||||
result = jc.parsers.ntpq.parse(ntpq_command_output)
|
||||
import jc
|
||||
result = jc.parse('ntpq', ntpq_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -204,16 +206,12 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.ntpq.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -221,14 +219,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, freebsd
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.passwd"></a>
|
||||
|
||||
# jc.parsers.passwd
|
||||
jc - JSON CLI output utility `/etc/passwd` file Parser
|
||||
|
||||
jc - JSON Convert `/etc/passwd` file Parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -9,8 +11,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.passwd
|
||||
result = jc.parsers.passwd.parse(passwd_file_output)
|
||||
import jc
|
||||
result = jc.parse('passwd', passwd_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -92,16 +94,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.passwd.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -109,14 +107,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, aix, freebsd
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
151
docs/parsers/pidstat.md
Normal file
151
docs/parsers/pidstat.md
Normal file
@@ -0,0 +1,151 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.pidstat"></a>
|
||||
|
||||
# jc.parsers.pidstat
|
||||
|
||||
jc - JSON Convert `pidstat -h` command output parser
|
||||
|
||||
Must use the `-h` option in `pidstat`. All other `pidstat` options are
|
||||
supported in combination with `-h`.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ pidstat -h | jc --pidstat
|
||||
|
||||
or
|
||||
|
||||
$ jc pidstat -h
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('pidstat', pidstat_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"time": integer,
|
||||
"uid": integer,
|
||||
"pid": integer,
|
||||
"percent_usr": float,
|
||||
"percent_system": float,
|
||||
"percent_guest": float,
|
||||
"percent_cpu": float,
|
||||
"cpu": integer,
|
||||
"minflt_s": float,
|
||||
"majflt_s": float,
|
||||
"vsz": integer,
|
||||
"rss": integer,
|
||||
"percent_mem": float,
|
||||
"stksize": integer,
|
||||
"stkref": integer,
|
||||
"kb_rd_s": float,
|
||||
"kb_wr_s": float,
|
||||
"kb_ccwr_s": float,
|
||||
"cswch_s": float,
|
||||
"nvcswch_s": float,
|
||||
"command": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ pidstat -hl | jc --pidstat -p
|
||||
[
|
||||
{
|
||||
"time": 1646859134,
|
||||
"uid": 0,
|
||||
"pid": 1,
|
||||
"percent_usr": 0.0,
|
||||
"percent_system": 0.03,
|
||||
"percent_guest": 0.0,
|
||||
"percent_cpu": 0.03,
|
||||
"cpu": 0,
|
||||
"command": "/usr/lib/systemd/systemd --switched-root --system..."
|
||||
},
|
||||
{
|
||||
"time": 1646859134,
|
||||
"uid": 0,
|
||||
"pid": 6,
|
||||
"percent_usr": 0.0,
|
||||
"percent_system": 0.0,
|
||||
"percent_guest": 0.0,
|
||||
"percent_cpu": 0.0,
|
||||
"cpu": 0,
|
||||
"command": "ksoftirqd/0"
|
||||
},
|
||||
{
|
||||
"time": 1646859134,
|
||||
"uid": 0,
|
||||
"pid": 2263,
|
||||
"percent_usr": 0.0,
|
||||
"percent_system": 0.0,
|
||||
"percent_guest": 0.0,
|
||||
"percent_cpu": 0.0,
|
||||
"cpu": 0,
|
||||
"command": "kworker/0:0"
|
||||
}
|
||||
]
|
||||
|
||||
$ pidstat -hl | jc --pidstat -p -r
|
||||
[
|
||||
{
|
||||
"time": "1646859134",
|
||||
"uid": "0",
|
||||
"pid": "1",
|
||||
"percent_usr": "0.00",
|
||||
"percent_system": "0.03",
|
||||
"percent_guest": "0.00",
|
||||
"percent_cpu": "0.03",
|
||||
"cpu": "0",
|
||||
"command": "/usr/lib/systemd/systemd --switched-root --system..."
|
||||
},
|
||||
{
|
||||
"time": "1646859134",
|
||||
"uid": "0",
|
||||
"pid": "6",
|
||||
"percent_usr": "0.00",
|
||||
"percent_system": "0.00",
|
||||
"percent_guest": "0.00",
|
||||
"percent_cpu": "0.00",
|
||||
"cpu": "0",
|
||||
"command": "ksoftirqd/0"
|
||||
},
|
||||
{
|
||||
"time": "1646859134",
|
||||
"uid": "0",
|
||||
"pid": "2263",
|
||||
"percent_usr": "0.00",
|
||||
"percent_system": "0.00",
|
||||
"percent_guest": "0.00",
|
||||
"percent_cpu": "0.00",
|
||||
"cpu": "0",
|
||||
"command": "kworker/0:0"
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.pidstat.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
110
docs/parsers/pidstat_s.md
Normal file
110
docs/parsers/pidstat_s.md
Normal file
@@ -0,0 +1,110 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.pidstat_s"></a>
|
||||
|
||||
# jc.parsers.pidstat\_s
|
||||
|
||||
jc - JSON Convert `pidstat -h` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
Must use the `-h` option in `pidstat`. All other `pidstat` options are
|
||||
supported in combination with `-h`.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ pidstat | jc --pidstat-s
|
||||
|
||||
> Note: When piping `jc` converted `pidstat` output to other processes it
|
||||
> may appear the output is hanging due to the OS pipe buffers. This is
|
||||
> because `pidstat` output is too small to quickly fill up the buffer. Use
|
||||
> the `-u` option to unbuffer the `jc` output if you would like immediate
|
||||
> output. See the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
|
||||
> for more information.
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
|
||||
result = jc.parse('pidstat_s', pidstat_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"time": integer,
|
||||
"uid": integer,
|
||||
"pid": integer,
|
||||
"percent_usr": float,
|
||||
"percent_system": float,
|
||||
"percent_guest": float,
|
||||
"percent_cpu": float,
|
||||
"cpu": integer,
|
||||
"minflt_s": float,
|
||||
"majflt_s": float,
|
||||
"vsz": integer,
|
||||
"rss": integer,
|
||||
"percent_mem": float,
|
||||
"stksize": integer,
|
||||
"stkref": integer,
|
||||
"kb_rd_s": float,
|
||||
"kb_wr_s": float,
|
||||
"kb_ccwr_s": float,
|
||||
"cswch_s": float,
|
||||
"nvcswch_s": float,
|
||||
"command": string,
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # false if error parsing
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ pidstat -hl | jc --pidstat-s
|
||||
{"time":1646859134,"uid":0,"pid":1,"percent_usr":0.0,"percent_syste...}
|
||||
{"time":1646859134,"uid":0,"pid":6,"percent_usr":0.0,"percent_syste...}
|
||||
{"time":1646859134,"uid":0,"pid":9,"percent_usr":0.0,"percent_syste...}
|
||||
...
|
||||
|
||||
$ pidstat -hl | jc --pidstat-s -r
|
||||
{"time":"1646859134","uid":"0","pid":"1","percent_usr":"0.00","perc...}
|
||||
{"time":"1646859134","uid":"0","pid":"6","percent_usr":"0.00","perc...}
|
||||
{"time":"1646859134","uid":"0","pid":"9","percent_usr":"0.00","perc...}
|
||||
...
|
||||
|
||||
<a id="jc.parsers.pidstat_s.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
@add_jc_meta
|
||||
def parse(data: Iterable[str],
|
||||
raw: bool = False,
|
||||
quiet: bool = False,
|
||||
ignore_exceptions: bool = False) -> Union[Iterable[Dict], tuple]
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterable object.
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (iterable) line-based text data to parse
|
||||
(e.g. sys.stdin or str.splitlines())
|
||||
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||
|
||||
Returns:
|
||||
|
||||
Iterable of Dictionaries
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -1,13 +1,16 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.ping"></a>
|
||||
|
||||
# jc.parsers.ping
|
||||
jc - JSON CLI output utility `ping` command output parser
|
||||
|
||||
jc - JSON Convert `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`.
|
||||
> Note: Use the ping `-c` (count) option, otherwise data will not be
|
||||
> piped to `jc`.
|
||||
|
||||
$ ping -c 3 1.2.3.4 | jc --ping
|
||||
|
||||
@@ -17,8 +20,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.ping
|
||||
result = jc.parsers.ping.parse(ping_command_output)
|
||||
import jc
|
||||
result = jc.parse('ping', ping_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -26,7 +29,7 @@ Schema:
|
||||
"source_ip": string,
|
||||
"destination_ip": string,
|
||||
"data_bytes": integer,
|
||||
"pattern": string, # (null if not set)
|
||||
"pattern": string, # null if not set
|
||||
"destination": string,
|
||||
"packets_transmitted": integer,
|
||||
"packets_received": integer,
|
||||
@@ -38,8 +41,8 @@ Schema:
|
||||
"round_trip_ms_stddev": float,
|
||||
"responses": [
|
||||
{
|
||||
"type": string, # 'reply', 'timeout', 'unparsable_line', etc. See `_error_type.type_map` for all options
|
||||
"unparsed_line": string, # only if an 'unparsable_line' type
|
||||
"type": string, # [0]
|
||||
"unparsed_line": string, # [1]
|
||||
"timestamp": float,
|
||||
"bytes": integer,
|
||||
"response_ip": string,
|
||||
@@ -47,21 +50,26 @@ Schema:
|
||||
"ttl": integer,
|
||||
"time_ms": float,
|
||||
"duplicate": boolean,
|
||||
"vr": integer, # hex value converted to decimal
|
||||
"hl": integer, # hex value converted to decimal
|
||||
"tos": integer, # hex value converted to decimal
|
||||
"len": integer, # hex value converted to decimal
|
||||
"id": integer, # hex value converted to decimal
|
||||
"flg": integer, # hex value converted to decimal
|
||||
"off": integer, # hex value converted to decimal
|
||||
"pro": integer, # hex value converted to decimal
|
||||
"cks": ingeger, # hex value converted to decimal
|
||||
"vr": integer, # [2]
|
||||
"hl": integer, # [2]
|
||||
"tos": integer, # [2]
|
||||
"len": integer, # [2]
|
||||
"id": integer, # [2]
|
||||
"flg": integer, # [2]
|
||||
"off": integer, # [2]
|
||||
"pro": integer, # [2]
|
||||
"cks": ingeger, # [2]
|
||||
"src": string,
|
||||
"dst": string
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
[0] 'reply', 'timeout', 'unparsable_line', etc. See
|
||||
`_error_type.type_map` for all options
|
||||
[1] only if an 'unparsable_line' type
|
||||
[2] hex value converted to decimal
|
||||
|
||||
Examples:
|
||||
|
||||
$ ping -c 3 -p ff cnn.com | jc --ping -p
|
||||
@@ -154,16 +162,12 @@ Examples:
|
||||
]
|
||||
}
|
||||
|
||||
<a id="jc.parsers.ping.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -171,14 +175,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,101 +1,109 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.ping_s"></a>
|
||||
|
||||
# jc.parsers.ping_s
|
||||
jc - JSON CLI output utility `ping` command output streaming parser
|
||||
# jc.parsers.ping\_s
|
||||
|
||||
> This streaming parser outputs JSON Lines
|
||||
jc - JSON Convert `ping` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
Supports `ping` and `ping6` output.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ ping | jc --ping-s
|
||||
$ ping 1.2.3.4 | jc --ping-s
|
||||
|
||||
> Note: When piping `jc` converted `ping` output to other processes it may appear the output is hanging due to the OS pipe buffers. This is because `ping` output is too small to quickly fill up the buffer. Use the `-u` option to unbuffer the `jc` output if you would like immediate output. See the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output) for more information.
|
||||
> Note: When piping `jc` converted `ping` output to other processes it may
|
||||
> appear the output is hanging due to the OS pipe buffers. This is because
|
||||
> `ping` output is too small to quickly fill up the buffer. Use the `-u`
|
||||
> option to unbuffer the `jc` output if you would like immediate output.
|
||||
> See the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
|
||||
> for more information.
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.ping_s
|
||||
result = jc.parsers.ping_s.parse(ping_command_output.splitlines()) # result is an iterable object
|
||||
import jc
|
||||
|
||||
result = jc.parse('ping_s', ping_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"type": string, # 'reply', 'timeout', 'summary', etc. See `_error_type.type_map` for all options.
|
||||
"source_ip": string,
|
||||
"destination_ip": string,
|
||||
"sent_bytes": integer,
|
||||
"pattern": string, # (null if not set)
|
||||
"destination": string,
|
||||
"timestamp": float,
|
||||
"response_bytes": integer,
|
||||
"response_ip": string,
|
||||
"icmp_seq": integer,
|
||||
"ttl": integer,
|
||||
"time_ms": float,
|
||||
"duplicate": boolean,
|
||||
"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,
|
||||
"_jc_meta": # This object only exists if using -qq or ignore_exceptions=True
|
||||
{
|
||||
"success": boolean, # true if successfully parsed, false if error
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
"type": string, # [0]
|
||||
"source_ip": string,
|
||||
"destination_ip": string,
|
||||
"sent_bytes": integer,
|
||||
"pattern": string, # (null if not set)
|
||||
"destination": string,
|
||||
"timestamp": float,
|
||||
"response_bytes": integer,
|
||||
"response_ip": string,
|
||||
"icmp_seq": integer,
|
||||
"ttl": integer,
|
||||
"time_ms": float,
|
||||
"duplicate": boolean,
|
||||
"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,
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # false if error parsing
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
}
|
||||
|
||||
[0] 'reply', 'timeout', 'summary', etc. See `_error_type.type_map`
|
||||
for all options.
|
||||
|
||||
Examples:
|
||||
|
||||
$ ping 1.1.1.1 | jc --ping-s
|
||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"pattern":null,"response_bytes":64,"response_ip":"1.1.1.1","icmp_seq":0,"ttl":56,"time_ms":23.703}
|
||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"pattern":null,"response_bytes":64,"response_ip":"1.1.1.1","icmp_seq":1,"ttl":56,"time_ms":22.862}
|
||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"pattern":null,"response_bytes":64,"response_ip":"1.1.1.1","icmp_seq":2,"ttl":56,"time_ms":22.82}
|
||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"patte...}
|
||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"patte...}
|
||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"patte...}
|
||||
...
|
||||
|
||||
$ ping 1.1.1.1 | jc --ping-s -r
|
||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","pattern":null,"response_bytes":"64","response_ip":"1.1.1.1","icmp_seq":"0","ttl":"56","time_ms":"23.054"}
|
||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","pattern":null,"response_bytes":"64","response_ip":"1.1.1.1","icmp_seq":"1","ttl":"56","time_ms":"24.739"}
|
||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","pattern":null,"response_bytes":"64","response_ip":"1.1.1.1","icmp_seq":"2","ttl":"56","time_ms":"23.232"}
|
||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","patte...}
|
||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","patte...}
|
||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","patte...}
|
||||
...
|
||||
|
||||
<a id="jc.parsers.ping_s.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||
@add_jc_meta
|
||||
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterator object.
|
||||
Main text parsing generator function. Returns an iterable object.
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (iterable) line-based text data to parse (e.g. sys.stdin or str.splitlines())
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
data: (iterable) line-based text data to parse
|
||||
(e.g. sys.stdin or str.splitlines())
|
||||
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||
|
||||
Yields:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
Returns:
|
||||
|
||||
Iterator object
|
||||
Iterable of Dictionaries
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 0.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.pip_list"></a>
|
||||
|
||||
# jc.parsers.pip_list
|
||||
jc - JSON CLI output utility `pip-list` command output parser
|
||||
# jc.parsers.pip\_list
|
||||
|
||||
jc - JSON Convert `pip-list` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,8 +15,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.pip_list
|
||||
result = jc.parsers.pip_list.parse(pip_list_command_output)
|
||||
import jc
|
||||
result = jc.parse('pip_list', pip_list_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -45,16 +47,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.pip_list.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -62,14 +60,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.pip_show"></a>
|
||||
|
||||
# jc.parsers.pip_show
|
||||
jc - JSON CLI output utility `pip-show` command output parser
|
||||
# jc.parsers.pip\_show
|
||||
|
||||
jc - JSON Convert `pip-show` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,8 +15,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.pip_show
|
||||
result = jc.parsers.pip_show.parse(pip_show_command_output)
|
||||
import jc
|
||||
result = jc.parse('pip_show', pip_show_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -63,16 +65,12 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.pip_show.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -80,14 +78,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
115
docs/parsers/postconf.md
Normal file
115
docs/parsers/postconf.md
Normal file
@@ -0,0 +1,115 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.postconf"></a>
|
||||
|
||||
# jc.parsers.postconf
|
||||
|
||||
jc - JSON Convert `postconf -M` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ postconf -M | jc --postconf
|
||||
|
||||
or
|
||||
|
||||
$ jc postconf -M
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('postconf', postconf_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"service_name": string,
|
||||
"service_type": string,
|
||||
"private": boolean/null, # [0]
|
||||
"unprivileged": boolean/null, # [0]
|
||||
"chroot": boolean/null, # [0]
|
||||
"wake_up_time": integer/null, # [0]
|
||||
"no_wake_up_before_first_use": boolean/null, # [1]
|
||||
"process_limit": integer/null, # [0]
|
||||
"command": string
|
||||
}
|
||||
]
|
||||
|
||||
[0] '-' converted to null/None
|
||||
[1] null/None if `wake_up_time` is null/None
|
||||
|
||||
Examples:
|
||||
|
||||
$ postconf -M | jc --postconf -p
|
||||
[
|
||||
{
|
||||
"service_name": "smtp",
|
||||
"service_type": "inet",
|
||||
"private": false,
|
||||
"unprivileged": null,
|
||||
"chroot": true,
|
||||
"wake_up_time": null,
|
||||
"process_limit": null,
|
||||
"command": "smtpd",
|
||||
"no_wake_up_before_first_use": null
|
||||
},
|
||||
{
|
||||
"service_name": "pickup",
|
||||
"service_type": "unix",
|
||||
"private": false,
|
||||
"unprivileged": null,
|
||||
"chroot": true,
|
||||
"wake_up_time": 60,
|
||||
"process_limit": 1,
|
||||
"command": "pickup",
|
||||
"no_wake_up_before_first_use": false
|
||||
}
|
||||
]
|
||||
|
||||
$ postconf -M | jc --postconf -p -r
|
||||
[
|
||||
{
|
||||
"service_name": "smtp",
|
||||
"service_type": "inet",
|
||||
"private": "n",
|
||||
"unprivileged": "-",
|
||||
"chroot": "y",
|
||||
"wake_up_time": "-",
|
||||
"process_limit": "-",
|
||||
"command": "smtpd"
|
||||
},
|
||||
{
|
||||
"service_name": "pickup",
|
||||
"service_type": "unix",
|
||||
"private": "n",
|
||||
"unprivileged": "-",
|
||||
"chroot": "y",
|
||||
"wake_up_time": "60",
|
||||
"process_limit": "1",
|
||||
"command": "pickup"
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.postconf.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.ps"></a>
|
||||
|
||||
# jc.parsers.ps
|
||||
jc - JSON CLI output utility `ps` command output parser
|
||||
|
||||
jc - JSON Convert `ps` command output parser
|
||||
|
||||
`ps` options supported:
|
||||
- `ef`
|
||||
@@ -17,8 +19,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.ps
|
||||
result = jc.parsers.ps.parse(ps_command_output)
|
||||
import jc
|
||||
result = jc.parse('ps', ps_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -56,7 +58,7 @@ Examples:
|
||||
"stime": "Nov01",
|
||||
"tty": null,
|
||||
"time": "00:00:11",
|
||||
"cmd": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
||||
"cmd": "/usr/lib/systemd/systemd --switched-root --system --dese..."
|
||||
},
|
||||
{
|
||||
"uid": "root",
|
||||
@@ -91,7 +93,7 @@ Examples:
|
||||
"stime": "Nov01",
|
||||
"tty": "?",
|
||||
"time": "00:00:11",
|
||||
"cmd": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
||||
"cmd": "/usr/lib/systemd/systemd --switched-root --system --dese..."
|
||||
},
|
||||
{
|
||||
"uid": "root",
|
||||
@@ -129,7 +131,7 @@ Examples:
|
||||
"stat": "Ss",
|
||||
"start": "Nov09",
|
||||
"time": "0:08",
|
||||
"command": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
||||
"command": "/usr/lib/systemd/systemd --switched-root --system --..."
|
||||
},
|
||||
{
|
||||
"user": "root",
|
||||
@@ -173,7 +175,7 @@ Examples:
|
||||
"stat": "Ss",
|
||||
"start": "Nov09",
|
||||
"time": "0:08",
|
||||
"command": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
||||
"command": "/usr/lib/systemd/systemd --switched-root --system --..."
|
||||
},
|
||||
{
|
||||
"user": "root",
|
||||
@@ -204,16 +206,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.ps.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -221,14 +219,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.route"></a>
|
||||
|
||||
# jc.parsers.route
|
||||
jc - JSON CLI output utility `route` command output parser
|
||||
|
||||
jc - JSON Convert `route` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,27 +15,27 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.route
|
||||
result = jc.parsers.route.parse(route_command_output)
|
||||
import jc
|
||||
result = jc.parse('route', route_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"destination": string,
|
||||
"gateway": string,
|
||||
"genmask": string,
|
||||
"flags": string,
|
||||
"destination": string,
|
||||
"gateway": string,
|
||||
"genmask": string,
|
||||
"flags": string,
|
||||
"flags_pretty": [
|
||||
string
|
||||
string
|
||||
]
|
||||
"metric": integer,
|
||||
"ref": integer,
|
||||
"use": integer,
|
||||
"mss": integer,
|
||||
"window": integer,
|
||||
"irtt": integer,
|
||||
"iface": string
|
||||
"metric": integer,
|
||||
"ref": integer,
|
||||
"use": integer,
|
||||
"mss": integer,
|
||||
"window": integer,
|
||||
"irtt": integer,
|
||||
"iface": string
|
||||
}
|
||||
]
|
||||
|
||||
@@ -106,16 +108,12 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.route.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -123,14 +121,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.rpm_qi"></a>
|
||||
|
||||
# jc.parsers.rpm_qi
|
||||
jc - JSON CLI output utility `rpm -qi` command output parser
|
||||
# jc.parsers.rpm\_qi
|
||||
|
||||
jc - JSON Convert `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` 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.
|
||||
The `..._epoch_utc` calculated timestamp fields are timezone-aware and are
|
||||
only available if the timezone field is UTC.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -19,8 +23,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.rpm_qi
|
||||
result = jc.parsers.rpm_qi.parse(rpm_qi_command_output)
|
||||
import jc
|
||||
result = jc.parse('rpm_qi', rpm_qi_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -32,16 +36,16 @@ Schema:
|
||||
"release": string,
|
||||
"architecture": string,
|
||||
"install_date": string,
|
||||
"install_date_epoch": integer, # naive timestamp
|
||||
"install_date_epoch_utc": integer, # Aware timestamp if timezone is UTC
|
||||
"install_date_epoch": integer, # [0]
|
||||
"install_date_epoch_utc": integer, # [1]
|
||||
"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_epoch": integer, # [0]
|
||||
"build_epoch_utc": integer, # [1]
|
||||
"build_host": string,
|
||||
"relocations": string,
|
||||
"packager": string,
|
||||
@@ -52,6 +56,9 @@ Schema:
|
||||
}
|
||||
]
|
||||
|
||||
[0] naive timestamp
|
||||
[1] Aware timestamp if timezone is UTC
|
||||
|
||||
Examples:
|
||||
|
||||
$ rpm -qia | jc --rpm-qi -p
|
||||
@@ -66,7 +73,7 @@ Examples:
|
||||
"group": "Development/Tools",
|
||||
"size": 1160660,
|
||||
"license": "GPLv2+",
|
||||
"signature": "RSA/SHA256, Thu 22 Aug 2019 02:34:59 PM PDT, Key ID 24c6a8a7f4a80eb5",
|
||||
"signature": "RSA/SHA256, Thu 22 Aug 2019 02:34:59 PM PDT, Key ...",
|
||||
"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",
|
||||
@@ -74,8 +81,8 @@ Examples:
|
||||
"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...",
|
||||
"summary": "A GNU tool which simplifies the build process for ...",
|
||||
"description": "A GNU tool for controlling the generation of ex...",
|
||||
"build_epoch": 1565311645,
|
||||
"build_epoch_utc": null,
|
||||
"install_date_epoch": 1571242902,
|
||||
@@ -90,7 +97,7 @@ Examples:
|
||||
"group": "System Environment/Base",
|
||||
"size": 503608,
|
||||
"license": "GPLv2+",
|
||||
"signature": "RSA/SHA256, Mon 12 Nov 2018 07:17:49 AM PST, Key ID 24c6a8a7f4a80eb5",
|
||||
"signature": "RSA/SHA256, Mon 12 Nov 2018 07:17:49 AM PST, Key ...",
|
||||
"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",
|
||||
@@ -99,7 +106,7 @@ Examples:
|
||||
"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...",
|
||||
"description": "The kbd-legacy package contains original keymap...",
|
||||
"build_epoch": 1540939200,
|
||||
"build_epoch_utc": null,
|
||||
"install_date_epoch": 1565891588,
|
||||
@@ -120,7 +127,7 @@ Examples:
|
||||
"group": "Development/Tools",
|
||||
"size": "1160660",
|
||||
"license": "GPLv2+",
|
||||
"signature": "RSA/SHA256, Thu 22 Aug 2019 02:34:59 PM PDT, Key ID 24c6a8a7f4a80eb5",
|
||||
"signature": "RSA/SHA256, Thu 22 Aug 2019 02:34:59 PM PDT, Key ...",
|
||||
"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",
|
||||
@@ -128,8 +135,8 @@ Examples:
|
||||
"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..."
|
||||
"summary": "A GNU tool which simplifies the build process for...",
|
||||
"description": "A GNU tool for controlling the generation of exe..."
|
||||
},
|
||||
{
|
||||
"name": "kbd-legacy",
|
||||
@@ -140,7 +147,7 @@ Examples:
|
||||
"group": "System Environment/Base",
|
||||
"size": "503608",
|
||||
"license": "GPLv2+",
|
||||
"signature": "RSA/SHA256, Mon 12 Nov 2018 07:17:49 AM PST, Key ID 24c6a8a7f4a80eb5",
|
||||
"signature": "RSA/SHA256, Mon 12 Nov 2018 07:17:49 AM PST, Key ...",
|
||||
"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",
|
||||
@@ -149,21 +156,17 @@ Examples:
|
||||
"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..."
|
||||
"description": "The kbd-legacy package contains original keymaps..."
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.rpm_qi.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -171,14 +174,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
160
docs/parsers/rsync.md
Normal file
160
docs/parsers/rsync.md
Normal file
@@ -0,0 +1,160 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.rsync"></a>
|
||||
|
||||
# jc.parsers.rsync
|
||||
|
||||
jc - JSON Convert `rsync` command output parser
|
||||
|
||||
Supports the `-i` or `--itemize-changes` options with all levels of
|
||||
verbosity. This parser will process the `STDOUT` output or a log file
|
||||
generated with the `--log-file` option.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ rsync -i -a source/ dest | jc --rsync
|
||||
|
||||
or
|
||||
|
||||
$ jc rsync -i -a source/ dest
|
||||
|
||||
or
|
||||
|
||||
$ cat rsync-backup.log | jc --rsync
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('rsync', rsync_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"summary": {
|
||||
"date": string,
|
||||
"time": string,
|
||||
"process": integer,
|
||||
"sent": integer,
|
||||
"received": integer,
|
||||
"total_size": integer,
|
||||
"matches": integer,
|
||||
"hash_hits": integer,
|
||||
"false_alarms": integer,
|
||||
"data": integer,
|
||||
"bytes_sec": float,
|
||||
"speedup": float
|
||||
},
|
||||
"files": [
|
||||
{
|
||||
"filename": string,
|
||||
"date": string,
|
||||
"time": string,
|
||||
"process": integer,
|
||||
"metadata": string,
|
||||
"update_type": string/null, # [0]
|
||||
"file_type": string/null, # [1]
|
||||
"checksum_or_value_different": bool/null,
|
||||
"size_different": bool/null,
|
||||
"modification_time_different": bool/null,
|
||||
"permissions_different": bool/null,
|
||||
"owner_different": bool/null,
|
||||
"group_different": bool/null,
|
||||
"acl_different": bool/null,
|
||||
"extended_attribute_different": bool/null,
|
||||
"epoch": integer, # [2]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
[0] 'file sent', 'file received', 'local change or creation',
|
||||
'hard link', 'not updated', 'message'
|
||||
[1] 'file', 'directory', 'symlink', 'device', 'special file'
|
||||
[2] naive timestamp if time and date fields exist and can be converted.
|
||||
|
||||
Examples:
|
||||
|
||||
$ rsync -i -a source/ dest | jc --rsync -p
|
||||
[
|
||||
{
|
||||
"summary": {
|
||||
"sent": 1708,
|
||||
"received": 8209,
|
||||
"bytes_sec": 19834.0,
|
||||
"total_size": 235,
|
||||
"speedup": 0.02
|
||||
},
|
||||
"files": [
|
||||
{
|
||||
"filename": "./",
|
||||
"metadata": ".d..t......",
|
||||
"update_type": "not updated",
|
||||
"file_type": "directory",
|
||||
"checksum_or_value_different": false,
|
||||
"size_different": false,
|
||||
"modification_time_different": true,
|
||||
"permissions_different": false,
|
||||
"owner_different": false,
|
||||
"group_different": false,
|
||||
"acl_different": false,
|
||||
"extended_attribute_different": false
|
||||
},
|
||||
...
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
$ rsync | jc --rsync -p -r
|
||||
[
|
||||
{
|
||||
"summary": {
|
||||
"sent": "1,708",
|
||||
"received": "8,209",
|
||||
"bytes_sec": "19,834.00",
|
||||
"total_size": "235",
|
||||
"speedup": "0.02"
|
||||
},
|
||||
"files": [
|
||||
{
|
||||
"filename": "./",
|
||||
"metadata": ".d..t......",
|
||||
"update_type": "not updated",
|
||||
"file_type": "directory",
|
||||
"checksum_or_value_different": false,
|
||||
"size_different": false,
|
||||
"modification_time_different": true,
|
||||
"permissions_different": false,
|
||||
"owner_different": false,
|
||||
"group_different": false,
|
||||
"acl_different": false,
|
||||
"extended_attribute_different": false
|
||||
},
|
||||
...
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.rsync.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
117
docs/parsers/rsync_s.md
Normal file
117
docs/parsers/rsync_s.md
Normal file
@@ -0,0 +1,117 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.rsync_s"></a>
|
||||
|
||||
# jc.parsers.rsync\_s
|
||||
|
||||
jc - JSON Convert `rsync` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
Supports the `-i` or `--itemize-changes` options with all levels of
|
||||
verbosity. This parser will process the `STDOUT` output or a log file
|
||||
generated with the `--log-file` option.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ rsync -i -a source/ dest | jc --rsync-s
|
||||
|
||||
or
|
||||
|
||||
$ cat rsync-backup.log | jc --rsync-s
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
|
||||
result = jc.parse('rsync_s', rsync_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"type": string, # 'file' or 'summary'
|
||||
"date": string,
|
||||
"time": string,
|
||||
"process": integer,
|
||||
"sent": integer,
|
||||
"received": integer,
|
||||
"total_size": integer,
|
||||
"matches": integer,
|
||||
"hash_hits": integer,
|
||||
"false_alarms": integer,
|
||||
"data": integer,
|
||||
"bytes_sec": float,
|
||||
"speedup": float,
|
||||
"filename": string,
|
||||
"date": string,
|
||||
"time": string,
|
||||
"process": integer,
|
||||
"metadata": string,
|
||||
"update_type": string/null, # [0]
|
||||
"file_type": string/null, # [1]
|
||||
"checksum_or_value_different": bool/null,
|
||||
"size_different": bool/null,
|
||||
"modification_time_different": bool/null,
|
||||
"permissions_different": bool/null,
|
||||
"owner_different": bool/null,
|
||||
"group_different": bool/null,
|
||||
"acl_different": bool/null,
|
||||
"extended_attribute_different": bool/null,
|
||||
"epoch": integer, # [2]
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # false if error parsing
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
}
|
||||
|
||||
[0] 'file sent', 'file received', 'local change or creation',
|
||||
'hard link', 'not updated', 'message'
|
||||
[1] 'file', 'directory', 'symlink', 'device', 'special file'
|
||||
[2] naive timestamp if time and date fields exist and can be converted.
|
||||
|
||||
Examples:
|
||||
|
||||
$ rsync -i -a source/ dest | jc --rsync-s
|
||||
{"type":"file","filename":"./","metadata":".d..t......","update_...}
|
||||
...
|
||||
|
||||
$ cat rsync_backup.log | jc --rsync-s
|
||||
{"type":"file","filename":"./","date":"2022/01/28","time":"03:53...}
|
||||
...
|
||||
|
||||
<a id="jc.parsers.rsync_s.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
@add_jc_meta
|
||||
def parse(data: Iterable[str],
|
||||
raw: bool = False,
|
||||
quiet: bool = False,
|
||||
ignore_exceptions: bool = False) -> Union[Iterable[Dict], tuple]
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterable object.
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (iterable) line-based text data to parse
|
||||
(e.g. sys.stdin or str.splitlines())
|
||||
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||
|
||||
Returns:
|
||||
|
||||
Iterable of Dictionaries
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.sfdisk"></a>
|
||||
|
||||
# jc.parsers.sfdisk
|
||||
jc - JSON CLI output utility `sfdisk` command output parser
|
||||
|
||||
jc - JSON Convert `sfdisk` command output parser
|
||||
|
||||
Supports the following `sfdisk` options:
|
||||
- `-l`
|
||||
@@ -22,8 +24,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.sfdisk
|
||||
result = jc.parsers.sfdisk.parse(sfdisk_command_output)
|
||||
import jc
|
||||
result = jc.parse('sfdisk', sfdisk_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -53,7 +55,7 @@ Schema:
|
||||
"boot": boolean,
|
||||
"start": integer,
|
||||
"end": integer,
|
||||
"size": string, # Note: will be integer when using deprecated -d sfdisk option
|
||||
"size": string, # [0]
|
||||
"cyls": integer,
|
||||
"mib": integer,
|
||||
"blocks": integer,
|
||||
@@ -66,6 +68,8 @@ Schema:
|
||||
}
|
||||
]
|
||||
|
||||
[0] will be integer when using deprecated -d sfdisk option
|
||||
|
||||
Examples:
|
||||
|
||||
# sfdisk -l | jc --sfdisk -p
|
||||
@@ -75,7 +79,7 @@ Examples:
|
||||
"cylinders": 2610,
|
||||
"heads": 255,
|
||||
"sectors_per_track": 63,
|
||||
"units": "cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0",
|
||||
"units": "cylinders of 8225280 bytes, blocks of 1024 bytes, ...",
|
||||
"partitions": [
|
||||
{
|
||||
"device": "/dev/sda1",
|
||||
@@ -140,7 +144,7 @@ Examples:
|
||||
"cylinders": "2610",
|
||||
"heads": "255",
|
||||
"sectors_per_track": "63",
|
||||
"units": "cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0",
|
||||
"units": "cylinders of 8225280 bytes, blocks of 1024 bytes, co...",
|
||||
"partitions": [
|
||||
{
|
||||
"device": "/dev/sda1",
|
||||
@@ -198,16 +202,12 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.sfdisk.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -215,14 +215,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.shadow"></a>
|
||||
|
||||
# jc.parsers.shadow
|
||||
jc - JSON CLI output utility `/etc/shadow` file parser
|
||||
|
||||
jc - JSON Convert `/etc/shadow` file parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -9,8 +11,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.shadow
|
||||
result = jc.parsers.shadow.parse(shadow_file_output)
|
||||
import jc
|
||||
result = jc.parse('shadow', shadow_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -99,16 +101,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.shadow.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -116,14 +114,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, aix, freebsd
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.ss"></a>
|
||||
|
||||
# jc.parsers.ss
|
||||
jc - JSON CLI output utility `ss` command output parser
|
||||
|
||||
Extended information options like -e and -p are not supported and may cause parsing irregularities.
|
||||
jc - JSON Convert `ss` command output parser
|
||||
|
||||
Extended information options like `-e` and `-p` are not supported and may
|
||||
cause parsing irregularities.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -15,12 +18,13 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.ss
|
||||
result = jc.parsers.ss.parse(ss_command_output)
|
||||
import jc
|
||||
result = jc.parse('ss', ss_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
Information from https://www.cyberciti.biz/files/ss.html used to define field names
|
||||
Information from https://www.cyberciti.biz/files/ss.html used to define
|
||||
field names
|
||||
|
||||
[
|
||||
{
|
||||
@@ -276,16 +280,12 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.ss.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -293,14 +293,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.stat"></a>
|
||||
|
||||
# jc.parsers.stat
|
||||
jc - JSON CLI output utility `stat` command output parser
|
||||
|
||||
The `xxx_epoch` calculated timestamp fields are naive (i.e. based on the local time of the system the parser is run on)
|
||||
jc - JSON Convert `stat` command output parser
|
||||
|
||||
The `xxx_epoch_utc` calculated timestamp fields are timezone-aware and are only available if the timezone field is UTC.
|
||||
The `xxx_epoch` calculated timestamp fields are naive. (i.e. based on the
|
||||
local time of the system the parser is run on)
|
||||
|
||||
The `xxx_epoch_utc` calculated timestamp fields are timezone-aware and are
|
||||
only available if the timezone field is UTC.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -17,8 +21,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.stat
|
||||
result = jc.parsers.stat.parse(stat_command_output)
|
||||
import jc
|
||||
result = jc.parse('stat', stat_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -166,16 +170,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.stat.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -183,14 +183,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.10 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.12 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
107
docs/parsers/stat_s.md
Normal file
107
docs/parsers/stat_s.md
Normal file
@@ -0,0 +1,107 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.stat_s"></a>
|
||||
|
||||
# jc.parsers.stat\_s
|
||||
|
||||
jc - JSON Convert `stat` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
||||
> Dictionaries (module)
|
||||
|
||||
The `xxx_epoch` calculated timestamp fields are naive. (i.e. based on the
|
||||
local time of the system the parser is run on).
|
||||
|
||||
The `xxx_epoch_utc` calculated timestamp fields are timezone-aware and are
|
||||
only available if the timezone field is UTC.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ stat * | jc --stat-s
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
|
||||
result = jc.parse('stat_s', stat_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
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,
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # false if error parsing
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ stat | jc --stat-s
|
||||
{"file":"(stdin)","unix_device":1027739696,"inode":1155,"flags":"cr...}
|
||||
|
||||
$ stat | jc --stat-s -r
|
||||
{"file":"(stdin)","unix_device":"1027739696","inode":"1155","flag...}
|
||||
|
||||
<a id="jc.parsers.stat_s.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
@add_jc_meta
|
||||
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterable object.
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (iterable) line-based text data to parse
|
||||
(e.g. sys.stdin or str.splitlines())
|
||||
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
||||
|
||||
Returns:
|
||||
|
||||
Iterable of Dictionaries
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
@@ -1,9 +1,14 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.sysctl"></a>
|
||||
|
||||
# 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()`.
|
||||
jc - JSON Convert `sysctl -a` command output parser
|
||||
|
||||
> Note: Since `sysctl` output is not easily parsable only a very simple
|
||||
> key/value object will be output. An attempt is made to convert obvious
|
||||
> integers and floats. If no conversion is desired, use the `-r`
|
||||
> command-line argument or the `raw=True` argument in `parse()`.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -15,13 +20,13 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.sysctl
|
||||
result = jc.parsers.sysctl.parse(sysctl_command_output)
|
||||
import jc
|
||||
result = jc.parse('sysctl', sysctl_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"key1": string/integer/float, # best guess based on value
|
||||
"key1": string/integer/float, # best guess based on value
|
||||
"key2": string/integer/float,
|
||||
"key3": string/integer/float
|
||||
}
|
||||
@@ -52,16 +57,12 @@ Examples:
|
||||
...
|
||||
}
|
||||
|
||||
<a id="jc.parsers.sysctl.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -69,14 +70,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.systemctl"></a>
|
||||
|
||||
# jc.parsers.systemctl
|
||||
jc - JSON CLI output utility `systemctl` command output parser
|
||||
|
||||
jc - JSON Convert `systemctl` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,8 +15,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.systemctl
|
||||
result = jc.parsers.systemctl.parse(systemctl_command_output)
|
||||
import jc
|
||||
result = jc.parse('systemctl', systemctl_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -37,14 +39,14 @@ Examples:
|
||||
"load": "loaded",
|
||||
"active": "active",
|
||||
"sub": "waiting",
|
||||
"description": "Arbitrary Executable File Formats File System Automount Point"
|
||||
"description": "Arbitrary Executable File Formats File System ..."
|
||||
},
|
||||
{
|
||||
"unit": "dev-block-8:2.device",
|
||||
"load": "loaded",
|
||||
"active": "active",
|
||||
"sub": "plugged",
|
||||
"description": "LVM PV 3klkIj-w1qk-DkJi-0XBJ-y3o7-i2Ac-vHqWBM on /dev/sda2 2"
|
||||
"description": "LVM PV 3klkIj-w1qk-DkJi-0XBJ-y3o7-i2Ac-vHqWBM o..."
|
||||
},
|
||||
{
|
||||
"unit": "dev-cdrom.device",
|
||||
@@ -56,16 +58,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.systemctl.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -73,14 +71,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.systemctl_lj"></a>
|
||||
|
||||
# jc.parsers.systemctl_lj
|
||||
jc - JSON CLI output utility `systemctl list-jobs` command output parser
|
||||
# jc.parsers.systemctl\_lj
|
||||
|
||||
jc - JSON Convert `systemctl list-jobs` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,8 +15,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.systemctl_lj
|
||||
result = jc.parsers.systemctl_lj.parse(systemctl_lj_command_output)
|
||||
import jc
|
||||
result = jc.parse('systemctl_lj', systemctl_lj_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -73,16 +75,12 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.systemctl_lj.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -90,14 +88,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.systemctl_ls"></a>
|
||||
|
||||
# jc.parsers.systemctl_ls
|
||||
jc - JSON CLI output utility `systemctl list-sockets` command output parser
|
||||
# jc.parsers.systemctl\_ls
|
||||
|
||||
jc - JSON Convert `systemctl list-sockets` command output
|
||||
parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,8 +16,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.systemctl_ls
|
||||
result = jc.parsers.systemctl_ls.parse(systemctl_ls_command_output)
|
||||
import jc
|
||||
result = jc.parse('systemctl_ls', systemctl_ls_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -48,16 +51,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.systemctl_ls.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -65,14 +64,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.systemctl_luf"></a>
|
||||
|
||||
# jc.parsers.systemctl_luf
|
||||
jc - JSON CLI output utility `systemctl list-unit-files` command output parser
|
||||
# jc.parsers.systemctl\_luf
|
||||
|
||||
jc - JSON Convert `systemctl list-unit-files` command output
|
||||
parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -13,8 +16,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.systemctl_luf
|
||||
result = jc.parsers.systemctl_luf.parse(systemctl_luf_command_output)
|
||||
import jc
|
||||
result = jc.parse('systemctl_luf', systemctl_luf_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -44,16 +47,12 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
<a id="jc.parsers.systemctl_luf.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -61,14 +60,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.systeminfo"></a>
|
||||
|
||||
# jc.parsers.systeminfo
|
||||
jc - JSON CLI output utility `systeminfo` command output parser
|
||||
|
||||
jc - JSON Convert `systeminfo` command output parser
|
||||
|
||||
Blank or missing elements are set to `null`.
|
||||
|
||||
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` 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.
|
||||
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):
|
||||
|
||||
@@ -15,8 +21,8 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.systeminfo
|
||||
result = jc.parsers.systeminfo.parse(systeminfo_command_output)
|
||||
import jc
|
||||
result = jc.parse('systeminfo', systeminfo_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -31,11 +37,11 @@ Schema:
|
||||
"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
|
||||
"original_install_date_epoch": integer, # [0]
|
||||
"original_install_date_epoch_utc": integer, # [1]
|
||||
"system_boot_time": string,
|
||||
"system_boot_time_epoch": integer, # naive timestamp
|
||||
"system_boot_time_epoch_utc": integer, # timezone-aware timestamp
|
||||
"system_boot_time_epoch": integer, # [0]
|
||||
"system_boot_time_epoch_utc": integer, # [1]
|
||||
"system_manufacturer": string,
|
||||
"system_model": string,
|
||||
"system_type": string,
|
||||
@@ -80,6 +86,9 @@ Schema:
|
||||
}
|
||||
}
|
||||
|
||||
[0] naive timestamp
|
||||
[1] timezone-aware timestamp
|
||||
|
||||
Examples:
|
||||
|
||||
$ systeminfo | jc --systeminfo -p
|
||||
@@ -102,9 +111,9 @@ Examples:
|
||||
"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",
|
||||
"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",
|
||||
@@ -113,9 +122,9 @@ Examples:
|
||||
"virtual_memory_max_size_mb": 37367,
|
||||
"virtual_memory_available_mb": 22266,
|
||||
"virtual_memory_in_use_mb": 15101,
|
||||
"page_file_locations": "C:\pagefile.sys",
|
||||
"page_file_locations": "C:\\pagefile.sys",
|
||||
"domain": "test.com",
|
||||
"logon_server": "\\TESTDC01",
|
||||
"logon_server": "\\\\TESTDC01",
|
||||
"hotfixs": [
|
||||
"KB2693643",
|
||||
"KB4601054"
|
||||
@@ -164,9 +173,9 @@ Examples:
|
||||
"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",
|
||||
"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",
|
||||
@@ -175,9 +184,9 @@ Examples:
|
||||
"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",
|
||||
"page_file_locations": "C:\\pagefile.sys",
|
||||
"domain": "test.com",
|
||||
"logon_server": "\\TESTDC01",
|
||||
"logon_server": "\\\\TESTDC01",
|
||||
"hotfixs": [
|
||||
"KB2693643",
|
||||
"KB4601054"
|
||||
@@ -202,16 +211,12 @@ Examples:
|
||||
}
|
||||
}
|
||||
|
||||
<a id="jc.parsers.systeminfo.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -219,14 +224,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: win32
|
||||
|
||||
Version 1.1 by Jon Smith (jon@rebelliondefense.com)
|
||||
Version 1.3 by Jon Smith (jon@rebelliondefense.com)
|
||||
|
||||
@@ -1,27 +1,33 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.time"></a>
|
||||
|
||||
# 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`.
|
||||
jc - JSON Convert `/usr/bin/time` command output parser
|
||||
|
||||
Alternatively, the output from `/usr/bin/time` can be redirected to `STDOUT` so `jc` can receive it.
|
||||
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`.
|
||||
|
||||
Note: `/usr/bin/time` is similar but different from the Bash builtin `time` command.
|
||||
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
|
||||
$ /usr/bin/time -o timefile.out sleep 2; cat timefile.out | \\
|
||||
jc --time -p
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.time
|
||||
result = jc.parsers.time.parse(time_command_output)
|
||||
import jc
|
||||
result = jc.parse('time', time_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
Source: https://www.freebsd.org/cgi/man.cgi?query=getrusage
|
||||
https://man7.org/linux/man-pages/man1/time.1.html
|
||||
Source: https://www.freebsd.org/cgi/man.cgi?query=getrusage,
|
||||
https://man7.org/linux/man-pages/man1/time.1.html
|
||||
|
||||
{
|
||||
"real_time": float,
|
||||
@@ -39,8 +45,8 @@ Schema:
|
||||
"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
|
||||
"block_input_operations": integer, # [0]
|
||||
"block_output_operations": integer, # [1]
|
||||
"major_pagefaults": integer,
|
||||
"minor_pagefaults": integer,
|
||||
"swaps": integer,
|
||||
@@ -60,15 +66,19 @@ Schema:
|
||||
"exit_status": integer
|
||||
}
|
||||
|
||||
[0] aka File system inputs
|
||||
[1] aka File system outputs
|
||||
|
||||
Examples:
|
||||
|
||||
$ /usr/bin/time --verbose -o timefile.out sleep 2.5; cat timefile.out | jc --time -p
|
||||
$ /usr/bin/time --verbose -o timefile.out sleep 2; cat timefile.out | \\
|
||||
jc --time -p
|
||||
{
|
||||
"command_being_timed": "sleep 2.5",
|
||||
"command_being_timed": "sleep 2",
|
||||
"user_time": 0.0,
|
||||
"system_time": 0.0,
|
||||
"cpu_percent": 0,
|
||||
"elapsed_time": "0:02.50",
|
||||
"elapsed_time": "0:02.00",
|
||||
"average_shared_text_size": 0,
|
||||
"average_unshared_data_size": 0,
|
||||
"average_stack_size": 0,
|
||||
@@ -94,13 +104,14 @@ Examples:
|
||||
"elapsed_time_total_seconds": 2.5
|
||||
}
|
||||
|
||||
$ /usr/bin/time --verbose -o timefile.out sleep 2.5; cat timefile.out | jc --time -p -r
|
||||
$ /usr/bin/time --verbose -o timefile.out sleep 2; cat timefile.out | \\
|
||||
jc --time -p -r
|
||||
{
|
||||
"command_being_timed": ""sleep 2.5"",
|
||||
"command_being_timed": "\"sleep 2\"",
|
||||
"user_time": "0.00",
|
||||
"system_time": "0.00",
|
||||
"cpu_percent": "0",
|
||||
"elapsed_time": "0:02.50",
|
||||
"elapsed_time": "0:02.00",
|
||||
"average_shared_text_size": "0",
|
||||
"average_unshared_data_size": "0",
|
||||
"average_stack_size": "0",
|
||||
@@ -121,16 +132,12 @@ Examples:
|
||||
"exit_status": "0"
|
||||
}
|
||||
|
||||
<a id="jc.parsers.time.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -138,14 +145,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.timedatectl"></a>
|
||||
|
||||
# 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.
|
||||
jc - JSON Convert `timedatectl` command output parser
|
||||
|
||||
The `epoch_utc` calculated timestamp field is timezone-aware and is only
|
||||
available if the `universal_time` field is available.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@@ -15,15 +18,15 @@ Usage (cli):
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.timedatectl
|
||||
result = jc.parsers.timedatectl.parse(timedatectl_command_output)
|
||||
import jc
|
||||
result = jc.parse('timedatectl', timedatectl_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"local_time": string,
|
||||
"universal_time": string,
|
||||
"epoch_utc": integer, # timezone-aware timestamp
|
||||
"epoch_utc": integer, # timezone-aware
|
||||
"rtc_time": string,
|
||||
"time_zone": string,
|
||||
"ntp_enabled": boolean,
|
||||
@@ -61,16 +64,12 @@ Examples:
|
||||
"dst_active": "yes"
|
||||
}
|
||||
|
||||
<a id="jc.parsers.timedatectl.parse"></a>
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
### parse
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@@ -78,14 +77,14 @@ Main text parsing function
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
||||
122
docs/parsers/timestamp.md
Normal file
122
docs/parsers/timestamp.md
Normal file
@@ -0,0 +1,122 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.timestamp"></a>
|
||||
|
||||
# jc.parsers.timestamp
|
||||
|
||||
jc - JSON Convert UNIX Epoch Timestamp string parser
|
||||
|
||||
The naive fields are based on the local time of the system the parser is
|
||||
run on.
|
||||
|
||||
The utc fields are timezone-aware, based on the UTC timezone.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ echo "2022-07-20T14:52:45Z" | jc --timestamp
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('timestamp', timestamp_string)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"naive": {
|
||||
"year": integer,
|
||||
"month": string,
|
||||
"month_num": integer,
|
||||
"day": integer,
|
||||
"weekday": string,
|
||||
"weekday_num": integer,
|
||||
"hour": integer,
|
||||
"hour_24": integer,
|
||||
"minute": integer,
|
||||
"second": integer,
|
||||
"period": string,
|
||||
"day_of_year": integer,
|
||||
"week_of_year": integer,
|
||||
"iso": string
|
||||
},
|
||||
"utc": {
|
||||
"year": integer,
|
||||
"month": string,
|
||||
"month_num": integer,
|
||||
"day": integer,
|
||||
"weekday": string,
|
||||
"weekday_num": integer,
|
||||
"hour": integer,
|
||||
"hour_24": integer,
|
||||
"minute": integer,
|
||||
"second": integer,
|
||||
"period": string,
|
||||
"utc_offset": string,
|
||||
"day_of_year": integer,
|
||||
"week_of_year": integer,
|
||||
"iso": string
|
||||
}
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ echo '1658599410' | jc --timestamp -p
|
||||
{
|
||||
"naive": {
|
||||
"year": 2022,
|
||||
"month": "Jul",
|
||||
"month_num": 7,
|
||||
"day": 23,
|
||||
"weekday": "Sat",
|
||||
"weekday_num": 6,
|
||||
"hour": 11,
|
||||
"hour_24": 11,
|
||||
"minute": 3,
|
||||
"second": 30,
|
||||
"period": "AM",
|
||||
"day_of_year": 204,
|
||||
"week_of_year": 29,
|
||||
"iso": "2022-07-23T11:03:30"
|
||||
},
|
||||
"utc": {
|
||||
"year": 2022,
|
||||
"month": "Jul",
|
||||
"month_num": 7,
|
||||
"day": 23,
|
||||
"weekday": "Sat",
|
||||
"weekday_num": 6,
|
||||
"hour": 6,
|
||||
"hour_24": 18,
|
||||
"minute": 3,
|
||||
"second": 30,
|
||||
"period": "PM",
|
||||
"utc_offset": "+0000",
|
||||
"day_of_year": 204,
|
||||
"week_of_year": 29,
|
||||
"iso": "2022-07-23T18:03:30+00:00"
|
||||
}
|
||||
}
|
||||
|
||||
<a id="jc.parsers.timestamp.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, aix, freebsd, darwin, win32, cygwin
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user