mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2026-04-03 17:44:07 +02:00
Compare commits
1944 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7de9111d9 | ||
|
|
7933dfdbe7 | ||
|
|
f7cb5f7d01 | ||
|
|
a26a298f1a | ||
|
|
dbd134d0da | ||
|
|
11aa01b0d9 | ||
|
|
6f18e53443 | ||
|
|
7b467c4665 | ||
|
|
537b8f2630 | ||
|
|
4d823575e7 | ||
|
|
541aa1d09f | ||
|
|
8f02021014 | ||
|
|
158a15157c | ||
|
|
2752e0d66a | ||
|
|
6c11e912af | ||
|
|
43d34461e2 | ||
|
|
4dfdc9b0f6 | ||
|
|
e2311cbb03 | ||
|
|
bf15575e90 | ||
|
|
406336c718 | ||
|
|
6665ffaeb8 | ||
|
|
dcf552ca0c | ||
|
|
7a6ebf3c95 | ||
|
|
d2dc4a983c | ||
|
|
1168259bc2 | ||
|
|
e8e4b46021 | ||
|
|
12d2de2282 | ||
|
|
0e2fe401e1 | ||
|
|
14247adb0a | ||
|
|
3a9f0934c4 | ||
|
|
caf0a5c871 | ||
|
|
cfb58b1cf3 | ||
|
|
975cf195cc | ||
|
|
8a46a259a3 | ||
|
|
e395142e59 | ||
|
|
caaeaf0d67 | ||
|
|
21e69a7cbf | ||
|
|
603964935b | ||
|
|
47eb83ae55 | ||
|
|
fc0ce6c959 | ||
|
|
077a29fb4e | ||
|
|
8568d0d328 | ||
|
|
597d39c28e | ||
|
|
eb888dcbbc | ||
|
|
d1b9ac0841 | ||
|
|
89a6d9c5c3 | ||
|
|
85d9837616 | ||
|
|
cd7731484d | ||
|
|
086da16b17 | ||
|
|
20830528f0 | ||
|
|
83371edd8f | ||
|
|
364a81decc | ||
|
|
ef09592ad3 | ||
|
|
4a86e109cc | ||
|
|
7fa5391b66 | ||
|
|
9b53ba5714 | ||
|
|
b59e38cfd2 | ||
|
|
5ba22dae59 | ||
|
|
4232e523ac | ||
|
|
bee80b35d2 | ||
|
|
c32395f695 | ||
|
|
735c5e1078 | ||
|
|
d09c94b292 | ||
|
|
4d04866f48 | ||
|
|
a2d90f4dfc | ||
|
|
93a5002c8b | ||
|
|
23bf5227a4 | ||
|
|
77c96fa2a9 | ||
|
|
3f5a1f015e | ||
|
|
b280c4fc18 | ||
|
|
3ab9b43a2e | ||
|
|
46f568414a | ||
|
|
cba2fd299f | ||
|
|
1e6e44f656 | ||
|
|
acac039994 | ||
|
|
50a3b34016 | ||
|
|
b45396070c | ||
|
|
218b9aec8a | ||
|
|
2b887debc6 | ||
|
|
0313e3f8ca | ||
|
|
1669e6e20c | ||
|
|
ef6de75dda | ||
|
|
a6bcec425a | ||
|
|
596ad9a64d | ||
|
|
7a91c93319 | ||
|
|
b5f7b35f89 | ||
|
|
2f47fb7f14 | ||
|
|
1b214c4036 | ||
|
|
8f94f8acc6 | ||
|
|
3a2a69cfa5 | ||
|
|
f599c65988 | ||
|
|
ad12849fd9 | ||
|
|
f36b3789e8 | ||
|
|
6d18c0ba61 | ||
|
|
17097abec9 | ||
|
|
b7ddd3b285 | ||
|
|
75b23f62c9 | ||
|
|
f88967b2a5 | ||
|
|
ba2846664b | ||
|
|
10dba37ca2 | ||
|
|
0e6f938514 | ||
|
|
159d87c112 | ||
|
|
9e7b1621cf | ||
|
|
2057817ef8 | ||
|
|
a1eabad2d3 | ||
|
|
92bf2b1ca2 | ||
|
|
2b2123a4ba | ||
|
|
908b2f9200 | ||
|
|
deff0c7bfd | ||
|
|
7cd01efa64 | ||
|
|
2dbe56456b | ||
|
|
6078a411ef | ||
|
|
4a3656562f | ||
|
|
ba75989a24 | ||
|
|
9e9e2c3628 | ||
|
|
9a2a8c6b61 | ||
|
|
dae42ef161 | ||
|
|
931f2cab78 | ||
|
|
72b061bed4 | ||
|
|
29a7c73990 | ||
|
|
2d1d68e300 | ||
|
|
c5c1e170d1 | ||
|
|
9c1bb66452 | ||
|
|
a4f3306bae | ||
|
|
1bc638b6ee | ||
|
|
9ad0cd9dae | ||
|
|
6d4a469127 | ||
|
|
ed6997e3ff | ||
|
|
eb788fca6e | ||
|
|
9186f5f377 | ||
|
|
30cff5f281 | ||
|
|
b724e0969a | ||
|
|
a62c49e871 | ||
|
|
9b160f6279 | ||
|
|
338a4e2612 | ||
|
|
0140688750 | ||
|
|
73e5ea98c1 | ||
|
|
77dcbc544d | ||
|
|
c7bcb0947a | ||
|
|
5cd3f7f71d | ||
|
|
5044388ab2 | ||
|
|
ee075db598 | ||
|
|
9904e0be61 | ||
|
|
31b69b3242 | ||
|
|
e6a80fea32 | ||
|
|
d6aec00e03 | ||
|
|
4aa7d81e11 | ||
|
|
48cdabc3b0 | ||
|
|
a1791ef547 | ||
|
|
7bc87f6c2d | ||
|
|
bbed9e274b | ||
|
|
486282b985 | ||
|
|
a4d45b653f | ||
|
|
22e151b01c | ||
|
|
7a4ebcd1ec | ||
|
|
651cbfe02f | ||
|
|
8c3e764516 | ||
|
|
b4e75da7e3 | ||
|
|
37223f086c | ||
|
|
a404033735 | ||
|
|
b7433ed085 | ||
|
|
224d3d65ad | ||
|
|
a349fb0bda | ||
|
|
e7ddcfb83f | ||
|
|
abd20dfe36 | ||
|
|
dc1fd3ef1b | ||
|
|
98a7686db4 | ||
|
|
9c6c6c4330 | ||
|
|
f9be5651da | ||
|
|
df9835a3e6 | ||
|
|
92363be2dd | ||
|
|
31b6203015 | ||
|
|
18805858d6 | ||
|
|
e676f0e20f | ||
|
|
20652edefa | ||
|
|
98c29d0747 | ||
|
|
41a6311f6b | ||
|
|
978760ec57 | ||
|
|
d410425537 | ||
|
|
6b7430329c | ||
|
|
40fe0d4a60 | ||
|
|
365c5354a0 | ||
|
|
b246a05cbb | ||
|
|
9e5a7a4abb | ||
|
|
f266acbcca | ||
|
|
4e3b471f18 | ||
|
|
5e28736c2e | ||
|
|
a91913a3b5 | ||
|
|
90c64f0ae0 | ||
|
|
7cc642ed1a | ||
|
|
809f64d35a | ||
|
|
a6f859a55e | ||
|
|
39ef88078f | ||
|
|
aeea5e8d2e | ||
|
|
1a0700bff4 | ||
|
|
b5fa6d068f | ||
|
|
1baec0b420 | ||
|
|
4f2a4e1dee | ||
|
|
758d617668 | ||
|
|
55322c37f5 | ||
|
|
d19ea5552b | ||
|
|
130c3527c1 | ||
|
|
3f221f4714 | ||
|
|
d64c4cb390 | ||
|
|
448c56aa46 | ||
|
|
9fbea15b6d | ||
|
|
932060314b | ||
|
|
5e68ae5009 | ||
|
|
d03541beae | ||
|
|
516fa571d9 | ||
|
|
a19c12096a | ||
|
|
758f27945d | ||
|
|
8b1e8d58df | ||
|
|
b967489d08 | ||
|
|
870d0218be | ||
|
|
84020bc2af | ||
|
|
4efe5344e0 | ||
|
|
9182c54513 | ||
|
|
28f0ab0b02 | ||
|
|
90d1a30696 | ||
|
|
130b3738cc | ||
|
|
92c7357615 | ||
|
|
c80f863334 | ||
|
|
4642c20179 | ||
|
|
5288eb22aa | ||
|
|
df8387a1a9 | ||
|
|
cc38c27f44 | ||
|
|
64f5357d69 | ||
|
|
51debb5649 | ||
|
|
b48d05a431 | ||
|
|
4e7f6b337d | ||
|
|
a509d99caf | ||
|
|
481e45fb64 | ||
|
|
e9038e1720 | ||
|
|
8fd9e582bf | ||
|
|
c1fd6f48a5 | ||
|
|
af615c7f4b | ||
|
|
bf0bc32d7a | ||
|
|
2d6b53e012 | ||
|
|
51271fea0f | ||
|
|
2deb473e0b | ||
|
|
23eeb33b3d | ||
|
|
f50dfaef45 | ||
|
|
55bb71e9d4 | ||
|
|
dab9357d28 | ||
|
|
27eb427245 | ||
|
|
260f3685d9 | ||
|
|
76e78fc0c3 | ||
|
|
1ac944fa02 | ||
|
|
986bc9b042 | ||
|
|
5a7942069b | ||
|
|
f6c6fc13ac | ||
|
|
1d8cfae89f | ||
|
|
787df51239 | ||
|
|
5e7f302a9c | ||
|
|
3d10fd40b5 | ||
|
|
57e3bf239c | ||
|
|
ccb09861e8 | ||
|
|
94551d75dd | ||
|
|
6e21218425 | ||
|
|
ff0fda48fc | ||
|
|
528aac7ad8 | ||
|
|
ab482e521d | ||
|
|
e08b61fa81 | ||
|
|
ce61bd1d2b | ||
|
|
7b708f7518 | ||
|
|
89ca50c7fc | ||
|
|
fb54899dcc | ||
|
|
0a625ad7dd | ||
|
|
d32e45efbe | ||
|
|
c77696bc78 | ||
|
|
736fde9e78 | ||
|
|
9c1ad92fed | ||
|
|
1a9fd2139d | ||
|
|
7661e7f27a | ||
|
|
f857b7fbf7 | ||
|
|
d94d12dbc5 | ||
|
|
700916276a | ||
|
|
834e52369c | ||
|
|
1ce53365de | ||
|
|
473f70668f | ||
|
|
0dbd2702f6 | ||
|
|
01e3764a9b | ||
|
|
ff9c81722a | ||
|
|
166aef7a02 | ||
|
|
78caf7646b | ||
|
|
1f99d40cec | ||
|
|
4c2912d3d5 | ||
|
|
45e6e06be5 | ||
|
|
fdbe3e05f3 | ||
|
|
7cc168f640 | ||
|
|
ff2d609c9b | ||
|
|
2689697b4c | ||
|
|
f90a0ea8ab | ||
|
|
caabe60f84 | ||
|
|
2bef4ed603 | ||
|
|
ee57be533b | ||
|
|
c5b7aaca25 | ||
|
|
7a1be905bb | ||
|
|
5798495a11 | ||
|
|
46171e2202 | ||
|
|
dd5c924ff5 | ||
|
|
30c4ab2976 | ||
|
|
26ea4d47b3 | ||
|
|
2732cd175c | ||
|
|
3e54b597be | ||
|
|
f10ebea209 | ||
|
|
2c6f3993cb | ||
|
|
708a696920 | ||
|
|
20bbb5d331 | ||
|
|
223e785b54 | ||
|
|
3d78692c59 | ||
|
|
5321a15dcf | ||
|
|
a452f8252a | ||
|
|
49267f09ac | ||
|
|
db47f35783 | ||
|
|
d48abf312c | ||
|
|
3b22ce4110 | ||
|
|
c521ca5bc9 | ||
|
|
3ddc1c6659 | ||
|
|
a8e19402b7 | ||
|
|
0927902b30 | ||
|
|
572548b42f | ||
|
|
ff7ab0a1ed | ||
|
|
5db71b05cb | ||
|
|
f9b952885a | ||
|
|
e7983bc0b2 | ||
|
|
473a643142 | ||
|
|
14f3d442cb | ||
|
|
d6f4ed9ab5 | ||
|
|
1b8d654444 | ||
|
|
6002af0dca | ||
|
|
0924d822a3 | ||
|
|
72a37b9289 | ||
|
|
5eef7bd769 | ||
|
|
c6893e1bd5 | ||
|
|
039f6612e4 | ||
|
|
95aec9c6f9 | ||
|
|
4e9652a8ec | ||
|
|
773b7f4b1f | ||
|
|
d17ffde9cd | ||
|
|
9c57c09c00 | ||
|
|
4d730a9de5 | ||
|
|
fc57bcfce2 | ||
|
|
fa5571486c | ||
|
|
9996c4fe23 | ||
|
|
038d429024 | ||
|
|
9bf6facb0d | ||
|
|
965717886e | ||
|
|
e9bfc3dd29 | ||
|
|
f46b33eacf | ||
|
|
f475fe44df | ||
|
|
5fdbe2962d | ||
|
|
ab291b9eef | ||
|
|
fd411fd772 | ||
|
|
b1e95a60a2 | ||
|
|
bb1439f0d5 | ||
|
|
ba963d98a0 | ||
|
|
83440ccb55 | ||
|
|
796f61bfa4 | ||
|
|
070cac4ae1 | ||
|
|
3ed84f9f42 | ||
|
|
a205afb6f3 | ||
|
|
a6d983dd8f | ||
|
|
b6c8d6d01d | ||
|
|
b5a5d5b133 | ||
|
|
da528e7814 | ||
|
|
4acebf4f62 | ||
|
|
4d40808d2b | ||
|
|
c543f00bd3 | ||
|
|
947cf41dfa | ||
|
|
8d8c58742e | ||
|
|
995ecc9bfb | ||
|
|
21a15225eb | ||
|
|
48921d4584 | ||
|
|
342db45edc | ||
|
|
5f88ecf844 | ||
|
|
a56aebfe70 | ||
|
|
422bb744a8 | ||
|
|
c3b814a15f | ||
|
|
e4574047a0 | ||
|
|
0d7d7951f8 | ||
|
|
da904e4770 | ||
|
|
19b540041a | ||
|
|
f2ffb93eea | ||
|
|
c0c0e05642 | ||
|
|
966978f17e | ||
|
|
8ab08a5231 | ||
|
|
48e534fa03 | ||
|
|
61851c1bd0 | ||
|
|
3c51b2d83d | ||
|
|
ee3a28528e | ||
|
|
916bcdae38 | ||
|
|
efb1d3e6b2 | ||
|
|
4e6ae66bac | ||
|
|
5ee88e7b67 | ||
|
|
c3b68903cb | ||
|
|
fe1f1013a7 | ||
|
|
fb14f5439f | ||
|
|
5ca0fc364e | ||
|
|
a1fe7037e5 | ||
|
|
c2af7d113e | ||
|
|
ff034e401d | ||
|
|
5abe095beb | ||
|
|
33de5f01e6 | ||
|
|
8ce155d843 | ||
|
|
b921d5ec95 | ||
|
|
e21542aaa2 | ||
|
|
6150aae0ae | ||
|
|
f27b35f371 | ||
|
|
d24f9a885d | ||
|
|
48dd82c8d1 | ||
|
|
e57167ad1f | ||
|
|
ada9137642 | ||
|
|
bd428a9fd7 | ||
|
|
934941332f | ||
|
|
0c209dbd10 | ||
|
|
56e041aa26 | ||
|
|
cf9d48582e | ||
|
|
92e2252bee | ||
|
|
fd7861db11 | ||
|
|
35464bbbfb | ||
|
|
db8ddd7f0e | ||
|
|
72207c54ee | ||
|
|
a683f68003 | ||
|
|
8d2d3db3fa | ||
|
|
eca785450d | ||
|
|
5b40a97ce4 | ||
|
|
66cb4e9bde | ||
|
|
d1f33645ca | ||
|
|
5eff65c326 | ||
|
|
929c38715d | ||
|
|
8c91a7b760 | ||
|
|
14289ecd6c | ||
|
|
b833c44783 | ||
|
|
e23aa818ea | ||
|
|
473d919c13 | ||
|
|
9f925d6ac9 | ||
|
|
f6ca32b3a3 | ||
|
|
4cbe84c3d6 | ||
|
|
ffac5bf9d3 | ||
|
|
9aa424f9f8 | ||
|
|
0a8495c68e | ||
|
|
6aea066cf0 | ||
|
|
ff3c2d809e | ||
|
|
145059fc89 | ||
|
|
20e5c19de4 | ||
|
|
4c98fd4b87 | ||
|
|
125e54213e | ||
|
|
0152e0665f | ||
|
|
0679bcbc56 | ||
|
|
5500648aa0 | ||
|
|
bb50caad4d | ||
|
|
7eef5d94d5 | ||
|
|
74f623f8d6 | ||
|
|
f638aca092 | ||
|
|
da35eaf80a | ||
|
|
ade0e8e8fc | ||
|
|
90076090f0 | ||
|
|
23635def8b | ||
|
|
4eeec087bd | ||
|
|
7331961038 | ||
|
|
e4acb3d5b7 | ||
|
|
c60549a994 | ||
|
|
d46fc8bbfa | ||
|
|
b133d1f90d | ||
|
|
5be615a97e | ||
|
|
ea1d820f96 | ||
|
|
47e262cf72 | ||
|
|
eec673be90 | ||
|
|
9a0fb2a7c8 | ||
|
|
b5145d6c14 | ||
|
|
9747ca414d | ||
|
|
312d465b61 | ||
|
|
7dcf87d24a | ||
|
|
cf3cfd16a9 | ||
|
|
fcc7e52949 | ||
|
|
3ab9d48014 | ||
|
|
7eddf41c5f | ||
|
|
27a196c938 | ||
|
|
e4324f05fb | ||
|
|
d36b332bd7 | ||
|
|
1f034826f6 | ||
|
|
246c707c98 | ||
|
|
b5d8968144 | ||
|
|
f7b9fbefdd | ||
|
|
b1fc453383 | ||
|
|
7581c8d0f4 | ||
|
|
32bf8ad6f4 | ||
|
|
b083bcc10f | ||
|
|
4f6fdd120d | ||
|
|
eb0038be24 | ||
|
|
7ecdf819fa | ||
|
|
c6aa4d0835 | ||
|
|
7c584b89a6 | ||
|
|
c166c0bfda | ||
|
|
a8dd3f7802 | ||
|
|
3b0e2f03f3 | ||
|
|
8390ae48c8 | ||
|
|
2db82c0a7e | ||
|
|
6147954075 | ||
|
|
691df271fc | ||
|
|
89f52b95f7 | ||
|
|
146acc1bf6 | ||
|
|
c4a345f59a | ||
|
|
dfd2703f75 | ||
|
|
325fab2de7 | ||
|
|
f3d00cf38a | ||
|
|
14838f7f5d | ||
|
|
af74047b81 | ||
|
|
660c59129c | ||
|
|
89a88e186e | ||
|
|
f861cf95b9 | ||
|
|
ee8f06cbdb | ||
|
|
a2e8b3c7b6 | ||
|
|
6c83846075 | ||
|
|
e0681eebb9 | ||
|
|
e5732d1cea | ||
|
|
6e7ae3cd3f | ||
|
|
f95632d1aa | ||
|
|
2f8b7b26e5 | ||
|
|
10292f7502 | ||
|
|
aef54705f5 | ||
|
|
bba5980fa5 | ||
|
|
977425abfb | ||
|
|
37a3565a1b | ||
|
|
13deb8bfb6 | ||
|
|
a3ed9d075a | ||
|
|
fb0ced549e | ||
|
|
7eb31bc7d2 | ||
|
|
6a06a39142 | ||
|
|
bdcdaee6c5 | ||
|
|
605353fdce | ||
|
|
490c9e1769 | ||
|
|
6ebebb659d | ||
|
|
0e70c5ee12 | ||
|
|
cd531acf60 | ||
|
|
908ac1f61c | ||
|
|
f5c7e7e404 | ||
|
|
001c700b5b | ||
|
|
9b41e9bef0 | ||
|
|
34bd6e32dc | ||
|
|
c5d058490b | ||
|
|
dd1ae6d9a7 | ||
|
|
d8ea9bde82 | ||
|
|
125edc9c90 | ||
|
|
15ea43e394 | ||
|
|
b55b02687c | ||
|
|
da611f0ac6 | ||
|
|
b8b8dfead4 | ||
|
|
4290a3cbd1 | ||
|
|
a5e2203cee | ||
|
|
e28c08b136 | ||
|
|
a4b6846f63 | ||
|
|
2bc8307861 | ||
|
|
9b39917c79 | ||
|
|
57c13cc0a3 | ||
|
|
b7355fd30d | ||
|
|
93ae309e40 | ||
|
|
5d8f8365e2 | ||
|
|
f26909eefb | ||
|
|
55bfbb2797 | ||
|
|
8970b8342a | ||
|
|
5285e699c3 | ||
|
|
275f3860d5 | ||
|
|
a73fdb7478 | ||
|
|
f2d746403a | ||
|
|
b7dbf2c49b | ||
|
|
21f3c97788 | ||
|
|
14b727cc71 | ||
|
|
abee226591 | ||
|
|
293ad39f4b | ||
|
|
9244302581 | ||
|
|
753cac25fb | ||
|
|
0548263e89 | ||
|
|
53776a9bf8 | ||
|
|
cc7def9b76 | ||
|
|
11a4422c25 | ||
|
|
3a44785260 | ||
|
|
e0d430c26c | ||
|
|
417b70020a | ||
|
|
7b29c464b7 | ||
|
|
26d5529d86 | ||
|
|
852103c478 | ||
|
|
26a115421b | ||
|
|
755b941a9a | ||
|
|
fd1ca82d86 | ||
|
|
6fe175344f | ||
|
|
3590cda13a | ||
|
|
2f1011dd85 | ||
|
|
2b155261b3 | ||
|
|
02f4d606d0 | ||
|
|
577811f00b | ||
|
|
b4098d67a3 | ||
|
|
88bd7554ae | ||
|
|
b5ec16c5ca | ||
|
|
68fcb60a14 | ||
|
|
e4781d60ce | ||
|
|
6201fb346a | ||
|
|
f88c8343f9 | ||
|
|
25410d3316 | ||
|
|
4ff9952938 | ||
|
|
5e3f63a412 | ||
|
|
e1f57be69e | ||
|
|
2c65d5eecc | ||
|
|
aa621f2f1e | ||
|
|
ac932c6e59 | ||
|
|
029f79da16 | ||
|
|
153b2b4a7a | ||
|
|
709b2fe4ee | ||
|
|
09c1fccc58 | ||
|
|
fd254d99b7 | ||
|
|
88bd2c1722 | ||
|
|
d03e2f0fc1 | ||
|
|
3f12a393bd | ||
|
|
8c21284c50 | ||
|
|
e7d396c215 | ||
|
|
f238fac0eb | ||
|
|
017228f80d | ||
|
|
286c5fa943 | ||
|
|
74cfc13abe | ||
|
|
0ee4a6c377 | ||
|
|
283433578d | ||
|
|
9559c85057 | ||
|
|
c5c020f565 | ||
|
|
95ec79bceb | ||
|
|
8f8be8aa33 | ||
|
|
5b60c7445a | ||
|
|
d9dbcc8b52 | ||
|
|
79bc525970 | ||
|
|
9dae1091dd | ||
|
|
74d3ac686a | ||
|
|
cf3cc636ba | ||
|
|
a720441e1d | ||
|
|
0a7ed0959d | ||
|
|
eb83c9b86d | ||
|
|
5c0142dd19 | ||
|
|
c326c8dc83 | ||
|
|
fc4082a03f | ||
|
|
c8655565ff | ||
|
|
638f879f16 | ||
|
|
1d221bf7e6 | ||
|
|
60ea71f0ef | ||
|
|
d8bdd35a3f | ||
|
|
7463891c53 | ||
|
|
7537aec76f | ||
|
|
62234e39a8 | ||
|
|
be004b7b3f | ||
|
|
82539444b2 | ||
|
|
a571d3cbaf | ||
|
|
a038c14c23 | ||
|
|
25a85d874c | ||
|
|
884c36ff42 | ||
|
|
b98e72b8b4 | ||
|
|
05885c0096 | ||
|
|
4c9761231a | ||
|
|
656eaa1508 | ||
|
|
1560dcddcf | ||
|
|
08d4cd4870 | ||
|
|
9767a50ced | ||
|
|
cd86890ed1 | ||
|
|
ba0dd3b9ca | ||
|
|
8d7fa07ffd | ||
|
|
cade1bfe6e | ||
|
|
daec4ab0a7 | ||
|
|
3c96bc3196 | ||
|
|
7f7d8d4bd6 | ||
|
|
47263661a4 | ||
|
|
4c42a086d2 | ||
|
|
5d2541a5c4 | ||
|
|
d91d170b49 | ||
|
|
6d1f4584a9 | ||
|
|
1d76d96bcf | ||
|
|
e8847c998c | ||
|
|
da88e49bae | ||
|
|
65c3a12e54 | ||
|
|
d8d600cc36 | ||
|
|
507999b117 | ||
|
|
8ad164eb34 | ||
|
|
a507df140b | ||
|
|
8912a99986 | ||
|
|
1953f98828 | ||
|
|
7515218ddd | ||
|
|
36c1120136 | ||
|
|
8fa0fe64d8 | ||
|
|
c1a8201b14 | ||
|
|
398bbac48c | ||
|
|
ea71a42bbd | ||
|
|
1c16d25b17 | ||
|
|
9d12ded889 | ||
|
|
5312701515 | ||
|
|
808c7bc0a9 | ||
|
|
4d394015f4 | ||
|
|
3638298af8 | ||
|
|
5f00973e40 | ||
|
|
0f6e2c14fc | ||
|
|
51813da619 | ||
|
|
e7751322ea | ||
|
|
26ef298437 | ||
|
|
badaf8ce73 | ||
|
|
b123a62203 | ||
|
|
cfd77e4252 | ||
|
|
38f814072e | ||
|
|
a0db7754e3 | ||
|
|
f07620afc7 | ||
|
|
c1b0d27752 | ||
|
|
430a5108aa | ||
|
|
111ce92fc9 | ||
|
|
c851e8a58d | ||
|
|
39f4bcd9b4 | ||
|
|
4a610c4c81 | ||
|
|
89ee11945d | ||
|
|
dadb09b74a | ||
|
|
1b1f638b97 | ||
|
|
794fc4ed44 | ||
|
|
72f735bf92 | ||
|
|
912877f25a | ||
|
|
2772c5ae43 | ||
|
|
a7ad24d2cb | ||
|
|
a364a6a9fa | ||
|
|
7b2dc86a8d | ||
|
|
ad645636d0 | ||
|
|
2f2f297b29 | ||
|
|
099ae3fde0 | ||
|
|
e9febe98ac | ||
|
|
5fbd07cccf | ||
|
|
5fed4698c2 | ||
|
|
ed7eb0983a | ||
|
|
90c7e18e5f | ||
|
|
953ab5c3bd | ||
|
|
699c97d8a0 | ||
|
|
e4ca0de92a | ||
|
|
04745a36b8 | ||
|
|
5936940532 | ||
|
|
b3eb064b67 | ||
|
|
e4b41057e3 | ||
|
|
1d41c46cc7 | ||
|
|
a5c444587b | ||
|
|
a56f471be9 | ||
|
|
6a6b26ed8d | ||
|
|
f62446c152 | ||
|
|
56011f1f17 | ||
|
|
6d44091c80 | ||
|
|
440c458eb4 | ||
|
|
798250af61 | ||
|
|
c762de29c6 | ||
|
|
0701e65e97 | ||
|
|
209d54e8b5 | ||
|
|
2b38462de7 | ||
|
|
1e8e553316 | ||
|
|
ab42e6bb15 | ||
|
|
6802884540 | ||
|
|
7cb8577b96 | ||
|
|
55810ccd1f | ||
|
|
f9921720cd | ||
|
|
cda1ebd271 | ||
|
|
6901e4a23a | ||
|
|
6bc21d3c73 | ||
|
|
1ef231e26a | ||
|
|
3cd43f0f98 | ||
|
|
1565019966 | ||
|
|
0a4de2d3a1 | ||
|
|
a058f6c174 | ||
|
|
d8e5d03b01 | ||
|
|
9dc62eff2e | ||
|
|
d4fea17c57 | ||
|
|
3dd7a5b77e | ||
|
|
d77c90a3ba | ||
|
|
01f0c20df0 | ||
|
|
aafbe576b3 | ||
|
|
bd68ad4034 | ||
|
|
bfee017c13 | ||
|
|
61f532cfd0 | ||
|
|
58dbbb75b6 | ||
|
|
8d88b91fcf | ||
|
|
ad39fc6029 | ||
|
|
89f1fd96e6 | ||
|
|
bd425f2493 | ||
|
|
46962ff02a | ||
|
|
e4cb88b051 | ||
|
|
32840703dc | ||
|
|
1f7aafd041 | ||
|
|
7378d5dce4 | ||
|
|
84f76866cd | ||
|
|
322da9ea6a | ||
|
|
58645301ec | ||
|
|
1e18dd30a8 | ||
|
|
cc6a19adcc | ||
|
|
2a5588b177 | ||
|
|
20f9b7f88b | ||
|
|
d7e32313cd | ||
|
|
fb5654d3c4 | ||
|
|
258f1433b3 | ||
|
|
fb723ae8bd | ||
|
|
283b89e37c | ||
|
|
f450f9eb8b | ||
|
|
b3f8cf99a4 | ||
|
|
4301ea8cae | ||
|
|
c672d1c174 | ||
|
|
229e953a38 | ||
|
|
87b506dc9b | ||
|
|
15c9002d9e | ||
|
|
042aaa61b9 | ||
|
|
ef856c6ba5 | ||
|
|
9cf5be73e3 | ||
|
|
63fc149e2a | ||
|
|
3c25839350 | ||
|
|
58246e33b7 | ||
|
|
8b1407c706 | ||
|
|
2fde4a4e22 | ||
|
|
60b9e97982 | ||
|
|
0adac79c0f | ||
|
|
9f485b5981 | ||
|
|
db17d21b8f | ||
|
|
996d394e89 | ||
|
|
5885b960f9 | ||
|
|
79987b35f3 | ||
|
|
661b3ef311 | ||
|
|
fb422726a8 | ||
|
|
4fb6f3ea59 | ||
|
|
f78fe771e1 | ||
|
|
567b887253 | ||
|
|
e516e6b946 | ||
|
|
62748676aa | ||
|
|
7351c72e45 | ||
|
|
2b7405c5e2 | ||
|
|
e2c77cb935 | ||
|
|
7ac621e4c9 | ||
|
|
d8b5d6c66c | ||
|
|
22b461eb4b | ||
|
|
b37ee8555a | ||
|
|
1d0ad2f045 | ||
|
|
ceccfb2c81 | ||
|
|
03c02953cd | ||
|
|
f254a0eaa1 | ||
|
|
9e3b88727c | ||
|
|
b12217466e | ||
|
|
8b9c932f9b | ||
|
|
5986ce03db | ||
|
|
a7b0e936e4 | ||
|
|
cb02211424 | ||
|
|
bd443bf392 | ||
|
|
1f547edd36 | ||
|
|
e4bac3a493 | ||
|
|
5e6bfa681a | ||
|
|
276160125e | ||
|
|
d4ae5543f2 | ||
|
|
55f360e267 | ||
|
|
fdedab2a0c | ||
|
|
a9be42e303 | ||
|
|
6da9510e46 | ||
|
|
0431798178 | ||
|
|
62432f3c48 | ||
|
|
9fbbc30906 | ||
|
|
d1567d1f62 | ||
|
|
6ca1f5970b | ||
|
|
1c880b9e24 | ||
|
|
3b7d54c720 | ||
|
|
44a7406057 | ||
|
|
8157dcfdb1 | ||
|
|
28762aea15 | ||
|
|
439871ea9f | ||
|
|
c9180b005c | ||
|
|
b14e0725f8 | ||
|
|
70fe3dcb4d | ||
|
|
8c554604a4 | ||
|
|
a0a35454bd | ||
|
|
e8467e2af5 | ||
|
|
7515deb566 | ||
|
|
ed9e52af24 | ||
|
|
592a380410 | ||
|
|
1a458d2d5b | ||
|
|
0e4cf53b92 | ||
|
|
e2f06ccb33 | ||
|
|
8abff004cd | ||
|
|
c4a0e2e3fe | ||
|
|
4f10f79c73 | ||
|
|
69e7a560fd | ||
|
|
59b1055808 | ||
|
|
6ed48c6289 | ||
|
|
f2fb4d3f41 | ||
|
|
6aeea59ea8 | ||
|
|
d016f3bbb3 | ||
|
|
7131c29718 | ||
|
|
7432442983 | ||
|
|
5344883394 | ||
|
|
3fcd2f6c2e | ||
|
|
f3d84bd5bf | ||
|
|
549780c232 | ||
|
|
2a6da69b82 | ||
|
|
5c538816cf | ||
|
|
7b8b378a7d | ||
|
|
e30a75e25c | ||
|
|
85ad5cfd0b | ||
|
|
88b9d5068c | ||
|
|
f8c4948a09 | ||
|
|
412322447f | ||
|
|
d4f289e40f | ||
|
|
e1f3feb8f5 | ||
|
|
37d3bc699c | ||
|
|
672fd18016 | ||
|
|
bc2c23a2a0 | ||
|
|
865f7e7812 | ||
|
|
720212b552 | ||
|
|
d3be61f608 | ||
|
|
13418b16b8 | ||
|
|
42d2017cd6 | ||
|
|
4345e76ead | ||
|
|
741431322b | ||
|
|
980beaaf41 | ||
|
|
2205034e09 | ||
|
|
82b9c87a66 | ||
|
|
dda517a937 | ||
|
|
4e6d283b9e | ||
|
|
55acab05aa | ||
|
|
ed38a18d23 | ||
|
|
95b3c11203 | ||
|
|
dce318f4fd | ||
|
|
85127f0fb8 | ||
|
|
fb45058244 | ||
|
|
45bb5ae389 | ||
|
|
339238ab36 | ||
|
|
032cda8b3d | ||
|
|
6badd3fb1e | ||
|
|
724d825745 | ||
|
|
ff1e32ad2e | ||
|
|
a5f97febd3 | ||
|
|
5baa6cc865 | ||
|
|
7a4f30b843 | ||
|
|
b2c385dc4f | ||
|
|
5d5da8d33f | ||
|
|
e604571578 | ||
|
|
f9dacc3f95 | ||
|
|
6086920332 | ||
|
|
f52f3163bc | ||
|
|
d18ff73e88 | ||
|
|
1e5d602cae | ||
|
|
12912521ec | ||
|
|
842ea3a94b | ||
|
|
a8560dbc15 | ||
|
|
a65e27540a | ||
|
|
c3c5ed11e6 | ||
|
|
ce24149335 | ||
|
|
0314ca8c48 | ||
|
|
ebd8ee49a9 | ||
|
|
38d10c9781 | ||
|
|
360106c24d | ||
|
|
ca470a5d02 | ||
|
|
57f66e6b1d | ||
|
|
e774f67924 | ||
|
|
ac10e576c1 | ||
|
|
bcae0a99cd | ||
|
|
c73c2ff879 | ||
|
|
c39b1a3356 | ||
|
|
125dc2d9e0 | ||
|
|
b7d4ddc7ce | ||
|
|
f5e546c6fa | ||
|
|
928e39cd10 | ||
|
|
d0b7ea68a0 | ||
|
|
8444690133 | ||
|
|
c03c42d767 | ||
|
|
ab67688a00 | ||
|
|
5dcb7166da | ||
|
|
14697b86d7 | ||
|
|
4f4b6276d4 | ||
|
|
7bc497e129 | ||
|
|
68a37a6a5a | ||
|
|
6f5cd1d7c5 | ||
|
|
126b1b121c | ||
|
|
2341e456a0 | ||
|
|
72d80e95bb | ||
|
|
f5ec82440c | ||
|
|
c8e526ead3 | ||
|
|
066adfb764 | ||
|
|
5b444d4717 | ||
|
|
69c95adc8d | ||
|
|
2b0e0d8f5c | ||
|
|
778d1bacbf | ||
|
|
7e1b041016 | ||
|
|
313b9b329c | ||
|
|
6830062256 | ||
|
|
323072c982 | ||
|
|
8719d96bdd | ||
|
|
dd5d318ab5 | ||
|
|
d6dc7f5e65 | ||
|
|
c203664eb5 | ||
|
|
19ecf1fa19 | ||
|
|
b8deb0426c | ||
|
|
3b8371f020 | ||
|
|
20bb1cdf39 | ||
|
|
301daa48d0 | ||
|
|
8421ec8803 | ||
|
|
74211eb012 | ||
|
|
60bd42f298 | ||
|
|
14bdd74526 | ||
|
|
fb0f3eda04 | ||
|
|
91ee6e6701 | ||
|
|
51f4e6927c | ||
|
|
94988d8667 | ||
|
|
fe36f5a98c | ||
|
|
f9eb18b927 | ||
|
|
cc60f36748 | ||
|
|
604ade791f | ||
|
|
690ac52a91 | ||
|
|
34ed772775 | ||
|
|
d5ab95571f | ||
|
|
ffb3a0ee5f | ||
|
|
94b12b57aa | ||
|
|
6d149e8457 | ||
|
|
1ad89c90d8 | ||
|
|
fb71c7b020 | ||
|
|
28ed17ad3b | ||
|
|
0c2a4e2bf7 | ||
|
|
62bec30de2 | ||
|
|
3fced77e4e | ||
|
|
a09d1d8b76 | ||
|
|
8f4243fbd8 | ||
|
|
47aaf20549 | ||
|
|
0c5289ea50 | ||
|
|
3e53323514 | ||
|
|
a5ee9861b9 | ||
|
|
feb8ca7654 | ||
|
|
a7abe4473b | ||
|
|
780b9b61de | ||
|
|
19ace36ffa | ||
|
|
5fff8afc9f | ||
|
|
4ad230c927 | ||
|
|
dd98eb1ec8 | ||
|
|
c6baf42e72 | ||
|
|
e2bac97d56 | ||
|
|
d112ee94d0 | ||
|
|
27b21b2faf | ||
|
|
8c96d5cd20 | ||
|
|
c29ed3fd69 | ||
|
|
cedf603f12 | ||
|
|
279161c36f | ||
|
|
ce0b43d919 | ||
|
|
ddafa5bf06 | ||
|
|
bc7116c31b | ||
|
|
53b7092721 | ||
|
|
beb9174b1b | ||
|
|
aea41ed341 | ||
|
|
d789494cb1 | ||
|
|
608e7b4cff | ||
|
|
4ee199c02a | ||
|
|
fbf47d4085 | ||
|
|
5a238e4b42 | ||
|
|
f852b8246a | ||
|
|
88140d929a | ||
|
|
45f7268240 | ||
|
|
3a3c8e4d4a | ||
|
|
c1ac183a04 | ||
|
|
18bb779ee5 | ||
|
|
8b6612fe79 | ||
|
|
fde0bc8534 | ||
|
|
e661a78939 | ||
|
|
847e346602 | ||
|
|
b969751688 | ||
|
|
ad6f2ba03a | ||
|
|
63c6a5edc0 | ||
|
|
9f4cf9dd5e | ||
|
|
51331b6dc0 | ||
|
|
efb6761033 | ||
|
|
6a4f737a0f | ||
|
|
be6864b778 | ||
|
|
de3b91a36c | ||
|
|
ef5482c3b5 | ||
|
|
d20b795137 | ||
|
|
8a134065df | ||
|
|
22aee1bfa4 | ||
|
|
b282820fd6 | ||
|
|
3ee098306d | ||
|
|
09e8f379a6 | ||
|
|
69018cdb3a | ||
|
|
d0d7254c6a | ||
|
|
cc0f0971d7 | ||
|
|
2af61730f0 | ||
|
|
83f41b83dc | ||
|
|
1fb84fce88 | ||
|
|
a8837e1244 | ||
|
|
04d2eec558 | ||
|
|
1b57ec92f0 | ||
|
|
4d88595404 | ||
|
|
52b1272a3a | ||
|
|
d2ccad6a83 | ||
|
|
cad6dde4ac | ||
|
|
06811c3539 | ||
|
|
0cb23c2b21 | ||
|
|
ac4688dca2 | ||
|
|
326c3b4670 | ||
|
|
9b29d0c268 | ||
|
|
e0013c3871 | ||
|
|
a75744075b | ||
|
|
525aec1a02 | ||
|
|
0bf9a7a072 | ||
|
|
d8f2f4c95b | ||
|
|
35d733b44f | ||
|
|
9179b4175c | ||
|
|
bb07d78c78 | ||
|
|
07b179cd7f | ||
|
|
054422d837 | ||
|
|
3e052d1810 | ||
|
|
c8e72805cf | ||
|
|
12a80e7db0 | ||
|
|
ee7ff9a09d | ||
|
|
f6478fb636 | ||
|
|
811a0b0495 | ||
|
|
aeb48edf72 | ||
|
|
b1e94f0df7 | ||
|
|
60050e3c0f | ||
|
|
39ef09aa5b | ||
|
|
8377d43116 | ||
|
|
54e4c447ab | ||
|
|
937a9fa9cf | ||
|
|
808ff6cf0e | ||
|
|
7f5c649a95 | ||
|
|
b72727dec9 | ||
|
|
3fc88bfb33 | ||
|
|
9f2279d586 | ||
|
|
346a14cb9b | ||
|
|
dac00d17ff | ||
|
|
9ca7cd4060 | ||
|
|
aa31628970 | ||
|
|
bed694fcf5 | ||
|
|
4b4af69fa1 | ||
|
|
9d96190a5b | ||
|
|
fa44d48c09 | ||
|
|
4ef961c278 | ||
|
|
292a837d5c | ||
|
|
aa7b915d84 | ||
|
|
c46fe73236 | ||
|
|
039b2c129c | ||
|
|
8f2e5e4808 | ||
|
|
c4da8e4f78 | ||
|
|
bcab9078a4 | ||
|
|
b3c6c1ea92 | ||
|
|
a3af8662bd | ||
|
|
35940d0bc8 | ||
|
|
26994cdcb7 | ||
|
|
017159a829 | ||
|
|
b4e9c85e08 | ||
|
|
189146cd84 | ||
|
|
af34153ffa | ||
|
|
bf2ff3ffbb | ||
|
|
6423c9efd6 | ||
|
|
58ab0d4ece | ||
|
|
83a738bf4d | ||
|
|
3640671fc6 | ||
|
|
1da623b30e | ||
|
|
b10ca64646 | ||
|
|
2128763ee6 | ||
|
|
a27e7ed39c | ||
|
|
f07b7eaa47 | ||
|
|
6ce18de84c | ||
|
|
8631b756e7 | ||
|
|
7414d98412 | ||
|
|
d7b19892e8 | ||
|
|
96df396eaf | ||
|
|
2f6f640317 | ||
|
|
c4a0a50f3a | ||
|
|
658f8a3842 | ||
|
|
bfb876a1e3 | ||
|
|
90c34b1f4e | ||
|
|
3f9164ea77 | ||
|
|
7fd6fecbf5 | ||
|
|
8029f72363 | ||
|
|
c7fdce5d3b | ||
|
|
84f48aa369 | ||
|
|
2e9a0a9c12 | ||
|
|
c1f6f2b950 | ||
|
|
ede21bca13 | ||
|
|
8dd9a9f9cb | ||
|
|
04f92cd133 | ||
|
|
8be8d2393b | ||
|
|
0a879681be | ||
|
|
2ca1587a49 | ||
|
|
ec2cd2d708 | ||
|
|
5d0dbece93 | ||
|
|
df1e4b414b | ||
|
|
40760991e7 | ||
|
|
464f5f86cf | ||
|
|
7b09e9fccd | ||
|
|
6cba7d4298 | ||
|
|
9730f62e49 | ||
|
|
e0c1c87f54 | ||
|
|
931b3d2b83 | ||
|
|
e5d561baee | ||
|
|
2867593e7a | ||
|
|
dd52fee563 | ||
|
|
8e1f885827 | ||
|
|
2d39a58f90 | ||
|
|
9c4fa2ae26 | ||
|
|
de52d84e82 | ||
|
|
ce9b55059a | ||
|
|
bcd370a6a0 | ||
|
|
c8216850ab | ||
|
|
f5feedb90b | ||
|
|
a4371cd187 | ||
|
|
9d5ba4c834 | ||
|
|
1639dee1bb | ||
|
|
9363f430f2 | ||
|
|
9192a09073 | ||
|
|
b915eb9755 | ||
|
|
1cfcc2b592 | ||
|
|
7138dd02b7 | ||
|
|
b4276643b7 | ||
|
|
2ef00763bf | ||
|
|
54364928fc | ||
|
|
09b3b4932b | ||
|
|
29d6670119 | ||
|
|
2f654b5f1a | ||
|
|
e53b9f5992 | ||
|
|
addb234e61 | ||
|
|
76eca3b659 | ||
|
|
f90dec4c0e | ||
|
|
8900a59d4c | ||
|
|
6685138200 | ||
|
|
4d3e65b980 | ||
|
|
e9282bb546 | ||
|
|
f5627a4594 | ||
|
|
81ffdb2510 | ||
|
|
4c00a99850 | ||
|
|
2bfcb45b28 | ||
|
|
ab0c10e791 | ||
|
|
2c1935115d | ||
|
|
d98e43dc78 | ||
|
|
9348988d64 | ||
|
|
1285c66467 | ||
|
|
b7191bbc13 | ||
|
|
98b97509f7 | ||
|
|
2b2b570490 | ||
|
|
cce2d1ff29 | ||
|
|
b79600c572 | ||
|
|
140f1a8543 | ||
|
|
e34657cfde | ||
|
|
99070fa607 | ||
|
|
2b46785b1f | ||
|
|
c72562524b | ||
|
|
b7dd6441c7 | ||
|
|
31fcc2f755 | ||
|
|
b391aa14bc | ||
|
|
d3c45debbb | ||
|
|
5b08469b87 | ||
|
|
4a77ec63a4 | ||
|
|
d13606b6dc | ||
|
|
05291c93bb | ||
|
|
8cf00a208e | ||
|
|
06d73c8876 | ||
|
|
649c646ea2 | ||
|
|
b7756d9250 | ||
|
|
1cd2cd954c | ||
|
|
72020b8da9 | ||
|
|
cf9720b749 | ||
|
|
967b9db7f9 | ||
|
|
bb3acb1182 | ||
|
|
560c7f7e6d | ||
|
|
79b2841764 | ||
|
|
a06a89cbd1 | ||
|
|
431bd969eb | ||
|
|
c87b722aec | ||
|
|
3688b8b014 | ||
|
|
07b8d9e0c0 | ||
|
|
7454b53e39 | ||
|
|
3d6a76024d | ||
|
|
421b980957 | ||
|
|
4a22e27d6a | ||
|
|
99f7842dee | ||
|
|
7f869b4b18 | ||
|
|
9665f4ee84 | ||
|
|
606904d48b | ||
|
|
3f5279b97c | ||
|
|
f5ec21e6ac | ||
|
|
578a284465 | ||
|
|
422e392d9d | ||
|
|
54dfffd34a | ||
|
|
cffba64d2b | ||
|
|
56a0c12a59 | ||
|
|
c174d3de18 | ||
|
|
a9c59ef9fc | ||
|
|
abdb9b2673 | ||
|
|
548aaab626 | ||
|
|
20571c87ae | ||
|
|
19e49200de | ||
|
|
d32f5c67a9 | ||
|
|
b83b626435 | ||
|
|
ab2c1b25ec | ||
|
|
f2d46313a4 | ||
|
|
87e4796a6c | ||
|
|
0014a5c2f4 | ||
|
|
7af56e0dad | ||
|
|
a5ae6e3c01 | ||
|
|
fe1a0d1faf | ||
|
|
302f05cdda | ||
|
|
c0044be7b0 | ||
|
|
0110078807 | ||
|
|
42eacb45f8 | ||
|
|
a43e2e1991 | ||
|
|
c8b721d4f6 | ||
|
|
d0bfddc3d9 | ||
|
|
6b925a16c8 | ||
|
|
89ebd9fc22 | ||
|
|
6b4ba66231 | ||
|
|
5b697dc381 | ||
|
|
9ba73c95d1 | ||
|
|
93aa390447 | ||
|
|
3cfb8945dd | ||
|
|
cd8d38f2a1 | ||
|
|
8ec8cd6294 | ||
|
|
c028113561 | ||
|
|
5f22e1c803 | ||
|
|
d3351787e5 | ||
|
|
e5bea9ae3b | ||
|
|
93c710abe9 | ||
|
|
c29e7cfe5c | ||
|
|
cb5c1ba00d | ||
|
|
9a012b94e1 | ||
|
|
400f5a44ec | ||
|
|
a2ab5bab91 | ||
|
|
fc8ab27361 | ||
|
|
59f19d33a5 | ||
|
|
dfc9618115 | ||
|
|
8e02e5c75a | ||
|
|
970493ab93 | ||
|
|
64d78956eb | ||
|
|
40c05346f4 | ||
|
|
e9b0bc1409 | ||
|
|
798e6bb7d9 | ||
|
|
12a370deed | ||
|
|
553bfbe1a0 | ||
|
|
52494321fc | ||
|
|
c6c9e06496 | ||
|
|
e3a6c05a58 | ||
|
|
391d06f68d | ||
|
|
99804ea06e | ||
|
|
51935deb2a | ||
|
|
b24d0c3a47 | ||
|
|
762a886d6f | ||
|
|
2c3e9ddfe4 | ||
|
|
c7cd2b63c8 | ||
|
|
f0528ea831 | ||
|
|
5bc5596f60 | ||
|
|
2c27ac46be | ||
|
|
caad840153 | ||
|
|
65bd7e2904 | ||
|
|
c3d7d7db12 | ||
|
|
5605310362 | ||
|
|
17b6efe82e | ||
|
|
a032ae56ae | ||
|
|
eab2f4b056 | ||
|
|
aff86ae6c7 | ||
|
|
7ece9ddc1a | ||
|
|
7cd048e839 | ||
|
|
1e22f610a3 | ||
|
|
5249c972ae | ||
|
|
fd45f856a0 | ||
|
|
c8ab40cd33 | ||
|
|
b2c872925b | ||
|
|
f48e229202 | ||
|
|
799fec92c3 | ||
|
|
87a41c2fca | ||
|
|
7f85de0c46 | ||
|
|
13661b1993 | ||
|
|
51d5c3892d | ||
|
|
e4eab4641a | ||
|
|
9b148e0ba3 | ||
|
|
de28932650 | ||
|
|
5f798d603e | ||
|
|
a0757b2dd3 | ||
|
|
498d51b4e8 | ||
|
|
b06b6bae3f | ||
|
|
b5eaff2137 | ||
|
|
c01bcd3734 | ||
|
|
d75c4068ca | ||
|
|
6aa2d5a3d2 | ||
|
|
065276805f | ||
|
|
a63408c8cf | ||
|
|
69576f6bfa | ||
|
|
19845624e2 | ||
|
|
22ff2964e9 | ||
|
|
d96b3a65a9 | ||
|
|
4989445ef4 | ||
|
|
6770892acd | ||
|
|
d4eba8740f | ||
|
|
9f60760560 | ||
|
|
0a8f8ac934 | ||
|
|
6ae24c8244 | ||
|
|
d3679082a8 | ||
|
|
fb08b42dca | ||
|
|
4aeaa9f42a | ||
|
|
5f5693da04 | ||
|
|
5eb0f61727 | ||
|
|
958e998991 | ||
|
|
b78c1509f6 | ||
|
|
ce184d4d57 | ||
|
|
b4c3714ced | ||
|
|
5b7dfa0438 | ||
|
|
391a388476 | ||
|
|
d9c4e2ed4c | ||
|
|
0c42db38b1 | ||
|
|
2f9be8bf33 | ||
|
|
e8c00155e8 | ||
|
|
cc88fdd9ee | ||
|
|
d9de11ef1d | ||
|
|
0ceda97d09 | ||
|
|
d0dec92ba8 | ||
|
|
d420c008d8 | ||
|
|
f0b32db433 | ||
|
|
bc838eda59 | ||
|
|
afe55b6af0 | ||
|
|
dd3a3ac302 | ||
|
|
f9982a7947 | ||
|
|
07c1be9e9a | ||
|
|
f832b88755 | ||
|
|
0fac757efc | ||
|
|
fc15742065 | ||
|
|
6f2466a131 | ||
|
|
4b90e22f0a | ||
|
|
c493568785 | ||
|
|
1cdf004b77 | ||
|
|
a4ea504261 | ||
|
|
4c2c234c3b | ||
|
|
3d4c0f3e89 | ||
|
|
52fad02903 | ||
|
|
9dcabc057c | ||
|
|
db8c1079dd | ||
|
|
8f954673ab | ||
|
|
79522d1c7d | ||
|
|
a18bf03079 | ||
|
|
c02b6b5d82 | ||
|
|
f99b423284 | ||
|
|
d7d9d45d4f | ||
|
|
90065ec0cd | ||
|
|
51157ebb86 | ||
|
|
96d95c79ca | ||
|
|
e5da34c233 | ||
|
|
f09d657f77 | ||
|
|
0f4b0189f5 | ||
|
|
4666042abb | ||
|
|
027d544c2b | ||
|
|
f1967d0138 | ||
|
|
c1d896027d | ||
|
|
5c2d2a6618 | ||
|
|
997b269b0b | ||
|
|
61257e7525 | ||
|
|
53ee2c3631 | ||
|
|
8bfa0bddec | ||
|
|
ad61e6bc81 | ||
|
|
873b5ba8ac | ||
|
|
6ae50054e2 | ||
|
|
22a35f41bf | ||
|
|
961696c963 | ||
|
|
c7b7f1a5dc | ||
|
|
b5a0d650b1 | ||
|
|
573b279464 | ||
|
|
116e07f161 | ||
|
|
964868c8af | ||
|
|
c8dac32df8 | ||
|
|
72a0016bd8 | ||
|
|
2ad3167434 | ||
|
|
ddabfaa05c | ||
|
|
f857523ca7 | ||
|
|
00d53858e8 | ||
|
|
c008167e66 | ||
|
|
102344a041 | ||
|
|
c865298ef3 | ||
|
|
6ac03faf93 | ||
|
|
49c2701743 | ||
|
|
d1a271b08e | ||
|
|
7388ad19b9 | ||
|
|
2e63cb5fad | ||
|
|
e7f14d02b1 | ||
|
|
873771d05a | ||
|
|
d7de122e36 | ||
|
|
4ef0434f53 | ||
|
|
1aa2c99259 | ||
|
|
c2450b27b0 | ||
|
|
14d6d8b84f | ||
|
|
f0e3846c03 | ||
|
|
6ba64f1128 | ||
|
|
13bcdbc6c9 | ||
|
|
cfba62db20 | ||
|
|
18fb69e36e | ||
|
|
474eb0f3fd | ||
|
|
7f47b53370 | ||
|
|
dc2907d3ce | ||
|
|
1af85811e0 | ||
|
|
1c1b19a478 | ||
|
|
66942d64ba | ||
|
|
2fb6ae08d7 | ||
|
|
bf8811e03e | ||
|
|
c8b502c571 | ||
|
|
81c11a975c | ||
|
|
0d370eb403 | ||
|
|
7492c3f1e3 | ||
|
|
515a8a84b7 | ||
|
|
dd6680efb2 | ||
|
|
a7158373cd | ||
|
|
6d50ec7199 | ||
|
|
95dbf98e8e | ||
|
|
d49323e4eb | ||
|
|
08c1e2aec9 | ||
|
|
a2c137df2e | ||
|
|
fe27dcdb8f | ||
|
|
028e136161 | ||
|
|
9a85a0a4d5 | ||
|
|
3a1cbc4d50 | ||
|
|
77d334f7f3 | ||
|
|
53cdf863ac | ||
|
|
7b7e7fe0fe | ||
|
|
0c03132847 | ||
|
|
3b81f7e2a1 | ||
|
|
3d76437b43 | ||
|
|
4bc54c78ce | ||
|
|
3d303a96b9 | ||
|
|
33c99d031d | ||
|
|
caf7e9f69a | ||
|
|
9449f1f5d5 | ||
|
|
6bad164b5e | ||
|
|
bb5ba7ddb1 | ||
|
|
8b2e01d540 | ||
|
|
ff1159b1de | ||
|
|
a2fd3202a0 | ||
|
|
7b53715b91 | ||
|
|
e05fc0a510 | ||
|
|
43604c33f6 | ||
|
|
eb67c484ff | ||
|
|
a7b7bdd467 | ||
|
|
ab06989a18 | ||
|
|
657b722f94 | ||
|
|
dd2aecad27 | ||
|
|
c82c5c5c64 | ||
|
|
a1761cd68f | ||
|
|
d618a7f583 | ||
|
|
831a42f660 | ||
|
|
3b36022e5a | ||
|
|
d01dfa25f1 | ||
|
|
395a99037b | ||
|
|
025986c51d | ||
|
|
c56b83093f | ||
|
|
7c712a4133 | ||
|
|
9a0cfe6dfa | ||
|
|
a116cdbcec | ||
|
|
f2d616c98e | ||
|
|
42cbd1777d | ||
|
|
ebf375aac0 | ||
|
|
1f9050267e | ||
|
|
d7f9707a15 | ||
|
|
ab589ee3ed | ||
|
|
c84ec0361f | ||
|
|
47d2f8968a | ||
|
|
019c480bcc | ||
|
|
547c6d3d59 | ||
|
|
b5ebf8b76a | ||
|
|
c690e328f2 | ||
|
|
cbb92c1a95 | ||
|
|
beb41997c9 | ||
|
|
755a6faf11 | ||
|
|
021f8350a3 | ||
|
|
76583dcd2f | ||
|
|
bf033239a7 | ||
|
|
eb37fccd37 | ||
|
|
d04ad45331 | ||
|
|
db157b8ca7 | ||
|
|
68f277bb20 | ||
|
|
4de8f42664 | ||
|
|
4f11855935 | ||
|
|
2b9a5fcc32 | ||
|
|
224948d1f2 | ||
|
|
36f2812d5a | ||
|
|
be06aa2b31 | ||
|
|
41f8e3aba2 | ||
|
|
093c0df897 | ||
|
|
37afc7dc8a | ||
|
|
efbf354960 | ||
|
|
5e39fe0d80 | ||
|
|
47328dc659 | ||
|
|
addeef50ba | ||
|
|
ad338cc5b5 | ||
|
|
202bc8201e | ||
|
|
5ff99de405 | ||
|
|
86ebe2cf9c | ||
|
|
facf0b399c | ||
|
|
33db7b0bcb | ||
|
|
663d07bca1 | ||
|
|
ba04e4997f | ||
|
|
c4fee1b658 | ||
|
|
99b92a15bb | ||
|
|
b076ab5b57 | ||
|
|
687759f75d | ||
|
|
9eaac7f3af | ||
|
|
4c24e00cfc | ||
|
|
beb17011b0 | ||
|
|
e882bf55bc | ||
|
|
3a3016adb6 | ||
|
|
1e8b68153a | ||
|
|
9335cf65fb | ||
|
|
83f35256ae | ||
|
|
4283333948 | ||
|
|
b8f902796b | ||
|
|
8f99ab295c | ||
|
|
882310e268 | ||
|
|
56bce95214 | ||
|
|
c13ecbec29 | ||
|
|
0ffaaa6e73 | ||
|
|
75eff3adea | ||
|
|
bf5f80476c | ||
|
|
9aaf0fbb2f | ||
|
|
8f01ef7953 | ||
|
|
da1d087452 | ||
|
|
e16bc7e882 | ||
|
|
fe9bdd4811 | ||
|
|
17b6f3f6d6 | ||
|
|
90a6baf0ee | ||
|
|
f0e73d0e72 | ||
|
|
a762882f1c | ||
|
|
4c1bc59236 | ||
|
|
f2962083f8 | ||
|
|
a0b22a5bcf | ||
|
|
dcf393354c | ||
|
|
5f771656e3 | ||
|
|
f376aab793 | ||
|
|
3c96464217 | ||
|
|
c9892833a1 | ||
|
|
127c98affc | ||
|
|
8687a772f5 | ||
|
|
b1162b14d4 | ||
|
|
8a8ee35707 | ||
|
|
5e109a3665 | ||
|
|
11db478430 | ||
|
|
a85377014d | ||
|
|
3aea86234d | ||
|
|
916ec6ed6b | ||
|
|
9dca6ba539 | ||
|
|
0ebb89f561 | ||
|
|
e237867e24 | ||
|
|
78fa44fd9a | ||
|
|
d615fa3b93 | ||
|
|
ce134dc332 | ||
|
|
a56e4dc752 | ||
|
|
d221b4aa29 | ||
|
|
d2cba6ad2f | ||
|
|
84b3c30b52 | ||
|
|
68eeec19a8 | ||
|
|
c6d1528a2e | ||
|
|
50a6b256b8 | ||
|
|
bbba1fe477 | ||
|
|
46b827da6b | ||
|
|
5e8c28a30a | ||
|
|
e5d3903164 | ||
|
|
23975c9c9e | ||
|
|
1e0dab8355 | ||
|
|
5f4c10ffd5 | ||
|
|
6f3d2b4b56 | ||
|
|
fea8ace844 | ||
|
|
6633d9262c | ||
|
|
7d54137140 | ||
|
|
2fcda6f248 | ||
|
|
9c1b8bacf9 | ||
|
|
4867655eb2 | ||
|
|
47410d1a95 | ||
|
|
5fa49f5e67 | ||
|
|
36c53827fa | ||
|
|
51631aef5b | ||
|
|
a0298ac8a3 | ||
|
|
98c0188821 | ||
|
|
ab1dabe3e4 | ||
|
|
94bdb11fdf | ||
|
|
b6727d68ba | ||
|
|
89bad7fc2b | ||
|
|
c0b8b810a2 | ||
|
|
31eb65acd1 | ||
|
|
513bbeb464 | ||
|
|
3a52fb725a | ||
|
|
5affd44499 | ||
|
|
5dbc6e806c | ||
|
|
59ae31f3f3 | ||
|
|
230e921c2e | ||
|
|
a7c3d88b08 | ||
|
|
9b453bcb84 | ||
|
|
ce43c782f6 | ||
|
|
cb16faaf4d | ||
|
|
3f1d3ff6d8 | ||
|
|
6f67eecd5e | ||
|
|
e75c819190 | ||
|
|
601e68d104 | ||
|
|
8285ecfd1e | ||
|
|
8726de902e | ||
|
|
4133585274 | ||
|
|
ad913b1417 | ||
|
|
7113e5a844 | ||
|
|
a3a8369dc0 | ||
|
|
64016b8ef0 | ||
|
|
1cb49d60c8 | ||
|
|
c858adfd12 | ||
|
|
08d68327c7 | ||
|
|
0d7c6c5664 | ||
|
|
8bfa41dbf4 | ||
|
|
7e2fa48ed4 | ||
|
|
340635cad5 | ||
|
|
8f77d1de09 | ||
|
|
7dcf1b25ff | ||
|
|
9b73538106 | ||
|
|
3bf8c8c6db | ||
|
|
04a1ff2ca7 | ||
|
|
64647d230a | ||
|
|
c2a67e1b70 | ||
|
|
edb9a7c76e | ||
|
|
a407f5b678 | ||
|
|
e5b4987acb | ||
|
|
ba8cc18eeb | ||
|
|
d2c7316e00 | ||
|
|
609aa14d24 | ||
|
|
ef1ad4c700 | ||
|
|
a0e2732152 | ||
|
|
9b5d3e3be1 | ||
|
|
2663ef31fb | ||
|
|
a4cdd3378e | ||
|
|
2f805da24d | ||
|
|
79152a946d | ||
|
|
de37bb37d0 | ||
|
|
f783e44e5c | ||
|
|
af82f2c991 | ||
|
|
46774daf9d | ||
|
|
648306b785 | ||
|
|
b7a4f205b8 | ||
|
|
fdb168b43a | ||
|
|
b6f65c93c4 | ||
|
|
3f4838f17a | ||
|
|
eef0dee2aa | ||
|
|
e17388d3b2 | ||
|
|
7e6a1bc719 | ||
|
|
37738a2ea2 | ||
|
|
c5834a57db | ||
|
|
91b9373f38 | ||
|
|
ce0bb5b816 | ||
|
|
f330ff0eff | ||
|
|
4b02700414 | ||
|
|
ee30180376 | ||
|
|
338e0ff15c | ||
|
|
3ac75305df | ||
|
|
3bdcf44afb | ||
|
|
e3f4ffede5 | ||
|
|
f0c8725d43 | ||
|
|
5473bc4eb6 | ||
|
|
b9bd9422bf | ||
|
|
cb5729a070 | ||
|
|
f0b1ab4233 | ||
|
|
b15386e849 | ||
|
|
d2a2c8da35 | ||
|
|
7251548cbb | ||
|
|
146e29f7cb | ||
|
|
363fd3eab4 | ||
|
|
4083dd4260 | ||
|
|
b2b74547ba | ||
|
|
dddb0baabf | ||
|
|
84b4f67ef9 | ||
|
|
3a089138b8 | ||
|
|
3ff0305c8e | ||
|
|
761edc3c6c | ||
|
|
3351c81f64 | ||
|
|
3dfc6f67d7 | ||
|
|
1546ec3bd1 | ||
|
|
2a953011f7 | ||
|
|
d2f755de9d | ||
|
|
f363334639 | ||
|
|
750197e485 | ||
|
|
36b349e4ed | ||
|
|
b5f1e94fe2 | ||
|
|
6a504fb0e1 | ||
|
|
e02bad2240 | ||
|
|
1d4043a3b6 | ||
|
|
039e034829 | ||
|
|
d828de4f4f | ||
|
|
098000bb10 | ||
|
|
b41165eff5 | ||
|
|
6ad7891b2b | ||
|
|
7213831559 | ||
|
|
10eedd82e4 | ||
|
|
a55493da0f | ||
|
|
89973f4162 | ||
|
|
4802222ad5 | ||
|
|
bcd28f06f8 | ||
|
|
e17a47a7fa | ||
|
|
cad2e16c7a | ||
|
|
5da5d278da | ||
|
|
81b6776e57 | ||
|
|
5ecb6bd58b | ||
|
|
21b56096c5 | ||
|
|
8c78f95973 | ||
|
|
94a88bb566 | ||
|
|
579124475b | ||
|
|
5da83e0200 | ||
|
|
a90a76d004 | ||
|
|
bdfa959123 | ||
|
|
4380594275 | ||
|
|
88bf252c0d | ||
|
|
a5efd8adce | ||
|
|
2ee392eeff | ||
|
|
9c1d893e16 | ||
|
|
88dcb90c83 | ||
|
|
a3bcabc89c | ||
|
|
dafbf9fdcf | ||
|
|
680cb2b2ca | ||
|
|
54818a06e0 | ||
|
|
88f4c5b5a9 | ||
|
|
2bb7409887 | ||
|
|
c780aac3ab | ||
|
|
5010aaec28 | ||
|
|
066e93cb07 | ||
|
|
0bd2faa7f7 | ||
|
|
e2f926453b | ||
|
|
b953b79f9c | ||
|
|
7f99677806 | ||
|
|
721b546659 | ||
|
|
2de5e41269 | ||
|
|
dfe0f6e99b | ||
|
|
8873b1bc69 | ||
|
|
9ff9470700 | ||
|
|
2c58fca530 | ||
|
|
9e5cd90da7 | ||
|
|
7ee0d49424 | ||
|
|
a9058ee21e | ||
|
|
fcf0aac87d | ||
|
|
daec5f0681 | ||
|
|
5b2491d5ae | ||
|
|
d9b41ac73b | ||
|
|
7168ffddf8 | ||
|
|
a855344bec | ||
|
|
d8b3b59fae | ||
|
|
4b7d7840d3 | ||
|
|
58a094a9b4 | ||
|
|
65adbb4189 | ||
|
|
f7350959c9 | ||
|
|
8934a7d832 | ||
|
|
669a424fd6 | ||
|
|
591a65c2bd | ||
|
|
a78fb89078 | ||
|
|
8979dab2a5 | ||
|
|
0a891f0add | ||
|
|
c220e35b14 | ||
|
|
f26c5818bd | ||
|
|
e712cd3fc4 | ||
|
|
0309c9ac67 | ||
|
|
9a9eb4120a | ||
|
|
d1927456b0 | ||
|
|
a3d9213a1e | ||
|
|
3365c03a1e | ||
|
|
4f6c87389b | ||
|
|
41a2a9adac | ||
|
|
74dae2905b | ||
|
|
d1f64214de | ||
|
|
d3e1aa20a8 | ||
|
|
72cae95777 | ||
|
|
219bc8130f | ||
|
|
e8c1a554c0 | ||
|
|
087a60bc2a | ||
|
|
9c9823c3b8 | ||
|
|
cf8d13030b | ||
|
|
1eff69c187 | ||
|
|
b10fb77d71 | ||
|
|
87cee8b230 | ||
|
|
83ab10d628 | ||
|
|
d58a6e1d1d | ||
|
|
cb46ca5c27 | ||
|
|
5528d979f0 | ||
|
|
ee94a038a6 | ||
|
|
1d658f7a9f | ||
|
|
392cb44f9b | ||
|
|
579bef079c | ||
|
|
0691cfcab3 | ||
|
|
db29c7c186 | ||
|
|
fb1e036375 | ||
|
|
c3eaf59836 | ||
|
|
c9849ce0db | ||
|
|
d3c89a3092 | ||
|
|
a3d43f27f7 | ||
|
|
f4d9c1b699 | ||
|
|
de647bba4a | ||
|
|
d791307031 | ||
|
|
1a4fc204e2 | ||
|
|
0328e14c7c | ||
|
|
1acc4d6c29 | ||
|
|
27245590ce | ||
|
|
7ca2a4bdb9 | ||
|
|
5f1ec67348 | ||
|
|
7e44c4278a | ||
|
|
eda726c4a3 | ||
|
|
5f8e70d730 | ||
|
|
25b90546c6 | ||
|
|
75c0841538 | ||
|
|
5b532b9b71 | ||
|
|
8c7b3193d1 | ||
|
|
0897c96ef3 | ||
|
|
57d0ab2ed7 | ||
|
|
a07d9a0e4b | ||
|
|
b3996cb4df | ||
|
|
4fa88c1ba3 | ||
|
|
c8c5564b29 | ||
|
|
6d047486d9 | ||
|
|
42bdc05814 | ||
|
|
85bfb68886 | ||
|
|
08ec21556b | ||
|
|
320929bf25 | ||
|
|
41cd489c34 | ||
|
|
f101d881a1 | ||
|
|
fa7466022b | ||
|
|
ea0cf0acf2 | ||
|
|
e7921b65f5 | ||
|
|
2cc1b1bd54 | ||
|
|
58ae976db0 | ||
|
|
66772392ae | ||
|
|
29c47c03a6 | ||
|
|
91eb9a4d13 | ||
|
|
a1a3de32ec | ||
|
|
9c47fd05bf | ||
|
|
649c0aa7c1 | ||
|
|
3db758764e | ||
|
|
802f1510eb | ||
|
|
56901788de | ||
|
|
679ae6d5dc | ||
|
|
b15c8c352a | ||
|
|
393e8bc560 | ||
|
|
976fd7d9bd | ||
|
|
d8337870ca | ||
|
|
39a8aec77f | ||
|
|
306d539b6b | ||
|
|
f3087b8a8e | ||
|
|
414c2ecef8 | ||
|
|
776ef2d1be | ||
|
|
9ac5746996 | ||
|
|
a3e55d97c0 | ||
|
|
b15227e7ba | ||
|
|
ec3d1f84ce | ||
|
|
753d5fd9fe | ||
|
|
73a0d70c92 | ||
|
|
c2c189f3e6 | ||
|
|
36bc55a310 | ||
|
|
a023001cd3 | ||
|
|
e3750b4962 | ||
|
|
b5ea08e55b | ||
|
|
8e71b8e352 | ||
|
|
4c8610c54f | ||
|
|
c8f886dc8f | ||
|
|
4cfc2d22b3 |
37
.github/workflows/pythonapp.yml
vendored
Normal file
37
.github/workflows/pythonapp.yml
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- "**/*.py"
|
||||
pull_request:
|
||||
paths:
|
||||
- "**/*.py"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
python-version: [3.7, 3.8, 3.9, 3.10.0]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: "Set up timezone to America/Los_Angeles"
|
||||
uses: szenius/set-timezone@v1.0
|
||||
with:
|
||||
timezoneLinux: "America/Los_Angeles"
|
||||
timezoneMacos: "America/Los_Angeles"
|
||||
timezoneWindows: "Pacific Standard Time"
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
- name: Test with unittest
|
||||
run: |
|
||||
python -m unittest discover tests
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -3,4 +3,6 @@ __pycache__
|
||||
dist/
|
||||
build/
|
||||
*.egg-info/
|
||||
jc/parsers.old/
|
||||
.github/
|
||||
.vscode/
|
||||
_config.yml
|
||||
|
||||
437
CHANGELOG
Normal file
437
CHANGELOG
Normal file
@@ -0,0 +1,437 @@
|
||||
jc changelog
|
||||
|
||||
20211202 v1.17.3
|
||||
- Update parsers to exit with error if non-string input is detected (raise TypeError)
|
||||
- Update streaming parsers to exit with error if non-iterable input is detected (raise TypeError)
|
||||
- Simplify quiet-checking in parsers
|
||||
- Add iostat parser tested on linux
|
||||
- Add iostat streaming parser tested on linux
|
||||
|
||||
20211117 v1.17.2
|
||||
- Fix ping parser to add Alpine linux support
|
||||
- Fix netstat parser for older versions of netstat on linux
|
||||
- Fix df parser for cases where the filesystem field overflows the column length
|
||||
|
||||
20211030 v1.17.1
|
||||
- Fix file parser for gzip files
|
||||
- Fix uname parser for cases where the 'processor' and/or 'hardware_platform' fields are missing on linux
|
||||
- Fix uname parser on FreeBSD
|
||||
- Add lsusb parser tested on linux
|
||||
- Add CSV file streaming parser
|
||||
- Add testing for Python 3.10.0
|
||||
|
||||
20210923 v1.17.0
|
||||
- Note to Package Maintainers: please see note at 20210720 v1.16.0
|
||||
- Add wrapping of warning and error messages
|
||||
- Add vmstat parser tested on linux
|
||||
- Add support for streaming parsers
|
||||
- Add ls command streaming parser tested on linux, macOS, and freeBSD
|
||||
- Add ping command streaming parser tested on linux, macOS, and freeBSD
|
||||
- Add vmstat command streaming parser tested on linux
|
||||
- Add -u option to allow unbuffered output
|
||||
|
||||
20210830 v1.16.2
|
||||
- Note to Package Maintainers: please see note at 20210720 v1.16.0
|
||||
- Update sfdisk parser to support the -F option and newer versions of sfdisk
|
||||
|
||||
20210813 v1.16.1
|
||||
- Note to Package Maintainers: please see note at 20210720 v1.16.0
|
||||
- Fix issue with process substitution with the magic syntax
|
||||
- Fix issue with globs not including filenames with spaces with magic syntax
|
||||
- Fix stat parser to properly handle filenames with spaces on macOS/BSD
|
||||
|
||||
20210720 v1.16.0
|
||||
- Note to Package Maintainers:
|
||||
TL;DR: `/man/jc.1.gz` and `/jc/man/jc.1.gz` are deprecated and only `/man/jc.1` should be used.
|
||||
|
||||
The Man page in the PyPi source packages will be moving from `/jc/man/jc.1.gz` to `/man/jc.1`
|
||||
in version 1.17.0. For now the Man pages will be available in both locations, but be aware that
|
||||
the Man page at `/jc/man/jc.1.gz` is now considered deprecated.
|
||||
|
||||
Also, starting in v1.17.0, the Man page will no longer be compressed in the source package,
|
||||
therefore `/man/jc.1.gz` should also be considered deprecated and will no longer be available
|
||||
after v1.17.0. Please use `/man/jc.1` and compress downstream if you would like.
|
||||
- Include CHANGELOG in source distribution
|
||||
- Fix Man page location in source packages
|
||||
- Add sfdisk command parser tested on linux
|
||||
- Update unit test files to change the timezone when needed (POSIX only)
|
||||
- Binaries and DEB/RPM/MSI packages now include Python 3.9.5 interpreter
|
||||
|
||||
20210628 v1.15.6
|
||||
- Fix issue to only load local plugin parsers that have filenames that end in .py
|
||||
|
||||
20210520 v1.15.5
|
||||
- Fix issue where help and about information would not display if a 3rd party parser library was missing. (e.g. xmltodict)
|
||||
- Add more error message detail when encountering ParseError and LibraryNotFound exceptions
|
||||
|
||||
20210517 v1.15.4
|
||||
- Update ping parser to support error responses in OSX and BSD
|
||||
- Update ping parser to be more resilient against parsing errors for unknown error types
|
||||
- Update dig parser to support `+noall +answer` use case
|
||||
- Update dig parser compatibility to all platforms
|
||||
- Fix colors in Windows terminals (cmd.exe and PowerShell)
|
||||
- Fix epoch calculations when UTC is referenced as "Coordinated Universal Time"
|
||||
- Add Windows time format for systeminfo output
|
||||
- Add exceptions module to standardize parser exceptions
|
||||
- JC no longer swallows exit codes when using the "magic" syntax. See the Exit Codes section of the README and man page for details
|
||||
|
||||
20210426 v1.15.3
|
||||
- Add ufw status command parser tested on linux
|
||||
- Add ufw-appinfo command parser tested on linux
|
||||
- Fix deb package name to conform to standard
|
||||
- Add Caveats section to readme and manpage
|
||||
|
||||
20210418 v1.15.2
|
||||
- Add systeminfo parser tested on Windows
|
||||
- Update dig parser to fix an issue with IPv6 addresses in the server field
|
||||
- Update dig parser to fix an issue when axfr entries contain a semicolon
|
||||
- Update dig parser to add support for Additional Section and Opt Pseudosection
|
||||
- Update dig parser to add query_size field
|
||||
- Use dig parser as the main example in readme, documentation, and man page
|
||||
- Standardize int, float, and boolean conversion rules with functions in jc.utils
|
||||
|
||||
20210413 v1.15.1
|
||||
- New feature to show parser documentation interactively with -h --parser_name
|
||||
for example: $ jc -h --arp
|
||||
- Add man page to pypi package for easier packaging in homebrew
|
||||
- Update rpm-qi parser to add two calculated timestamp fields: install_date_epoch and install_date_epoch_utc
|
||||
- Clean up documentation and autogenerate the Parser Information section from metadata
|
||||
|
||||
20210407 v1.15.0
|
||||
- Add acpi command parser tested on linux
|
||||
- Add upower command parser tested on linux
|
||||
- Add /usr/bin/time command parser tested on linux and macOS
|
||||
- Add dpkg -l command parser tested on linux
|
||||
- Add rpm -qi command parser tested on linux
|
||||
- Add finger command parser tested on linux and macOS
|
||||
- Add dir command parser tested on Windows 10
|
||||
- Update date parser: complete rewrite (v2.0) providing many enhancements:
|
||||
- Make weekday numbering ISO 8601 compliant
|
||||
- Add a calculated naive timestamp field
|
||||
- Add a calculated UTC timestamp field (only if date output is in UTC)
|
||||
- Add several fields, including: hour_24, utc_offset, day_of_year, week_of_year, iso, and timezone_aware
|
||||
- Update uptime parser to add uptime_days, uptime_hours, uptime_minutes, uptime_total_seconds, time_hour,
|
||||
time_minute, and time_second fields
|
||||
- Update last parser to use new timestamp function
|
||||
- Update stat parser to add access_time_epoch, access_time_epoch_utc, modify_time_epoch, modify_time_epoch_utc,
|
||||
change_time_epoch, change_time_epoch_utc, birth_time_epoch, birth_time_epoch_utc fields
|
||||
- Update timedatectl parser to add epoch_utc field
|
||||
- Update who parser to add epoch field
|
||||
- Update dig parser to add when_epoch and when_epoch_utc fields
|
||||
- Update ls parser to add epoch and epoch_utc fields
|
||||
- Add -h option to display the help text. Piping errors no longer show the help text.
|
||||
- Add -v option to display version information.
|
||||
- Add contributing information to project root
|
||||
- Make all external python library dependencies optional: pygments, ruamel.yaml, xmltodict
|
||||
- JSON output now supports unencoded unicode characters
|
||||
- JSON output is now more compact unless the -p (pretty) option is used
|
||||
- Developer scripts added and enhanced to automate documentation and man page creation
|
||||
- Enhanced man page
|
||||
|
||||
20210305 v1.14.4
|
||||
- Packaging fix only for binaries and RPMs hosted on https://github.com/kellyjonbrazil/jc-packaging.
|
||||
Packages from PyPi and OS repositories are not affected. This fixes an issue that kept the YAML
|
||||
parser from initializing.
|
||||
|
||||
20210210 v1.14.3
|
||||
- Add hciconfig parser tested on linux
|
||||
- Update dig parser to simplify answer data logic
|
||||
|
||||
20210205 v1.14.2
|
||||
- Update dig parser to fix cases where there are spaces in the answer data (e.g. TXT records)
|
||||
|
||||
20210106 v1.14.1
|
||||
- Add iw-scan parser tested on linux (beta)
|
||||
- Update date parser for Ubuntu 20.04 support
|
||||
- Update last parser for last -F support
|
||||
- Update last parser to add convenience fields and augment data for easier parsing
|
||||
- Update man page
|
||||
- Minor documentation updates
|
||||
|
||||
20201231 v1.14.0
|
||||
- Add hashsum parser tested on linux, macos
|
||||
- Add hash parser tested on linux, macos
|
||||
- Add cksum parser tested on linux, macos
|
||||
- Add wc parser tested on linux, macos
|
||||
- Add printenv support under env parser
|
||||
- Add vdir support under ls parser
|
||||
- Add python 3.9 to github automation tests
|
||||
|
||||
20200805 v1.13.4
|
||||
- Update crontab and crontab-u parsers to tighten up variable detection
|
||||
- Update ping parser to tighten linux/bsd detection
|
||||
|
||||
20200804 v1.13.3
|
||||
- Update ping parser for Raspberry Pi compatibility
|
||||
|
||||
20200803 v1.13.2
|
||||
- Add key/value file parser (wrapper for ini parser)
|
||||
- Add date command parser
|
||||
- Update traceroute parser to more gracefully handle missing header row
|
||||
- Update traceroute parser to handle annotations
|
||||
- Update traceroute parser to only return successful probes
|
||||
|
||||
20200727 v1.13.1
|
||||
- Add route -6 tests
|
||||
|
||||
20200727 v1.13.0
|
||||
- Add ping and ping6 command parser tested on linux, macos, and freebsd
|
||||
- Add traceroute and traceroute6 command parser tested on linux, macos, and freebsd
|
||||
- Add tracepath command parser tested on linux
|
||||
- Update ini parser to support files only containing key/value pairs
|
||||
- Update uname parser exception with a hint to use "uname -a"
|
||||
- Update route parser to support IPv6 tables
|
||||
|
||||
20200711 v1.12.1
|
||||
- Fix tests when using older version of pygments library
|
||||
|
||||
20200710 v1.12.0
|
||||
- Add sysctl command parser tested on linux, macOS, and freebsd
|
||||
- Update the cli code to allow older versions of the pygments library (2.3.0) for debian packaging
|
||||
- Code cleanup on the cli
|
||||
- Add tests for the cli
|
||||
- Vendorize cgitb as tracebackplus for verbose debug messages
|
||||
|
||||
20200625 v1.11.8
|
||||
- Add verbose debug option using -dd argument
|
||||
|
||||
20200622 v1.11.7
|
||||
- Fix iptables parser issue which would not output the last chain
|
||||
|
||||
20200614 v1.11.6
|
||||
- Improve and standardize empty data check for all parsers
|
||||
|
||||
20200612 v1.11.5
|
||||
- Update airport_s parser to fix error on parsing empty data
|
||||
- Update arp parser to fix error on parsing empty data
|
||||
- Update blkid parser to fix error on parsing empty data
|
||||
- Update crontab parser to fix error on parsing empty data
|
||||
- Update crontab_u parser to fix error on parsing empty data
|
||||
- Update df parser to fix error on parsing empty data
|
||||
- Update free parser to fix error on parsing empty data
|
||||
- Update lsblk parser to fix error on parsing empty data
|
||||
- Update lsmod parser to fix error on parsing empty data
|
||||
- Update mount parser to fix error on parsing empty data
|
||||
- Update netstat parser to fix error on parsing empty data
|
||||
- Update ntpq parser to fix error on parsing empty data
|
||||
- Update ps parser to fix error on parsing empty data
|
||||
- Update route parser to fix error on parsing empty data
|
||||
- Update systemctl parser to fix error on parsing empty data
|
||||
- Update systemctl_lj parser to fix error on parsing empty data
|
||||
- Update systemctl_ls parser to fix error on parsing empty data
|
||||
- Update systemctl_luf parser to fix error on parsing empty data
|
||||
- Update uptime parser to fix error on parsing empty data
|
||||
- Update w parser to fix error on parsing empty data
|
||||
- Update xml parser to fix error on parsing empty data
|
||||
- Add tests to all parsers for no data condition
|
||||
- Update ss parser to fix integer fields
|
||||
|
||||
20200610 v1.11.4
|
||||
- Update ls parser to fix error on parsing an empty directory
|
||||
|
||||
20200609 v1.11.3
|
||||
- Add local parser plugin feature (contributed by Dean Serenevy)
|
||||
|
||||
20200530 v1.11.2
|
||||
- Update netstat parser to add freebsd support
|
||||
- Update netstat parser to add route_flags_pretty field
|
||||
- Update netstat parser to change osx_inode field name to unix_inode
|
||||
- Update netstat parser to change osx_flags field name to unix_flags
|
||||
- Update netstat parser to strip whitespace from state field
|
||||
- Update route parser to add flags_pretty field
|
||||
- Update arp parser to add permanent field (freebsd and osx)
|
||||
- Update arp parser to add expires field (freebsd)
|
||||
- Update w parser to strip whitespace from what field
|
||||
- Update last parser to fix FreeBSD issues
|
||||
- Update stat parser to change osx_flags field name to unix_flags
|
||||
- Update stat parser to add unix_device field for freebsd and osx
|
||||
- Fix freebsd compatibility message for df, fstab, mount, ntpq, stat, and uname parsers
|
||||
- Fix compatibility message for platforms that include the version number at the end (e.g. freebsd12)
|
||||
|
||||
20200523 v1.11.1
|
||||
- Update stat command parser to change osx_flags field to string
|
||||
|
||||
20200522 v1.11.0
|
||||
- Add dmidecode command parser
|
||||
- Update stat command parser to add OSX support
|
||||
- Update netstat command parser to add OSX support
|
||||
- Update netstat command parser to add -r (route) functionality for linux and OSX
|
||||
- Update netstat command parser to add -i (interface) functionality for linux and OSX
|
||||
|
||||
20200511 v1.10.12
|
||||
- Remove shebang from jc/cli.py for Fedora packaging
|
||||
|
||||
20200511 v1.10.11
|
||||
- Change file permissions for Fedora packaging
|
||||
|
||||
20200509 v1.10.10
|
||||
- Fix ls parser issue where the first file was skipped for ls -R on some platforms
|
||||
- Update last parser to handle 'gone - no logout' condition
|
||||
- Update netstat parser to handle bluetooth section (ignore gracefully for now)
|
||||
|
||||
20200508 v1.10.9
|
||||
- Add license info to vendorized ifconfig-parser class
|
||||
|
||||
20200508 v1.10.8
|
||||
- Add license file to dist for Fedora RPM packaging requirements
|
||||
- Remove tests from package to keep from polluting the global site-packages
|
||||
|
||||
20200501 v1.10.7
|
||||
- Requirements modifications for Fedora RPM packaging requirements
|
||||
|
||||
20200420 v1.10.6
|
||||
- Remove homebrew shim references from du osx tests
|
||||
|
||||
20200414 v1.10.5
|
||||
- Minor change of using sys.exit(0) instead of exit()
|
||||
|
||||
20200412 v1.10.4
|
||||
- Add color customization via JC_COLORS env variable
|
||||
|
||||
20200409 v1.10.3
|
||||
- Fix break on pipe error
|
||||
|
||||
20200409 v1.10.2
|
||||
- Change colors to ansi and match jello colors
|
||||
|
||||
20200402 v1.10.1
|
||||
- Code cleanup
|
||||
|
||||
20200402 v1.10.0
|
||||
- Add color output by default when not piping data to another program
|
||||
- Add -m option for monochrome output
|
||||
|
||||
20200326 v1.9.3
|
||||
- Add axfr support for dig command parser
|
||||
|
||||
20200312 v1.9.2
|
||||
- Updated arp parser to fix OSX detection for some edge cases
|
||||
|
||||
20200312 v1.9.1
|
||||
- Updated file command parser to make filename splitting more robust
|
||||
|
||||
20200311 v1.9.0
|
||||
- Added ntpq command parser
|
||||
- Added timedatectl status command parser
|
||||
- Added airport -I and airport -s command parser
|
||||
- Added file command parser
|
||||
- Optimized history command parser by https://github.com/philippeitis
|
||||
- Magic syntax fix for certain edge cases
|
||||
|
||||
20200308 v1.8.1
|
||||
- CLI optimizations by https://github.com/philippeitis
|
||||
- Refactored magic syntax function and added tests (https://github.com/philippeitis)
|
||||
- Github actions for CI testing on multiple platforms by https://github.com/philippeitis
|
||||
- Updated ls parser to fix parsing error in OSX with -lR when there are empty folders
|
||||
|
||||
20200303 v1.8.0
|
||||
- Added blkid command parser
|
||||
- Added last and lastb command parser
|
||||
- Added who command parser
|
||||
- Added CSV file parser
|
||||
- Added /etc/passwd file parser
|
||||
- Added /etc/shadow file parser
|
||||
- Added /etc/group file parser
|
||||
- Added /etc/gshadow file parser
|
||||
|
||||
20200227 v1.7.5
|
||||
- Updated ls parser to support filenames with newline characters
|
||||
|
||||
20200219 v1.7.4
|
||||
- Updated ls parser to support multiple directories, globbing, and -R (recursive)
|
||||
|
||||
20200211 v1.7.3
|
||||
- Add alternative 'magic' syntax: e.g. `jc ls -al`
|
||||
- Options can now be condensed (e.g. -prq is equivalant to -p -r -q)
|
||||
|
||||
20200208 v1.7.2
|
||||
- Include test fixtures in wheel and sdist
|
||||
|
||||
20200205 v1.7.1
|
||||
- Add YAML file parser
|
||||
- Add INI file parser
|
||||
- Add XML file parser
|
||||
- Add id parser (tested on linux and OSX)
|
||||
- Add crontab file parser with user support (tested on linux)
|
||||
- Add __version__ variable to parser modules
|
||||
- Add exit code on error
|
||||
- Updated history parser to output "line" as an integer
|
||||
- Updated compatibility list for some parsers
|
||||
- Bugfix in crontab file parser: header insertion was clobbering first row
|
||||
- Just-in-time loading of parser modules instead of loading all at start
|
||||
|
||||
20191217 v1.6.1
|
||||
- Add du parser (tested on linux and OSX)
|
||||
- Add crontab parser (tested on linux and OSX)
|
||||
- Add pip list parser (tested on linux and OSX)
|
||||
- Add pip show parser (tested on linux and OSX)
|
||||
- Add OSX support for the ifconfig, arp, df, mount, and uname parsers
|
||||
- Add tests for ls, dig, ps, w, uptime on OSX
|
||||
- Add about option
|
||||
- Add universal parsers to refactor repetitive code
|
||||
- Updated ifconfig parser to output 'state' as an array
|
||||
|
||||
20191117 v1.5.1
|
||||
- Add ss parser
|
||||
- Add stat parser
|
||||
- Add /etc/hosts parser
|
||||
- Add /etc/fstab parser
|
||||
- Add systemctl parser (includes list-jobs, list-sockets, and list-unit-files)
|
||||
- Add -r and raw=True options. By default, jc will now convert numbers and boolean, if possible, and add other semantic information, while the raw output will keep all values as text and provide a more literal JSON output
|
||||
- Add -q and quiet=True options to suppress warnings to stderr
|
||||
- Add -d option to debug parsing issues
|
||||
- Add compatibility warnings to stderr
|
||||
- Add documentation
|
||||
- Updated iptables parser to allow --line-numbers option
|
||||
- Updated lsblk parser to allow parsing of added columns
|
||||
- Updated mount parser: changed 'access' field name to 'options'
|
||||
- Updated netstat parser to allow parsing of unix sockets and raw network connections
|
||||
- Updated w parser to fix unaligned data where blanks are possible
|
||||
- Clean up code and reorganize package
|
||||
|
||||
20191031 v1.1.1
|
||||
- Add arp parser
|
||||
- Add dig parser
|
||||
- Add unit tests
|
||||
- fix netstat parser (remove side effects due to global variable)
|
||||
|
||||
20191025 v1.0.1
|
||||
- Add w parser
|
||||
- Add uptime parser
|
||||
- Add history parser
|
||||
- Flatten env parser output
|
||||
- Remove problematic characters from key names in: df, free, history, lsblk, lsof, and w
|
||||
- Where possible, lowercase all keys (except cases like env where the key is the variable name)
|
||||
- Remove integer values
|
||||
- Handle CTRL-C gracefully
|
||||
|
||||
20191023 v0.9.1
|
||||
- Add jobs parser
|
||||
- Add lsof parser
|
||||
- Add lsmod parser
|
||||
- No blocking if no piped data
|
||||
- Better help text
|
||||
- Clean up iptables parser code
|
||||
|
||||
20191022 v0.8.1
|
||||
- Add env parser
|
||||
- Add df parser
|
||||
- Add free parser
|
||||
- Add lsblk parser
|
||||
- Add mount parser
|
||||
- Add uname parser
|
||||
- Add iptables parser
|
||||
|
||||
20191021 v0.6.4
|
||||
- Flatten netstat parser output
|
||||
- Clean up argument parsing
|
||||
- Fix command help
|
||||
|
||||
20191018 v0.5.5
|
||||
- Fix netstat -p parsing for Ubuntu
|
||||
- Add ps parser
|
||||
- Add route parser
|
||||
- ls parser fixes
|
||||
|
||||
20191017 v0.2.0
|
||||
- ifconfig, ls, and netstat support
|
||||
89
CONTRIBUTING.md
Normal file
89
CONTRIBUTING.md
Normal file
@@ -0,0 +1,89 @@
|
||||
# Contributing to jc
|
||||
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
|
||||
|
||||
- Reporting a bug
|
||||
- Discussing the current state of the code
|
||||
- Submitting a fix
|
||||
- Proposing new features
|
||||
- Proposing a new parser
|
||||
|
||||
## We Develop with Github
|
||||
We use github to host code, to track issues and feature requests, as well as accept pull requests.
|
||||
|
||||
## We Use Github Flow, So All Code Changes Happen Through Pull Requests
|
||||
Pull requests are the best way to propose changes to the codebase (we use [Github Flow](https://guides.github.com/introduction/flow/index.html)). We actively welcome your pull requests:
|
||||
|
||||
1. Open an issue to discuss the new feature, bug fix, or parser before opening a pull request. For new parsers, it is important to agree upon a schema before developing the parser.
|
||||
2. Fork the repo and create your branch from `dev`, if available, otherwise `master`.
|
||||
3. For new parsers: Use the [`jc/parsers/foo.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo.py) or [`jc/parsers/foo_s.py (streaming)`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo_s.py) parsers as a template to get started. You can even place a new parser python module file in the [parser plugin directory](https://github.com/kellyjonbrazil/jc#custom-parsers) to get started right away with just a standard `jc` installation.
|
||||
4. If you've added code that should be tested, add tests. All new parsers should have several sample outputs and tests.
|
||||
5. Documentation is auto-generated from docstrings, so ensure they are clear and accurate.
|
||||
6. Ensure the test suite passes. (Note: "**America/Los_Angeles**" timezone should be configured on the test system)
|
||||
7. Make sure your code lints.
|
||||
8. Issue that pull request!
|
||||
|
||||
## Parser Schema Guidelines
|
||||
- Try to keep the schema as flat as possible - typically a list of flat dictionaries
|
||||
- Keys should be lowercase, contain no special characters, and spaces should be converted to underscores
|
||||
- Keys should be static, if possible. If they have to be dynamic, then they should not contain lists or dictionaries
|
||||
|
||||
This will make it easier to use tools like `jq` without requiring escaping of special characters, encapsulating key names in [""], keeps paths predictable, and makes iterating and searching for values easier.
|
||||
|
||||
**Examples**
|
||||
|
||||
Bad:
|
||||
```json
|
||||
{
|
||||
"Interface 1": [
|
||||
"192.168.1.1",
|
||||
"172.16.1.1"
|
||||
],
|
||||
"Wifi Interface 1": [
|
||||
"10.1.1.1"
|
||||
]
|
||||
}
|
||||
```
|
||||
Good:
|
||||
```json
|
||||
[
|
||||
{
|
||||
"interface": "Interface 1",
|
||||
"ip_addresses": [
|
||||
"192.168.1.1",
|
||||
"172.16.1.1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"interface": "Wifi Interface 1",
|
||||
"ip_addresses": [
|
||||
"10.1.1.1"
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## Tests
|
||||
It is essential to have good command output sample coverage and tests to keep the `jc` parser quality high.
|
||||
|
||||
Many parsers include calculated timestamp fields using the `jc.utils.timestamp` class. Naive timestamps created with this class should be generated on a system configured with the "**America/Los_Angeles**" timezone on linux/macOS/unix and "**Pacific Standard Time**" timezone on Windows for tests to pass on the Github Actions CI tests. This timezone should be configured on your local system before running the tests locally, as well.
|
||||
|
||||
## Any contributions you make will be under the MIT Software License
|
||||
In short, when you submit code changes, your submissions are understood to be under the same [MIT License](http://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern.
|
||||
|
||||
## Report bugs using Github's Issues
|
||||
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/kellyjonbrazil/jc/issues); it's that easy!
|
||||
|
||||
## Write bug reports with detail, background, and sample code
|
||||
**Great Bug Reports** tend to have:
|
||||
|
||||
- A quick summary and/or background
|
||||
- Steps to reproduce
|
||||
- Be specific!
|
||||
- Give sample code if you can.
|
||||
- What you expected would happen
|
||||
- What actually happens
|
||||
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)
|
||||
|
||||
## Use a Consistent Coding Style
|
||||
* 4 spaces for indentation rather than tabs
|
||||
* Use a Python linter that will enforce PEP 8 and other best practices
|
||||
3797
EXAMPLES.md
Normal file
3797
EXAMPLES.md
Normal file
File diff suppressed because it is too large
Load Diff
2
LICENSE.md
Executable file → Normal file
2
LICENSE.md
Executable file → Normal file
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Kelly Brazil
|
||||
Copyright (c) 2020 Kelly Brazil
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
3
MANIFEST.in
Normal file
3
MANIFEST.in
Normal file
@@ -0,0 +1,3 @@
|
||||
include jc/man/jc.1.gz
|
||||
include man/jc.1
|
||||
include CHANGELOG
|
||||
1
_config.yml
Normal file
1
_config.yml
Normal file
@@ -0,0 +1 @@
|
||||
theme: jekyll-theme-cayman
|
||||
@@ -1,14 +0,0 @@
|
||||
jc changelog
|
||||
|
||||
20191021 v0.6.1
|
||||
- Flatten netstat parser output
|
||||
- Clean up argument parsing
|
||||
|
||||
20191018 v0.5.5
|
||||
- Fix netstat -p parsing for Ubuntu
|
||||
- Add ps parser
|
||||
- Add route parser
|
||||
- ls parser fixes
|
||||
|
||||
20191017 v0.2.0
|
||||
- ifconfig, ls, and netstat support
|
||||
37
docgen.sh
Executable file
37
docgen.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
# Generate docs.md
|
||||
# requires pydoc-markdown 2.1.0.post1
|
||||
|
||||
cd jc
|
||||
echo Building docs for: package
|
||||
pydocmd simple jc+ > ../docs/readme.md
|
||||
echo Building docs for: utils
|
||||
pydocmd simple utils+ > ../docs/utils.md
|
||||
|
||||
# a bit of inception here... jc is being used to help
|
||||
# automate the generation of its own documentation. :)
|
||||
|
||||
# pull jc parser objects into a bash array from jq
|
||||
parsers=()
|
||||
while read -r value
|
||||
do
|
||||
parsers+=("$value")
|
||||
done < <(jc -a | jq -c '.parsers[]')
|
||||
|
||||
# iterate over the bash array
|
||||
for parser in "${parsers[@]}"
|
||||
do
|
||||
parser_name=$(jq -r '.name' <<< "$parser")
|
||||
compatible=$(jq -r '.compatible | join(", ")' <<< "$parser")
|
||||
version=$(jq -r '.version' <<< "$parser")
|
||||
author=$(jq -r '.author' <<< "$parser")
|
||||
author_email=$(jq -r '.author_email' <<< "$parser")
|
||||
|
||||
echo "Building docs for: ${parser_name}"
|
||||
echo "[Home](https://kellyjonbrazil.github.io/jc/)" > ../docs/parsers/"${parser_name}".md
|
||||
pydocmd simple jc.parsers."${parser_name}"+ >> ../docs/parsers/"${parser_name}".md
|
||||
echo "## Parser Information" >> ../docs/parsers/"${parser_name}".md
|
||||
echo "Compatibility: ${compatible}" >> ../docs/parsers/"${parser_name}".md
|
||||
echo >> ../docs/parsers/"${parser_name}".md
|
||||
echo "Version ${version} by ${author} (${author_email})" >> ../docs/parsers/"${parser_name}".md
|
||||
done
|
||||
1
docs/_config.yml
Normal file
1
docs/_config.yml
Normal file
@@ -0,0 +1 @@
|
||||
theme: jekyll-theme-cayman
|
||||
255
docs/parsers/acpi.md
Normal file
255
docs/parsers/acpi.md
Normal file
@@ -0,0 +1,255 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.acpi
|
||||
jc - JSON CLI output utility `acpi` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ acpi -V | jc --acpi
|
||||
|
||||
or
|
||||
|
||||
$ jc acpi -V
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.acpi
|
||||
result = jc.parsers.acpi.parse(acpi_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"type": string,
|
||||
"id": integer,
|
||||
"state": string,
|
||||
"charge_percent": integer,
|
||||
"until_charged": string,
|
||||
"until_charged_hours": integer,
|
||||
"until_charged_minuts": integer,
|
||||
"until_charged_seconds": integer,
|
||||
"until_charged_total_seconds": integer,
|
||||
"charge_remaining": string,
|
||||
"charge_remaining_hours": integer,
|
||||
"charge_remaining_minutes": integer,
|
||||
"charge_remaining_seconds": integer,
|
||||
"charge_remaining_total_seconds": integer,
|
||||
"design_capacity_mah": integer,
|
||||
"last_full_capacity": integer,
|
||||
"last_full_capacity_percent": integer,
|
||||
"on-line": boolean,
|
||||
"mode": string,
|
||||
"temperature": float,
|
||||
"temperature_unit": string,
|
||||
"trip_points": [
|
||||
{
|
||||
"id": integer,
|
||||
"switches_to_mode": string,
|
||||
"temperature": float,
|
||||
"temperature_unit": string
|
||||
}
|
||||
],
|
||||
"messages": [
|
||||
string
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ acpi -V | jc --acpi -p
|
||||
[
|
||||
{
|
||||
"type": "Battery",
|
||||
"id": 0,
|
||||
"state": "Charging",
|
||||
"charge_percent": 71,
|
||||
"until_charged": "00:29:20",
|
||||
"design_capacity_mah": 2110,
|
||||
"last_full_capacity": 2271,
|
||||
"last_full_capacity_percent": 100,
|
||||
"until_charged_hours": 0,
|
||||
"until_charged_minutes": 29,
|
||||
"until_charged_seconds": 20,
|
||||
"until_charged_total_seconds": 1760
|
||||
},
|
||||
{
|
||||
"type": "Adapter",
|
||||
"id": 0,
|
||||
"on-line": true
|
||||
},
|
||||
{
|
||||
"type": "Thermal",
|
||||
"id": 0,
|
||||
"mode": "ok",
|
||||
"temperature": 46.0,
|
||||
"temperature_unit": "C",
|
||||
"trip_points": [
|
||||
{
|
||||
"id": 0,
|
||||
"switches_to_mode": "critical",
|
||||
"temperature": 127.0,
|
||||
"temperature_unit": "C"
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"switches_to_mode": "hot",
|
||||
"temperature": 127.0,
|
||||
"temperature_unit": "C"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Cooling",
|
||||
"id": 0,
|
||||
"messages": [
|
||||
"Processor 0 of 10"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Cooling",
|
||||
"id": 1,
|
||||
"messages": [
|
||||
"Processor 0 of 10"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Cooling",
|
||||
"id": 2,
|
||||
"messages": [
|
||||
"x86_pkg_temp no state information available"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Cooling",
|
||||
"id": 3,
|
||||
"messages": [
|
||||
"Processor 0 of 10"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Cooling",
|
||||
"id": 4,
|
||||
"messages": [
|
||||
"intel_powerclamp no state information available"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Cooling",
|
||||
"id": 5,
|
||||
"messages": [
|
||||
"Processor 0 of 10"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
$ acpi -V | jc --acpi -p -r
|
||||
[
|
||||
{
|
||||
"type": "Battery",
|
||||
"id": "0",
|
||||
"state": "Charging",
|
||||
"charge_percent": "71",
|
||||
"until_charged": "00:29:20",
|
||||
"design_capacity_mah": "2110",
|
||||
"last_full_capacity": "2271",
|
||||
"last_full_capacity_percent": "100"
|
||||
},
|
||||
{
|
||||
"type": "Adapter",
|
||||
"id": "0",
|
||||
"on-line": true
|
||||
},
|
||||
{
|
||||
"type": "Thermal",
|
||||
"id": "0",
|
||||
"mode": "ok",
|
||||
"temperature": "46.0",
|
||||
"temperature_unit": "C",
|
||||
"trip_points": [
|
||||
{
|
||||
"id": "0",
|
||||
"switches_to_mode": "critical",
|
||||
"temperature": "127.0",
|
||||
"temperature_unit": "C"
|
||||
},
|
||||
{
|
||||
"id": "1",
|
||||
"switches_to_mode": "hot",
|
||||
"temperature": "127.0",
|
||||
"temperature_unit": "C"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Cooling",
|
||||
"id": "0",
|
||||
"messages": [
|
||||
"Processor 0 of 10"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Cooling",
|
||||
"id": "1",
|
||||
"messages": [
|
||||
"Processor 0 of 10"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Cooling",
|
||||
"id": "2",
|
||||
"messages": [
|
||||
"x86_pkg_temp no state information available"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Cooling",
|
||||
"id": "3",
|
||||
"messages": [
|
||||
"Processor 0 of 10"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Cooling",
|
||||
"id": "4",
|
||||
"messages": [
|
||||
"intel_powerclamp no state information available"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Cooling",
|
||||
"id": "5",
|
||||
"messages": [
|
||||
"Processor 0 of 10"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
108
docs/parsers/airport.md
Normal file
108
docs/parsers/airport.md
Normal file
@@ -0,0 +1,108 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.airport
|
||||
jc - JSON CLI output utility `airport -I` command output parser
|
||||
|
||||
The `airport` program can be found at `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport`.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ airport -I | jc --airport
|
||||
|
||||
or
|
||||
|
||||
$ jc airport -I
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.airport
|
||||
result = jc.parsers.airport.parse(airport_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"agrctlrssi": integer,
|
||||
"agrextrssi": integer,
|
||||
"agrctlnoise": integer,
|
||||
"agrextnoise": integer,
|
||||
"state": string,
|
||||
"op_mode": string,
|
||||
"lasttxrate": integer,
|
||||
"maxrate": integer,
|
||||
"lastassocstatus": integer,
|
||||
"802_11_auth": string,
|
||||
"link_auth": string,
|
||||
"bssid": string,
|
||||
"ssid": string,
|
||||
"mcs": integer,
|
||||
"channel": string
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ airport -I | jc --airport -p
|
||||
{
|
||||
"agrctlrssi": -66,
|
||||
"agrextrssi": 0,
|
||||
"agrctlnoise": -90,
|
||||
"agrextnoise": 0,
|
||||
"state": "running",
|
||||
"op_mode": "station",
|
||||
"lasttxrate": 195,
|
||||
"maxrate": 867,
|
||||
"lastassocstatus": 0,
|
||||
"802_11_auth": "open",
|
||||
"link_auth": "wpa2-psk",
|
||||
"bssid": "3c:37:86:15:ad:f9",
|
||||
"ssid": "SnazzleDazzle",
|
||||
"mcs": 0,
|
||||
"channel": "48,80"
|
||||
}
|
||||
|
||||
$ airport -I | jc --airport -p -r
|
||||
{
|
||||
"agrctlrssi": "-66",
|
||||
"agrextrssi": "0",
|
||||
"agrctlnoise": "-90",
|
||||
"agrextnoise": "0",
|
||||
"state": "running",
|
||||
"op_mode": "station",
|
||||
"lasttxrate": "195",
|
||||
"maxrate": "867",
|
||||
"lastassocstatus": "0",
|
||||
"802_11_auth": "open",
|
||||
"link_auth": "wpa2-psk",
|
||||
"bssid": "3c:37:86:15:ad:f9",
|
||||
"ssid": "SnazzleDazzle",
|
||||
"mcs": "0",
|
||||
"channel": "48,80"
|
||||
}
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: darwin
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
136
docs/parsers/airport_s.md
Normal file
136
docs/parsers/airport_s.md
Normal file
@@ -0,0 +1,136 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.airport_s
|
||||
jc - JSON CLI output utility `airport -s` command output parser
|
||||
|
||||
The `airport` program can be found at `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport`.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ airport -s | jc --airport-s
|
||||
|
||||
or
|
||||
|
||||
$ jc airport -s
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.airport_s
|
||||
result = jc.parsers.airport_s.parse(airport_s_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"ssid": string,
|
||||
"bssid": string,
|
||||
"rssi": integer,
|
||||
"channel": string,
|
||||
"ht": boolean,
|
||||
"cc": string,
|
||||
"security": [
|
||||
string,
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ airport -s | jc --airport-s -p
|
||||
[
|
||||
{
|
||||
"ssid": "DIRECT-4A-HP OfficeJet 3830",
|
||||
"bssid": "00:67:eb:2a:a7:3b",
|
||||
"rssi": -90,
|
||||
"channel": "6",
|
||||
"ht": true,
|
||||
"cc": "--",
|
||||
"security": [
|
||||
"WPA2(PSK/AES/AES)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ssid": "Latitude38",
|
||||
"bssid": "c0:ff:d5:d2:7a:f3",
|
||||
"rssi": -85,
|
||||
"channel": "11",
|
||||
"ht": true,
|
||||
"cc": "US",
|
||||
"security": [
|
||||
"WPA2(PSK/AES/AES)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ssid": "xfinitywifi",
|
||||
"bssid": "6e:e3:0e:b8:45:99",
|
||||
"rssi": -83,
|
||||
"channel": "11",
|
||||
"ht": true,
|
||||
"cc": "US",
|
||||
"security": [
|
||||
"NONE"
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ airport -s | jc --airport -p -r
|
||||
[
|
||||
{
|
||||
"ssid": "DIRECT-F3-HP ENVY 5660 series",
|
||||
"bssid": "b0:5a:da:6f:0a:d4",
|
||||
"rssi": "-93",
|
||||
"channel": "1",
|
||||
"ht": "Y",
|
||||
"cc": "--",
|
||||
"security": "WPA2(PSK/AES/AES)"
|
||||
},
|
||||
{
|
||||
"ssid": "YouAreInfected-5",
|
||||
"bssid": "5c:e3:0e:c2:85:da",
|
||||
"rssi": "-85",
|
||||
"channel": "36",
|
||||
"ht": "Y",
|
||||
"cc": "US",
|
||||
"security": "WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP)"
|
||||
},
|
||||
{
|
||||
"ssid": "YuanFamily",
|
||||
"bssid": "5c:e3:0e:b8:5f:9a",
|
||||
"rssi": "-84",
|
||||
"channel": "11",
|
||||
"ht": "Y",
|
||||
"cc": "US",
|
||||
"security": "WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP)"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: darwin
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
145
docs/parsers/arp.md
Normal file
145
docs/parsers/arp.md
Normal file
@@ -0,0 +1,145 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.arp
|
||||
jc - JSON CLI output utility `arp` command output parser
|
||||
|
||||
Supports `arp` and `arp -a` output.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ arp | jc --arp
|
||||
|
||||
or
|
||||
|
||||
$ jc arp
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.arp
|
||||
result = jc.parsers.arp.parse(arp_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"name": string,
|
||||
"address": string,
|
||||
"hwtype": string,
|
||||
"hwaddress": string,
|
||||
"flags_mask": string,
|
||||
"iface": string,
|
||||
"permanent": boolean,
|
||||
"expires": integer
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ arp | jc --arp -p
|
||||
[
|
||||
{
|
||||
"address": "192.168.71.254",
|
||||
"hwtype": "ether",
|
||||
"hwaddress": "00:50:56:f0:98:26",
|
||||
"flags_mask": "C",
|
||||
"iface": "ens33"
|
||||
},
|
||||
{
|
||||
"address": "gateway",
|
||||
"hwtype": "ether",
|
||||
"hwaddress": "00:50:56:f7:4a:fc",
|
||||
"flags_mask": "C",
|
||||
"iface": "ens33"
|
||||
}
|
||||
]
|
||||
|
||||
$ arp | jc --arp -p -r
|
||||
[
|
||||
{
|
||||
"address": "gateway",
|
||||
"hwtype": "ether",
|
||||
"hwaddress": "00:50:56:f7:4a:fc",
|
||||
"flags_mask": "C",
|
||||
"iface": "ens33"
|
||||
},
|
||||
{
|
||||
"address": "192.168.71.254",
|
||||
"hwtype": "ether",
|
||||
"hwaddress": "00:50:56:fe:7a:b4",
|
||||
"flags_mask": "C",
|
||||
"iface": "ens33"
|
||||
}
|
||||
]
|
||||
|
||||
$ arp -a | jc --arp -p
|
||||
[
|
||||
{
|
||||
"name": null,
|
||||
"address": "192.168.71.254",
|
||||
"hwtype": "ether",
|
||||
"hwaddress": "00:50:56:f0:98:26",
|
||||
"iface": "ens33"
|
||||
"permanent": false,
|
||||
"expires": 1182
|
||||
},
|
||||
{
|
||||
"name": "gateway",
|
||||
"address": "192.168.71.2",
|
||||
"hwtype": "ether",
|
||||
"hwaddress": "00:50:56:f7:4a:fc",
|
||||
"iface": "ens33"
|
||||
"permanent": false,
|
||||
"expires": 110
|
||||
}
|
||||
]
|
||||
|
||||
$ arp -a | jc --arp -p -r
|
||||
[
|
||||
{
|
||||
"name": "?",
|
||||
"address": "192.168.71.254",
|
||||
"hwtype": "ether",
|
||||
"hwaddress": "00:50:56:fe:7a:b4",
|
||||
"iface": "ens33"
|
||||
"permanent": false,
|
||||
"expires": "1182"
|
||||
},
|
||||
{
|
||||
"name": "_gateway",
|
||||
"address": "192.168.71.2",
|
||||
"hwtype": "ether",
|
||||
"hwaddress": "00:50:56:f7:4a:fc",
|
||||
"iface": "ens33"
|
||||
"permanent": false,
|
||||
"expires": "110"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, aix, freebsd, darwin
|
||||
|
||||
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
148
docs/parsers/blkid.md
Normal file
148
docs/parsers/blkid.md
Normal file
@@ -0,0 +1,148 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.blkid
|
||||
jc - JSON CLI output utility `blkid` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ blkid | jc --blkid
|
||||
|
||||
or
|
||||
|
||||
$ jc blkid
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.blkid
|
||||
result = jc.parsers.blkid.parse(blkid_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"device": string,
|
||||
"uuid": string,
|
||||
"type": string,
|
||||
"usage": string,
|
||||
"part_entry_scheme": string,
|
||||
"part_entry_type": string,
|
||||
"part_entry_flags": string,
|
||||
"part_entry_number": integer,
|
||||
"part_entry_offset": integer,
|
||||
"part_entry_size": integer,
|
||||
"part_entry_disk": string,
|
||||
"id_fs_uuid": string,
|
||||
"id_fs_uuid_enc": string,
|
||||
"id_fs_version": string,
|
||||
"id_fs_type": string,
|
||||
"id_fs_usage": string,
|
||||
"id_part_entry_scheme": string,
|
||||
"id_part_entry_type": string,
|
||||
"id_part_entry_flags": string,
|
||||
"id_part_entry_number": integer,
|
||||
"id_part_entry_offset": integer,
|
||||
"id_part_entry_size": integer,
|
||||
"id_iolimit_minimum_io_size": integer,
|
||||
"id_iolimit_physical_sector_size": integer,
|
||||
"id_iolimit_logical_sector_size": integer,
|
||||
"id_part_entry_disk": string,
|
||||
"minimum_io_size": integer,
|
||||
"physical_sector_size": integer,
|
||||
"logical_sector_size": integer
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ blkid | jc --blkid -p
|
||||
[
|
||||
{
|
||||
"device": "/dev/sda1",
|
||||
"uuid": "05d927ab-5875-49e4-ada1-7f46cb32c932",
|
||||
"type": "xfs"
|
||||
},
|
||||
{
|
||||
"device": "/dev/sda2",
|
||||
"uuid": "3klkIj-w1kk-DkJi-0XBJ-y3i7-i2Ac-vHqWBM",
|
||||
"type": "LVM2_member"
|
||||
},
|
||||
{
|
||||
"device": "/dev/mapper/centos-root",
|
||||
"uuid": "07d718ff-950c-4e5b-98f0-42a1147c77d9",
|
||||
"type": "xfs"
|
||||
},
|
||||
{
|
||||
"device": "/dev/mapper/centos-swap",
|
||||
"uuid": "615eb89a-bcbf-46fd-80e3-c483ff5c931f",
|
||||
"type": "swap"
|
||||
}
|
||||
]
|
||||
|
||||
$ sudo blkid -o udev -ip /dev/sda2 | jc --blkid -p
|
||||
[
|
||||
{
|
||||
"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_type": "LVM2_member",
|
||||
"id_fs_usage": "raid",
|
||||
"id_iolimit_minimum_io_size": 512,
|
||||
"id_iolimit_physical_sector_size": 512,
|
||||
"id_iolimit_logical_sector_size": 512,
|
||||
"id_part_entry_scheme": "dos",
|
||||
"id_part_entry_type": "0x8e",
|
||||
"id_part_entry_number": 2,
|
||||
"id_part_entry_offset": 2099200,
|
||||
"id_part_entry_size": 39843840,
|
||||
"id_part_entry_disk": "8:0"
|
||||
}
|
||||
]
|
||||
|
||||
$ sudo blkid -ip /dev/sda1 | jc --blkid -p -r
|
||||
[
|
||||
{
|
||||
"devname": "/dev/sda1",
|
||||
"uuid": "05d927bb-5875-49e3-ada1-7f46cb31c932",
|
||||
"type": "xfs",
|
||||
"usage": "filesystem",
|
||||
"minimum_io_size": "512",
|
||||
"physical_sector_size": "512",
|
||||
"logical_sector_size": "512",
|
||||
"part_entry_scheme": "dos",
|
||||
"part_entry_type": "0x83",
|
||||
"part_entry_flags": "0x80",
|
||||
"part_entry_number": "1",
|
||||
"part_entry_offset": "2048",
|
||||
"part_entry_size": "2097152",
|
||||
"part_entry_disk": "8:0"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
82
docs/parsers/cksum.md
Normal file
82
docs/parsers/cksum.md
Normal file
@@ -0,0 +1,82 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.cksum
|
||||
jc - JSON CLI output utility `cksum` command output parser
|
||||
|
||||
This parser works with the following checksum calculation utilities:
|
||||
- `sum`
|
||||
- `cksum`
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cksum file.txt | jc --cksum
|
||||
|
||||
or
|
||||
|
||||
$ jc cksum file.txt
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.cksum
|
||||
result = jc.parsers.cksum.parse(cksum_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"filename": string,
|
||||
"checksum": integer,
|
||||
"blocks": integer
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ cksum * | jc --cksum -p
|
||||
[
|
||||
{
|
||||
"filename": "__init__.py",
|
||||
"checksum": 4294967295,
|
||||
"blocks": 0
|
||||
},
|
||||
{
|
||||
"filename": "airport.py",
|
||||
"checksum": 2208551092,
|
||||
"blocks": 3745
|
||||
},
|
||||
{
|
||||
"filename": "airport_s.py",
|
||||
"checksum": 1113817598,
|
||||
"blocks": 4572
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
198
docs/parsers/crontab.md
Normal file
198
docs/parsers/crontab.md
Normal file
@@ -0,0 +1,198 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.crontab
|
||||
jc - JSON CLI output utility `crontab -l` command output and crontab file parser
|
||||
|
||||
Supports `crontab -l` command output and crontab files.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ crontab -l | jc --crontab
|
||||
|
||||
or
|
||||
|
||||
$ jc crontab -l
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.crontab
|
||||
result = jc.parsers.crontab.parse(crontab_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"variables": [
|
||||
"name": string,
|
||||
"value": string
|
||||
],
|
||||
"schedule": [
|
||||
{
|
||||
"occurrence" string,
|
||||
"minute": [
|
||||
string
|
||||
],
|
||||
"hour": [
|
||||
string
|
||||
],
|
||||
"day_of_month": [
|
||||
string
|
||||
],
|
||||
"month": [
|
||||
string
|
||||
],
|
||||
"day_of_week": [
|
||||
string
|
||||
],
|
||||
"occurrence": string,
|
||||
"command": string
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ crontab -l | jc --crontab -p
|
||||
{
|
||||
"variables": [
|
||||
{
|
||||
"name": "MAILTO",
|
||||
"value": "root"
|
||||
},
|
||||
{
|
||||
"name": "PATH",
|
||||
"value": "/sbin:/bin:/usr/sbin:/usr/bin"
|
||||
},
|
||||
{
|
||||
"name": "SHELL",
|
||||
"value": "/bin/bash"
|
||||
}
|
||||
],
|
||||
"schedule": [
|
||||
{
|
||||
"minute": [
|
||||
"5"
|
||||
],
|
||||
"hour": [
|
||||
"10-11",
|
||||
"22"
|
||||
],
|
||||
"day_of_month": [
|
||||
"*"
|
||||
],
|
||||
"month": [
|
||||
"*"
|
||||
],
|
||||
"day_of_week": [
|
||||
"*"
|
||||
],
|
||||
"command": "/var/www/devdaily.com/bin/mk-new-links.php"
|
||||
},
|
||||
{
|
||||
"minute": [
|
||||
"30"
|
||||
],
|
||||
"hour": [
|
||||
"4/2"
|
||||
],
|
||||
"day_of_month": [
|
||||
"*"
|
||||
],
|
||||
"month": [
|
||||
"*"
|
||||
],
|
||||
"day_of_week": [
|
||||
"*"
|
||||
],
|
||||
"command": "/var/www/devdaily.com/bin/create-all-backups.sh"
|
||||
},
|
||||
{
|
||||
"occurrence": "yearly",
|
||||
"command": "/home/maverick/bin/annual-maintenance"
|
||||
},
|
||||
{
|
||||
"occurrence": "reboot",
|
||||
"command": "/home/cleanup"
|
||||
},
|
||||
{
|
||||
"occurrence": "monthly",
|
||||
"command": "/home/maverick/bin/tape-backup"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
$ cat /etc/crontab | jc --crontab -p -r
|
||||
{
|
||||
"variables": [
|
||||
{
|
||||
"name": "MAILTO",
|
||||
"value": "root"
|
||||
},
|
||||
{
|
||||
"name": "PATH",
|
||||
"value": "/sbin:/bin:/usr/sbin:/usr/bin"
|
||||
},
|
||||
{
|
||||
"name": "SHELL",
|
||||
"value": "/bin/bash"
|
||||
}
|
||||
],
|
||||
"schedule": [
|
||||
{
|
||||
"minute": "5",
|
||||
"hour": "10-11,22",
|
||||
"day_of_month": "*",
|
||||
"month": "*",
|
||||
"day_of_week": "*",
|
||||
"command": "/var/www/devdaily.com/bin/mk-new-links.php"
|
||||
},
|
||||
{
|
||||
"minute": "30",
|
||||
"hour": "4/2",
|
||||
"day_of_month": "*",
|
||||
"month": "*",
|
||||
"day_of_week": "*",
|
||||
"command": "/var/www/devdaily.com/bin/create-all-backups.sh"
|
||||
},
|
||||
{
|
||||
"occurrence": "yearly",
|
||||
"command": "/home/maverick/bin/annual-maintenance"
|
||||
},
|
||||
{
|
||||
"occurrence": "reboot",
|
||||
"command": "/home/cleanup"
|
||||
},
|
||||
{
|
||||
"occurrence": "monthly",
|
||||
"command": "/home/maverick/bin/tape-backup"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, aix, freebsd
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
194
docs/parsers/crontab_u.md
Normal file
194
docs/parsers/crontab_u.md
Normal file
@@ -0,0 +1,194 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.crontab_u
|
||||
jc - JSON CLI output utility `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):
|
||||
|
||||
$ crontab -l | jc --crontab-u
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.crontab_u
|
||||
result = jc.parsers.crontab_u.parse(crontab_u_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"variables": [
|
||||
"name": string,
|
||||
"value": string
|
||||
],
|
||||
"schedule": [
|
||||
{
|
||||
"occurrence" string,
|
||||
"minute": [
|
||||
string
|
||||
],
|
||||
"hour": [
|
||||
string
|
||||
],
|
||||
"day_of_month": [
|
||||
string
|
||||
],
|
||||
"month": [
|
||||
string
|
||||
],
|
||||
"day_of_week": [
|
||||
string
|
||||
],
|
||||
"occurrence": string,
|
||||
"user": string,
|
||||
"command": string
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat /etc/crontab | jc --crontab-u -p
|
||||
{
|
||||
"variables": [
|
||||
{
|
||||
"name": "PATH",
|
||||
"value": "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
|
||||
},
|
||||
{
|
||||
"name": "SHELL",
|
||||
"value": "/bin/sh"
|
||||
}
|
||||
],
|
||||
"schedule": [
|
||||
{
|
||||
"minute": [
|
||||
"25"
|
||||
],
|
||||
"hour": [
|
||||
"6"
|
||||
],
|
||||
"day_of_month": [
|
||||
"*"
|
||||
],
|
||||
"month": [
|
||||
"*"
|
||||
],
|
||||
"day_of_week": [
|
||||
"*"
|
||||
],
|
||||
"user": "root",
|
||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )"
|
||||
},
|
||||
{
|
||||
"minute": [
|
||||
"47"
|
||||
],
|
||||
"hour": [
|
||||
"6"
|
||||
],
|
||||
"day_of_month": [
|
||||
"*"
|
||||
],
|
||||
"month": [
|
||||
"*"
|
||||
],
|
||||
"day_of_week": [
|
||||
"7"
|
||||
],
|
||||
"user": "root",
|
||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )"
|
||||
},
|
||||
{
|
||||
"minute": [
|
||||
"52"
|
||||
],
|
||||
"hour": [
|
||||
"6"
|
||||
],
|
||||
"day_of_month": [
|
||||
"1"
|
||||
],
|
||||
"month": [
|
||||
"*"
|
||||
],
|
||||
"day_of_week": [
|
||||
"*"
|
||||
],
|
||||
"user": "root",
|
||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
$ cat /etc/crontab | jc --crontab-u -p -r
|
||||
{
|
||||
"variables": [
|
||||
{
|
||||
"name": "PATH",
|
||||
"value": "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
|
||||
},
|
||||
{
|
||||
"name": "SHELL",
|
||||
"value": "/bin/sh"
|
||||
}
|
||||
],
|
||||
"schedule": [
|
||||
{
|
||||
"minute": "25",
|
||||
"hour": "6",
|
||||
"day_of_month": "*",
|
||||
"month": "*",
|
||||
"day_of_week": "*",
|
||||
"user": "root",
|
||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )"
|
||||
},
|
||||
{
|
||||
"minute": "47",
|
||||
"hour": "6",
|
||||
"day_of_month": "*",
|
||||
"month": "*",
|
||||
"day_of_week": "7",
|
||||
"user": "root",
|
||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )"
|
||||
},
|
||||
{
|
||||
"minute": "52",
|
||||
"hour": "6",
|
||||
"day_of_month": "1",
|
||||
"month": "*",
|
||||
"day_of_week": "*",
|
||||
"user": "root",
|
||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, aix, freebsd
|
||||
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
102
docs/parsers/csv.md
Normal file
102
docs/parsers/csv.md
Normal file
@@ -0,0 +1,102 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# 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.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat file.csv | jc --csv
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.csv
|
||||
result = jc.parsers.csv.parse(csv_output)
|
||||
|
||||
Schema:
|
||||
|
||||
csv file converted to a Dictionary: https://docs.python.org/3/library/csv.html
|
||||
|
||||
[
|
||||
{
|
||||
"column_name1": string,
|
||||
"column_name2": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat homes.csv
|
||||
"Sell", "List", "Living", "Rooms", "Beds", "Baths", "Age", "Acres", "Taxes"
|
||||
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 -p
|
||||
[
|
||||
{
|
||||
"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"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
85
docs/parsers/csv_s.md
Normal file
85
docs/parsers/csv_s.md
Normal file
@@ -0,0 +1,85 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.csv_s
|
||||
jc - JSON CLI output utility `csv` file streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines
|
||||
|
||||
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):
|
||||
|
||||
$ cat file.csv | jc --csv-s
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.csv_s
|
||||
result = jc.parsers.csv_s.parse(csv_output.splitlines()) # result is an iterable object
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
Schema:
|
||||
|
||||
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": booean, # true if successfully parsed, false if error
|
||||
"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"
|
||||
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"}
|
||||
...
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterator object.
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (iterable) line-based text data to parse (e.g. sys.stdin or str.splitlines())
|
||||
raw: (boolean) output preprocessed JSON 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
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
99
docs/parsers/date.md
Normal file
99
docs/parsers/date.md
Normal file
@@ -0,0 +1,99 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.date
|
||||
jc - JSON CLI output utility `date` command output parser
|
||||
|
||||
The `epoch` calculated timestamp field is naive. (i.e. based on the local time of the system the parser is run on)
|
||||
|
||||
The `epoch_utc` calculated timestamp field is timezone-aware and is only available if the timezone field is UTC.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ date | jc --date
|
||||
|
||||
or
|
||||
|
||||
$ jc date
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.date
|
||||
result = jc.parsers.date.parse(date_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"year": integer,
|
||||
"month": string,
|
||||
"month_num": integer,
|
||||
"day": integer,
|
||||
"weekday": string,
|
||||
"weekday_num": integer,
|
||||
"hour": integer,
|
||||
"hour_24": integer,
|
||||
"minute": integer,
|
||||
"second": integer,
|
||||
"period": string,
|
||||
"timezone": string,
|
||||
"utc_offset": string, # null if timezone field is not UTC
|
||||
"day_of_year": integer,
|
||||
"week_of_year": integer,
|
||||
"iso": string,
|
||||
"epoch": integer, # naive timestamp
|
||||
"epoch_utc": integer, # timezone-aware timestamp. Only available if timezone field is UTC
|
||||
"timezone_aware": boolean # if true, all fields are correctly based on UTC
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ date | jc --date -p
|
||||
{
|
||||
"year": 2021,
|
||||
"month": "Mar",
|
||||
"month_num": 3,
|
||||
"day": 25,
|
||||
"weekday": "Thu",
|
||||
"weekday_num": 4,
|
||||
"hour": 2,
|
||||
"hour_24": 2,
|
||||
"minute": 2,
|
||||
"second": 26,
|
||||
"period": "AM",
|
||||
"timezone": "UTC",
|
||||
"utc_offset": "+0000",
|
||||
"day_of_year": 84,
|
||||
"week_of_year": 12,
|
||||
"iso": "2021-03-25T02:02:26+00:00",
|
||||
"epoch": 1616662946,
|
||||
"epoch_utc": 1616637746,
|
||||
"timezone_aware": true
|
||||
}
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 2.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
125
docs/parsers/df.md
Normal file
125
docs/parsers/df.md
Normal file
@@ -0,0 +1,125 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.df
|
||||
jc - JSON CLI output utility `df` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ df | jc --df
|
||||
|
||||
or
|
||||
|
||||
$ jc df
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.df
|
||||
result = jc.parsers.df.parse(df_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"filesystem": string,
|
||||
"size": string,
|
||||
"1k_blocks": integer,
|
||||
"512_blocks": integer,
|
||||
"used": integer,
|
||||
"available": integer,
|
||||
"capacity_percent": integer,
|
||||
"ifree": integer,
|
||||
"iused": integer,
|
||||
"use_percent": integer,
|
||||
"iused_percent": integer,
|
||||
"mounted_on": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ df | jc --df -p
|
||||
[
|
||||
{
|
||||
"filesystem": "devtmpfs",
|
||||
"1k_blocks": 1918820,
|
||||
"used": 0,
|
||||
"available": 1918820,
|
||||
"use_percent": 0,
|
||||
"mounted_on": "/dev"
|
||||
},
|
||||
{
|
||||
"filesystem": "tmpfs",
|
||||
"1k_blocks": 1930668,
|
||||
"used": 0,
|
||||
"available": 1930668,
|
||||
"use_percent": 0,
|
||||
"mounted_on": "/dev/shm"
|
||||
},
|
||||
{
|
||||
"filesystem": "tmpfs",
|
||||
"1k_blocks": 1930668,
|
||||
"used": 11800,
|
||||
"available": 1918868,
|
||||
"use_percent": 1,
|
||||
"mounted_on": "/run"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ df | jc --df -p -r
|
||||
[
|
||||
{
|
||||
"filesystem": "devtmpfs",
|
||||
"1k_blocks": "1918820",
|
||||
"used": "0",
|
||||
"available": "1918820",
|
||||
"use_percent": "0%",
|
||||
"mounted_on": "/dev"
|
||||
},
|
||||
{
|
||||
"filesystem": "tmpfs",
|
||||
"1k_blocks": "1930668",
|
||||
"used": "0",
|
||||
"available": "1930668",
|
||||
"use_percent": "0%",
|
||||
"mounted_on": "/dev/shm"
|
||||
},
|
||||
{
|
||||
"filesystem": "tmpfs",
|
||||
"1k_blocks": "1930668",
|
||||
"used": "11800",
|
||||
"available": "1918868",
|
||||
"use_percent": "1%",
|
||||
"mounted_on": "/run"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
344
docs/parsers/dig.md
Normal file
344
docs/parsers/dig.md
Normal file
@@ -0,0 +1,344 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.dig
|
||||
jc - JSON CLI output utility `dig` command output parser
|
||||
|
||||
Options supported:
|
||||
- `+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_utc` calculated timestamp field is timezone-aware and is only available if the timezone field is UTC.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ dig example.com | jc --dig
|
||||
|
||||
or
|
||||
|
||||
$ jc dig example.com
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.dig
|
||||
result = jc.parsers.dig.parse(dig_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"id": integer,
|
||||
"opcode": string,
|
||||
"status": string,
|
||||
"flags": [
|
||||
string
|
||||
],
|
||||
"query_num": integer,
|
||||
"answer_num": integer,
|
||||
"authority_num": integer,
|
||||
"additional_num": integer,
|
||||
"axfr": [
|
||||
{
|
||||
"name": string,
|
||||
"class": string,
|
||||
"type": string,
|
||||
"ttl": integer,
|
||||
"data": string
|
||||
}
|
||||
],
|
||||
"opt_pseudosection": {
|
||||
"edns": {
|
||||
"version": integer,
|
||||
"flags": [
|
||||
string
|
||||
],
|
||||
"udp": integer
|
||||
},
|
||||
"cookie": string
|
||||
},
|
||||
"question": {
|
||||
"name": string,
|
||||
"class": string,
|
||||
"type": string
|
||||
},
|
||||
"answer": [
|
||||
{
|
||||
"name": string,
|
||||
"class": string,
|
||||
"type": string,
|
||||
"ttl": integer,
|
||||
"data": string
|
||||
}
|
||||
],
|
||||
"additional": [
|
||||
{
|
||||
"name": string,
|
||||
"class": string,
|
||||
"type": string,
|
||||
"ttl": integer,
|
||||
"data": string
|
||||
}
|
||||
],
|
||||
"authority": [
|
||||
{
|
||||
"name": string,
|
||||
"class": string,
|
||||
"type": string,
|
||||
"ttl": integer,
|
||||
"data": string
|
||||
}
|
||||
],
|
||||
"query_size": integer,
|
||||
"query_time": integer, # in msec
|
||||
"server": string,
|
||||
"when": string,
|
||||
"when_epoch": integer, # naive timestamp if when field is parsable, else null
|
||||
"when_epoch_utc": integer, # timezone aware timestamp availabe for UTC, else null
|
||||
"rcvd": integer
|
||||
"size": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ dig example.com | jc --dig -p
|
||||
[
|
||||
{
|
||||
"id": 2951,
|
||||
"opcode": "QUERY",
|
||||
"status": "NOERROR",
|
||||
"flags": [
|
||||
"qr",
|
||||
"rd",
|
||||
"ra"
|
||||
],
|
||||
"query_num": 1,
|
||||
"answer_num": 1,
|
||||
"authority_num": 0,
|
||||
"additional_num": 1,
|
||||
"opt_pseudosection": {
|
||||
"edns": {
|
||||
"version": 0,
|
||||
"flags": [],
|
||||
"udp": 4096
|
||||
}
|
||||
},
|
||||
"question": {
|
||||
"name": "example.com.",
|
||||
"class": "IN",
|
||||
"type": "A"
|
||||
},
|
||||
"answer": [
|
||||
{
|
||||
"name": "example.com.",
|
||||
"class": "IN",
|
||||
"type": "A",
|
||||
"ttl": 39302,
|
||||
"data": "93.184.216.34"
|
||||
}
|
||||
],
|
||||
"query_time": 49,
|
||||
"server": "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
|
||||
"when": "Fri Apr 16 16:05:10 PDT 2021",
|
||||
"rcvd": 56,
|
||||
"when_epoch": 1618614310,
|
||||
"when_epoch_utc": null
|
||||
}
|
||||
]
|
||||
|
||||
$ dig cnn.com www.cnn.com @205.251.194.64 | jc --dig -p -r
|
||||
[
|
||||
{
|
||||
"id": "46052",
|
||||
"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": "40426",
|
||||
"data": "93.184.216.34"
|
||||
}
|
||||
],
|
||||
"query_time": "48 msec",
|
||||
"server": "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
|
||||
"when": "Fri Apr 16 16:06:12 PDT 2021",
|
||||
"rcvd": "56"
|
||||
}
|
||||
]
|
||||
|
||||
$ dig -x 1.1.1.1 | jc --dig -p
|
||||
[
|
||||
{
|
||||
"id": 20785,
|
||||
"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": "1.1.1.1.in-addr.arpa.",
|
||||
"class": "IN",
|
||||
"type": "PTR"
|
||||
},
|
||||
"answer": [
|
||||
{
|
||||
"name": "1.1.1.1.in-addr.arpa.",
|
||||
"class": "IN",
|
||||
"type": "PTR",
|
||||
"ttl": 1800,
|
||||
"data": "one.one.one.one."
|
||||
}
|
||||
],
|
||||
"query_time": 40,
|
||||
"server": "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
|
||||
"when": "Sat Apr 17 14:50:50 PDT 2021",
|
||||
"rcvd": 78,
|
||||
"when_epoch": 1618696250,
|
||||
"when_epoch_utc": null
|
||||
}
|
||||
]
|
||||
|
||||
$ dig -x 1.1.1.1 | jc --dig -p -r
|
||||
[
|
||||
{
|
||||
"id": "32644",
|
||||
"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": "1.1.1.1.in-addr.arpa.",
|
||||
"class": "IN",
|
||||
"type": "PTR"
|
||||
},
|
||||
"answer": [
|
||||
{
|
||||
"name": "1.1.1.1.in-addr.arpa.",
|
||||
"class": "IN",
|
||||
"type": "PTR",
|
||||
"ttl": "1800",
|
||||
"data": "one.one.one.one."
|
||||
}
|
||||
],
|
||||
"query_time": "52 msec",
|
||||
"server": "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
|
||||
"when": "Sat Apr 17 14:51:46 PDT 2021",
|
||||
"rcvd": "78"
|
||||
}
|
||||
]
|
||||
|
||||
$ dig +noall +answer cnn.com | jc --dig -p
|
||||
[
|
||||
{
|
||||
"answer": [
|
||||
{
|
||||
"name": "cnn.com.",
|
||||
"class": "IN",
|
||||
"type": "A",
|
||||
"ttl": 60,
|
||||
"data": "151.101.193.67"
|
||||
},
|
||||
{
|
||||
"name": "cnn.com.",
|
||||
"class": "IN",
|
||||
"type": "A",
|
||||
"ttl": 60,
|
||||
"data": "151.101.65.67"
|
||||
},
|
||||
{
|
||||
"name": "cnn.com.",
|
||||
"class": "IN",
|
||||
"type": "A",
|
||||
"ttl": 60,
|
||||
"data": "151.101.1.67"
|
||||
},
|
||||
{
|
||||
"name": "cnn.com.",
|
||||
"class": "IN",
|
||||
"type": "A",
|
||||
"ttl": 60,
|
||||
"data": "151.101.129.67"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, aix, freebsd, darwin, win32, cygwin
|
||||
|
||||
Version 2.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
146
docs/parsers/dir.md
Normal file
146
docs/parsers/dir.md
Normal file
@@ -0,0 +1,146 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.dir
|
||||
jc - JSON CLI output utility `dir` command output parser
|
||||
|
||||
Options supported:
|
||||
- `/T timefield`
|
||||
- `/O sortorder`
|
||||
- `/C, /-C`
|
||||
- `/S`
|
||||
|
||||
The "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)
|
||||
|
||||
Usage (cli):
|
||||
|
||||
C:> dir | jc --dir
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.dir
|
||||
result = jc.parsers.dir.parse(dir_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"date": string,
|
||||
"time": string,
|
||||
"epoch": integer, # naive timestamp
|
||||
"dir": boolean,
|
||||
"size": integer,
|
||||
"filename: string,
|
||||
"parent": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
C:> dir | jc --dir -p
|
||||
[
|
||||
{
|
||||
"date": "03/24/2021",
|
||||
"time": "03:15 PM",
|
||||
"dir": true,
|
||||
"size": null,
|
||||
"filename": ".",
|
||||
"parent": "C:\Program Files\Internet Explorer",
|
||||
"epoch": 1616624100
|
||||
},
|
||||
{
|
||||
"date": "03/24/2021",
|
||||
"time": "03:15 PM",
|
||||
"dir": true,
|
||||
"size": null,
|
||||
"filename": "..",
|
||||
"parent": "C:\Program Files\Internet Explorer",
|
||||
"epoch": 1616624100
|
||||
},
|
||||
{
|
||||
"date": "12/07/2019",
|
||||
"time": "02:49 AM",
|
||||
"dir": true,
|
||||
"size": null,
|
||||
"filename": "en-US",
|
||||
"parent": "C:\Program Files\Internet Explorer",
|
||||
"epoch": 1575715740
|
||||
},
|
||||
{
|
||||
"date": "12/07/2019",
|
||||
"time": "02:09 AM",
|
||||
"dir": false,
|
||||
"size": 54784,
|
||||
"filename": "ExtExport.exe",
|
||||
"parent": "C:\Program Files\Internet Explorer",
|
||||
"epoch": 1575713340
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
C:> dir | jc --dir -p -r
|
||||
[
|
||||
{
|
||||
"date": "03/24/2021",
|
||||
"time": "03:15 PM",
|
||||
"dir": true,
|
||||
"size": null,
|
||||
"filename": ".",
|
||||
"parent": "C:\Program Files\Internet Explorer"
|
||||
},
|
||||
{
|
||||
"date": "03/24/2021",
|
||||
"time": "03:15 PM",
|
||||
"dir": true,
|
||||
"size": null,
|
||||
"filename": "..",
|
||||
"parent": "C:\Program Files\Internet Explorer"
|
||||
},
|
||||
{
|
||||
"date": "12/07/2019",
|
||||
"time": "02:49 AM",
|
||||
"dir": true,
|
||||
"size": null,
|
||||
"filename": "en-US",
|
||||
"parent": "C:\Program Files\Internet Explorer"
|
||||
},
|
||||
{
|
||||
"date": "12/07/2019",
|
||||
"time": "02:09 AM",
|
||||
"dir": false,
|
||||
"size": "54,784",
|
||||
"filename": "ExtExport.exe",
|
||||
"parent": "C:\Program Files\Internet Explorer"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: win32
|
||||
|
||||
Version 1.4 by Rasheed Elsaleh (rasheed@rebelliondefense.com)
|
||||
153
docs/parsers/dmidecode.md
Normal file
153
docs/parsers/dmidecode.md
Normal file
@@ -0,0 +1,153 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.dmidecode
|
||||
jc - JSON CLI output utility `dmidecode` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ dmidecode | jc --dmidecode
|
||||
|
||||
or
|
||||
|
||||
$ jc dmidecode
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.dmidecode
|
||||
result = jc.parsers.dmidecode.parse(dmidecode_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"handle": string,
|
||||
"type": integer,
|
||||
"bytes": integer,
|
||||
"description": string,
|
||||
"values": { (null if empty)
|
||||
"lowercase_no_spaces_keys": string,
|
||||
"multiline_key_values": [
|
||||
string,
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
# dmidecode | jc --dmidecode -p
|
||||
[
|
||||
{
|
||||
"handle": "0x0000",
|
||||
"type": 0,
|
||||
"bytes": 24,
|
||||
"description": "BIOS Information",
|
||||
"values": {
|
||||
"vendor": "Phoenix Technologies LTD",
|
||||
"version": "6.00",
|
||||
"release_date": "04/13/2018",
|
||||
"address": "0xEA490",
|
||||
"runtime_size": "88944 bytes",
|
||||
"rom_size": "64 kB",
|
||||
"characteristics": [
|
||||
"ISA is supported",
|
||||
"PCI is supported",
|
||||
"PC Card (PCMCIA) is supported",
|
||||
"PNP is supported",
|
||||
"APM is supported",
|
||||
"BIOS is upgradeable",
|
||||
"BIOS shadowing is allowed",
|
||||
"ESCD support is available",
|
||||
"Boot from CD is supported",
|
||||
"Selectable boot is supported",
|
||||
"EDD is supported",
|
||||
"Print screen service is supported (int 5h)",
|
||||
"8042 keyboard services are supported (int 9h)",
|
||||
"Serial services are supported (int 14h)",
|
||||
"Printer services are supported (int 17h)",
|
||||
"CGA/mono video services are supported (int 10h)",
|
||||
"ACPI is supported",
|
||||
"Smart battery is supported",
|
||||
"BIOS boot specification is supported",
|
||||
"Function key-initiated network boot is supported",
|
||||
"Targeted content distribution is supported"
|
||||
],
|
||||
"bios_revision": "4.6",
|
||||
"firmware_revision": "0.0"
|
||||
}
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
# dmidecode | jc --dmidecode -p -r
|
||||
[
|
||||
{
|
||||
"handle": "0x0000",
|
||||
"type": "0",
|
||||
"bytes": "24",
|
||||
"description": "BIOS Information",
|
||||
"values": {
|
||||
"vendor": "Phoenix Technologies LTD",
|
||||
"version": "6.00",
|
||||
"release_date": "04/13/2018",
|
||||
"address": "0xEA490",
|
||||
"runtime_size": "88944 bytes",
|
||||
"rom_size": "64 kB",
|
||||
"characteristics": [
|
||||
"ISA is supported",
|
||||
"PCI is supported",
|
||||
"PC Card (PCMCIA) is supported",
|
||||
"PNP is supported",
|
||||
"APM is supported",
|
||||
"BIOS is upgradeable",
|
||||
"BIOS shadowing is allowed",
|
||||
"ESCD support is available",
|
||||
"Boot from CD is supported",
|
||||
"Selectable boot is supported",
|
||||
"EDD is supported",
|
||||
"Print screen service is supported (int 5h)",
|
||||
"8042 keyboard services are supported (int 9h)",
|
||||
"Serial services are supported (int 14h)",
|
||||
"Printer services are supported (int 17h)",
|
||||
"CGA/mono video services are supported (int 10h)",
|
||||
"ACPI is supported",
|
||||
"Smart battery is supported",
|
||||
"BIOS boot specification is supported",
|
||||
"Function key-initiated network boot is supported",
|
||||
"Targeted content distribution is supported"
|
||||
],
|
||||
"bios_revision": "4.6",
|
||||
"firmware_revision": "0.0"
|
||||
}
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
158
docs/parsers/dpkg_l.md
Normal file
158
docs/parsers/dpkg_l.md
Normal file
@@ -0,0 +1,158 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.dpkg_l
|
||||
jc - JSON CLI output utility `dpkg -l` command output parser
|
||||
|
||||
Set the `COLUMNS` environment variable to a large value to avoid field truncation. For example:
|
||||
|
||||
$ COLUMNS=500 dpkg -l | jc --dpkg-l
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ dpkg -l | jc --dpkg-l
|
||||
|
||||
or
|
||||
|
||||
$ jc dpkg -l
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.dpkg_l
|
||||
result = jc.parsers.dpkg_l.parse(dpkg_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"codes": string,
|
||||
"name": string,
|
||||
"version": string,
|
||||
"architecture": string,
|
||||
"description": string,
|
||||
"desired": string,
|
||||
"status": string,
|
||||
"error": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ dpkg -l | jc --dpkg-l -p
|
||||
[
|
||||
{
|
||||
"codes": "ii",
|
||||
"name": "accountsservice",
|
||||
"version": "0.6.45-1ubuntu1.3",
|
||||
"architecture": "amd64",
|
||||
"description": "query and manipulate user account information",
|
||||
"desired": "install",
|
||||
"status": "installed"
|
||||
},
|
||||
{
|
||||
"codes": "rc",
|
||||
"name": "acl",
|
||||
"version": "2.2.52-3build1",
|
||||
"architecture": "amd64",
|
||||
"description": "Access control list utilities",
|
||||
"desired": "remove",
|
||||
"status": "config-files"
|
||||
},
|
||||
{
|
||||
"codes": "uWR",
|
||||
"name": "acpi",
|
||||
"version": "1.7-1.1",
|
||||
"architecture": "amd64",
|
||||
"description": "displays information on ACPI devices",
|
||||
"desired": "unknown",
|
||||
"status": "trigger await",
|
||||
"error": "reinstall required"
|
||||
},
|
||||
{
|
||||
"codes": "rh",
|
||||
"name": "acpid",
|
||||
"version": "1:2.0.28-1ubuntu1",
|
||||
"architecture": "amd64",
|
||||
"description": "Advanced Configuration and Power Interface event daemon",
|
||||
"desired": "remove",
|
||||
"status": "half installed"
|
||||
},
|
||||
{
|
||||
"codes": "pn",
|
||||
"name": "adduser",
|
||||
"version": "3.116ubuntu1",
|
||||
"architecture": "all",
|
||||
"description": "add and remove users and groups",
|
||||
"desired": "purge",
|
||||
"status": "not installed"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ dpkg -l | jc --dpkg-l -p -r
|
||||
[
|
||||
{
|
||||
"codes": "ii",
|
||||
"name": "accountsservice",
|
||||
"version": "0.6.45-1ubuntu1.3",
|
||||
"architecture": "amd64",
|
||||
"description": "query and manipulate user account information"
|
||||
},
|
||||
{
|
||||
"codes": "rc",
|
||||
"name": "acl",
|
||||
"version": "2.2.52-3build1",
|
||||
"architecture": "amd64",
|
||||
"description": "Access control list utilities"
|
||||
},
|
||||
{
|
||||
"codes": "uWR",
|
||||
"name": "acpi",
|
||||
"version": "1.7-1.1",
|
||||
"architecture": "amd64",
|
||||
"description": "displays information on ACPI devices"
|
||||
},
|
||||
{
|
||||
"codes": "rh",
|
||||
"name": "acpid",
|
||||
"version": "1:2.0.28-1ubuntu1",
|
||||
"architecture": "amd64",
|
||||
"description": "Advanced Configuration and Power Interface event daemon"
|
||||
},
|
||||
{
|
||||
"codes": "pn",
|
||||
"name": "adduser",
|
||||
"version": "3.116ubuntu1",
|
||||
"architecture": "all",
|
||||
"description": "add and remove users and groups"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
115
docs/parsers/du.md
Normal file
115
docs/parsers/du.md
Normal file
@@ -0,0 +1,115 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.du
|
||||
jc - JSON CLI output utility `du` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ du | jc --du
|
||||
|
||||
or
|
||||
|
||||
$ jc du
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.du
|
||||
result = jc.parsers.du.parse(du_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"size": integer,
|
||||
"name": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ du /usr | jc --du -p
|
||||
[
|
||||
{
|
||||
"size": 104608,
|
||||
"name": "/usr/bin"
|
||||
},
|
||||
{
|
||||
"size": 56,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/_CodeSignature"
|
||||
},
|
||||
{
|
||||
"size": 0,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local/standalone"
|
||||
},
|
||||
{
|
||||
"size": 0,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local"
|
||||
},
|
||||
{
|
||||
"size": 0,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr"
|
||||
},
|
||||
{
|
||||
"size": 1008,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/dfu"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ du /usr | jc --du -p -r
|
||||
[
|
||||
{
|
||||
"size": "104608",
|
||||
"name": "/usr/bin"
|
||||
},
|
||||
{
|
||||
"size": "56",
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/_CodeSignature"
|
||||
},
|
||||
{
|
||||
"size": "0",
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local/standalone"
|
||||
},
|
||||
{
|
||||
"size": "0",
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local"
|
||||
},
|
||||
{
|
||||
"size": "0",
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr"
|
||||
},
|
||||
{
|
||||
"size": "1008",
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/dfu"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, aix, freebsd
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
98
docs/parsers/env.md
Normal file
98
docs/parsers/env.md
Normal file
@@ -0,0 +1,98 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# 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.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ env | jc --env
|
||||
|
||||
or
|
||||
|
||||
$ jc env
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.env
|
||||
result = jc.parsers.env.parse(env_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"name": string,
|
||||
"value": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ env | jc --env -p
|
||||
[
|
||||
{
|
||||
"name": "XDG_SESSION_ID",
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"name": "HOSTNAME",
|
||||
"value": "localhost.localdomain"
|
||||
},
|
||||
{
|
||||
"name": "TERM",
|
||||
"value": "vt220"
|
||||
},
|
||||
{
|
||||
"name": "SHELL",
|
||||
"value": "/bin/bash"
|
||||
},
|
||||
{
|
||||
"name": "HISTSIZE",
|
||||
"value": "1000"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ env | jc --env -p -r
|
||||
{
|
||||
"TERM": "xterm-256color",
|
||||
"SHELL": "/bin/bash",
|
||||
"USER": "root",
|
||||
"PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
|
||||
"PWD": "/root",
|
||||
"LANG": "en_US.UTF-8",
|
||||
"HOME": "/root",
|
||||
"LOGNAME": "root",
|
||||
"_": "/usr/bin/env"
|
||||
}
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary of raw structured data or
|
||||
List of Dictionaries of processed structured data
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
90
docs/parsers/file.md
Normal file
90
docs/parsers/file.md
Normal file
@@ -0,0 +1,90 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.file
|
||||
jc - JSON CLI output utility `file` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ file * | jc --file
|
||||
|
||||
or
|
||||
|
||||
$ jc file *
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.file
|
||||
result = jc.parsers.file.parse(file_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"filename": string,
|
||||
"type ": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ file * | jc --file -p
|
||||
[
|
||||
{
|
||||
"filename": "Applications",
|
||||
"type": "directory"
|
||||
},
|
||||
{
|
||||
"filename": "another file with spaces",
|
||||
"type": "empty"
|
||||
},
|
||||
{
|
||||
"filename": "argstest.py",
|
||||
"type": "Python script text executable, ASCII text"
|
||||
},
|
||||
{
|
||||
"filename": "blkid-p.out",
|
||||
"type": "ASCII text"
|
||||
},
|
||||
{
|
||||
"filename": "blkid-pi.out",
|
||||
"type": "ASCII text, with very long lines"
|
||||
},
|
||||
{
|
||||
"filename": "cd_catalog.xml",
|
||||
"type": "XML 1.0 document text, ASCII text, with CRLF line terminators"
|
||||
},
|
||||
{
|
||||
"filename": "centosserial.sh",
|
||||
"type": "Bourne-Again shell script text executable, UTF-8 Unicode text"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, aix, freebsd, darwin
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
118
docs/parsers/finger.md
Normal file
118
docs/parsers/finger.md
Normal file
@@ -0,0 +1,118 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.finger
|
||||
jc - JSON CLI output utility `finger` command output parser
|
||||
|
||||
Supports `-s` output option. Does not support the `-l` detail option.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ finger | jc --finger
|
||||
|
||||
or
|
||||
|
||||
$ jc finger
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.finger
|
||||
result = jc.parsers.finger.parse(finger_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"login": string,
|
||||
"name": string,
|
||||
"tty": string,
|
||||
"idle": string, # null if empty
|
||||
"login_time": string,
|
||||
"details": string,
|
||||
"tty_writeable": boolean,
|
||||
"idle_minutes": integer,
|
||||
"idle_hours": integer,
|
||||
"idle_days": integer,
|
||||
"total_idle_minutes": integer
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ finger | jc --finger -p
|
||||
[
|
||||
{
|
||||
"login": "jdoe",
|
||||
"name": "John Doe",
|
||||
"tty": "tty1",
|
||||
"idle": "14d",
|
||||
"login_time": "Mar 22 21:14",
|
||||
"tty_writeable": false,
|
||||
"idle_minutes": 0,
|
||||
"idle_hours": 0,
|
||||
"idle_days": 14,
|
||||
"total_idle_minutes": 20160
|
||||
},
|
||||
{
|
||||
"login": "jdoe",
|
||||
"name": "John Doe",
|
||||
"tty": "pts/0",
|
||||
"idle": null,
|
||||
"login_time": "Apr 5 15:33",
|
||||
"details": "(192.168.1.22)",
|
||||
"tty_writeable": true,
|
||||
"idle_minutes": 0,
|
||||
"idle_hours": 0,
|
||||
"idle_days": 0,
|
||||
"total_idle_minutes": 0
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ finger | jc --finger -p -r
|
||||
[
|
||||
{
|
||||
"login": "jdoe",
|
||||
"name": "John Doe",
|
||||
"tty": "*tty1",
|
||||
"idle": "14d",
|
||||
"login_time": "Mar 22 21:14"
|
||||
},
|
||||
{
|
||||
"login": "jdoe",
|
||||
"name": "John Doe",
|
||||
"tty": "pts/0",
|
||||
"idle": null,
|
||||
"login_time": "Apr 5 15:33",
|
||||
"details": "(192.168.1.22)"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, freebsd
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
100
docs/parsers/free.md
Normal file
100
docs/parsers/free.md
Normal file
@@ -0,0 +1,100 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.free
|
||||
jc - JSON CLI output utility `free` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ free | jc --free
|
||||
|
||||
or
|
||||
|
||||
$ jc free
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.free
|
||||
result = jc.parsers.free.parse(free_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"type": string,
|
||||
"total": integer,
|
||||
"used": integer,
|
||||
"free": integer,
|
||||
"shared": integer,
|
||||
"buff_cache": integer,
|
||||
"available": integer
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ free | jc --free -p
|
||||
[
|
||||
{
|
||||
"type": "Mem",
|
||||
"total": 3861340,
|
||||
"used": 220508,
|
||||
"free": 3381972,
|
||||
"shared": 11800,
|
||||
"buff_cache": 258860,
|
||||
"available": 3397784
|
||||
},
|
||||
{
|
||||
"type": "Swap",
|
||||
"total": 2097148,
|
||||
"used": 0,
|
||||
"free": 2097148
|
||||
}
|
||||
]
|
||||
|
||||
$ free | jc --free -p -r
|
||||
[
|
||||
{
|
||||
"type": "Mem",
|
||||
"total": "2017300",
|
||||
"used": "213104",
|
||||
"free": "1148452",
|
||||
"shared": "1176",
|
||||
"buff_cache": "655744",
|
||||
"available": "1622204"
|
||||
},
|
||||
{
|
||||
"type": "Swap",
|
||||
"total": "2097148",
|
||||
"used": "0",
|
||||
"free": "2097148"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
113
docs/parsers/fstab.md
Normal file
113
docs/parsers/fstab.md
Normal file
@@ -0,0 +1,113 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.fstab
|
||||
jc - JSON CLI output utility `fstab` file parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat /etc/fstab | jc --fstab
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.fstab
|
||||
result = jc.parsers.fstab.parse(fstab_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"fs_spec": string,
|
||||
"fs_file": string,
|
||||
"fs_vfstype": string,
|
||||
"fs_mntops": string,
|
||||
"fs_freq": integer,
|
||||
"fs_passno": integer
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat /etc/fstab | jc --fstab -p
|
||||
[
|
||||
{
|
||||
"fs_spec": "/dev/mapper/centos-root",
|
||||
"fs_file": "/",
|
||||
"fs_vfstype": "xfs",
|
||||
"fs_mntops": "defaults",
|
||||
"fs_freq": 0,
|
||||
"fs_passno": 0
|
||||
},
|
||||
{
|
||||
"fs_spec": "UUID=05d927bb-5875-49e3-ada1-7f46cb31c932",
|
||||
"fs_file": "/boot",
|
||||
"fs_vfstype": "xfs",
|
||||
"fs_mntops": "defaults",
|
||||
"fs_freq": 0,
|
||||
"fs_passno": 0
|
||||
},
|
||||
{
|
||||
"fs_spec": "/dev/mapper/centos-swap",
|
||||
"fs_file": "swap",
|
||||
"fs_vfstype": "swap",
|
||||
"fs_mntops": "defaults",
|
||||
"fs_freq": 0,
|
||||
"fs_passno": 0
|
||||
}
|
||||
]
|
||||
|
||||
$ cat /etc/fstab | jc --fstab -p -r
|
||||
[
|
||||
{
|
||||
"fs_spec": "/dev/mapper/centos-root",
|
||||
"fs_file": "/",
|
||||
"fs_vfstype": "xfs",
|
||||
"fs_mntops": "defaults",
|
||||
"fs_freq": "0",
|
||||
"fs_passno": "0"
|
||||
},
|
||||
{
|
||||
"fs_spec": "UUID=05d927bb-5875-49e3-ada1-7f46cb31c932",
|
||||
"fs_file": "/boot",
|
||||
"fs_vfstype": "xfs",
|
||||
"fs_mntops": "defaults",
|
||||
"fs_freq": "0",
|
||||
"fs_passno": "0"
|
||||
},
|
||||
{
|
||||
"fs_spec": "/dev/mapper/centos-swap",
|
||||
"fs_file": "swap",
|
||||
"fs_vfstype": "swap",
|
||||
"fs_mntops": "defaults",
|
||||
"fs_freq": "0",
|
||||
"fs_passno": "0"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, freebsd
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
137
docs/parsers/group.md
Normal file
137
docs/parsers/group.md
Normal file
@@ -0,0 +1,137 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.group
|
||||
jc - JSON CLI output utility `/etc/group` file parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat /etc/group | jc --group
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.group
|
||||
result = jc.parsers.group.parse(group_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"group_name": string,
|
||||
"password": string,
|
||||
"gid": integer,
|
||||
"members": [
|
||||
string
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat /etc/group | jc --group -p
|
||||
[
|
||||
{
|
||||
"group_name": "nobody",
|
||||
"password": "*",
|
||||
"gid": -2,
|
||||
"members": []
|
||||
},
|
||||
{
|
||||
"group_name": "nogroup",
|
||||
"password": "*",
|
||||
"gid": -1,
|
||||
"members": []
|
||||
},
|
||||
{
|
||||
"group_name": "wheel",
|
||||
"password": "*",
|
||||
"gid": 0,
|
||||
"members": [
|
||||
"root"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group_name": "certusers",
|
||||
"password": "*",
|
||||
"gid": 29,
|
||||
"members": [
|
||||
"root",
|
||||
"_jabber",
|
||||
"_postfix",
|
||||
"_cyrus",
|
||||
"_calendar",
|
||||
"_dovecot"
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ cat /etc/group | jc --group -p -r
|
||||
[
|
||||
{
|
||||
"group_name": "nobody",
|
||||
"password": "*",
|
||||
"gid": "-2",
|
||||
"members": [
|
||||
""
|
||||
]
|
||||
},
|
||||
{
|
||||
"group_name": "nogroup",
|
||||
"password": "*",
|
||||
"gid": "-1",
|
||||
"members": [
|
||||
""
|
||||
]
|
||||
},
|
||||
{
|
||||
"group_name": "wheel",
|
||||
"password": "*",
|
||||
"gid": "0",
|
||||
"members": [
|
||||
"root"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group_name": "certusers",
|
||||
"password": "*",
|
||||
"gid": "29",
|
||||
"members": [
|
||||
"root",
|
||||
"_jabber",
|
||||
"_postfix",
|
||||
"_cyrus",
|
||||
"_calendar",
|
||||
"_dovecot"
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, aix, freebsd
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
105
docs/parsers/gshadow.md
Normal file
105
docs/parsers/gshadow.md
Normal file
@@ -0,0 +1,105 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.gshadow
|
||||
jc - JSON CLI output utility `/etc/gshadow` file parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat /etc/gshadow | jc --gshadow
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.gshadow
|
||||
result = jc.parsers.gshadow.parse(gshadow_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"group_name": string,
|
||||
"password": string,
|
||||
"administrators": [
|
||||
string
|
||||
],
|
||||
"members": [
|
||||
string
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat /etc/gshadow | jc --gshadow -p
|
||||
[
|
||||
{
|
||||
"group_name": "root",
|
||||
"password": "*",
|
||||
"administrators": [],
|
||||
"members": []
|
||||
},
|
||||
{
|
||||
"group_name": "adm",
|
||||
"password": "*",
|
||||
"administrators": [],
|
||||
"members": [
|
||||
"syslog",
|
||||
"joeuser"
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ cat /etc/gshadow | jc --gshadow -p -r
|
||||
[
|
||||
{
|
||||
"group_name": "root",
|
||||
"password": "*",
|
||||
"administrators": [
|
||||
""
|
||||
],
|
||||
"members": [
|
||||
""
|
||||
]
|
||||
},
|
||||
{
|
||||
"group_name": "adm",
|
||||
"password": "*",
|
||||
"administrators": [
|
||||
""
|
||||
],
|
||||
"members": [
|
||||
"syslog",
|
||||
"joeuser"
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, aix, freebsd
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
65
docs/parsers/hash.md
Normal file
65
docs/parsers/hash.md
Normal file
@@ -0,0 +1,65 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.hash
|
||||
jc - JSON CLI output utility `hash` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ hash | jc --hash
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.hash
|
||||
result = jc.parsers.hash.parse(hash_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"command": string,
|
||||
"hits": integer
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ hash | jc --hash -p
|
||||
[
|
||||
{
|
||||
"hits": 2,
|
||||
"command": "/bin/cat"
|
||||
},
|
||||
{
|
||||
"hits": 1,
|
||||
"command": "/bin/ls"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
96
docs/parsers/hashsum.md
Normal file
96
docs/parsers/hashsum.md
Normal file
@@ -0,0 +1,96 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.hashsum
|
||||
jc - JSON CLI output utility `hash sum` command output parser
|
||||
|
||||
This parser works with the following hash calculation utilities:
|
||||
- `md5`
|
||||
- `md5sum`
|
||||
- `shasum`
|
||||
- `sha1sum`
|
||||
- `sha224sum`
|
||||
- `sha256sum`
|
||||
- `sha384sum`
|
||||
- `sha512sum`
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ md5sum file.txt | jc --hashsum
|
||||
|
||||
or
|
||||
|
||||
$ jc md5sum file.txt
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.hashsum
|
||||
result = jc.parsers.hashsum.parse(md5sum_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"filename": string,
|
||||
"hash": string,
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ md5sum * | jc --hashsum -p
|
||||
[
|
||||
{
|
||||
"filename": "devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm",
|
||||
"hash": "65fc958c1add637ec23c4b137aecf3d3"
|
||||
},
|
||||
{
|
||||
"filename": "digout",
|
||||
"hash": "5b9312ee5aff080927753c63a347707d"
|
||||
},
|
||||
{
|
||||
"filename": "dmidecode.out",
|
||||
"hash": "716fd11c2ac00db109281f7110b8fb9d"
|
||||
},
|
||||
{
|
||||
"filename": "file with spaces in the name",
|
||||
"hash": "d41d8cd98f00b204e9800998ecf8427e"
|
||||
},
|
||||
{
|
||||
"filename": "id-centos.out",
|
||||
"hash": "4295be239a14ad77ef3253103de976d2"
|
||||
},
|
||||
{
|
||||
"filename": "ifcfg.json",
|
||||
"hash": "01fda0d9ba9a75618b072e64ff512b43"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
345
docs/parsers/hciconfig.md
Normal file
345
docs/parsers/hciconfig.md
Normal file
@@ -0,0 +1,345 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.hciconfig
|
||||
jc - JSON CLI output utility `hciconfig` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ hciconfig | jc --hciconfig
|
||||
|
||||
or
|
||||
|
||||
$ jc hciconfig
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.hciconfig
|
||||
result = jc.parsers.hciconfig.parse(hciconfig_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"device": string,
|
||||
"type": string,
|
||||
"bus": string,
|
||||
"bd_address": string,
|
||||
"acl_mtu": integer,
|
||||
"acl_mtu_packets": integer,
|
||||
"sco_mtu": integer,
|
||||
"sco_mtu_packets": integer,
|
||||
"state": [
|
||||
string
|
||||
],
|
||||
"rx_bytes": integer,
|
||||
"rx_acl": integer,
|
||||
"rx_sco": integer,
|
||||
"rx_events": integer,
|
||||
"rx_errors": integer,
|
||||
"tx_bytes": integer,
|
||||
"tx_acl": integer,
|
||||
"tx_sco": integer,
|
||||
"tx_commands": integer,
|
||||
"tx_errors": integer,
|
||||
"features": [
|
||||
string
|
||||
],
|
||||
"packet_type": [
|
||||
string
|
||||
],
|
||||
"link_policy": [
|
||||
string
|
||||
],
|
||||
"link_mode": [
|
||||
string
|
||||
],
|
||||
"name": string,
|
||||
"class": string,
|
||||
"service_classes": [
|
||||
string # 'Unspecified' is null
|
||||
],
|
||||
"device_class": string,
|
||||
"hci_version": string,
|
||||
"hci_revision": string,
|
||||
"lmp_version": string,
|
||||
"lmp_subversion": string,
|
||||
"manufacturer": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ hciconfig -a | jc --hciconfig -p
|
||||
[
|
||||
{
|
||||
"device": "hci0",
|
||||
"type": "Primary",
|
||||
"bus": "USB",
|
||||
"bd_address": "00:1A:7D:DA:71:13",
|
||||
"acl_mtu": 310,
|
||||
"acl_mtu_packets": 10,
|
||||
"sco_mtu": 64,
|
||||
"sco_mtu_packets": 8,
|
||||
"state": [
|
||||
"UP",
|
||||
"RUNNING"
|
||||
],
|
||||
"rx_bytes": 13905869,
|
||||
"rx_acl": 0,
|
||||
"rx_sco": 0,
|
||||
"rx_events": 393300,
|
||||
"rx_errors": 0,
|
||||
"tx_bytes": 62629,
|
||||
"tx_acl": 0,
|
||||
"tx_sco": 0,
|
||||
"tx_commands": 3893,
|
||||
"tx_errors": 0,
|
||||
"features": [
|
||||
"0xff",
|
||||
"0xff",
|
||||
"0x8f",
|
||||
"0xfe",
|
||||
"0xdb",
|
||||
"0xff",
|
||||
"0x5b",
|
||||
"0x87"
|
||||
],
|
||||
"packet_type": [
|
||||
"DM1",
|
||||
"DM3",
|
||||
"DM5",
|
||||
"DH1",
|
||||
"DH3",
|
||||
"DH5",
|
||||
"HV1",
|
||||
"HV2",
|
||||
"HV3"
|
||||
],
|
||||
"link_policy": [
|
||||
"RSWITCH",
|
||||
"HOLD",
|
||||
"SNIFF",
|
||||
"PARK"
|
||||
],
|
||||
"link_mode": [
|
||||
"SLAVE",
|
||||
"ACCEPT"
|
||||
],
|
||||
"name": "CSR8510 A10",
|
||||
"class": "0x000000",
|
||||
"service_classes": null,
|
||||
"device_class": "Miscellaneous",
|
||||
"hci_version": "4.0 (0x6)",
|
||||
"hci_revision": "0x22bb",
|
||||
"lmp_version": "4.0 (0x6)",
|
||||
"lmp_subversion": "0x22bb",
|
||||
"manufacturer": "Cambridge Silicon Radio (10)"
|
||||
},
|
||||
{
|
||||
"device": "hci1",
|
||||
"type": "Primary",
|
||||
"bus": "USB",
|
||||
"bd_address": "00:1A:7D:DA:71:13",
|
||||
"acl_mtu": 310,
|
||||
"acl_mtu_packets": 10,
|
||||
"sco_mtu": 64,
|
||||
"sco_mtu_packets": 8,
|
||||
"state": [
|
||||
"DOWN"
|
||||
],
|
||||
"rx_bytes": 4388363,
|
||||
"rx_acl": 0,
|
||||
"rx_sco": 0,
|
||||
"rx_events": 122021,
|
||||
"rx_errors": 0,
|
||||
"tx_bytes": 52350,
|
||||
"tx_acl": 0,
|
||||
"tx_sco": 0,
|
||||
"tx_commands": 3480,
|
||||
"tx_errors": 2,
|
||||
"features": [
|
||||
"0xff",
|
||||
"0xff",
|
||||
"0x8f",
|
||||
"0xfe",
|
||||
"0xdb",
|
||||
"0xff",
|
||||
"0x5b",
|
||||
"0x87"
|
||||
],
|
||||
"packet_type": [
|
||||
"DM1",
|
||||
"DM3",
|
||||
"DM5",
|
||||
"DH1",
|
||||
"DH3",
|
||||
"DH5",
|
||||
"HV1",
|
||||
"HV2",
|
||||
"HV3"
|
||||
],
|
||||
"link_policy": [
|
||||
"RSWITCH",
|
||||
"HOLD",
|
||||
"SNIFF",
|
||||
"PARK"
|
||||
],
|
||||
"link_mode": [
|
||||
"SLAVE",
|
||||
"ACCEPT"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
$ hciconfig -a | jc --hciconfig -p -r
|
||||
[
|
||||
{
|
||||
"device": "hci0",
|
||||
"type": "Primary",
|
||||
"bus": "USB",
|
||||
"bd_address": "00:1A:7D:DA:71:13",
|
||||
"acl_mtu": "310",
|
||||
"acl_mtu_packets": "10",
|
||||
"sco_mtu": "64",
|
||||
"sco_mtu_packets": "8",
|
||||
"state": [
|
||||
"UP",
|
||||
"RUNNING"
|
||||
],
|
||||
"rx_bytes": "13905869",
|
||||
"rx_acl": "0",
|
||||
"rx_sco": "0",
|
||||
"rx_events": "393300",
|
||||
"rx_errors": "0",
|
||||
"tx_bytes": "62629",
|
||||
"tx_acl": "0",
|
||||
"tx_sco": "0",
|
||||
"tx_commands": "3893",
|
||||
"tx_errors": "0",
|
||||
"features": [
|
||||
"0xff",
|
||||
"0xff",
|
||||
"0x8f",
|
||||
"0xfe",
|
||||
"0xdb",
|
||||
"0xff",
|
||||
"0x5b",
|
||||
"0x87"
|
||||
],
|
||||
"packet_type": [
|
||||
"DM1",
|
||||
"DM3",
|
||||
"DM5",
|
||||
"DH1",
|
||||
"DH3",
|
||||
"DH5",
|
||||
"HV1",
|
||||
"HV2",
|
||||
"HV3"
|
||||
],
|
||||
"link_policy": [
|
||||
"RSWITCH",
|
||||
"HOLD",
|
||||
"SNIFF",
|
||||
"PARK"
|
||||
],
|
||||
"link_mode": [
|
||||
"SLAVE",
|
||||
"ACCEPT"
|
||||
],
|
||||
"name": "CSR8510 A10",
|
||||
"class": "0x000000",
|
||||
"service_classes": [
|
||||
"Unspecified"
|
||||
],
|
||||
"device_class": "Miscellaneous",
|
||||
"hci_version": "4.0 (0x6)",
|
||||
"hci_revision": "0x22bb",
|
||||
"lmp_version": "4.0 (0x6)",
|
||||
"lmp_subversion": "0x22bb",
|
||||
"manufacturer": "Cambridge Silicon Radio (10)"
|
||||
},
|
||||
{
|
||||
"device": "hci1",
|
||||
"type": "Primary",
|
||||
"bus": "USB",
|
||||
"bd_address": "00:1A:7D:DA:71:13",
|
||||
"acl_mtu": "310",
|
||||
"acl_mtu_packets": "10",
|
||||
"sco_mtu": "64",
|
||||
"sco_mtu_packets": "8",
|
||||
"state": [
|
||||
"DOWN"
|
||||
],
|
||||
"rx_bytes": "4388363",
|
||||
"rx_acl": "0",
|
||||
"rx_sco": "0",
|
||||
"rx_events": "122021",
|
||||
"rx_errors": "0",
|
||||
"tx_bytes": "52350",
|
||||
"tx_acl": "0",
|
||||
"tx_sco": "0",
|
||||
"tx_commands": "3480",
|
||||
"tx_errors": "2",
|
||||
"features": [
|
||||
"0xff",
|
||||
"0xff",
|
||||
"0x8f",
|
||||
"0xfe",
|
||||
"0xdb",
|
||||
"0xff",
|
||||
"0x5b",
|
||||
"0x87"
|
||||
],
|
||||
"packet_type": [
|
||||
"DM1",
|
||||
"DM3",
|
||||
"DM5",
|
||||
"DH1",
|
||||
"DH3",
|
||||
"DH5",
|
||||
"HV1",
|
||||
"HV2",
|
||||
"HV3"
|
||||
],
|
||||
"link_policy": [
|
||||
"RSWITCH",
|
||||
"HOLD",
|
||||
"SNIFF",
|
||||
"PARK"
|
||||
],
|
||||
"link_mode": [
|
||||
"SLAVE",
|
||||
"ACCEPT"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
88
docs/parsers/history.md
Normal file
88
docs/parsers/history.md
Normal file
@@ -0,0 +1,88 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# 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.
|
||||
|
||||
The "Magic" syntax is not supported since the `history` command is a shell builtin.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ history | jc --history
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.history
|
||||
result = jc.parsers.history.parse(history_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"line": integer,
|
||||
"command": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ history | jc --history -p
|
||||
[
|
||||
{
|
||||
"line": 118,
|
||||
"command": "sleep 100"
|
||||
},
|
||||
{
|
||||
"line": 119,
|
||||
"command": "ls /bin"
|
||||
},
|
||||
{
|
||||
"line": 120,
|
||||
"command": "echo "hello""
|
||||
},
|
||||
{
|
||||
"line": 121,
|
||||
"command": "docker images"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ history | jc --history -p -r
|
||||
{
|
||||
"118": "sleep 100",
|
||||
"119": "ls /bin",
|
||||
"120": "echo "hello"",
|
||||
"121": "docker images",
|
||||
...
|
||||
}
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary of raw structured data or
|
||||
List of Dictionaries of processed structured data
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
102
docs/parsers/hosts.md
Normal file
102
docs/parsers/hosts.md
Normal file
@@ -0,0 +1,102 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.hosts
|
||||
jc - JSON CLI output utility `/etc/hosts` file parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat /etc/hosts | jc --hosts
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.hosts
|
||||
result = jc.parsers.hosts.parse(hosts_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"ip": string,
|
||||
"hostname": [
|
||||
string
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat /etc/hosts | jc --hosts -p
|
||||
[
|
||||
{
|
||||
"ip": "127.0.0.1",
|
||||
"hostname": [
|
||||
"localhost"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ip": "127.0.1.1",
|
||||
"hostname": [
|
||||
"root-ubuntu"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ip": "::1",
|
||||
"hostname": [
|
||||
"ip6-localhost",
|
||||
"ip6-loopback"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ip": "fe00::0",
|
||||
"hostname": [
|
||||
"ip6-localnet"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ip": "ff00::0",
|
||||
"hostname": [
|
||||
"ip6-mcastprefix"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ip": "ff02::1",
|
||||
"hostname": [
|
||||
"ip6-allnodes"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ip": "ff02::2",
|
||||
"hostname": [
|
||||
"ip6-allrouters"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
133
docs/parsers/id.md
Normal file
133
docs/parsers/id.md
Normal file
@@ -0,0 +1,133 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.id
|
||||
jc - JSON CLI output utility `id` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ id | jc --id
|
||||
|
||||
or
|
||||
|
||||
$ jc id
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.id
|
||||
result = jc.parsers.id.parse(id_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"uid": {
|
||||
"id": integer,
|
||||
"name": string
|
||||
},
|
||||
"gid": {
|
||||
"id": integer,
|
||||
"name": string
|
||||
},
|
||||
"groups": [
|
||||
{
|
||||
"id": integer,
|
||||
"name": string
|
||||
},
|
||||
{
|
||||
"id": integer,
|
||||
"name": string
|
||||
}
|
||||
],
|
||||
"context": {
|
||||
"user": string,
|
||||
"role": string,
|
||||
"type": string,
|
||||
"level": string
|
||||
}
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ id | jc --id -p
|
||||
{
|
||||
"uid": {
|
||||
"id": 1000,
|
||||
"name": "joeuser"
|
||||
},
|
||||
"gid": {
|
||||
"id": 1000,
|
||||
"name": "joeuser"
|
||||
},
|
||||
"groups": [
|
||||
{
|
||||
"id": 1000,
|
||||
"name": "joeuser"
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"name": "wheel"
|
||||
}
|
||||
],
|
||||
"context": {
|
||||
"user": "unconfined_u",
|
||||
"role": "unconfined_r",
|
||||
"type": "unconfined_t",
|
||||
"level": "s0-s0:c0.c1023"
|
||||
}
|
||||
}
|
||||
|
||||
$ id | jc --id -p -r
|
||||
{
|
||||
"uid": {
|
||||
"id": "1000",
|
||||
"name": "joeuser"
|
||||
},
|
||||
"gid": {
|
||||
"id": "1000",
|
||||
"name": "joeuser"
|
||||
},
|
||||
"groups": [
|
||||
{
|
||||
"id": "1000",
|
||||
"name": "joeuser"
|
||||
},
|
||||
{
|
||||
"id": "10",
|
||||
"name": "wheel"
|
||||
}
|
||||
],
|
||||
"context": {
|
||||
"user": "unconfined_u",
|
||||
"role": "unconfined_r",
|
||||
"type": "unconfined_t",
|
||||
"level": "s0-s0:c0.c1023"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, aix, freebsd
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
214
docs/parsers/ifconfig.md
Normal file
214
docs/parsers/ifconfig.md
Normal file
@@ -0,0 +1,214 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.ifconfig
|
||||
jc - JSON CLI output utility `ifconfig` command output parser
|
||||
|
||||
Note: No `ifconfig` options are supported.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ ifconfig | jc --ifconfig
|
||||
|
||||
or
|
||||
|
||||
$ jc ifconfig
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.ifconfig
|
||||
result = jc.parsers.ifconfig.parse(ifconfig_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"name": string,
|
||||
"flags": integer,
|
||||
"state": [
|
||||
string
|
||||
],
|
||||
"mtu": integer,
|
||||
"ipv4_addr": string,
|
||||
"ipv4_mask": string,
|
||||
"ipv4_bcast": string,
|
||||
"ipv6_addr": string,
|
||||
"ipv6_mask": integer,
|
||||
"ipv6_scope": string,
|
||||
"mac_addr": string,
|
||||
"type": string,
|
||||
"rx_packets": integer,
|
||||
"rx_bytes": integer,
|
||||
"rx_errors": integer,
|
||||
"rx_dropped": integer,
|
||||
"rx_overruns": integer,
|
||||
"rx_frame": integer,
|
||||
"tx_packets": integer,
|
||||
"tx_bytes": integer,
|
||||
"tx_errors": integer,
|
||||
"tx_dropped": integer,
|
||||
"tx_overruns": integer,
|
||||
"tx_carrier": integer,
|
||||
"tx_collisions": integer,
|
||||
"metric": integer
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ ifconfig | jc --ifconfig -p
|
||||
[
|
||||
{
|
||||
"name": "ens33",
|
||||
"flags": 4163,
|
||||
"state": [
|
||||
"UP",
|
||||
"BROADCAST",
|
||||
"RUNNING",
|
||||
"MULTICAST"
|
||||
],
|
||||
"mtu": 1500,
|
||||
"ipv4_addr": "192.168.71.137",
|
||||
"ipv4_mask": "255.255.255.0",
|
||||
"ipv4_bcast": "192.168.71.255",
|
||||
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
|
||||
"ipv6_mask": 64,
|
||||
"ipv6_scope": "0x20",
|
||||
"mac_addr": "00:0c:29:3b:58:0e",
|
||||
"type": "Ethernet",
|
||||
"rx_packets": 8061,
|
||||
"rx_bytes": 1514413,
|
||||
"rx_errors": 0,
|
||||
"rx_dropped": 0,
|
||||
"rx_overruns": 0,
|
||||
"rx_frame": 0,
|
||||
"tx_packets": 4502,
|
||||
"tx_bytes": 866622,
|
||||
"tx_errors": 0,
|
||||
"tx_dropped": 0,
|
||||
"tx_overruns": 0,
|
||||
"tx_carrier": 0,
|
||||
"tx_collisions": 0,
|
||||
"metric": null
|
||||
},
|
||||
{
|
||||
"name": "lo",
|
||||
"flags": 73,
|
||||
"state": [
|
||||
"UP",
|
||||
"LOOPBACK",
|
||||
"RUNNING"
|
||||
],
|
||||
"mtu": 65536,
|
||||
"ipv4_addr": "127.0.0.1",
|
||||
"ipv4_mask": "255.0.0.0",
|
||||
"ipv4_bcast": null,
|
||||
"ipv6_addr": "::1",
|
||||
"ipv6_mask": 128,
|
||||
"ipv6_scope": "0x10",
|
||||
"mac_addr": null,
|
||||
"type": "Local Loopback",
|
||||
"rx_packets": 73,
|
||||
"rx_bytes": 6009,
|
||||
"rx_errors": 0,
|
||||
"rx_dropped": 0,
|
||||
"rx_overruns": 0,
|
||||
"rx_frame": 0,
|
||||
"tx_packets": 73,
|
||||
"tx_bytes": 6009,
|
||||
"tx_errors": 0,
|
||||
"tx_dropped": 0,
|
||||
"tx_overruns": 0,
|
||||
"tx_carrier": 0,
|
||||
"tx_collisions": 0,
|
||||
"metric": null
|
||||
}
|
||||
]
|
||||
|
||||
$ ifconfig | jc --ifconfig -p -r
|
||||
[
|
||||
{
|
||||
"name": "ens33",
|
||||
"flags": "4163",
|
||||
"state": "UP,BROADCAST,RUNNING,MULTICAST",
|
||||
"mtu": "1500",
|
||||
"ipv4_addr": "192.168.71.137",
|
||||
"ipv4_mask": "255.255.255.0",
|
||||
"ipv4_bcast": "192.168.71.255",
|
||||
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
|
||||
"ipv6_mask": "64",
|
||||
"ipv6_scope": "0x20",
|
||||
"mac_addr": "00:0c:29:3b:58:0e",
|
||||
"type": "Ethernet",
|
||||
"rx_packets": "8061",
|
||||
"rx_bytes": "1514413",
|
||||
"rx_errors": "0",
|
||||
"rx_dropped": "0",
|
||||
"rx_overruns": "0",
|
||||
"rx_frame": "0",
|
||||
"tx_packets": "4502",
|
||||
"tx_bytes": "866622",
|
||||
"tx_errors": "0",
|
||||
"tx_dropped": "0",
|
||||
"tx_overruns": "0",
|
||||
"tx_carrier": "0",
|
||||
"tx_collisions": "0",
|
||||
"metric": null
|
||||
},
|
||||
{
|
||||
"name": "lo",
|
||||
"flags": "73",
|
||||
"state": "UP,LOOPBACK,RUNNING",
|
||||
"mtu": "65536",
|
||||
"ipv4_addr": "127.0.0.1",
|
||||
"ipv4_mask": "255.0.0.0",
|
||||
"ipv4_bcast": null,
|
||||
"ipv6_addr": "::1",
|
||||
"ipv6_mask": "128",
|
||||
"ipv6_scope": "0x10",
|
||||
"mac_addr": null,
|
||||
"type": "Local Loopback",
|
||||
"rx_packets": "73",
|
||||
"rx_bytes": "6009",
|
||||
"rx_errors": "0",
|
||||
"rx_dropped": "0",
|
||||
"rx_overruns": "0",
|
||||
"rx_frame": "0",
|
||||
"tx_packets": "73",
|
||||
"tx_bytes": "6009",
|
||||
"tx_errors": "0",
|
||||
"tx_dropped": "0",
|
||||
"tx_overruns": "0",
|
||||
"tx_carrier": "0",
|
||||
"tx_collisions": "0",
|
||||
"metric": null
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, aix, freebsd, darwin
|
||||
|
||||
Version 1.11 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
93
docs/parsers/ini.md
Normal file
93
docs/parsers/ini.md
Normal file
@@ -0,0 +1,93 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# 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.
|
||||
|
||||
Note: Values starting and ending with quotation marks will have the marks removed. If you would like to keep the quotation marks, use the `-r` command-line argument or the `raw=True` argument in `parse()`.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat foo.ini | jc --ini
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.ini
|
||||
result = jc.parsers.ini.parse(ini_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
ini or key/value document converted to a dictionary - see configparser standard
|
||||
library documentation for more details.
|
||||
|
||||
Note: Values starting and ending with quotation marks will have the marks removed.
|
||||
If you would like to keep the quotation marks, use the -r or raw=True argument.
|
||||
|
||||
{
|
||||
"key1": string,
|
||||
"key2": string
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat example.ini
|
||||
[DEFAULT]
|
||||
ServerAliveInterval = 45
|
||||
Compression = yes
|
||||
CompressionLevel = 9
|
||||
ForwardX11 = yes
|
||||
|
||||
[bitbucket.org]
|
||||
User = hg
|
||||
|
||||
[topsecret.server.com]
|
||||
Port = 50022
|
||||
ForwardX11 = no
|
||||
|
||||
$ cat example.ini | jc --ini -p
|
||||
{
|
||||
"bitbucket.org": {
|
||||
"serveraliveinterval": "45",
|
||||
"compression": "yes",
|
||||
"compressionlevel": "9",
|
||||
"forwardx11": "yes",
|
||||
"user": "hg"
|
||||
},
|
||||
"topsecret.server.com": {
|
||||
"serveraliveinterval": "45",
|
||||
"compression": "yes",
|
||||
"compressionlevel": "9",
|
||||
"forwardx11": "no",
|
||||
"port": "50022"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary representing the ini file
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
187
docs/parsers/iostat.md
Normal file
187
docs/parsers/iostat.md
Normal file
@@ -0,0 +1,187 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.iostat
|
||||
jc - JSON CLI output utility `iostat` command output parser
|
||||
|
||||
Note: `iostat` version 11 and higher include a JSON output option
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ iostat | jc --iostat
|
||||
|
||||
or
|
||||
|
||||
$ jc iostat
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.iostat
|
||||
result = jc.parsers.iostat.parse(iostat_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"type": string,
|
||||
"percent_user": float,
|
||||
"percent_nice": float,
|
||||
"percent_system": float,
|
||||
"percent_iowait": float,
|
||||
"percent_steal": float,
|
||||
"percent_idle": float,
|
||||
"device": string,
|
||||
"tps": float,
|
||||
"kb_read_s": float,
|
||||
"mb_read_s": float,
|
||||
"kb_wrtn_s": float,
|
||||
"mb_wrtn_s": float,
|
||||
"kb_read": integer,
|
||||
"mb_read": integer,
|
||||
"kb_wrtn": integer,
|
||||
"mb_wrtn": integer,
|
||||
'kb_dscd': integer,
|
||||
'mb_dscd': integer,
|
||||
"rrqm_s": float,
|
||||
"wrqm_s": float,
|
||||
"r_s": float,
|
||||
"w_s": float,
|
||||
"rmb_s": float,
|
||||
"rkb_s": float,
|
||||
"wmb_s": float,
|
||||
"wkb_s": float,
|
||||
"avgrq_sz": float,
|
||||
"avgqu_sz": float,
|
||||
"await": float,
|
||||
"r_await": float,
|
||||
"w_await": float,
|
||||
"svctm": float,
|
||||
"aqu_sz": float,
|
||||
"rareq_sz": float,
|
||||
"wareq_sz": float,
|
||||
"d_s": float,
|
||||
"dkb_s": float,
|
||||
"dmb_s": float,
|
||||
"drqm_s": float,
|
||||
"percent_drqm": float,
|
||||
"d_await": float,
|
||||
"dareq_sz": float,
|
||||
"f_s": float,
|
||||
"f_await": float,
|
||||
"kb_dscd_s": float,
|
||||
"mb_dscd_s": float,
|
||||
"percent_util": float,
|
||||
"percent_rrqm": float,
|
||||
"percent_wrqm": float
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ iostat | jc --iostat -p
|
||||
[
|
||||
{
|
||||
"percent_user": 0.15,
|
||||
"percent_nice": 0.0,
|
||||
"percent_system": 0.18,
|
||||
"percent_iowait": 0.0,
|
||||
"percent_steal": 0.0,
|
||||
"percent_idle": 99.67,
|
||||
"type": "cpu"
|
||||
},
|
||||
{
|
||||
"device": "sda",
|
||||
"tps": 0.29,
|
||||
"kb_read_s": 7.22,
|
||||
"kb_wrtn_s": 1.25,
|
||||
"kb_read": 194341,
|
||||
"kb_wrtn": 33590,
|
||||
"type": "device"
|
||||
},
|
||||
{
|
||||
"device": "dm-0",
|
||||
"tps": 0.29,
|
||||
"kb_read_s": 5.99,
|
||||
"kb_wrtn_s": 1.17,
|
||||
"kb_read": 161361,
|
||||
"kb_wrtn": 31522,
|
||||
"type": "device"
|
||||
},
|
||||
{
|
||||
"device": "dm-1",
|
||||
"tps": 0.0,
|
||||
"kb_read_s": 0.08,
|
||||
"kb_wrtn_s": 0.0,
|
||||
"kb_read": 2204,
|
||||
"kb_wrtn": 0,
|
||||
"type": "device"
|
||||
}
|
||||
]
|
||||
|
||||
$ iostat | jc --iostat -p -r
|
||||
[
|
||||
{
|
||||
"percent_user": "0.15",
|
||||
"percent_nice": "0.00",
|
||||
"percent_system": "0.18",
|
||||
"percent_iowait": "0.00",
|
||||
"percent_steal": "0.00",
|
||||
"percent_idle": "99.67",
|
||||
"type": "cpu"
|
||||
},
|
||||
{
|
||||
"device": "sda",
|
||||
"tps": "0.29",
|
||||
"kb_read_s": "7.22",
|
||||
"kb_wrtn_s": "1.25",
|
||||
"kb_read": "194341",
|
||||
"kb_wrtn": "33590",
|
||||
"type": "device"
|
||||
},
|
||||
{
|
||||
"device": "dm-0",
|
||||
"tps": "0.29",
|
||||
"kb_read_s": "5.99",
|
||||
"kb_wrtn_s": "1.17",
|
||||
"kb_read": "161361",
|
||||
"kb_wrtn": "31522",
|
||||
"type": "device"
|
||||
},
|
||||
{
|
||||
"device": "dm-1",
|
||||
"tps": "0.00",
|
||||
"kb_read_s": "0.08",
|
||||
"kb_wrtn_s": "0.00",
|
||||
"kb_read": "2204",
|
||||
"kb_wrtn": "0",
|
||||
"type": "device"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
126
docs/parsers/iostat_s.md
Normal file
126
docs/parsers/iostat_s.md
Normal file
@@ -0,0 +1,126 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.iostat_s
|
||||
jc - JSON CLI output utility `iostat` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines
|
||||
|
||||
Note: `iostat` version 11 and higher include a JSON output option
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ iostat | jc --iostat-s
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.iostat_s
|
||||
result = jc.parsers.iostat_s.parse(iostat_command_output.splitlines()) # result is an iterable object
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"type": string,
|
||||
"percent_user": float,
|
||||
"percent_nice": float,
|
||||
"percent_system": float,
|
||||
"percent_iowait": float,
|
||||
"percent_steal": float,
|
||||
"percent_idle": float,
|
||||
"device": string,
|
||||
"tps": float,
|
||||
"kb_read_s": float,
|
||||
"mb_read_s": float,
|
||||
"kb_wrtn_s": float,
|
||||
"mb_wrtn_s": float,
|
||||
"kb_read": integer,
|
||||
"mb_read": integer,
|
||||
"kb_wrtn": integer,
|
||||
"mb_wrtn": integer,
|
||||
'kb_dscd': integer,
|
||||
'mb_dscd': integer,
|
||||
"rrqm_s": float,
|
||||
"wrqm_s": float,
|
||||
"r_s": float,
|
||||
"w_s": float,
|
||||
"rmb_s": float,
|
||||
"rkb_s": float,
|
||||
"wmb_s": float,
|
||||
"wkb_s": float,
|
||||
"avgrq_sz": float,
|
||||
"avgqu_sz": float,
|
||||
"await": float,
|
||||
"r_await": float,
|
||||
"w_await": float,
|
||||
"svctm": float,
|
||||
"aqu_sz": float,
|
||||
"rareq_sz": float,
|
||||
"wareq_sz": float,
|
||||
"d_s": float,
|
||||
"dkb_s": float,
|
||||
"dmb_s": float,
|
||||
"drqm_s": float,
|
||||
"percent_drqm": float,
|
||||
"d_await": float,
|
||||
"dareq_sz": float,
|
||||
"f_s": float,
|
||||
"f_await": float,
|
||||
"kb_dscd_s": float,
|
||||
"mb_dscd_s": float,
|
||||
"percent_util": float,
|
||||
"percent_rrqm": float,
|
||||
"percent_wrqm": float,
|
||||
"_jc_meta": # This object only exists if using -qq or ignore_exceptions=True
|
||||
{
|
||||
"success": booean, # true if successfully parsed, false if error
|
||||
"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"}
|
||||
...
|
||||
|
||||
$ 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"}
|
||||
...
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterator object.
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (iterable) line-based text data to parse (e.g. sys.stdin or str.splitlines())
|
||||
raw: (boolean) output preprocessed JSON 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
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
191
docs/parsers/iptables.md
Normal file
191
docs/parsers/iptables.md
Normal file
@@ -0,0 +1,191 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.iptables
|
||||
jc - JSON CLI output utility `ipables` command output parser
|
||||
|
||||
Supports `-vLn` and `--line-numbers` for all tables.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ sudo iptables -L -t nat | jc --iptables
|
||||
|
||||
or
|
||||
|
||||
$ jc iptables -L -t nat
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.iptables
|
||||
result = jc.parsers.iptables.parse(iptables_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"chain": string,
|
||||
"rules": [
|
||||
{
|
||||
"num" integer,
|
||||
"pkts": integer,
|
||||
"bytes": integer, # converted based on suffix
|
||||
"target": string,
|
||||
"prot": string,
|
||||
"opt": string, # "--" = Null
|
||||
"in": string,
|
||||
"out": string,
|
||||
"source": string,
|
||||
"destination": string,
|
||||
"options": string
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p
|
||||
[
|
||||
{
|
||||
"chain": "PREROUTING",
|
||||
"rules": [
|
||||
{
|
||||
"num": 1,
|
||||
"pkts": 2183,
|
||||
"bytes": 186000,
|
||||
"target": "PREROUTING_direct",
|
||||
"prot": "all",
|
||||
"opt": null,
|
||||
"in": "any",
|
||||
"out": "any",
|
||||
"source": "anywhere",
|
||||
"destination": "anywhere"
|
||||
},
|
||||
{
|
||||
"num": 2,
|
||||
"pkts": 2183,
|
||||
"bytes": 186000,
|
||||
"target": "PREROUTING_ZONES_SOURCE",
|
||||
"prot": "all",
|
||||
"opt": null,
|
||||
"in": "any",
|
||||
"out": "any",
|
||||
"source": "anywhere",
|
||||
"destination": "anywhere"
|
||||
},
|
||||
{
|
||||
"num": 3,
|
||||
"pkts": 2183,
|
||||
"bytes": 186000,
|
||||
"target": "PREROUTING_ZONES",
|
||||
"prot": "all",
|
||||
"opt": null,
|
||||
"in": "any",
|
||||
"out": "any",
|
||||
"source": "anywhere",
|
||||
"destination": "anywhere"
|
||||
},
|
||||
{
|
||||
"num": 4,
|
||||
"pkts": 0,
|
||||
"bytes": 0,
|
||||
"target": "DOCKER",
|
||||
"prot": "all",
|
||||
"opt": null,
|
||||
"in": "any",
|
||||
"out": "any",
|
||||
"source": "anywhere",
|
||||
"destination": "anywhere",
|
||||
"options": "ADDRTYPE match dst-type LOCAL"
|
||||
}
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p -r
|
||||
[
|
||||
{
|
||||
"chain": "PREROUTING",
|
||||
"rules": [
|
||||
{
|
||||
"num": "1",
|
||||
"pkts": "2183",
|
||||
"bytes": "186K",
|
||||
"target": "PREROUTING_direct",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "any",
|
||||
"out": "any",
|
||||
"source": "anywhere",
|
||||
"destination": "anywhere"
|
||||
},
|
||||
{
|
||||
"num": "2",
|
||||
"pkts": "2183",
|
||||
"bytes": "186K",
|
||||
"target": "PREROUTING_ZONES_SOURCE",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "any",
|
||||
"out": "any",
|
||||
"source": "anywhere",
|
||||
"destination": "anywhere"
|
||||
},
|
||||
{
|
||||
"num": "3",
|
||||
"pkts": "2183",
|
||||
"bytes": "186K",
|
||||
"target": "PREROUTING_ZONES",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "any",
|
||||
"out": "any",
|
||||
"source": "anywhere",
|
||||
"destination": "anywhere"
|
||||
},
|
||||
{
|
||||
"num": "4",
|
||||
"pkts": "0",
|
||||
"bytes": "0",
|
||||
"target": "DOCKER",
|
||||
"prot": "all",
|
||||
"opt": "--",
|
||||
"in": "any",
|
||||
"out": "any",
|
||||
"source": "anywhere",
|
||||
"destination": "anywhere",
|
||||
"options": "ADDRTYPE match dst-type LOCAL"
|
||||
}
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
148
docs/parsers/iw_scan.md
Normal file
148
docs/parsers/iw_scan.md
Normal file
@@ -0,0 +1,148 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.iw_scan
|
||||
jc - JSON CLI output utility `iw dev <device> scan` command output parser
|
||||
|
||||
This parser is considered beta quality. Not all fields are parsed and there are not enough samples to test.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ iw dev wlan0 scan | jc --iw-scan
|
||||
|
||||
or
|
||||
|
||||
$ jc iw dev wlan0 scan
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.iw-scan
|
||||
result = jc.parsers.iw-scan.parse(iw-scan_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"foo": string/integer/float, # best guess based on value
|
||||
"bar": string/integer/float,
|
||||
"baz": string/integer/float
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ iw dev wlan0 scan | jc --iw-scan -p
|
||||
[
|
||||
{
|
||||
"bssid": "71:31:72:65:e1:a2",
|
||||
"interface": "wlan0",
|
||||
"freq": 2462,
|
||||
"capability": "ESS Privacy ShortSlotTime (0x0411)",
|
||||
"ssid": "WLAN-1234",
|
||||
"supported_rates": [
|
||||
1.0,
|
||||
2.0,
|
||||
5.5,
|
||||
11.0,
|
||||
18.0,
|
||||
24.0,
|
||||
36.0,
|
||||
54.0
|
||||
],
|
||||
"erp": "<no flags>",
|
||||
"erp_d4.0": "<no flags>",
|
||||
"rsn": "Version: 1",
|
||||
"group_cipher": "CCMP",
|
||||
"pairwise_ciphers": "CCMP",
|
||||
"authentication_suites": "PSK",
|
||||
"capabilities": "0x186c",
|
||||
"extended_supported_rates": [
|
||||
6.0,
|
||||
9.0,
|
||||
12.0,
|
||||
48.0
|
||||
],
|
||||
"ht_rx_mcs_rate_indexes_supported": "0-15",
|
||||
"primary_channel": 11,
|
||||
"secondary_channel_offset": "no secondary",
|
||||
"rifs": 1,
|
||||
"ht_protection": "no",
|
||||
"non-gf_present": 1,
|
||||
"obss_non-gf_present": 0,
|
||||
"dual_beacon": 0,
|
||||
"dual_cts_protection": 0,
|
||||
"stbc_beacon": 0,
|
||||
"l-sig_txop_prot": 0,
|
||||
"pco_active": 0,
|
||||
"pco_phase": 0,
|
||||
"bss_width_channel_transition_delay_factor": 5,
|
||||
"extended_capabilities": "HT Information Exchange Supported",
|
||||
"wmm": "Parameter version 1",
|
||||
"be": "CW 15-1023, AIFSN 3",
|
||||
"bk": "CW 15-1023, AIFSN 7",
|
||||
"vi": "CW 7-15, AIFSN 2, TXOP 3008 usec",
|
||||
"vo": "CW 3-7, AIFSN 2, TXOP 1504 usec",
|
||||
"wps": "Version: 1.0",
|
||||
"wi-fi_protected_setup_state": "2 (Configured)",
|
||||
"selected_registrar": "0x0",
|
||||
"response_type": "3 (AP)",
|
||||
"uuid": "00000000-0000-0003-0000-75317074f1a2",
|
||||
"manufacturer": "Corporation",
|
||||
"model": "VGV8539JW",
|
||||
"model_number": "1.47.000",
|
||||
"serial_number": "J144024542",
|
||||
"primary_device_type": "6-0050f204-1",
|
||||
"device_name": "Wireless Router(WFA)",
|
||||
"config_methods": "Label, PBC",
|
||||
"rf_bands": "0x3",
|
||||
"tsf_usec": 212098649788,
|
||||
"sta_channel_width_mhz": 20,
|
||||
"passive_dwell_tus": 20,
|
||||
"active_dwell_tus": 10,
|
||||
"channel_width_trigger_scan_interval_s": 300,
|
||||
"scan_passive_total_per_channel_tus": 200,
|
||||
"scan_active_total_per_channel_tus": 20,
|
||||
"beacon_interval_tus": 100,
|
||||
"signal_dbm": -80.0,
|
||||
"last_seen_ms": 11420,
|
||||
"selected_rates": [
|
||||
1.0,
|
||||
2.0,
|
||||
5.5,
|
||||
11.0
|
||||
],
|
||||
"obss_scan_activity_threshold_percent": 0.25,
|
||||
"ds_parameter_set_channel": 11,
|
||||
"max_amsdu_length_bytes": 7935,
|
||||
"minimum_rx_ampdu_time_spacing_usec": 16
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 0.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
120
docs/parsers/jobs.md
Normal file
120
docs/parsers/jobs.md
Normal file
@@ -0,0 +1,120 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.jobs
|
||||
jc - JSON CLI output utility `jobs` command output parser
|
||||
|
||||
Also supports the `-l` option.
|
||||
|
||||
The "Magic" syntax is not supported since the `jobs` command is a shell builtin.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ jobs | jc --jobs
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.jobs
|
||||
result = jc.parsers.jobs.parse(jobs_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"job_number": integer,
|
||||
"pid": integer,
|
||||
"history": string,
|
||||
"status": string,
|
||||
"command": string
|
||||
}
|
||||
]
|
||||
|
||||
Example:
|
||||
|
||||
$ jobs -l | jc --jobs -p
|
||||
[
|
||||
{
|
||||
"job_number": 1,
|
||||
"pid": 5283,
|
||||
"status": "Running",
|
||||
"command": "sleep 10000 &"
|
||||
},
|
||||
{
|
||||
"job_number": 2,
|
||||
"pid": 5284,
|
||||
"status": "Running",
|
||||
"command": "sleep 10100 &"
|
||||
},
|
||||
{
|
||||
"job_number": 3,
|
||||
"pid": 5285,
|
||||
"history": "previous",
|
||||
"status": "Running",
|
||||
"command": "sleep 10001 &"
|
||||
},
|
||||
{
|
||||
"job_number": 4,
|
||||
"pid": 5286,
|
||||
"history": "current",
|
||||
"status": "Running",
|
||||
"command": "sleep 10112 &"
|
||||
}
|
||||
]
|
||||
|
||||
$ jobs -l | jc --jobs -p -r
|
||||
[
|
||||
{
|
||||
"job_number": "1",
|
||||
"pid": "19510",
|
||||
"status": "Running",
|
||||
"command": "sleep 1000 &"
|
||||
},
|
||||
{
|
||||
"job_number": "2",
|
||||
"pid": "19511",
|
||||
"status": "Running",
|
||||
"command": "sleep 1001 &"
|
||||
},
|
||||
{
|
||||
"job_number": "3",
|
||||
"pid": "19512",
|
||||
"history": "previous",
|
||||
"status": "Running",
|
||||
"command": "sleep 1002 &"
|
||||
},
|
||||
{
|
||||
"job_number": "4",
|
||||
"pid": "19513",
|
||||
"history": "current",
|
||||
"status": "Running",
|
||||
"command": "sleep 1003 &"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
78
docs/parsers/kv.md
Normal file
78
docs/parsers/kv.md
Normal file
@@ -0,0 +1,78 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.kv
|
||||
jc - JSON CLI output utility `Key/Value` file parser
|
||||
|
||||
Supports files containing simple key/value pairs. Delimiter can be `=` or `:`. Missing values are supported. Comment prefix can be `#` or `;`. Comments must be on their own line.
|
||||
|
||||
Note: Values starting and ending with quotation marks will have the marks removed. If you would like to keep the quotation marks, use the `-r` command-line argument or the `raw=True` argument in `parse()`.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat foo.txt | jc --kv
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.kv
|
||||
result = jc.parsers.kv.parse(kv_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
key/value document converted to a dictionary - see configparser standard library documentation for more details.
|
||||
|
||||
{
|
||||
"key1": string,
|
||||
"key2": string
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat keyvalue.txt
|
||||
# this file contains key/value pairs
|
||||
name = John Doe
|
||||
address=555 California Drive
|
||||
age: 34
|
||||
; comments can include # or ;
|
||||
# delimiter can be = or :
|
||||
# quoted values have quotation marks stripped by default
|
||||
# but can be preserved with the -r argument
|
||||
occupation:"Engineer"
|
||||
|
||||
$ cat keyvalue.txt | jc --kv -p
|
||||
{
|
||||
"name": "John Doe",
|
||||
"address": "555 California Drive",
|
||||
"age": "34",
|
||||
"occupation": "Engineer"
|
||||
}
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Note: this is just a wrapper for jc.parsers.ini
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary representing the key/value file
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
131
docs/parsers/last.md
Normal file
131
docs/parsers/last.md
Normal file
@@ -0,0 +1,131 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.last
|
||||
jc - JSON CLI output utility `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.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ last | jc --last
|
||||
|
||||
or
|
||||
|
||||
$ jc last
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.last
|
||||
result = jc.parsers.last.parse(last_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"user": string,
|
||||
"tty": string,
|
||||
"hostname": string,
|
||||
"login": string,
|
||||
"logout": string,
|
||||
"duration": string,
|
||||
"login_epoch": integer, # (naive) available with last -F option
|
||||
"logout_epoch": integer, # (naive) available with last -F option
|
||||
"duration_seconds": integer # available with last -F option
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ last -F | jc --last -p
|
||||
[
|
||||
{
|
||||
"user": "kbrazil",
|
||||
"tty": "ttys002",
|
||||
"hostname": null,
|
||||
"login": "Mon Dec 28 17:24:10 2020",
|
||||
"logout": "still logged in"
|
||||
},
|
||||
{
|
||||
"user": "kbrazil",
|
||||
"tty": "ttys003",
|
||||
"hostname": null,
|
||||
"login": "Mon Dec 28 17:24:10 2020",
|
||||
"logout": "Mon Dec 28 17:25:01 2020",
|
||||
"duration": "00:00",
|
||||
"login_epoch": 1565891826,
|
||||
"logout_epoch": 1565895404,
|
||||
"duration_seconds": 3578
|
||||
},
|
||||
{
|
||||
"user": "kbrazil",
|
||||
"tty": "ttys003",
|
||||
"hostname": null,
|
||||
"login": "Mon Dec 28 17:24:10 2020",
|
||||
"logout": "Mon Dec 28 17:25:01 2020",
|
||||
"duration": "00:00",
|
||||
"login_epoch": 1565891826,
|
||||
"logout_epoch": 1565895404,
|
||||
"duration_seconds": 3578
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ last | jc --last -p -r
|
||||
[
|
||||
{
|
||||
"user": "kbrazil",
|
||||
"tty": "ttys002",
|
||||
"hostname": "-",
|
||||
"login": "Thu Feb 27 14:31",
|
||||
"logout": "still_logged_in"
|
||||
},
|
||||
{
|
||||
"user": "kbrazil",
|
||||
"tty": "ttys003",
|
||||
"hostname": "-",
|
||||
"login": "Thu Feb 27 10:38",
|
||||
"logout": "10:38",
|
||||
"duration": "00:00"
|
||||
},
|
||||
{
|
||||
"user": "kbrazil",
|
||||
"tty": "ttys003",
|
||||
"hostname": "-",
|
||||
"login": "Thu Feb 27 10:18",
|
||||
"logout": "10:18",
|
||||
"duration": "00:00"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, aix, freebsd
|
||||
|
||||
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
134
docs/parsers/ls.md
Normal file
134
docs/parsers/ls.md
Normal file
@@ -0,0 +1,134 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.ls
|
||||
jc - JSON CLI output utility `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`.
|
||||
|
||||
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):
|
||||
|
||||
$ ls | jc --ls
|
||||
|
||||
or
|
||||
|
||||
$ jc ls
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.ls
|
||||
result = jc.parsers.ls.parse(ls_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"filename": string,
|
||||
"flags": string,
|
||||
"links": integer,
|
||||
"parent": string,
|
||||
"owner": string,
|
||||
"group": string,
|
||||
"size": integer,
|
||||
"date": string,
|
||||
"epoch": integer, # naive timestamp if date field exists and can be converted
|
||||
"epoch_utc": integer # timezone aware timestamp if date field is in UTC and can be converted
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ ls /usr/bin | jc --ls -p
|
||||
[
|
||||
{
|
||||
"filename": "apropos"
|
||||
},
|
||||
{
|
||||
"filename": "arch"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ ls -l /usr/bin | jc --ls -p
|
||||
[
|
||||
{
|
||||
"filename": "apropos",
|
||||
"link_to": "whatis",
|
||||
"flags": "lrwxrwxrwx.",
|
||||
"links": 1,
|
||||
"owner": "root",
|
||||
"group": "root",
|
||||
"size": 6,
|
||||
"date": "Aug 15 10:53"
|
||||
},
|
||||
{
|
||||
"filename": "ar",
|
||||
"flags": "-rwxr-xr-x.",
|
||||
"links": 1,
|
||||
"owner": "root",
|
||||
"group": "root",
|
||||
"size": 62744,
|
||||
"date": "Aug 8 16:14"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ ls -l /usr/bin | jc --ls -p -r
|
||||
[
|
||||
{
|
||||
"filename": "apropos",
|
||||
"link_to": "whatis",
|
||||
"flags": "lrwxrwxrwx.",
|
||||
"links": "1",
|
||||
"owner": "root",
|
||||
"group": "root",
|
||||
"size": "6",
|
||||
"date": "Aug 15 10:53"
|
||||
},
|
||||
{
|
||||
"filename": "arch",
|
||||
"flags": "-rwxr-xr-x.",
|
||||
"links": "1",
|
||||
"owner": "root",
|
||||
"group": "root",
|
||||
"size": "33080",
|
||||
"date": "Aug 19 23:25"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.10 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
94
docs/parsers/ls_s.md
Normal file
94
docs/parsers/ls_s.md
Normal file
@@ -0,0 +1,94 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.ls_s
|
||||
jc - JSON CLI output utility `ls` and `vdir` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines
|
||||
|
||||
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 `jc` `-qq` option can be used to ignore parsing errors. (e.g. filenames with newline characters, but `-b` was not used)
|
||||
|
||||
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):
|
||||
|
||||
$ ls | jc --ls-s
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.ls_s
|
||||
result = jc.parsers.ls_s.parse(ls_command_output.splitlines()) # result is an iterable object
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"filename": string,
|
||||
"flags": string,
|
||||
"links": integer,
|
||||
"parent": string,
|
||||
"owner": string,
|
||||
"group": string,
|
||||
"size": integer,
|
||||
"date": string,
|
||||
"epoch": integer, # naive timestamp if date field exists and can be converted
|
||||
"epoch_utc": integer, # timezone aware timestamp if date field is in UTC and can be converted
|
||||
"_jc_meta": # This object only exists if using -qq or ignore_exceptions=True
|
||||
{
|
||||
"success": booean, # true if successfully parsed, false if error
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
}
|
||||
|
||||
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"}
|
||||
...
|
||||
|
||||
$ 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"}
|
||||
...
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterator object.
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (iterable) line-based text data to parse (e.g. sys.stdin or str.splitlines())
|
||||
raw: (boolean) output preprocessed JSON 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
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 0.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
296
docs/parsers/lsblk.md
Normal file
296
docs/parsers/lsblk.md
Normal file
@@ -0,0 +1,296 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.lsblk
|
||||
jc - JSON CLI output utility `lsblk` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ lsblk | jc --lsblk
|
||||
|
||||
or
|
||||
|
||||
$ jc lsblk
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.lsblk
|
||||
result = jc.parsers.lsblk.parse(lsblk_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"name": string,
|
||||
"maj_min": string,
|
||||
"rm": boolean,
|
||||
"size": string,
|
||||
"ro": boolean,
|
||||
"type": string,
|
||||
"mountpoint": string,
|
||||
"kname": string,
|
||||
"fstype": string,
|
||||
"label": string,
|
||||
"uuid": string,
|
||||
"partlabel": string,
|
||||
"partuuid": string,
|
||||
"ra": integer,
|
||||
"model": string,
|
||||
"serial": string,
|
||||
"state": string,
|
||||
"owner": string,
|
||||
"group": string,
|
||||
"mode": string,
|
||||
"alignment": integer,
|
||||
"min_io": integer,
|
||||
"opt_io": integer,
|
||||
"phy_sec": integer,
|
||||
"log_sec": integer,
|
||||
"rota": boolean,
|
||||
"sched": string,
|
||||
"rq_size": integer,
|
||||
"disc_aln": integer,
|
||||
"disc_gran": string,
|
||||
"disc_max": string,
|
||||
"disc_zero": boolean,
|
||||
"wsame": string,
|
||||
"wwn": string,
|
||||
"rand": boolean,
|
||||
"pkname": string,
|
||||
"hctl": string,
|
||||
"tran": string,
|
||||
"rev": string,
|
||||
"vendor": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ lsblk | jc --lsblk -p
|
||||
[
|
||||
{
|
||||
"name": "sda",
|
||||
"maj_min": "8:0",
|
||||
"rm": false,
|
||||
"size": "20G",
|
||||
"ro": false,
|
||||
"type": "disk",
|
||||
"mountpoint": null
|
||||
},
|
||||
{
|
||||
"name": "sda1",
|
||||
"maj_min": "8:1",
|
||||
"rm": false,
|
||||
"size": "1G",
|
||||
"ro": false,
|
||||
"type": "part",
|
||||
"mountpoint": "/boot"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ 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",
|
||||
"maj_min": "8:0",
|
||||
"rm": false,
|
||||
"size": "20G",
|
||||
"ro": false,
|
||||
"type": "disk",
|
||||
"mountpoint": null,
|
||||
"kname": "sda",
|
||||
"fstype": null,
|
||||
"label": null,
|
||||
"uuid": null,
|
||||
"partlabel": null,
|
||||
"partuuid": null,
|
||||
"ra": 4096,
|
||||
"model": "VMware Virtual S",
|
||||
"serial": null,
|
||||
"state": "running",
|
||||
"owner": "root",
|
||||
"group": "disk",
|
||||
"mode": "brw-rw----",
|
||||
"alignment": 0,
|
||||
"min_io": 512,
|
||||
"opt_io": 0,
|
||||
"phy_sec": 512,
|
||||
"log_sec": 512,
|
||||
"rota": true,
|
||||
"sched": "deadline",
|
||||
"rq_size": 128,
|
||||
"disc_aln": 0,
|
||||
"disc_gran": "0B",
|
||||
"disc_max": "0B",
|
||||
"disc_zero": false,
|
||||
"wsame": "32M",
|
||||
"wwn": null,
|
||||
"rand": true,
|
||||
"pkname": null,
|
||||
"hctl": "0:0:0:0",
|
||||
"tran": "spi",
|
||||
"rev": "1.0",
|
||||
"vendor": "VMware,"
|
||||
},
|
||||
{
|
||||
"name": "sda1",
|
||||
"maj_min": "8:1",
|
||||
"rm": false,
|
||||
"size": "1G",
|
||||
"ro": false,
|
||||
"type": "part",
|
||||
"mountpoint": "/boot",
|
||||
"kname": "sda1",
|
||||
"fstype": "xfs",
|
||||
"label": null,
|
||||
"uuid": "05d927bb-5875-49e3-ada1-7f46cb31c932",
|
||||
"partlabel": null,
|
||||
"partuuid": null,
|
||||
"ra": 4096,
|
||||
"model": null,
|
||||
"serial": null,
|
||||
"state": null,
|
||||
"owner": "root",
|
||||
"group": "disk",
|
||||
"mode": "brw-rw----",
|
||||
"alignment": 0,
|
||||
"min_io": 512,
|
||||
"opt_io": 0,
|
||||
"phy_sec": 512,
|
||||
"log_sec": 512,
|
||||
"rota": true,
|
||||
"sched": "deadline",
|
||||
"rq_size": 128,
|
||||
"disc_aln": 0,
|
||||
"disc_gran": "0B",
|
||||
"disc_max": "0B",
|
||||
"disc_zero": false,
|
||||
"wsame": "32M",
|
||||
"wwn": null,
|
||||
"rand": true,
|
||||
"pkname": "sda",
|
||||
"hctl": null,
|
||||
"tran": null,
|
||||
"rev": null,
|
||||
"vendor": null
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ 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",
|
||||
"maj_min": "8:0",
|
||||
"rm": "0",
|
||||
"size": "20G",
|
||||
"ro": "0",
|
||||
"type": "disk",
|
||||
"mountpoint": null,
|
||||
"kname": "sda",
|
||||
"fstype": null,
|
||||
"label": null,
|
||||
"uuid": null,
|
||||
"partlabel": null,
|
||||
"partuuid": null,
|
||||
"ra": "4096",
|
||||
"model": "VMware Virtual S",
|
||||
"serial": null,
|
||||
"state": "running",
|
||||
"owner": "root",
|
||||
"group": "disk",
|
||||
"mode": "brw-rw----",
|
||||
"alignment": "0",
|
||||
"min_io": "512",
|
||||
"opt_io": "0",
|
||||
"phy_sec": "512",
|
||||
"log_sec": "512",
|
||||
"rota": "1",
|
||||
"sched": "deadline",
|
||||
"rq_size": "128",
|
||||
"disc_aln": "0",
|
||||
"disc_gran": "0B",
|
||||
"disc_max": "0B",
|
||||
"disc_zero": "0",
|
||||
"wsame": "32M",
|
||||
"wwn": null,
|
||||
"rand": "1",
|
||||
"pkname": null,
|
||||
"hctl": "0:0:0:0",
|
||||
"tran": "spi",
|
||||
"rev": "1.0",
|
||||
"vendor": "VMware,"
|
||||
},
|
||||
{
|
||||
"name": "sda1",
|
||||
"maj_min": "8:1",
|
||||
"rm": "0",
|
||||
"size": "1G",
|
||||
"ro": "0",
|
||||
"type": "part",
|
||||
"mountpoint": "/boot",
|
||||
"kname": "sda1",
|
||||
"fstype": "xfs",
|
||||
"label": null,
|
||||
"uuid": "05d927bb-5875-49e3-ada1-7f46cb31c932",
|
||||
"partlabel": null,
|
||||
"partuuid": null,
|
||||
"ra": "4096",
|
||||
"model": null,
|
||||
"serial": null,
|
||||
"state": null,
|
||||
"owner": "root",
|
||||
"group": "disk",
|
||||
"mode": "brw-rw----",
|
||||
"alignment": "0",
|
||||
"min_io": "512",
|
||||
"opt_io": "0",
|
||||
"phy_sec": "512",
|
||||
"log_sec": "512",
|
||||
"rota": "1",
|
||||
"sched": "deadline",
|
||||
"rq_size": "128",
|
||||
"disc_aln": "0",
|
||||
"disc_gran": "0B",
|
||||
"disc_max": "0B",
|
||||
"disc_zero": "0",
|
||||
"wsame": "32M",
|
||||
"wwn": null,
|
||||
"rand": "1",
|
||||
"pkname": "sda",
|
||||
"hctl": null,
|
||||
"tran": null,
|
||||
"rev": null,
|
||||
"vendor": null
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
153
docs/parsers/lsmod.md
Normal file
153
docs/parsers/lsmod.md
Normal file
@@ -0,0 +1,153 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.lsmod
|
||||
jc - JSON CLI output utility `lsmod` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ lsmod | jc --lsmod
|
||||
|
||||
or
|
||||
|
||||
$ jc lsmod
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.lsmod
|
||||
result = jc.parsers.lsmod.parse(lsmod_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"module": string,
|
||||
"size": integer,
|
||||
"used": integer,
|
||||
"by": [
|
||||
string
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ lsmod | jc --lsmod -p
|
||||
[
|
||||
...
|
||||
{
|
||||
"module": "nf_nat",
|
||||
"size": 26583,
|
||||
"used": 3,
|
||||
"by": [
|
||||
"nf_nat_ipv4",
|
||||
"nf_nat_ipv6",
|
||||
"nf_nat_masquerade_ipv4"
|
||||
]
|
||||
},
|
||||
{
|
||||
"module": "iptable_mangle",
|
||||
"size": 12695,
|
||||
"used": 1
|
||||
},
|
||||
{
|
||||
"module": "iptable_security",
|
||||
"size": 12705,
|
||||
"used": 1
|
||||
},
|
||||
{
|
||||
"module": "iptable_raw",
|
||||
"size": 12678,
|
||||
"used": 1
|
||||
},
|
||||
{
|
||||
"module": "nf_conntrack",
|
||||
"size": 139224,
|
||||
"used": 7,
|
||||
"by": [
|
||||
"nf_nat",
|
||||
"nf_nat_ipv4",
|
||||
"nf_nat_ipv6",
|
||||
"xt_conntrack",
|
||||
"nf_nat_masquerade_ipv4",
|
||||
"nf_conntrack_ipv4",
|
||||
"nf_conntrack_ipv6"
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ lsmod | jc --lsmod -p -r
|
||||
[
|
||||
...
|
||||
{
|
||||
"module": "nf_conntrack",
|
||||
"size": "139224",
|
||||
"used": "7",
|
||||
"by": [
|
||||
"nf_nat",
|
||||
"nf_nat_ipv4",
|
||||
"nf_nat_ipv6",
|
||||
"xt_conntrack",
|
||||
"nf_nat_masquerade_ipv4",
|
||||
"nf_conntrack_ipv4",
|
||||
"nf_conntrack_ipv6"
|
||||
]
|
||||
},
|
||||
{
|
||||
"module": "ip_set",
|
||||
"size": "45799",
|
||||
"used": "0"
|
||||
},
|
||||
{
|
||||
"module": "nfnetlink",
|
||||
"size": "14519",
|
||||
"used": "1",
|
||||
"by": [
|
||||
"ip_set"
|
||||
]
|
||||
},
|
||||
{
|
||||
"module": "ebtable_filter",
|
||||
"size": "12827",
|
||||
"used": "1"
|
||||
},
|
||||
{
|
||||
"module": "ebtables",
|
||||
"size": "35009",
|
||||
"used": "2",
|
||||
"by": [
|
||||
"ebtable_nat",
|
||||
"ebtable_filter"
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
147
docs/parsers/lsof.md
Normal file
147
docs/parsers/lsof.md
Normal file
@@ -0,0 +1,147 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.lsof
|
||||
jc - JSON CLI output utility `lsof` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ lsof | jc --lsof
|
||||
|
||||
or
|
||||
|
||||
$ jc lsof
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.lsof
|
||||
result = jc.parsers.lsof.parse(lsof_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"command": string,
|
||||
"pid": integer,
|
||||
"tid": integer,
|
||||
"user": string,
|
||||
"fd": string,
|
||||
"type": string,
|
||||
"device": string,
|
||||
"size_off": integer,
|
||||
"node": integer,
|
||||
"name": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ sudo lsof | jc --lsof -p
|
||||
[
|
||||
{
|
||||
"command": "systemd",
|
||||
"pid": 1,
|
||||
"tid": null,
|
||||
"user": "root",
|
||||
"fd": "cwd",
|
||||
"type": "DIR",
|
||||
"device": "253,0",
|
||||
"size_off": 224,
|
||||
"node": 64,
|
||||
"name": "/"
|
||||
},
|
||||
{
|
||||
"command": "systemd",
|
||||
"pid": 1,
|
||||
"tid": null,
|
||||
"user": "root",
|
||||
"fd": "rtd",
|
||||
"type": "DIR",
|
||||
"device": "253,0",
|
||||
"size_off": 224,
|
||||
"node": 64,
|
||||
"name": "/"
|
||||
},
|
||||
{
|
||||
"command": "systemd",
|
||||
"pid": 1,
|
||||
"tid": null,
|
||||
"user": "root",
|
||||
"fd": "txt",
|
||||
"type": "REG",
|
||||
"device": "253,0",
|
||||
"size_off": 1624520,
|
||||
"node": 50360451,
|
||||
"name": "/usr/lib/systemd/systemd"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ sudo lsof | jc --lsof -p -r
|
||||
[
|
||||
{
|
||||
"command": "systemd",
|
||||
"pid": "1",
|
||||
"tid": null,
|
||||
"user": "root",
|
||||
"fd": "cwd",
|
||||
"type": "DIR",
|
||||
"device": "8,2",
|
||||
"size_off": "4096",
|
||||
"node": "2",
|
||||
"name": "/"
|
||||
},
|
||||
{
|
||||
"command": "systemd",
|
||||
"pid": "1",
|
||||
"tid": null,
|
||||
"user": "root",
|
||||
"fd": "rtd",
|
||||
"type": "DIR",
|
||||
"device": "8,2",
|
||||
"size_off": "4096",
|
||||
"node": "2",
|
||||
"name": "/"
|
||||
},
|
||||
{
|
||||
"command": "systemd",
|
||||
"pid": "1",
|
||||
"tid": null,
|
||||
"user": "root",
|
||||
"fd": "txt",
|
||||
"type": "REG",
|
||||
"device": "8,2",
|
||||
"size_off": "1595792",
|
||||
"node": "668802",
|
||||
"name": "/lib/systemd/systemd"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
288
docs/parsers/lsusb.md
Normal file
288
docs/parsers/lsusb.md
Normal file
@@ -0,0 +1,288 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.lsusb
|
||||
jc - JSON CLI output utility `lsusb` command output parser
|
||||
|
||||
Supports the `-v` option or no options.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ lsusb -v | jc --lsusb
|
||||
|
||||
or
|
||||
|
||||
$ jc lsusb -v
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.lsusb
|
||||
result = jc.parsers.lsusb.parse(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.
|
||||
|
||||
[
|
||||
{
|
||||
"bus": string,
|
||||
"device": string,
|
||||
"id": string,
|
||||
"description": string,
|
||||
"device_descriptor": {
|
||||
"<item>": {
|
||||
"value": string,
|
||||
"description": string,
|
||||
"attributes": [
|
||||
string
|
||||
]
|
||||
},
|
||||
"configuration_descriptor": {
|
||||
"<item>": {
|
||||
"value": string,
|
||||
"description": string,
|
||||
"attributes": [
|
||||
string
|
||||
]
|
||||
},
|
||||
"interface_association": {
|
||||
"<item>": {
|
||||
"value": string,
|
||||
"description": string,
|
||||
"attributes": [
|
||||
string
|
||||
]
|
||||
}
|
||||
},
|
||||
"interface_descriptors": [
|
||||
{
|
||||
"<item>": {
|
||||
"value": string,
|
||||
"description": string,
|
||||
"attributes": [
|
||||
string
|
||||
]
|
||||
},
|
||||
"cdc_header": {
|
||||
"<item>": {
|
||||
"value": string,
|
||||
"description": string,
|
||||
"attributes": [
|
||||
string
|
||||
]
|
||||
}
|
||||
},
|
||||
"cdc_call_management": {
|
||||
"<item>": {
|
||||
"value": string,
|
||||
"description": string,
|
||||
"attributes": [
|
||||
string
|
||||
]
|
||||
}
|
||||
},
|
||||
"cdc_acm": {
|
||||
"<item>": {
|
||||
"value": string,
|
||||
"description": string,
|
||||
"attributes": [
|
||||
string
|
||||
]
|
||||
}
|
||||
},
|
||||
"cdc_union": {
|
||||
"<item>": {
|
||||
"value": string,
|
||||
"description": string,
|
||||
"attributes": [
|
||||
string
|
||||
]
|
||||
}
|
||||
},
|
||||
"endpoint_descriptors": [
|
||||
{
|
||||
"<item>": {
|
||||
"value": string,
|
||||
"description": string,
|
||||
"attributes": [
|
||||
string
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"hub_descriptor": {
|
||||
"<item>": {
|
||||
"value": string,
|
||||
"description": string,
|
||||
"attributes": [
|
||||
string,
|
||||
]
|
||||
},
|
||||
"hub_port_status": {
|
||||
"<item>": {
|
||||
"value": string,
|
||||
"attributes": [
|
||||
string
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"device_status": {
|
||||
"value": string,
|
||||
"description": string
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ lsusb -v | jc --lsusb -p
|
||||
[
|
||||
{
|
||||
"bus": "002",
|
||||
"device": "001",
|
||||
"id": "1d6b:0001",
|
||||
"description": "Linux Foundation 1.1 root hub",
|
||||
"device_descriptor": {
|
||||
"bLength": {
|
||||
"value": "18"
|
||||
},
|
||||
"bDescriptorType": {
|
||||
"value": "1"
|
||||
},
|
||||
"bcdUSB": {
|
||||
"value": "1.10"
|
||||
},
|
||||
...
|
||||
"bNumConfigurations": {
|
||||
"value": "1"
|
||||
},
|
||||
"configuration_descriptor": {
|
||||
"bLength": {
|
||||
"value": "9"
|
||||
},
|
||||
...
|
||||
"iConfiguration": {
|
||||
"value": "0"
|
||||
},
|
||||
"bmAttributes": {
|
||||
"value": "0xe0",
|
||||
"attributes": [
|
||||
"Self Powered",
|
||||
"Remote Wakeup"
|
||||
]
|
||||
},
|
||||
"MaxPower": {
|
||||
"description": "0mA"
|
||||
},
|
||||
"interface_descriptors": [
|
||||
{
|
||||
"bLength": {
|
||||
"value": "9"
|
||||
},
|
||||
...
|
||||
"bInterfaceProtocol": {
|
||||
"value": "0",
|
||||
"description": "Full speed (or root) hub"
|
||||
},
|
||||
"iInterface": {
|
||||
"value": "0"
|
||||
},
|
||||
"endpoint_descriptors": [
|
||||
{
|
||||
"bLength": {
|
||||
"value": "7"
|
||||
},
|
||||
...
|
||||
"bmAttributes": {
|
||||
"value": "3",
|
||||
"attributes": [
|
||||
"Transfer Type Interrupt",
|
||||
"Synch Type None",
|
||||
"Usage Type Data"
|
||||
]
|
||||
},
|
||||
"wMaxPacketSize": {
|
||||
"value": "0x0002",
|
||||
"description": "1x 2 bytes"
|
||||
},
|
||||
"bInterval": {
|
||||
"value": "255"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"hub_descriptor": {
|
||||
"bLength": {
|
||||
"value": "9"
|
||||
},
|
||||
...
|
||||
"wHubCharacteristic": {
|
||||
"value": "0x000a",
|
||||
"attributes": [
|
||||
"No power switching (usb 1.0)",
|
||||
"Per-port overcurrent protection"
|
||||
]
|
||||
},
|
||||
...
|
||||
"hub_port_status": {
|
||||
"Port 1": {
|
||||
"value": "0000.0103",
|
||||
"attributes": [
|
||||
"power",
|
||||
"enable",
|
||||
"connect"
|
||||
]
|
||||
},
|
||||
"Port 2": {
|
||||
"value": "0000.0103",
|
||||
"attributes": [
|
||||
"power",
|
||||
"enable",
|
||||
"connect"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"device_status": {
|
||||
"value": "0x0001",
|
||||
"description": "Self Powered"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
103
docs/parsers/mount.md
Normal file
103
docs/parsers/mount.md
Normal file
@@ -0,0 +1,103 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.mount
|
||||
jc - JSON CLI output utility `mount` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ mount | jc --mount
|
||||
|
||||
or
|
||||
|
||||
$ jc mount
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.mount
|
||||
result = jc.parsers.mount.parse(mount_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"filesystem": string,
|
||||
"mount_point": string,
|
||||
"type": string,
|
||||
"access": [
|
||||
string
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Example:
|
||||
|
||||
$ mount | jc --mount -p
|
||||
[
|
||||
{
|
||||
"filesystem": "sysfs",
|
||||
"mount_point": "/sys",
|
||||
"type": "sysfs",
|
||||
"access": [
|
||||
"rw",
|
||||
"nosuid",
|
||||
"nodev",
|
||||
"noexec",
|
||||
"relatime"
|
||||
]
|
||||
},
|
||||
{
|
||||
"filesystem": "proc",
|
||||
"mount_point": "/proc",
|
||||
"type": "proc",
|
||||
"access": [
|
||||
"rw",
|
||||
"nosuid",
|
||||
"nodev",
|
||||
"noexec",
|
||||
"relatime"
|
||||
]
|
||||
},
|
||||
{
|
||||
"filesystem": "udev",
|
||||
"mount_point": "/dev",
|
||||
"type": "devtmpfs",
|
||||
"access": [
|
||||
"rw",
|
||||
"nosuid",
|
||||
"relatime",
|
||||
"size=977500k",
|
||||
"nr_inodes=244375",
|
||||
"mode=755"
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
382
docs/parsers/netstat.md
Normal file
382
docs/parsers/netstat.md
Normal file
@@ -0,0 +1,382 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.netstat
|
||||
jc - JSON CLI output utility `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`)
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ netstat | jc --netstat
|
||||
|
||||
or
|
||||
|
||||
$ jc netstat
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.netstat
|
||||
result = jc.parsers.netstat.parse(netstat_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"proto": string,
|
||||
"recv_q": integer,
|
||||
"send_q": integer,
|
||||
"transport_protocol" string,
|
||||
"network_protocol": string,
|
||||
"local_address": string,
|
||||
"local_port": string,
|
||||
"local_port_num": integer,
|
||||
"foreign_address": string,
|
||||
"foreign_port": string,
|
||||
"foreign_port_num": integer,
|
||||
"state": string,
|
||||
"program_name": string,
|
||||
"pid": integer,
|
||||
"user": string,
|
||||
"security_context": string,
|
||||
"refcnt": integer,
|
||||
"flags": string,
|
||||
"type": string,
|
||||
"inode": integer,
|
||||
"path": string,
|
||||
"kind": string,
|
||||
"address": string,
|
||||
"unix_inode": string,
|
||||
"conn": string,
|
||||
"refs": string,
|
||||
"nextref": string,
|
||||
"name": string,
|
||||
"unit": integer,
|
||||
"vendor": integer,
|
||||
"class": integer,
|
||||
"subcla": integer,
|
||||
"unix_flags": integer,
|
||||
"pcbcount": integer,
|
||||
"rcvbuf": integer,
|
||||
"sndbuf": integer,
|
||||
"rxbytes": integer,
|
||||
"txbytes": integer,
|
||||
"destination": string,
|
||||
"gateway": string,
|
||||
"route_flags": string,
|
||||
"route_flags_pretty": [
|
||||
string,
|
||||
]
|
||||
"route_refs": integer,
|
||||
"use": integer,
|
||||
"mtu": integer,
|
||||
"expire": string,
|
||||
"genmask": string,
|
||||
"mss": integer,
|
||||
"window": integer,
|
||||
"irtt": integer,
|
||||
"iface": string,
|
||||
"metric": integer,
|
||||
"network": string,
|
||||
"address": string,
|
||||
"ipkts": integer, # - = null
|
||||
"ierrs": integer, # - = null
|
||||
"idrop": integer, # - = null
|
||||
"opkts": integer, # - = null
|
||||
"oerrs": integer, # - = null
|
||||
"coll": integer, # - = null
|
||||
"rx_ok": integer,
|
||||
"rx_err": integer,
|
||||
"rx_drp": integer,
|
||||
"rx_ovr": integer,
|
||||
"tx_ok": integer,
|
||||
"tx_err": integer,
|
||||
"tx_drp": integer,
|
||||
"tx_ovr": integer,
|
||||
"flg": string,
|
||||
"ibytes": integer,
|
||||
"obytes": integer,
|
||||
"r_mbuf": integer,
|
||||
"s_mbuf": integer,
|
||||
"r_clus": integer,
|
||||
"s_clus": integer,
|
||||
"r_hiwa": integer,
|
||||
"s_hiwa": integer,
|
||||
"r_lowa": integer,
|
||||
"s_lowa": integer,
|
||||
"r_bcnt": integer,
|
||||
"s_bcnt": integer,
|
||||
"r_bmax": integer,
|
||||
"s_bmax": integer,
|
||||
"rexmit": integer,
|
||||
"ooorcv": integer,
|
||||
"0_win": integer,
|
||||
"rexmt": float,
|
||||
"persist": float,
|
||||
"keep": float,
|
||||
"2msl": float,
|
||||
"delack": float,
|
||||
"rcvtime": float,
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
# netstat -apee | jc --netstat -p
|
||||
[
|
||||
{
|
||||
"proto": "tcp",
|
||||
"recv_q": 0,
|
||||
"send_q": 0,
|
||||
"local_address": "localhost",
|
||||
"foreign_address": "0.0.0.0",
|
||||
"state": "LISTEN",
|
||||
"user": "systemd-resolve",
|
||||
"inode": 26958,
|
||||
"program_name": "systemd-resolve",
|
||||
"kind": "network",
|
||||
"pid": 887,
|
||||
"local_port": "domain",
|
||||
"foreign_port": "*",
|
||||
"transport_protocol": "tcp",
|
||||
"network_protocol": "ipv4"
|
||||
},
|
||||
{
|
||||
"proto": "tcp",
|
||||
"recv_q": 0,
|
||||
"send_q": 0,
|
||||
"local_address": "0.0.0.0",
|
||||
"foreign_address": "0.0.0.0",
|
||||
"state": "LISTEN",
|
||||
"user": "root",
|
||||
"inode": 30499,
|
||||
"program_name": "sshd",
|
||||
"kind": "network",
|
||||
"pid": 1186,
|
||||
"local_port": "ssh",
|
||||
"foreign_port": "*",
|
||||
"transport_protocol": "tcp",
|
||||
"network_protocol": "ipv4"
|
||||
},
|
||||
{
|
||||
"proto": "tcp",
|
||||
"recv_q": 0,
|
||||
"send_q": 0,
|
||||
"local_address": "localhost",
|
||||
"foreign_address": "localhost",
|
||||
"state": "ESTABLISHED",
|
||||
"user": "root",
|
||||
"inode": 46829,
|
||||
"program_name": "sshd: root",
|
||||
"kind": "network",
|
||||
"pid": 2242,
|
||||
"local_port": "ssh",
|
||||
"foreign_port": "52186",
|
||||
"transport_protocol": "tcp",
|
||||
"network_protocol": "ipv4",
|
||||
"foreign_port_num": 52186
|
||||
},
|
||||
{
|
||||
"proto": "tcp",
|
||||
"recv_q": 0,
|
||||
"send_q": 0,
|
||||
"local_address": "localhost",
|
||||
"foreign_address": "localhost",
|
||||
"state": "ESTABLISHED",
|
||||
"user": "root",
|
||||
"inode": 46828,
|
||||
"program_name": "ssh",
|
||||
"kind": "network",
|
||||
"pid": 2241,
|
||||
"local_port": "52186",
|
||||
"foreign_port": "ssh",
|
||||
"transport_protocol": "tcp",
|
||||
"network_protocol": "ipv4",
|
||||
"local_port_num": 52186
|
||||
},
|
||||
{
|
||||
"proto": "tcp6",
|
||||
"recv_q": 0,
|
||||
"send_q": 0,
|
||||
"local_address": "[::]",
|
||||
"foreign_address": "[::]",
|
||||
"state": "LISTEN",
|
||||
"user": "root",
|
||||
"inode": 30510,
|
||||
"program_name": "sshd",
|
||||
"kind": "network",
|
||||
"pid": 1186,
|
||||
"local_port": "ssh",
|
||||
"foreign_port": "*",
|
||||
"transport_protocol": "tcp",
|
||||
"network_protocol": "ipv6"
|
||||
},
|
||||
{
|
||||
"proto": "udp",
|
||||
"recv_q": 0,
|
||||
"send_q": 0,
|
||||
"local_address": "localhost",
|
||||
"foreign_address": "0.0.0.0",
|
||||
"state": null,
|
||||
"user": "systemd-resolve",
|
||||
"inode": 26957,
|
||||
"program_name": "systemd-resolve",
|
||||
"kind": "network",
|
||||
"pid": 887,
|
||||
"local_port": "domain",
|
||||
"foreign_port": "*",
|
||||
"transport_protocol": "udp",
|
||||
"network_protocol": "ipv4"
|
||||
},
|
||||
{
|
||||
"proto": "raw6",
|
||||
"recv_q": 0,
|
||||
"send_q": 0,
|
||||
"local_address": "[::]",
|
||||
"foreign_address": "[::]",
|
||||
"state": "7",
|
||||
"user": "systemd-network",
|
||||
"inode": 27001,
|
||||
"program_name": "systemd-network",
|
||||
"kind": "network",
|
||||
"pid": 867,
|
||||
"local_port": "ipv6-icmp",
|
||||
"foreign_port": "*",
|
||||
"transport_protocol": null,
|
||||
"network_protocol": "ipv6"
|
||||
},
|
||||
{
|
||||
"proto": "unix",
|
||||
"refcnt": 2,
|
||||
"flags": null,
|
||||
"type": "DGRAM",
|
||||
"state": null,
|
||||
"inode": 33322,
|
||||
"program_name": "systemd",
|
||||
"path": "/run/user/1000/systemd/notify",
|
||||
"kind": "socket",
|
||||
"pid": 1607
|
||||
},
|
||||
{
|
||||
"proto": "unix",
|
||||
"refcnt": 2,
|
||||
"flags": "ACC",
|
||||
"type": "SEQPACKET",
|
||||
"state": "LISTENING",
|
||||
"inode": 20835,
|
||||
"program_name": "init",
|
||||
"path": "/run/udev/control",
|
||||
"kind": "socket",
|
||||
"pid": 1
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ netstat -r | jc --netstat -p
|
||||
[
|
||||
{
|
||||
"destination": "default",
|
||||
"gateway": "gateway",
|
||||
"genmask": "0.0.0.0",
|
||||
"route_flags": "UG",
|
||||
"mss": 0,
|
||||
"window": 0,
|
||||
"irtt": 0,
|
||||
"iface": "ens33",
|
||||
"kind": "route",
|
||||
"route_flags_pretty": [
|
||||
"UP",
|
||||
"GATEWAY"
|
||||
]
|
||||
},
|
||||
{
|
||||
"destination": "172.17.0.0",
|
||||
"gateway": "0.0.0.0",
|
||||
"genmask": "255.255.0.0",
|
||||
"route_flags": "U",
|
||||
"mss": 0,
|
||||
"window": 0,
|
||||
"irtt": 0,
|
||||
"iface": "docker0",
|
||||
"kind": "route",
|
||||
"route_flags_pretty": [
|
||||
"UP"
|
||||
]
|
||||
},
|
||||
{
|
||||
"destination": "192.168.71.0",
|
||||
"gateway": "0.0.0.0",
|
||||
"genmask": "255.255.255.0",
|
||||
"route_flags": "U",
|
||||
"mss": 0,
|
||||
"window": 0,
|
||||
"irtt": 0,
|
||||
"iface": "ens33",
|
||||
"kind": "route",
|
||||
"route_flags_pretty": [
|
||||
"UP"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
$ netstat -i | jc --netstat -p
|
||||
[
|
||||
{
|
||||
"iface": "ens33",
|
||||
"mtu": 1500,
|
||||
"rx_ok": 476,
|
||||
"rx_err": 0,
|
||||
"rx_drp": 0,
|
||||
"rx_ovr": 0,
|
||||
"tx_ok": 312,
|
||||
"tx_err": 0,
|
||||
"tx_drp": 0,
|
||||
"tx_ovr": 0,
|
||||
"flg": "BMRU",
|
||||
"kind": "interface"
|
||||
},
|
||||
{
|
||||
"iface": "lo",
|
||||
"mtu": 65536,
|
||||
"rx_ok": 0,
|
||||
"rx_err": 0,
|
||||
"rx_drp": 0,
|
||||
"rx_ovr": 0,
|
||||
"tx_ok": 0,
|
||||
"tx_err": 0,
|
||||
"tx_drp": 0,
|
||||
"tx_ovr": 0,
|
||||
"flg": "LRU",
|
||||
"kind": "interface"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.12 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
234
docs/parsers/ntpq.md
Normal file
234
docs/parsers/ntpq.md
Normal file
@@ -0,0 +1,234 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.ntpq
|
||||
jc - JSON CLI output utility `ntpq -p` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ ntpq -p | jc --ntpq
|
||||
|
||||
or
|
||||
|
||||
$ jc ntpq -p
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.ntpq
|
||||
result = jc.parsers.ntpq.parse(ntpq_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"state": string, # space/~ converted to null
|
||||
"remote": string,
|
||||
"refid": string,
|
||||
"st": integer,
|
||||
"t": string,
|
||||
"when": integer, # - converted to null
|
||||
"poll": integer,
|
||||
"reach": integer,
|
||||
"delay": float,
|
||||
"offset": float,
|
||||
"jitter": float
|
||||
},
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ ntpq -p | jc --ntpq -p
|
||||
[
|
||||
{
|
||||
"remote": "44.190.6.254",
|
||||
"refid": "127.67.113.92",
|
||||
"st": 2,
|
||||
"t": "u",
|
||||
"when": 1,
|
||||
"poll": 64,
|
||||
"reach": 1,
|
||||
"delay": 23.399,
|
||||
"offset": -2.805,
|
||||
"jitter": 2.131,
|
||||
"state": null
|
||||
},
|
||||
{
|
||||
"remote": "ntp.wdc1.us.lea",
|
||||
"refid": "130.133.1.10",
|
||||
"st": 2,
|
||||
"t": "u",
|
||||
"when": null,
|
||||
"poll": 64,
|
||||
"reach": 1,
|
||||
"delay": 93.053,
|
||||
"offset": -0.807,
|
||||
"jitter": 2.839,
|
||||
"state": null
|
||||
},
|
||||
{
|
||||
"remote": "clock.team-cymr",
|
||||
"refid": "204.9.54.119",
|
||||
"st": 2,
|
||||
"t": "u",
|
||||
"when": null,
|
||||
"poll": 64,
|
||||
"reach": 1,
|
||||
"delay": 70.337,
|
||||
"offset": -2.909,
|
||||
"jitter": 2.6,
|
||||
"state": null
|
||||
},
|
||||
{
|
||||
"remote": "mirror1.sjc02.s",
|
||||
"refid": "216.218.254.202",
|
||||
"st": 2,
|
||||
"t": "u",
|
||||
"when": 2,
|
||||
"poll": 64,
|
||||
"reach": 1,
|
||||
"delay": 29.325,
|
||||
"offset": 1.044,
|
||||
"jitter": 4.069,
|
||||
"state": null,
|
||||
}
|
||||
]
|
||||
|
||||
$ ntpq -pn| jc --ntpq -p
|
||||
[
|
||||
{
|
||||
"remote": "44.190.6.254",
|
||||
"refid": "127.67.113.92",
|
||||
"st": 2,
|
||||
"t": "u",
|
||||
"when": 66,
|
||||
"poll": 64,
|
||||
"reach": 377,
|
||||
"delay": 22.69,
|
||||
"offset": -0.392,
|
||||
"jitter": 2.085,
|
||||
"state": "+"
|
||||
},
|
||||
{
|
||||
"remote": "108.59.2.24",
|
||||
"refid": "130.133.1.10",
|
||||
"st": 2,
|
||||
"t": "u",
|
||||
"when": 63,
|
||||
"poll": 64,
|
||||
"reach": 377,
|
||||
"delay": 90.805,
|
||||
"offset": 2.84,
|
||||
"jitter": 1.908,
|
||||
"state": "-"
|
||||
},
|
||||
{
|
||||
"remote": "38.229.71.1",
|
||||
"refid": "204.9.54.119",
|
||||
"st": 2,
|
||||
"t": "u",
|
||||
"when": 64,
|
||||
"poll": 64,
|
||||
"reach": 377,
|
||||
"delay": 68.699,
|
||||
"offset": -0.61,
|
||||
"jitter": 2.576,
|
||||
"state": "+"
|
||||
},
|
||||
{
|
||||
"remote": "72.5.72.15",
|
||||
"refid": "216.218.254.202",
|
||||
"st": 2,
|
||||
"t": "u",
|
||||
"when": 63,
|
||||
"poll": 64,
|
||||
"reach": 377,
|
||||
"delay": 22.654,
|
||||
"offset": 0.231,
|
||||
"jitter": 1.964,
|
||||
"state": "*"
|
||||
}
|
||||
]
|
||||
|
||||
$ ntpq -pn| jc --ntpq -p -r
|
||||
[
|
||||
{
|
||||
"s": "+",
|
||||
"remote": "44.190.6.254",
|
||||
"refid": "127.67.113.92",
|
||||
"st": "2",
|
||||
"t": "u",
|
||||
"when": "66",
|
||||
"poll": "64",
|
||||
"reach": "377",
|
||||
"delay": "22.690",
|
||||
"offset": "-0.392",
|
||||
"jitter": "2.085"
|
||||
},
|
||||
{
|
||||
"s": "-",
|
||||
"remote": "108.59.2.24",
|
||||
"refid": "130.133.1.10",
|
||||
"st": "2",
|
||||
"t": "u",
|
||||
"when": "63",
|
||||
"poll": "64",
|
||||
"reach": "377",
|
||||
"delay": "90.805",
|
||||
"offset": "2.840",
|
||||
"jitter": "1.908"
|
||||
},
|
||||
{
|
||||
"s": "+",
|
||||
"remote": "38.229.71.1",
|
||||
"refid": "204.9.54.119",
|
||||
"st": "2",
|
||||
"t": "u",
|
||||
"when": "64",
|
||||
"poll": "64",
|
||||
"reach": "377",
|
||||
"delay": "68.699",
|
||||
"offset": "-0.610",
|
||||
"jitter": "2.576"
|
||||
},
|
||||
{
|
||||
"s": "*",
|
||||
"remote": "72.5.72.15",
|
||||
"refid": "216.218.254.202",
|
||||
"st": "2",
|
||||
"t": "u",
|
||||
"when": "63",
|
||||
"poll": "64",
|
||||
"reach": "377",
|
||||
"delay": "22.654",
|
||||
"offset": "0.231",
|
||||
"jitter": "1.964"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, freebsd
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
122
docs/parsers/passwd.md
Normal file
122
docs/parsers/passwd.md
Normal file
@@ -0,0 +1,122 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.passwd
|
||||
jc - JSON CLI output utility `/etc/passwd` file Parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat /etc/passwd | jc --passwd
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.passwd
|
||||
result = jc.parsers.passwd.parse(passwd_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"username": string,
|
||||
"password": string,
|
||||
"uid": integer,
|
||||
"gid": integer,
|
||||
"comment": string,
|
||||
"home": string,
|
||||
"shell": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat /etc/passwd | jc --passwd -p
|
||||
[
|
||||
{
|
||||
"username": "nobody",
|
||||
"password": "*",
|
||||
"uid": -2,
|
||||
"gid": -2,
|
||||
"comment": "Unprivileged User",
|
||||
"home": "/var/empty",
|
||||
"shell": "/usr/bin/false"
|
||||
},
|
||||
{
|
||||
"username": "root",
|
||||
"password": "*",
|
||||
"uid": 0,
|
||||
"gid": 0,
|
||||
"comment": "System Administrator",
|
||||
"home": "/var/root",
|
||||
"shell": "/bin/sh"
|
||||
},
|
||||
{
|
||||
"username": "daemon",
|
||||
"password": "*",
|
||||
"uid": 1,
|
||||
"gid": 1,
|
||||
"comment": "System Services",
|
||||
"home": "/var/root",
|
||||
"shell": "/usr/bin/false"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ cat /etc/passwd | jc --passwd -p -r
|
||||
[
|
||||
{
|
||||
"username": "nobody",
|
||||
"password": "*",
|
||||
"uid": "-2",
|
||||
"gid": "-2",
|
||||
"comment": "Unprivileged User",
|
||||
"home": "/var/empty",
|
||||
"shell": "/usr/bin/false"
|
||||
},
|
||||
{
|
||||
"username": "root",
|
||||
"password": "*",
|
||||
"uid": "0",
|
||||
"gid": "0",
|
||||
"comment": "System Administrator",
|
||||
"home": "/var/root",
|
||||
"shell": "/bin/sh"
|
||||
},
|
||||
{
|
||||
"username": "daemon",
|
||||
"password": "*",
|
||||
"uid": "1",
|
||||
"gid": "1",
|
||||
"comment": "System Services",
|
||||
"home": "/var/root",
|
||||
"shell": "/usr/bin/false"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, aix, freebsd
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
184
docs/parsers/ping.md
Normal file
184
docs/parsers/ping.md
Normal file
@@ -0,0 +1,184 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.ping
|
||||
jc - JSON CLI output utility `ping` command output parser
|
||||
|
||||
Supports `ping` and `ping6` output.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
Note: Use the ping `-c` (count) option, otherwise data will not be piped to `jc`.
|
||||
|
||||
$ ping -c 3 1.2.3.4 | jc --ping
|
||||
|
||||
or
|
||||
|
||||
$ jc ping -c 3 1.2.3.4
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.ping
|
||||
result = jc.parsers.ping.parse(ping_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"source_ip": string,
|
||||
"destination_ip": string,
|
||||
"data_bytes": integer,
|
||||
"pattern": string, # (null if not set)
|
||||
"destination": string,
|
||||
"packets_transmitted": integer,
|
||||
"packets_received": integer,
|
||||
"packet_loss_percent": float,
|
||||
"duplicates": integer,
|
||||
"round_trip_ms_min": float,
|
||||
"round_trip_ms_avg": float,
|
||||
"round_trip_ms_max": float,
|
||||
"round_trip_ms_stddev": float,
|
||||
"responses": [
|
||||
{
|
||||
"type": string, # 'reply', 'timeout', 'unparsable_line', etc. See `_error_type.type_map` for all options
|
||||
"unparsed_line": string, # only if an 'unparsable_line' type
|
||||
"timestamp": float,
|
||||
"bytes": integer,
|
||||
"response_ip": string,
|
||||
"icmp_seq": integer,
|
||||
"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
|
||||
"src": string,
|
||||
"dst": string
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ ping -c 3 -p ff cnn.com | jc --ping -p
|
||||
{
|
||||
"destination_ip": "151.101.1.67",
|
||||
"data_bytes": 56,
|
||||
"pattern": "0xff",
|
||||
"destination": "cnn.com",
|
||||
"packets_transmitted": 3,
|
||||
"packets_received": 3,
|
||||
"packet_loss_percent": 0.0,
|
||||
"duplicates": 0,
|
||||
"round_trip_ms_min": 28.015,
|
||||
"round_trip_ms_avg": 32.848,
|
||||
"round_trip_ms_max": 39.376,
|
||||
"round_trip_ms_stddev": 4.79,
|
||||
"responses": [
|
||||
{
|
||||
"type": "reply",
|
||||
"bytes": 64,
|
||||
"response_ip": "151.101.1.67",
|
||||
"icmp_seq": 0,
|
||||
"ttl": 59,
|
||||
"time_ms": 28.015,
|
||||
"duplicate": false
|
||||
},
|
||||
{
|
||||
"type": "reply",
|
||||
"bytes": 64,
|
||||
"response_ip": "151.101.1.67",
|
||||
"icmp_seq": 1,
|
||||
"ttl": 59,
|
||||
"time_ms": 39.376,
|
||||
"duplicate": false
|
||||
},
|
||||
{
|
||||
"type": "reply",
|
||||
"bytes": 64,
|
||||
"response_ip": "151.101.1.67",
|
||||
"icmp_seq": 2,
|
||||
"ttl": 59,
|
||||
"time_ms": 31.153,
|
||||
"duplicate": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
$ ping -c 3 -p ff cnn.com | jc --ping -p -r
|
||||
{
|
||||
"destination_ip": "151.101.129.67",
|
||||
"data_bytes": "56",
|
||||
"pattern": "0xff",
|
||||
"destination": "cnn.com",
|
||||
"packets_transmitted": "3",
|
||||
"packets_received": "3",
|
||||
"packet_loss_percent": "0.0",
|
||||
"duplicates": "0",
|
||||
"round_trip_ms_min": "25.078",
|
||||
"round_trip_ms_avg": "29.543",
|
||||
"round_trip_ms_max": "32.553",
|
||||
"round_trip_ms_stddev": "3.221",
|
||||
"responses": [
|
||||
{
|
||||
"type": "reply",
|
||||
"bytes": "64",
|
||||
"response_ip": "151.101.129.67",
|
||||
"icmp_seq": "0",
|
||||
"ttl": "59",
|
||||
"time_ms": "25.078",
|
||||
"duplicate": false
|
||||
},
|
||||
{
|
||||
"type": "reply",
|
||||
"bytes": "64",
|
||||
"response_ip": "151.101.129.67",
|
||||
"icmp_seq": "1",
|
||||
"ttl": "59",
|
||||
"time_ms": "30.999",
|
||||
"duplicate": false
|
||||
},
|
||||
{
|
||||
"type": "reply",
|
||||
"bytes": "64",
|
||||
"response_ip": "151.101.129.67",
|
||||
"icmp_seq": "2",
|
||||
"ttl": "59",
|
||||
"time_ms": "32.553",
|
||||
"duplicate": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
101
docs/parsers/ping_s.md
Normal file
101
docs/parsers/ping_s.md
Normal file
@@ -0,0 +1,101 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.ping_s
|
||||
jc - JSON CLI output utility `ping` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines
|
||||
|
||||
Supports `ping` and `ping6` output.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ ping | 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.
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.ping_s
|
||||
result = jc.parsers.ping_s.parse(ping_command_output.splitlines()) # result is an iterable object
|
||||
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": booean, # true if successfully parsed, false if error
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
}
|
||||
|
||||
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}
|
||||
...
|
||||
|
||||
$ 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"}
|
||||
...
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterator object.
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (iterable) line-based text data to parse (e.g. sys.stdin or str.splitlines())
|
||||
raw: (boolean) output preprocessed JSON 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
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 0.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
75
docs/parsers/pip_list.md
Normal file
75
docs/parsers/pip_list.md
Normal file
@@ -0,0 +1,75 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.pip_list
|
||||
jc - JSON CLI output utility `pip-list` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ pip list | jc --pip-list
|
||||
|
||||
or
|
||||
|
||||
$ jc pip list
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.pip_list
|
||||
result = jc.parsers.pip_list.parse(pip_list_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"package": string,
|
||||
"version": string,
|
||||
"location": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ pip list | jc --pip-list -p
|
||||
[
|
||||
{
|
||||
"package": "ansible",
|
||||
"version": "2.8.5"
|
||||
},
|
||||
{
|
||||
"package": "antlr4-python3-runtime",
|
||||
"version": "4.7.2"
|
||||
},
|
||||
{
|
||||
"package": "asn1crypto",
|
||||
"version": "0.24.0"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
93
docs/parsers/pip_show.md
Normal file
93
docs/parsers/pip_show.md
Normal file
@@ -0,0 +1,93 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.pip_show
|
||||
jc - JSON CLI output utility `pip-show` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ pip show | jc --pip-show
|
||||
|
||||
or
|
||||
|
||||
$ jc pip show
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.pip_show
|
||||
result = jc.parsers.pip_show.parse(pip_show_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"name": string,
|
||||
"version": string,
|
||||
"summary": string,
|
||||
"home_page": string,
|
||||
"author": string,
|
||||
"author_email": string,
|
||||
"license": string,
|
||||
"location": string,
|
||||
"requires": string,
|
||||
"required_by": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ pip show wrapt jc wheel | jc --pip-show -p
|
||||
[
|
||||
{
|
||||
"name": "wrapt",
|
||||
"version": "1.11.2",
|
||||
"summary": "Module for decorators, wrappers and monkey patching.",
|
||||
"home_page": "https://github.com/GrahamDumpleton/wrapt",
|
||||
"author": "Graham Dumpleton",
|
||||
"author_email": "Graham.Dumpleton@gmail.com",
|
||||
"license": "BSD",
|
||||
"location": "/usr/local/lib/python3.7/site-packages",
|
||||
"requires": null,
|
||||
"required_by": "astroid"
|
||||
},
|
||||
{
|
||||
"name": "wheel",
|
||||
"version": "0.33.4",
|
||||
"summary": "A built-package format for Python.",
|
||||
"home_page": "https://github.com/pypa/wheel",
|
||||
"author": "Daniel Holth",
|
||||
"author_email": "dholth@fastmail.fm",
|
||||
"license": "MIT",
|
||||
"location": "/usr/local/lib/python3.7/site-packages",
|
||||
"requires": null,
|
||||
"required_by": null
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
234
docs/parsers/ps.md
Normal file
234
docs/parsers/ps.md
Normal file
@@ -0,0 +1,234 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.ps
|
||||
jc - JSON CLI output utility `ps` command output parser
|
||||
|
||||
`ps` options supported:
|
||||
- `ef`
|
||||
- `axu`
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ ps | jc --ps
|
||||
|
||||
or
|
||||
|
||||
$ jc ps
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.ps
|
||||
result = jc.parsers.ps.parse(ps_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"uid": string,
|
||||
"pid": integer,
|
||||
"ppid": integer,
|
||||
"c": integer,
|
||||
"stime": string,
|
||||
"tty": string, # ? or ?? = Null
|
||||
"tt": string, # ?? = Null
|
||||
"time": string,
|
||||
"cmd": string,
|
||||
"user": string,
|
||||
"cpu_percent": float,
|
||||
"mem_percent": float,
|
||||
"vsz": integer,
|
||||
"rss": integer,
|
||||
"stat": string,
|
||||
"start": string,
|
||||
"command": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ ps -ef | jc --ps -p
|
||||
[
|
||||
{
|
||||
"uid": "root",
|
||||
"pid": 1,
|
||||
"ppid": 0,
|
||||
"c": 0,
|
||||
"stime": "Nov01",
|
||||
"tty": null,
|
||||
"time": "00:00:11",
|
||||
"cmd": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
||||
},
|
||||
{
|
||||
"uid": "root",
|
||||
"pid": 2,
|
||||
"ppid": 0,
|
||||
"c": 0,
|
||||
"stime": "Nov01",
|
||||
"tty": null,
|
||||
"time": "00:00:00",
|
||||
"cmd": "[kthreadd]"
|
||||
},
|
||||
{
|
||||
"uid": "root",
|
||||
"pid": 4,
|
||||
"ppid": 2,
|
||||
"c": 0,
|
||||
"stime": "Nov01",
|
||||
"tty": null,
|
||||
"time": "00:00:00",
|
||||
"cmd": "[kworker/0:0H]"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ ps -ef | jc --ps -p -r
|
||||
[
|
||||
{
|
||||
"uid": "root",
|
||||
"pid": "1",
|
||||
"ppid": "0",
|
||||
"c": "0",
|
||||
"stime": "Nov01",
|
||||
"tty": "?",
|
||||
"time": "00:00:11",
|
||||
"cmd": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
||||
},
|
||||
{
|
||||
"uid": "root",
|
||||
"pid": "2",
|
||||
"ppid": "0",
|
||||
"c": "0",
|
||||
"stime": "Nov01",
|
||||
"tty": "?",
|
||||
"time": "00:00:00",
|
||||
"cmd": "[kthreadd]"
|
||||
},
|
||||
{
|
||||
"uid": "root",
|
||||
"pid": "4",
|
||||
"ppid": "2",
|
||||
"c": "0",
|
||||
"stime": "Nov01",
|
||||
"tty": "?",
|
||||
"time": "00:00:00",
|
||||
"cmd": "[kworker/0:0H]"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ ps axu | jc --ps -p
|
||||
[
|
||||
{
|
||||
"user": "root",
|
||||
"pid": 1,
|
||||
"cpu_percent": 0.0,
|
||||
"mem_percent": 0.1,
|
||||
"vsz": 128072,
|
||||
"rss": 6784,
|
||||
"tty": null,
|
||||
"stat": "Ss",
|
||||
"start": "Nov09",
|
||||
"time": "0:08",
|
||||
"command": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
||||
},
|
||||
{
|
||||
"user": "root",
|
||||
"pid": 2,
|
||||
"cpu_percent": 0.0,
|
||||
"mem_percent": 0.0,
|
||||
"vsz": 0,
|
||||
"rss": 0,
|
||||
"tty": null,
|
||||
"stat": "S",
|
||||
"start": "Nov09",
|
||||
"time": "0:00",
|
||||
"command": "[kthreadd]"
|
||||
},
|
||||
{
|
||||
"user": "root",
|
||||
"pid": 4,
|
||||
"cpu_percent": 0.0,
|
||||
"mem_percent": 0.0,
|
||||
"vsz": 0,
|
||||
"rss": 0,
|
||||
"tty": null,
|
||||
"stat": "S<",
|
||||
"start": "Nov09",
|
||||
"time": "0:00",
|
||||
"command": "[kworker/0:0H]"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ ps axu | jc --ps -p -r
|
||||
[
|
||||
{
|
||||
"user": "root",
|
||||
"pid": "1",
|
||||
"cpu_percent": "0.0",
|
||||
"mem_percent": "0.1",
|
||||
"vsz": "128072",
|
||||
"rss": "6784",
|
||||
"tty": "?",
|
||||
"stat": "Ss",
|
||||
"start": "Nov09",
|
||||
"time": "0:08",
|
||||
"command": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
||||
},
|
||||
{
|
||||
"user": "root",
|
||||
"pid": "2",
|
||||
"cpu_percent": "0.0",
|
||||
"mem_percent": "0.0",
|
||||
"vsz": "0",
|
||||
"rss": "0",
|
||||
"tty": "?",
|
||||
"stat": "S",
|
||||
"start": "Nov09",
|
||||
"time": "0:00",
|
||||
"command": "[kthreadd]"
|
||||
},
|
||||
{
|
||||
"user": "root",
|
||||
"pid": "4",
|
||||
"cpu_percent": "0.0",
|
||||
"mem_percent": "0.0",
|
||||
"vsz": "0",
|
||||
"rss": "0",
|
||||
"tty": "?",
|
||||
"stat": "S<",
|
||||
"start": "Nov09",
|
||||
"time": "0:00",
|
||||
"command": "[kworker/0:0H]"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
136
docs/parsers/route.md
Normal file
136
docs/parsers/route.md
Normal file
@@ -0,0 +1,136 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.route
|
||||
jc - JSON CLI output utility `route` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ route | jc --route
|
||||
|
||||
or
|
||||
|
||||
$ jc route
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.route
|
||||
result = jc.parsers.route.parse(route_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"destination": string,
|
||||
"gateway": string,
|
||||
"genmask": string,
|
||||
"flags": string,
|
||||
"flags_pretty": [
|
||||
string
|
||||
]
|
||||
"metric": integer,
|
||||
"ref": integer,
|
||||
"use": integer,
|
||||
"mss": integer,
|
||||
"window": integer,
|
||||
"irtt": integer,
|
||||
"iface": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ route -ee | jc --route -p
|
||||
[
|
||||
{
|
||||
"destination": "default",
|
||||
"gateway": "_gateway",
|
||||
"genmask": "0.0.0.0",
|
||||
"flags": "UG",
|
||||
"metric": 202,
|
||||
"ref": 0,
|
||||
"use": 0,
|
||||
"iface": "ens33",
|
||||
"mss": 0,
|
||||
"window": 0,
|
||||
"irtt": 0,
|
||||
"flags_pretty": [
|
||||
"UP",
|
||||
"GATEWAY"
|
||||
]
|
||||
},
|
||||
{
|
||||
"destination": "192.168.71.0",
|
||||
"gateway": "0.0.0.0",
|
||||
"genmask": "255.255.255.0",
|
||||
"flags": "U",
|
||||
"metric": 202,
|
||||
"ref": 0,
|
||||
"use": 0,
|
||||
"iface": "ens33",
|
||||
"mss": 0,
|
||||
"window": 0,
|
||||
"irtt": 0,
|
||||
"flags_pretty": [
|
||||
"UP"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
$ route -ee | jc --route -p -r
|
||||
[
|
||||
{
|
||||
"destination": "default",
|
||||
"gateway": "_gateway",
|
||||
"genmask": "0.0.0.0",
|
||||
"flags": "UG",
|
||||
"metric": "202",
|
||||
"ref": "0",
|
||||
"use": "0",
|
||||
"iface": "ens33",
|
||||
"mss": "0",
|
||||
"window": "0",
|
||||
"irtt": "0"
|
||||
},
|
||||
{
|
||||
"destination": "192.168.71.0",
|
||||
"gateway": "0.0.0.0",
|
||||
"genmask": "255.255.255.0",
|
||||
"flags": "U",
|
||||
"metric": "202",
|
||||
"ref": "0",
|
||||
"use": "0",
|
||||
"iface": "ens33",
|
||||
"mss": "0",
|
||||
"window": "0",
|
||||
"irtt": "0"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
184
docs/parsers/rpm_qi.md
Normal file
184
docs/parsers/rpm_qi.md
Normal file
@@ -0,0 +1,184 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.rpm_qi
|
||||
jc - JSON CLI output utility `rpm -qi` command output parser
|
||||
|
||||
Works with `rpm -qi [package]` or `rpm -qia`.
|
||||
|
||||
The `..._epoch` calculated timestamp fields are naive (i.e. based on the local time of the system the parser is run on)
|
||||
|
||||
The `..._epoch_utc` calculated timestamp fields are timezone-aware and is only available if the timezone field is UTC.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ rpm -qia | jc --rpm-qi
|
||||
|
||||
or
|
||||
|
||||
$ jc rpm -qia
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.rpm_qi
|
||||
result = jc.parsers.rpm_qi.parse(rpm_qi_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"name": string,
|
||||
"epoch": integer,
|
||||
"version": string,
|
||||
"release": string,
|
||||
"architecture": string,
|
||||
"install_date": string,
|
||||
"install_date_epoch": integer, # naive timestamp
|
||||
"install_date_epoch_utc": integer, # Aware timestamp if timezone is UTC
|
||||
"group": string,
|
||||
"size": integer,
|
||||
"license": string,
|
||||
"signature": string,
|
||||
"source_rpm": string,
|
||||
"build_date": string,
|
||||
"build_epoch": integer, # naive timestamp
|
||||
"build_epoch_utc": integer, # Aware timestamp if timezone is UTC
|
||||
"build_host": string,
|
||||
"relocations": string,
|
||||
"packager": string,
|
||||
"vendor": string,
|
||||
"url": string,
|
||||
"summary": string,
|
||||
"description": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ rpm -qia | jc --rpm-qi -p
|
||||
[
|
||||
{
|
||||
"name": "make",
|
||||
"epoch": 1,
|
||||
"version": "3.82",
|
||||
"release": "24.el7",
|
||||
"architecture": "x86_64",
|
||||
"install_date": "Wed 16 Oct 2019 09:21:42 AM PDT",
|
||||
"group": "Development/Tools",
|
||||
"size": 1160660,
|
||||
"license": "GPLv2+",
|
||||
"signature": "RSA/SHA256, Thu 22 Aug 2019 02:34:59 PM PDT, Key ID 24c6a8a7f4a80eb5",
|
||||
"source_rpm": "make-3.82-24.el7.src.rpm",
|
||||
"build_date": "Thu 08 Aug 2019 05:47:25 PM PDT",
|
||||
"build_host": "x86-01.bsys.centos.org",
|
||||
"relocations": "(not relocatable)",
|
||||
"packager": "CentOS BuildSystem <http://bugs.centos.org>",
|
||||
"vendor": "CentOS",
|
||||
"url": "http://www.gnu.org/software/make/",
|
||||
"summary": "A GNU tool which simplifies the build process for users",
|
||||
"description": "A GNU tool for controlling the generation of executables and other...",
|
||||
"build_epoch": 1565311645,
|
||||
"build_epoch_utc": null,
|
||||
"install_date_epoch": 1571242902,
|
||||
"install_date_epoch_utc": null
|
||||
},
|
||||
{
|
||||
"name": "kbd-legacy",
|
||||
"version": "1.15.5",
|
||||
"release": "15.el7",
|
||||
"architecture": "noarch",
|
||||
"install_date": "Thu 15 Aug 2019 10:53:08 AM PDT",
|
||||
"group": "System Environment/Base",
|
||||
"size": 503608,
|
||||
"license": "GPLv2+",
|
||||
"signature": "RSA/SHA256, Mon 12 Nov 2018 07:17:49 AM PST, Key ID 24c6a8a7f4a80eb5",
|
||||
"source_rpm": "kbd-1.15.5-15.el7.src.rpm",
|
||||
"build_date": "Tue 30 Oct 2018 03:40:00 PM PDT",
|
||||
"build_host": "x86-01.bsys.centos.org",
|
||||
"relocations": "(not relocatable)",
|
||||
"packager": "CentOS BuildSystem <http://bugs.centos.org>",
|
||||
"vendor": "CentOS",
|
||||
"url": "http://ftp.altlinux.org/pub/people/legion/kbd",
|
||||
"summary": "Legacy data for kbd package",
|
||||
"description": "The kbd-legacy package contains original keymaps for kbd package...",
|
||||
"build_epoch": 1540939200,
|
||||
"build_epoch_utc": null,
|
||||
"install_date_epoch": 1565891588,
|
||||
"install_date_epoch_utc": null
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ rpm -qia | jc --rpm-qi -p -r
|
||||
[
|
||||
{
|
||||
"name": "make",
|
||||
"epoch": "1",
|
||||
"version": "3.82",
|
||||
"release": "24.el7",
|
||||
"architecture": "x86_64",
|
||||
"install_date": "Wed 16 Oct 2019 09:21:42 AM PDT",
|
||||
"group": "Development/Tools",
|
||||
"size": "1160660",
|
||||
"license": "GPLv2+",
|
||||
"signature": "RSA/SHA256, Thu 22 Aug 2019 02:34:59 PM PDT, Key ID 24c6a8a7f4a80eb5",
|
||||
"source_rpm": "make-3.82-24.el7.src.rpm",
|
||||
"build_date": "Thu 08 Aug 2019 05:47:25 PM PDT",
|
||||
"build_host": "x86-01.bsys.centos.org",
|
||||
"relocations": "(not relocatable)",
|
||||
"packager": "CentOS BuildSystem <http://bugs.centos.org>",
|
||||
"vendor": "CentOS",
|
||||
"url": "http://www.gnu.org/software/make/",
|
||||
"summary": "A GNU tool which simplifies the build process for users",
|
||||
"description": "A GNU tool for controlling the generation of executables and other..."
|
||||
},
|
||||
{
|
||||
"name": "kbd-legacy",
|
||||
"version": "1.15.5",
|
||||
"release": "15.el7",
|
||||
"architecture": "noarch",
|
||||
"install_date": "Thu 15 Aug 2019 10:53:08 AM PDT",
|
||||
"group": "System Environment/Base",
|
||||
"size": "503608",
|
||||
"license": "GPLv2+",
|
||||
"signature": "RSA/SHA256, Mon 12 Nov 2018 07:17:49 AM PST, Key ID 24c6a8a7f4a80eb5",
|
||||
"source_rpm": "kbd-1.15.5-15.el7.src.rpm",
|
||||
"build_date": "Tue 30 Oct 2018 03:40:00 PM PDT",
|
||||
"build_host": "x86-01.bsys.centos.org",
|
||||
"relocations": "(not relocatable)",
|
||||
"packager": "CentOS BuildSystem <http://bugs.centos.org>",
|
||||
"vendor": "CentOS",
|
||||
"url": "http://ftp.altlinux.org/pub/people/legion/kbd",
|
||||
"summary": "Legacy data for kbd package",
|
||||
"description": "The kbd-legacy package contains original keymaps for kbd package..."
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
228
docs/parsers/sfdisk.md
Normal file
228
docs/parsers/sfdisk.md
Normal file
@@ -0,0 +1,228 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.sfdisk
|
||||
jc - JSON CLI output utility `sfdisk` command output parser
|
||||
|
||||
Supports the following `sfdisk` options:
|
||||
- `-l`
|
||||
- `-F`
|
||||
- `-d` (deprecated - only for older versions of util-linux)
|
||||
- `-uM` (deprecated - only for older versions of util-linux)
|
||||
- `-uC` (deprecated - only for older versions of util-linux)
|
||||
- `-uS` (deprecated - only for older versions of util-linux)
|
||||
- `-uB` (deprecated - only for older versions of util-linux)
|
||||
|
||||
Usage (cli):
|
||||
|
||||
# sfdisk -l | jc --sfdisk
|
||||
|
||||
or
|
||||
|
||||
# jc sfdisk -l
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.sfdisk
|
||||
result = jc.parsers.sfdisk.parse(sfdisk_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"disk": string,
|
||||
"disk_size": string,
|
||||
"free_disk_size": string,
|
||||
"bytes": integer,
|
||||
"free_bytes": integer,
|
||||
"sectors": integer,
|
||||
"free_sectors": integer,
|
||||
"cylinders": integer,
|
||||
"heads": integer,
|
||||
"sectors_per_track": integer,
|
||||
"units": string,
|
||||
"logical_sector_size": integer,
|
||||
"physical_sector_size": integer,
|
||||
"min_io_size": integer,
|
||||
"optimal_io_size": integer,
|
||||
"disk_label_type": string,
|
||||
"disk_identifier": string,
|
||||
"disk_model": string,
|
||||
"partitions": [
|
||||
{
|
||||
"device": string,
|
||||
"boot": boolean,
|
||||
"start": integer,
|
||||
"end": integer,
|
||||
"size": string, # Note: will be integer when using deprecated -d sfdisk option
|
||||
"cyls": integer,
|
||||
"mib": integer,
|
||||
"blocks": integer,
|
||||
"sectors": integer,
|
||||
"id": string,
|
||||
"system": string,
|
||||
"type": string
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
# sfdisk -l | jc --sfdisk -p
|
||||
[
|
||||
{
|
||||
"disk": "/dev/sda",
|
||||
"cylinders": 2610,
|
||||
"heads": 255,
|
||||
"sectors_per_track": 63,
|
||||
"units": "cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0",
|
||||
"partitions": [
|
||||
{
|
||||
"device": "/dev/sda1",
|
||||
"boot": true,
|
||||
"start": 0,
|
||||
"end": 130,
|
||||
"cyls": 131,
|
||||
"blocks": 1048576,
|
||||
"id": "83",
|
||||
"system": "Linux"
|
||||
},
|
||||
{
|
||||
"device": "/dev/sda2",
|
||||
"boot": false,
|
||||
"start": 130,
|
||||
"end": 2610,
|
||||
"cyls": 2481,
|
||||
"blocks": 19921920,
|
||||
"id": "8e",
|
||||
"system": "Linux LVM"
|
||||
},
|
||||
{
|
||||
"device": "/dev/sda3",
|
||||
"boot": false,
|
||||
"start": 0,
|
||||
"end": null,
|
||||
"cyls": 0,
|
||||
"blocks": 0,
|
||||
"id": "0",
|
||||
"system": "Empty"
|
||||
},
|
||||
{
|
||||
"device": "/dev/sda4",
|
||||
"boot": false,
|
||||
"start": 0,
|
||||
"end": null,
|
||||
"cyls": 0,
|
||||
"blocks": 0,
|
||||
"id": "0",
|
||||
"system": "Empty"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"disk": "/dev/mapper/centos-root",
|
||||
"cylinders": 2218,
|
||||
"heads": 255,
|
||||
"sectors_per_track": 63
|
||||
},
|
||||
{
|
||||
"disk": "/dev/mapper/centos-swap",
|
||||
"cylinders": 261,
|
||||
"heads": 255,
|
||||
"sectors_per_track": 63
|
||||
}
|
||||
]
|
||||
|
||||
# sfdisk -l | jc --sfdisk -p -r
|
||||
[
|
||||
{
|
||||
"disk": "/dev/sda",
|
||||
"cylinders": "2610",
|
||||
"heads": "255",
|
||||
"sectors_per_track": "63",
|
||||
"units": "cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0",
|
||||
"partitions": [
|
||||
{
|
||||
"device": "/dev/sda1",
|
||||
"boot": "*",
|
||||
"start": "0+",
|
||||
"end": "130-",
|
||||
"cyls": "131-",
|
||||
"blocks": "1048576",
|
||||
"id": "83",
|
||||
"system": "Linux"
|
||||
},
|
||||
{
|
||||
"device": "/dev/sda2",
|
||||
"boot": null,
|
||||
"start": "130+",
|
||||
"end": "2610-",
|
||||
"cyls": "2481-",
|
||||
"blocks": "19921920",
|
||||
"id": "8e",
|
||||
"system": "Linux LVM"
|
||||
},
|
||||
{
|
||||
"device": "/dev/sda3",
|
||||
"boot": null,
|
||||
"start": "0",
|
||||
"end": "-",
|
||||
"cyls": "0",
|
||||
"blocks": "0",
|
||||
"id": "0",
|
||||
"system": "Empty"
|
||||
},
|
||||
{
|
||||
"device": "/dev/sda4",
|
||||
"boot": null,
|
||||
"start": "0",
|
||||
"end": "-",
|
||||
"cyls": "0",
|
||||
"blocks": "0",
|
||||
"id": "0",
|
||||
"system": "Empty"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"disk": "/dev/mapper/centos-root",
|
||||
"cylinders": "2218",
|
||||
"heads": "255",
|
||||
"sectors_per_track": "63"
|
||||
},
|
||||
{
|
||||
"disk": "/dev/mapper/centos-swap",
|
||||
"cylinders": "261",
|
||||
"heads": "255",
|
||||
"sectors_per_track": "63"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
129
docs/parsers/shadow.md
Normal file
129
docs/parsers/shadow.md
Normal file
@@ -0,0 +1,129 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.shadow
|
||||
jc - JSON CLI output utility `/etc/shadow` file parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ sudo cat /etc/shadow | jc --shadow
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.shadow
|
||||
result = jc.parsers.shadow.parse(shadow_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"username": string,
|
||||
"password": string,
|
||||
"last_changed": integer,
|
||||
"minimum": integer,
|
||||
"maximum": integer,
|
||||
"warn": integer,
|
||||
"inactive": integer,
|
||||
"expire": integer
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ sudo cat /etc/shadow | jc --shadow -p
|
||||
[
|
||||
{
|
||||
"username": "root",
|
||||
"password": "*",
|
||||
"last_changed": 18113,
|
||||
"minimum": 0,
|
||||
"maximum": 99999,
|
||||
"warn": 7,
|
||||
"inactive": null,
|
||||
"expire": null
|
||||
},
|
||||
{
|
||||
"username": "daemon",
|
||||
"password": "*",
|
||||
"last_changed": 18113,
|
||||
"minimum": 0,
|
||||
"maximum": 99999,
|
||||
"warn": 7,
|
||||
"inactive": null,
|
||||
"expire": null
|
||||
},
|
||||
{
|
||||
"username": "bin",
|
||||
"password": "*",
|
||||
"last_changed": 18113,
|
||||
"minimum": 0,
|
||||
"maximum": 99999,
|
||||
"warn": 7,
|
||||
"inactive": null,
|
||||
"expire": null
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ sudo cat /etc/shadow | jc --shadow -p -r
|
||||
[
|
||||
{
|
||||
"username": "root",
|
||||
"password": "*",
|
||||
"last_changed": "18113",
|
||||
"minimum": "0",
|
||||
"maximum": "99999",
|
||||
"warn": "7",
|
||||
"inactive": "",
|
||||
"expire": ""
|
||||
},
|
||||
{
|
||||
"username": "daemon",
|
||||
"password": "*",
|
||||
"last_changed": "18113",
|
||||
"minimum": "0",
|
||||
"maximum": "99999",
|
||||
"warn": "7",
|
||||
"inactive": "",
|
||||
"expire": ""
|
||||
},
|
||||
{
|
||||
"username": "bin",
|
||||
"password": "*",
|
||||
"last_changed": "18113",
|
||||
"minimum": "0",
|
||||
"maximum": "99999",
|
||||
"warn": "7",
|
||||
"inactive": "",
|
||||
"expire": ""
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, aix, freebsd
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
306
docs/parsers/ss.md
Normal file
306
docs/parsers/ss.md
Normal file
@@ -0,0 +1,306 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# 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.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ ss | jc --ss
|
||||
|
||||
or
|
||||
|
||||
$ jc ss
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.ss
|
||||
result = jc.parsers.ss.parse(ss_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
Information from https://www.cyberciti.biz/files/ss.html used to define field names
|
||||
|
||||
[
|
||||
{
|
||||
"netid": string,
|
||||
"state": string,
|
||||
"recv_q": integer,
|
||||
"send_q": integer,
|
||||
"local_address": string,
|
||||
"local_port": string,
|
||||
"local_port_num": integer,
|
||||
"peer_address": string,
|
||||
"peer_port": string,
|
||||
"peer_port_num": integer,
|
||||
"interface": string,
|
||||
"link_layer" string,
|
||||
"channel": string,
|
||||
"path": string,
|
||||
"pid": integer
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ sudo ss -a | jc --ss -p
|
||||
[
|
||||
{
|
||||
"netid": "nl",
|
||||
"state": "UNCONN",
|
||||
"recv_q": 0,
|
||||
"send_q": 0,
|
||||
"peer_address": "*",
|
||||
"channel": "rtnl:kernel"
|
||||
},
|
||||
{
|
||||
"netid": "nl",
|
||||
"state": "UNCONN",
|
||||
"recv_q": 0,
|
||||
"send_q": 0,
|
||||
"peer_address": "*",
|
||||
"pid": 893,
|
||||
"channel": "rtnl:systemd-resolve"
|
||||
},
|
||||
...
|
||||
{
|
||||
"netid": "p_raw",
|
||||
"state": "UNCONN",
|
||||
"recv_q": 0,
|
||||
"send_q": 0,
|
||||
"peer_address": "*",
|
||||
"link_layer": "LLDP",
|
||||
"interface": "ens33"
|
||||
},
|
||||
{
|
||||
"netid": "u_dgr",
|
||||
"state": "UNCONN",
|
||||
"recv_q": 0,
|
||||
"send_q": 0,
|
||||
"local_port": "93066",
|
||||
"peer_address": "*",
|
||||
"peer_port": "0",
|
||||
"path": "/run/user/1000/systemd/notify"
|
||||
},
|
||||
{
|
||||
"netid": "u_seq",
|
||||
"state": "LISTEN",
|
||||
"recv_q": 0,
|
||||
"send_q": 128,
|
||||
"local_port": "20699",
|
||||
"peer_address": "*",
|
||||
"peer_port": "0",
|
||||
"path": "/run/udev/control"
|
||||
},
|
||||
...
|
||||
{
|
||||
"netid": "icmp6",
|
||||
"state": "UNCONN",
|
||||
"recv_q": 0,
|
||||
"send_q": 0,
|
||||
"local_address": "*",
|
||||
"local_port": "ipv6-icmp",
|
||||
"peer_address": "*",
|
||||
"peer_port": "*",
|
||||
"interface": "ens33"
|
||||
},
|
||||
{
|
||||
"netid": "udp",
|
||||
"state": "UNCONN",
|
||||
"recv_q": 0,
|
||||
"send_q": 0,
|
||||
"local_address": "127.0.0.53",
|
||||
"local_port": "domain",
|
||||
"peer_address": "0.0.0.0",
|
||||
"peer_port": "*",
|
||||
"interface": "lo"
|
||||
},
|
||||
{
|
||||
"netid": "tcp",
|
||||
"state": "LISTEN",
|
||||
"recv_q": 0,
|
||||
"send_q": 128,
|
||||
"local_address": "127.0.0.53",
|
||||
"local_port": "domain",
|
||||
"peer_address": "0.0.0.0",
|
||||
"peer_port": "*",
|
||||
"interface": "lo"
|
||||
},
|
||||
{
|
||||
"netid": "tcp",
|
||||
"state": "LISTEN",
|
||||
"recv_q": 0,
|
||||
"send_q": 128,
|
||||
"local_address": "0.0.0.0",
|
||||
"local_port": "ssh",
|
||||
"peer_address": "0.0.0.0",
|
||||
"peer_port": "*"
|
||||
},
|
||||
{
|
||||
"netid": "tcp",
|
||||
"state": "LISTEN",
|
||||
"recv_q": 0,
|
||||
"send_q": 128,
|
||||
"local_address": "[::]",
|
||||
"local_port": "ssh",
|
||||
"peer_address": "[::]",
|
||||
"peer_port": "*"
|
||||
},
|
||||
{
|
||||
"netid": "v_str",
|
||||
"state": "ESTAB",
|
||||
"recv_q": 0,
|
||||
"send_q": 0,
|
||||
"local_address": "999900439",
|
||||
"local_port": "1023",
|
||||
"peer_address": "0",
|
||||
"peer_port": "976",
|
||||
"local_port_num": 1023,
|
||||
"peer_port_num": 976
|
||||
}
|
||||
]
|
||||
|
||||
$ sudo ss -a | jc --ss -p -r
|
||||
[
|
||||
{
|
||||
"netid": "nl",
|
||||
"state": "UNCONN",
|
||||
"recv_q": "0",
|
||||
"send_q": "0",
|
||||
"peer_address": "*",
|
||||
"channel": "rtnl:kernel"
|
||||
},
|
||||
{
|
||||
"netid": "nl",
|
||||
"state": "UNCONN",
|
||||
"recv_q": "0",
|
||||
"send_q": "0",
|
||||
"peer_address": "*",
|
||||
"pid": "893",
|
||||
"channel": "rtnl:systemd-resolve"
|
||||
},
|
||||
...
|
||||
{
|
||||
"netid": "p_raw",
|
||||
"state": "UNCONN",
|
||||
"recv_q": "0",
|
||||
"send_q": "0",
|
||||
"peer_address": "*",
|
||||
"link_layer": "LLDP",
|
||||
"interface": "ens33"
|
||||
},
|
||||
{
|
||||
"netid": "u_dgr",
|
||||
"state": "UNCONN",
|
||||
"recv_q": "0",
|
||||
"send_q": "0",
|
||||
"local_port": "93066",
|
||||
"peer_address": "*",
|
||||
"peer_port": "0",
|
||||
"path": "/run/user/1000/systemd/notify"
|
||||
},
|
||||
{
|
||||
"netid": "u_seq",
|
||||
"state": "LISTEN",
|
||||
"recv_q": "0",
|
||||
"send_q": "128",
|
||||
"local_port": "20699",
|
||||
"peer_address": "*",
|
||||
"peer_port": "0",
|
||||
"path": "/run/udev/control"
|
||||
},
|
||||
...
|
||||
{
|
||||
"netid": "icmp6",
|
||||
"state": "UNCONN",
|
||||
"recv_q": "0",
|
||||
"send_q": "0",
|
||||
"local_address": "*",
|
||||
"local_port": "ipv6-icmp",
|
||||
"peer_address": "*",
|
||||
"peer_port": "*",
|
||||
"interface": "ens33"
|
||||
},
|
||||
{
|
||||
"netid": "udp",
|
||||
"state": "UNCONN",
|
||||
"recv_q": "0",
|
||||
"send_q": "0",
|
||||
"local_address": "127.0.0.53",
|
||||
"local_port": "domain",
|
||||
"peer_address": "0.0.0.0",
|
||||
"peer_port": "*",
|
||||
"interface": "lo"
|
||||
},
|
||||
{
|
||||
"netid": "tcp",
|
||||
"state": "LISTEN",
|
||||
"recv_q": "0",
|
||||
"send_q": "128",
|
||||
"local_address": "127.0.0.53",
|
||||
"local_port": "domain",
|
||||
"peer_address": "0.0.0.0",
|
||||
"peer_port": "*",
|
||||
"interface": "lo"
|
||||
},
|
||||
{
|
||||
"netid": "tcp",
|
||||
"state": "LISTEN",
|
||||
"recv_q": "0",
|
||||
"send_q": "128",
|
||||
"local_address": "0.0.0.0",
|
||||
"local_port": "ssh",
|
||||
"peer_address": "0.0.0.0",
|
||||
"peer_port": "*"
|
||||
},
|
||||
{
|
||||
"netid": "tcp",
|
||||
"state": "LISTEN",
|
||||
"recv_q": "0",
|
||||
"send_q": "128",
|
||||
"local_address": "[::]",
|
||||
"local_port": "ssh",
|
||||
"peer_address": "[::]",
|
||||
"peer_port": "*"
|
||||
},
|
||||
{
|
||||
"netid": "v_str",
|
||||
"state": "ESTAB",
|
||||
"recv_q": "0",
|
||||
"send_q": "0",
|
||||
"local_address": "999900439",
|
||||
"local_port": "1023",
|
||||
"peer_address": "0",
|
||||
"peer_port": "976"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
196
docs/parsers/stat.md
Normal file
196
docs/parsers/stat.md
Normal file
@@ -0,0 +1,196 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# 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)
|
||||
|
||||
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
|
||||
|
||||
or
|
||||
|
||||
$ jc stat *
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.stat
|
||||
result = jc.parsers.stat.parse(stat_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"file": string,
|
||||
"link_to" string,
|
||||
"size": integer,
|
||||
"blocks": integer,
|
||||
"io_blocks": integer,
|
||||
"type": string,
|
||||
"device": string,
|
||||
"inode": integer,
|
||||
"links": integer,
|
||||
"access": string,
|
||||
"flags": string,
|
||||
"uid": integer,
|
||||
"user": string,
|
||||
"gid": integer,
|
||||
"group": string,
|
||||
"access_time": string, # - = null
|
||||
"access_time_epoch": integer, # naive timestamp
|
||||
"access_time_epoch_utc": integer, # timezone-aware timestamp
|
||||
"modify_time": string, # - = null
|
||||
"modify_time_epoch": integer, # naive timestamp
|
||||
"modify_time_epoch_utc": integer, # timezone-aware timestamp
|
||||
"change_time": string, # - = null
|
||||
"change_time_epoch": integer, # naive timestamp
|
||||
"change_time_epoch_utc": integer, # timezone-aware timestamp
|
||||
"birth_time": string, # - = null
|
||||
"birth_time_epoch": integer, # naive timestamp
|
||||
"birth_time_epoch_utc": integer, # timezone-aware timestamp
|
||||
"unix_device": integer,
|
||||
"rdev": integer,
|
||||
"block_size": integer,
|
||||
"unix_flags": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ stat /bin/* | jc --stat -p
|
||||
[
|
||||
{
|
||||
"file": "/bin/bash",
|
||||
"size": 1113504,
|
||||
"blocks": 2176,
|
||||
"io_blocks": 4096,
|
||||
"type": "regular file",
|
||||
"device": "802h/2050d",
|
||||
"inode": 131099,
|
||||
"links": 1,
|
||||
"access": "0755",
|
||||
"flags": "-rwxr-xr-x",
|
||||
"uid": 0,
|
||||
"user": "root",
|
||||
"gid": 0,
|
||||
"group": "root",
|
||||
"access_time": "2019-11-14 08:18:03.509681766 +0000",
|
||||
"modify_time": "2019-06-06 22:28:15.000000000 +0000",
|
||||
"change_time": "2019-08-12 17:21:29.521945390 +0000",
|
||||
"birth_time": null,
|
||||
"access_time_epoch": 1573748283,
|
||||
"access_time_epoch_utc": 1573719483,
|
||||
"modify_time_epoch": 1559885295,
|
||||
"modify_time_epoch_utc": 1559860095,
|
||||
"change_time_epoch": 1565655689,
|
||||
"change_time_epoch_utc": 1565630489,
|
||||
"birth_time_epoch": null,
|
||||
"birth_time_epoch_utc": null
|
||||
},
|
||||
{
|
||||
"file": "/bin/btrfs",
|
||||
"size": 716464,
|
||||
"blocks": 1400,
|
||||
"io_blocks": 4096,
|
||||
"type": "regular file",
|
||||
"device": "802h/2050d",
|
||||
"inode": 131100,
|
||||
"links": 1,
|
||||
"access": "0755",
|
||||
"flags": "-rwxr-xr-x",
|
||||
"uid": 0,
|
||||
"user": "root",
|
||||
"gid": 0,
|
||||
"group": "root",
|
||||
"access_time": "2019-11-14 08:18:28.990834276 +0000",
|
||||
"modify_time": "2018-03-12 23:04:27.000000000 +0000",
|
||||
"change_time": "2019-08-12 17:21:29.545944399 +0000",
|
||||
"birth_time": null,
|
||||
"access_time_epoch": 1573748308,
|
||||
"access_time_epoch_utc": 1573719508,
|
||||
"modify_time_epoch": 1520921067,
|
||||
"modify_time_epoch_utc": 1520895867,
|
||||
"change_time_epoch": 1565655689,
|
||||
"change_time_epoch_utc": 1565630489,
|
||||
"birth_time_epoch": null,
|
||||
"birth_time_epoch_utc": null
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ stat /bin/* | jc --stat -p -r
|
||||
[
|
||||
{
|
||||
"file": "/bin/bash",
|
||||
"size": "1113504",
|
||||
"blocks": "2176",
|
||||
"io_blocks": "4096",
|
||||
"type": "regular file",
|
||||
"device": "802h/2050d",
|
||||
"inode": "131099",
|
||||
"links": "1",
|
||||
"access": "0755",
|
||||
"flags": "-rwxr-xr-x",
|
||||
"uid": "0",
|
||||
"user": "root",
|
||||
"gid": "0",
|
||||
"group": "root",
|
||||
"access_time": "2019-11-14 08:18:03.509681766 +0000",
|
||||
"modify_time": "2019-06-06 22:28:15.000000000 +0000",
|
||||
"change_time": "2019-08-12 17:21:29.521945390 +0000",
|
||||
"birth_time": null
|
||||
},
|
||||
{
|
||||
"file": "/bin/btrfs",
|
||||
"size": "716464",
|
||||
"blocks": "1400",
|
||||
"io_blocks": "4096",
|
||||
"type": "regular file",
|
||||
"device": "802h/2050d",
|
||||
"inode": "131100",
|
||||
"links": "1",
|
||||
"access": "0755",
|
||||
"flags": "-rwxr-xr-x",
|
||||
"uid": "0",
|
||||
"user": "root",
|
||||
"gid": "0",
|
||||
"group": "root",
|
||||
"access_time": "2019-11-14 08:18:28.990834276 +0000",
|
||||
"modify_time": "2018-03-12 23:04:27.000000000 +0000",
|
||||
"change_time": "2019-08-12 17:21:29.545944399 +0000",
|
||||
"birth_time": null
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.10 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
82
docs/parsers/sysctl.md
Normal file
82
docs/parsers/sysctl.md
Normal file
@@ -0,0 +1,82 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.sysctl
|
||||
jc - JSON CLI output utility `sysctl -a` command output parser
|
||||
|
||||
Note: Since `sysctl` output is not easily parsable only a very simple key/value object will be output. An attempt is made to convert obvious integers and floats. If no conversion is desired, use the `-r` command-line argument or the `raw=True` argument in `parse()`.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ sysctl -a | jc --sysctl
|
||||
|
||||
or
|
||||
|
||||
$ jc sysctl -a
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.sysctl
|
||||
result = jc.parsers.sysctl.parse(sysctl_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"key1": string/integer/float, # best guess based on value
|
||||
"key2": string/integer/float,
|
||||
"key3": string/integer/float
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ sysctl -a | jc --sysctl -p
|
||||
{
|
||||
"user.cs_path": "/usr/bin:/bin:/usr/sbin:/sbin",
|
||||
"user.bc_base_max": 99,
|
||||
"user.bc_dim_max": 2048,
|
||||
"user.bc_scale_max": 99,
|
||||
"user.bc_string_max": 1000,
|
||||
"user.coll_weights_max": 2,
|
||||
"user.expr_nest_max": 32
|
||||
...
|
||||
}
|
||||
|
||||
$ sysctl -a | jc --sysctl -p -r
|
||||
{
|
||||
"user.cs_path": "/usr/bin:/bin:/usr/sbin:/sbin",
|
||||
"user.bc_base_max": "99",
|
||||
"user.bc_dim_max": "2048",
|
||||
"user.bc_scale_max": "99",
|
||||
"user.bc_string_max": "1000",
|
||||
"user.coll_weights_max": "2",
|
||||
"user.expr_nest_max": "32",
|
||||
...
|
||||
}
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
86
docs/parsers/systemctl.md
Normal file
86
docs/parsers/systemctl.md
Normal file
@@ -0,0 +1,86 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.systemctl
|
||||
jc - JSON CLI output utility `systemctl` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ systemctl | jc --systemctl
|
||||
|
||||
or
|
||||
|
||||
$ jc systemctl
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.systemctl
|
||||
result = jc.parsers.systemctl.parse(systemctl_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"unit": string,
|
||||
"load": string,
|
||||
"active": string,
|
||||
"sub": string,
|
||||
"description": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ systemctl -a | jc --systemctl -p
|
||||
[
|
||||
{
|
||||
"unit": "proc-sys-fs-binfmt_misc.automount",
|
||||
"load": "loaded",
|
||||
"active": "active",
|
||||
"sub": "waiting",
|
||||
"description": "Arbitrary Executable File Formats File System Automount Point"
|
||||
},
|
||||
{
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"unit": "dev-cdrom.device",
|
||||
"load": "loaded",
|
||||
"active": "active",
|
||||
"sub": "plugged",
|
||||
"description": "VMware_Virtual_IDE_CDROM_Drive"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
103
docs/parsers/systemctl_lj.md
Normal file
103
docs/parsers/systemctl_lj.md
Normal file
@@ -0,0 +1,103 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.systemctl_lj
|
||||
jc - JSON CLI output utility `systemctl list-jobs` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ systemctl list-jobs | jc --systemctl-lj
|
||||
|
||||
or
|
||||
|
||||
$ jc systemctl list-jobs
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.systemctl_lj
|
||||
result = jc.parsers.systemctl_lj.parse(systemctl_lj_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"job": integer,
|
||||
"unit": string,
|
||||
"type": string,
|
||||
"state": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ systemctl list-jobs| jc --systemctl-lj -p
|
||||
[
|
||||
{
|
||||
"job": 3543,
|
||||
"unit": "nginxAfterGlusterfs.service",
|
||||
"type": "start",
|
||||
"state": "waiting"
|
||||
},
|
||||
{
|
||||
"job": 3545,
|
||||
"unit": "glusterReadyForLocalhostMount.service",
|
||||
"type": "start",
|
||||
"state": "running"
|
||||
},
|
||||
{
|
||||
"job": 3506,
|
||||
"unit": "nginx.service",
|
||||
"type": "start",
|
||||
"state": "waiting"
|
||||
}
|
||||
]
|
||||
|
||||
$ systemctl list-jobs| jc --systemctl-lj -p -r
|
||||
[
|
||||
{
|
||||
"job": "3543",
|
||||
"unit": "nginxAfterGlusterfs.service",
|
||||
"type": "start",
|
||||
"state": "waiting"
|
||||
},
|
||||
{
|
||||
"job": "3545",
|
||||
"unit": "glusterReadyForLocalhostMount.service",
|
||||
"type": "start",
|
||||
"state": "running"
|
||||
},
|
||||
{
|
||||
"job": "3506",
|
||||
"unit": "nginx.service",
|
||||
"type": "start",
|
||||
"state": "waiting"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
78
docs/parsers/systemctl_ls.md
Normal file
78
docs/parsers/systemctl_ls.md
Normal file
@@ -0,0 +1,78 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.systemctl_ls
|
||||
jc - JSON CLI output utility `systemctl list-sockets` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ systemctl list-sockets | jc --systemctl-ls
|
||||
|
||||
or
|
||||
|
||||
$ jc systemctl list-sockets
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.systemctl_ls
|
||||
result = jc.parsers.systemctl_ls.parse(systemctl_ls_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"listen": string,
|
||||
"unit": string,
|
||||
"activates": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ systemctl list-sockets | jc --systemctl-ls -p
|
||||
[
|
||||
{
|
||||
"listen": "/dev/log",
|
||||
"unit": "systemd-journald.socket",
|
||||
"activates": "systemd-journald.service"
|
||||
},
|
||||
{
|
||||
"listen": "/run/dbus/system_bus_socket",
|
||||
"unit": "dbus.socket",
|
||||
"activates": "dbus.service"
|
||||
},
|
||||
{
|
||||
"listen": "/run/dmeventd-client",
|
||||
"unit": "dm-event.socket",
|
||||
"activates": "dm-event.service"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
74
docs/parsers/systemctl_luf.md
Normal file
74
docs/parsers/systemctl_luf.md
Normal file
@@ -0,0 +1,74 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.systemctl_luf
|
||||
jc - JSON CLI output utility `systemctl list-unit-files` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ systemctl list-unit-files | jc --systemctl-luf
|
||||
|
||||
or
|
||||
|
||||
$ jc systemctl list-unit-files
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.systemctl_luf
|
||||
result = jc.parsers.systemctl_luf.parse(systemctl_luf_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"unit_file": string,
|
||||
"state": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ systemctl list-unit-files | jc --systemctl-luf -p
|
||||
[
|
||||
{
|
||||
"unit_file": "proc-sys-fs-binfmt_misc.automount",
|
||||
"state": "static"
|
||||
},
|
||||
{
|
||||
"unit_file": "dev-hugepages.mount",
|
||||
"state": "static"
|
||||
},
|
||||
{
|
||||
"unit_file": "dev-mqueue.mount",
|
||||
"state": "static"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
232
docs/parsers/systeminfo.md
Normal file
232
docs/parsers/systeminfo.md
Normal file
@@ -0,0 +1,232 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.systeminfo
|
||||
jc - JSON CLI output utility `systeminfo` command output parser
|
||||
|
||||
Blank or missing elements are set to `null`.
|
||||
|
||||
The `original_install_date_epoch` and `system_boot_time_epoch` calculated timestamp fields are naive (i.e. based on the local time of the system the parser is run on)
|
||||
|
||||
The `original_install_date_epoch_utc` and `system_boot_time_epoch_utc` calculated timestamp fields are timezone-aware and are only available if the timezone field is UTC.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ systeminfo | jc --systeminfo
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.systeminfo
|
||||
result = jc.parsers.systeminfo.parse(systeminfo_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"host_name": string,
|
||||
"os_name": string,
|
||||
"os_version": string,
|
||||
"os_manufacturer": string,
|
||||
"os_configuration": string,
|
||||
"os_build_type": string,
|
||||
"registered_owner": string,
|
||||
"registered_organization": string,
|
||||
"product_id": string,
|
||||
"original_install_date": string,
|
||||
"original_install_date_epoch": integer, # naive timestamp
|
||||
"original_install_date_epoch_utc": integer, # timezone-aware timestamp
|
||||
"system_boot_time": string,
|
||||
"system_boot_time_epoch": integer, # naive timestamp
|
||||
"system_boot_time_epoch_utc": integer, # timezone-aware timestamp
|
||||
"system_manufacturer": string,
|
||||
"system_model": string,
|
||||
"system_type": string,
|
||||
"processors": [
|
||||
string
|
||||
],
|
||||
"bios_version": string,
|
||||
"windows_directory": string,
|
||||
"system_directory": string,
|
||||
"boot_device": string,
|
||||
"system_locale": string,
|
||||
"input_locale": string,
|
||||
"time_zone": string,
|
||||
"total_physical_memory_mb": string,
|
||||
"available_physical_memory_mb": integer,
|
||||
"virtual_memory_max_size_mb": integer,
|
||||
"virtual_memory_available_mb": integer,
|
||||
"virtual_memory_in_use_mb": integer,
|
||||
"page_file_locations": string,
|
||||
"domain": string,
|
||||
"logon_server": string,
|
||||
"hotfixs": [
|
||||
string
|
||||
],
|
||||
"network_cards": [
|
||||
{
|
||||
"name": string,
|
||||
"connection_name": string,
|
||||
"status": string,
|
||||
"dhcp_enabled": boolean,
|
||||
"dhcp_server": string,
|
||||
"ip_addresses": [
|
||||
string
|
||||
]
|
||||
}
|
||||
],
|
||||
"hyperv_requirements": {
|
||||
"vm_monitor_mode_extensions": boolean,
|
||||
"virtualization_enabled_in_firmware": boolean,
|
||||
"second_level_address_translation": boolean,
|
||||
"data_execution_prevention_available": boolean
|
||||
}
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ systeminfo | jc --systeminfo -p
|
||||
{
|
||||
"host_name": "TESTLAPTOP",
|
||||
"os_name": "Microsoft Windows 10 Enterprise",
|
||||
"os_version": "10.0.17134 N/A Build 17134",
|
||||
"os_manufacturer": "Microsoft Corporation",
|
||||
"os_configuration": "Member Workstation",
|
||||
"os_build_type": "Multiprocessor Free",
|
||||
"registered_owner": "Test, Inc.",
|
||||
"registered_organization": "Test, Inc.",
|
||||
"product_id": "11111-11111-11111-AA111",
|
||||
"original_install_date": "3/26/2019, 3:51:30 PM",
|
||||
"system_boot_time": "3/30/2021, 6:13:59 AM",
|
||||
"system_manufacturer": "Dell Inc.",
|
||||
"system_model": "Precision 5530",
|
||||
"system_type": "x64-based PC",
|
||||
"processors": [
|
||||
"Intel64 Family 6 Model 158 Stepping 10 GenuineIntel ~2592 Mhz"
|
||||
],
|
||||
"bios_version": "Dell Inc. 1.16.2, 4/21/2020",
|
||||
"windows_directory": "C:\WINDOWS",
|
||||
"system_directory": "C:\WINDOWS\system32",
|
||||
"boot_device": "\Device\HarddiskVolume2",
|
||||
"system_locale": "en-us;English (United States)",
|
||||
"input_locale": "en-us;English (United States)",
|
||||
"time_zone": "(UTC+00:00) UTC",
|
||||
"total_physical_memory_mb": 32503,
|
||||
"available_physical_memory_mb": 19743,
|
||||
"virtual_memory_max_size_mb": 37367,
|
||||
"virtual_memory_available_mb": 22266,
|
||||
"virtual_memory_in_use_mb": 15101,
|
||||
"page_file_locations": "C:\pagefile.sys",
|
||||
"domain": "test.com",
|
||||
"logon_server": "\\TESTDC01",
|
||||
"hotfixs": [
|
||||
"KB2693643",
|
||||
"KB4601054"
|
||||
],
|
||||
"network_cards": [
|
||||
{
|
||||
"name": "Intel(R) Wireless-AC 9260 160MHz",
|
||||
"connection_name": "Wi-Fi",
|
||||
"status": null,
|
||||
"dhcp_enabled": true,
|
||||
"dhcp_server": "192.168.2.1",
|
||||
"ip_addresses": [
|
||||
"192.168.2.219"
|
||||
]
|
||||
}
|
||||
],
|
||||
"hyperv_requirements": {
|
||||
"vm_monitor_mode_extensions": true,
|
||||
"virtualization_enabled_in_firmware": true,
|
||||
"second_level_address_translation": false,
|
||||
"data_execution_prevention_available": true
|
||||
},
|
||||
"original_install_date_epoch": 1553640690,
|
||||
"original_install_date_epoch_utc": 1553615490,
|
||||
"system_boot_time_epoch": 1617110039,
|
||||
"system_boot_time_epoch_utc": 1617084839
|
||||
}
|
||||
|
||||
$ systeminfo | jc --systeminfo -p -r
|
||||
{
|
||||
"host_name": "TESTLAPTOP",
|
||||
"os_name": "Microsoft Windows 10 Enterprise",
|
||||
"os_version": "10.0.17134 N/A Build 17134",
|
||||
"os_manufacturer": "Microsoft Corporation",
|
||||
"os_configuration": "Member Workstation",
|
||||
"os_build_type": "Multiprocessor Free",
|
||||
"registered_owner": "Test, Inc.",
|
||||
"registered_organization": "Test, Inc.",
|
||||
"product_id": "11111-11111-11111-AA111",
|
||||
"original_install_date": "3/26/2019, 3:51:30 PM",
|
||||
"system_boot_time": "3/30/2021, 6:13:59 AM",
|
||||
"system_manufacturer": "Dell Inc.",
|
||||
"system_model": "Precision 5530",
|
||||
"system_type": "x64-based PC",
|
||||
"processors": [
|
||||
"Intel64 Family 6 Model 158 Stepping 10 GenuineIntel ~2592 Mhz"
|
||||
],
|
||||
"bios_version": "Dell Inc. 1.16.2, 4/21/2020",
|
||||
"windows_directory": "C:\WINDOWS",
|
||||
"system_directory": "C:\WINDOWS\system32",
|
||||
"boot_device": "\Device\HarddiskVolume2",
|
||||
"system_locale": "en-us;English (United States)",
|
||||
"input_locale": "en-us;English (United States)",
|
||||
"time_zone": "(UTC+00:00) UTC",
|
||||
"total_physical_memory_mb": "32,503 MB",
|
||||
"available_physical_memory_mb": "19,743 MB",
|
||||
"virtual_memory_max_size_mb": "37,367 MB",
|
||||
"virtual_memory_available_mb": "22,266 MB",
|
||||
"virtual_memory_in_use_mb": "15,101 MB",
|
||||
"page_file_locations": "C:\pagefile.sys",
|
||||
"domain": "test.com",
|
||||
"logon_server": "\\TESTDC01",
|
||||
"hotfixs": [
|
||||
"KB2693643",
|
||||
"KB4601054"
|
||||
],
|
||||
"network_cards": [
|
||||
{
|
||||
"name": "Intel(R) Wireless-AC 9260 160MHz",
|
||||
"connection_name": "Wi-Fi",
|
||||
"status": "",
|
||||
"dhcp_enabled": "Yes",
|
||||
"dhcp_server": "192.168.2.1",
|
||||
"ip_addresses": [
|
||||
"192.168.2.219"
|
||||
]
|
||||
}
|
||||
],
|
||||
"hyperv_requirements": {
|
||||
"vm_monitor_mode_extensions": "Yes",
|
||||
"virtualization_enabled_in_firmware": "Yes",
|
||||
"second_level_address_translation": "No",
|
||||
"data_execution_prevention_available": "Yes"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: win32
|
||||
|
||||
Version 1.1 by Jon Smith (jon@rebelliondefense.com)
|
||||
151
docs/parsers/time.md
Normal file
151
docs/parsers/time.md
Normal file
@@ -0,0 +1,151 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.time
|
||||
jc - JSON CLI output utility `/usr/bin/time` command output parser
|
||||
|
||||
Output from `/usr/bin/time` is sent to `STDERR`, so the `-o` option can be used to redirect the output to a file that can be read by `jc`.
|
||||
|
||||
Alternatively, the output from `/usr/bin/time` can be redirected to `STDOUT` so `jc` can receive it.
|
||||
|
||||
Note: `/usr/bin/time` is similar but different from the Bash builtin `time` command.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ /usr/bin/time -o timefile.out sleep 2.5; cat timefile.out | jc --time -p
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.time
|
||||
result = jc.parsers.time.parse(time_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
Source: https://www.freebsd.org/cgi/man.cgi?query=getrusage
|
||||
https://man7.org/linux/man-pages/man1/time.1.html
|
||||
|
||||
{
|
||||
"real_time": float,
|
||||
"user_time": float,
|
||||
"system_time": float,
|
||||
"elapsed_time": string,
|
||||
"elapsed_time_hours": integer,
|
||||
"elapsed_time_minutes": integer,
|
||||
"elapsed_time_seconds": integer,
|
||||
"elapsed_time_centiseconds": integer,
|
||||
"elapsed_time_total_seconds": float,
|
||||
"cpu_percent": integer, # null if ?
|
||||
"average_shared_text_size": integer,
|
||||
"average_unshared_data_size": integer,
|
||||
"average_unshared_stack_size": integer,
|
||||
"average_shared_memory_size": integer,
|
||||
"maximum_resident_set_size": integer,
|
||||
"block_input_operations": integer, # aka File system inputs
|
||||
"block_output_operations": integer, # aka File system outputs
|
||||
"major_pagefaults": integer,
|
||||
"minor_pagefaults": integer,
|
||||
"swaps": integer,
|
||||
"page_reclaims": integer,
|
||||
"page_faults": integer,
|
||||
"messages_sent": integer,
|
||||
"messages_received": integer,
|
||||
"signals_received": integer,
|
||||
"voluntary_context_switches": integer,
|
||||
"involuntary_context_switches": integer
|
||||
"command_being_timed": string,
|
||||
"average_stack_size": integer,
|
||||
"average_total_size": integer,
|
||||
"average_resident_set_size": integer,
|
||||
"signals_delivered": integer,
|
||||
"page_size": integer,
|
||||
"exit_status": integer
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ /usr/bin/time --verbose -o timefile.out sleep 2.5; cat timefile.out | jc --time -p
|
||||
{
|
||||
"command_being_timed": "sleep 2.5",
|
||||
"user_time": 0.0,
|
||||
"system_time": 0.0,
|
||||
"cpu_percent": 0,
|
||||
"elapsed_time": "0:02.50",
|
||||
"average_shared_text_size": 0,
|
||||
"average_unshared_data_size": 0,
|
||||
"average_stack_size": 0,
|
||||
"average_total_size": 0,
|
||||
"maximum_resident_set_size": 2084,
|
||||
"average_resident_set_size": 0,
|
||||
"major_pagefaults": 0,
|
||||
"minor_pagefaults": 72,
|
||||
"voluntary_context_switches": 2,
|
||||
"involuntary_context_switches": 1,
|
||||
"swaps": 0,
|
||||
"block_input_operations": 0,
|
||||
"block_output_operations": 0,
|
||||
"messages_sent": 0,
|
||||
"messages_received": 0,
|
||||
"signals_delivered": 0,
|
||||
"page_size": 4096,
|
||||
"exit_status": 0,
|
||||
"elapsed_time_hours": 0,
|
||||
"elapsed_time_minutes": 0,
|
||||
"elapsed_time_seconds": 2,
|
||||
"elapsed_time_centiseconds": 50,
|
||||
"elapsed_time_total_seconds": 2.5
|
||||
}
|
||||
|
||||
$ /usr/bin/time --verbose -o timefile.out sleep 2.5; cat timefile.out | jc --time -p -r
|
||||
{
|
||||
"command_being_timed": ""sleep 2.5"",
|
||||
"user_time": "0.00",
|
||||
"system_time": "0.00",
|
||||
"cpu_percent": "0",
|
||||
"elapsed_time": "0:02.50",
|
||||
"average_shared_text_size": "0",
|
||||
"average_unshared_data_size": "0",
|
||||
"average_stack_size": "0",
|
||||
"average_total_size": "0",
|
||||
"maximum_resident_set_size": "2084",
|
||||
"average_resident_set_size": "0",
|
||||
"major_pagefaults": "0",
|
||||
"minor_pagefaults": "72",
|
||||
"voluntary_context_switches": "2",
|
||||
"involuntary_context_switches": "0",
|
||||
"swaps": "0",
|
||||
"block_input_operations": "0",
|
||||
"block_output_operations": "0",
|
||||
"messages_sent": "0",
|
||||
"messages_received": "0",
|
||||
"signals_delivered": "0",
|
||||
"page_size": "4096",
|
||||
"exit_status": "0"
|
||||
}
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
91
docs/parsers/timedatectl.md
Normal file
91
docs/parsers/timedatectl.md
Normal file
@@ -0,0 +1,91 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.timedatectl
|
||||
jc - JSON CLI output utility `timedatectl` command output parser
|
||||
|
||||
The `epoch_utc` calculated timestamp field is timezone-aware and is only available if the `universal_time` field is available.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ timedatectl | jc --timedatectl
|
||||
|
||||
or
|
||||
|
||||
$ jc timedatectl
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.timedatectl
|
||||
result = jc.parsers.timedatectl.parse(timedatectl_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"local_time": string,
|
||||
"universal_time": string,
|
||||
"epoch_utc": integer, # timezone-aware timestamp
|
||||
"rtc_time": string,
|
||||
"time_zone": string,
|
||||
"ntp_enabled": boolean,
|
||||
"ntp_synchronized": boolean,
|
||||
"system_clock_synchronized": boolean,
|
||||
"systemd-timesyncd.service_active": boolean,
|
||||
"rtc_in_local_tz": boolean,
|
||||
"dst_active": boolean
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ timedatectl | jc --timedatectl -p
|
||||
{
|
||||
"local_time": "Tue 2020-03-10 17:53:21 PDT",
|
||||
"universal_time": "Wed 2020-03-11 00:53:21 UTC",
|
||||
"rtc_time": "Wed 2020-03-11 00:53:21",
|
||||
"time_zone": "America/Los_Angeles (PDT, -0700)",
|
||||
"ntp_enabled": true,
|
||||
"ntp_synchronized": true,
|
||||
"rtc_in_local_tz": false,
|
||||
"dst_active": true,
|
||||
"epoch_utc": 1583888001
|
||||
}
|
||||
|
||||
$ timedatectl | jc --timedatectl -p -r
|
||||
{
|
||||
"local_time": "Tue 2020-03-10 17:53:21 PDT",
|
||||
"universal_time": "Wed 2020-03-11 00:53:21 UTC",
|
||||
"rtc_time": "Wed 2020-03-11 00:53:21",
|
||||
"time_zone": "America/Los_Angeles (PDT, -0700)",
|
||||
"ntp_enabled": "yes",
|
||||
"ntp_synchronized": "yes",
|
||||
"rtc_in_local_tz": "no",
|
||||
"dst_active": "yes"
|
||||
}
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
159
docs/parsers/tracepath.md
Normal file
159
docs/parsers/tracepath.md
Normal file
@@ -0,0 +1,159 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.tracepath
|
||||
jc - JSON CLI output utility `tracepath` command output parser
|
||||
|
||||
Supports `tracepath` and `tracepath6` output.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ tracepath 1.2.3.4 | jc --tracepath
|
||||
|
||||
or
|
||||
|
||||
$ jc tracepath 1.2.3.4
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.tracepath
|
||||
result = jc.parsers.tracepath.parse(tracepath_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"pmtu": integer,
|
||||
"forward_hops": integer,
|
||||
"return_hops": integer,
|
||||
"hops": [
|
||||
{
|
||||
"ttl": integer,
|
||||
"guess": boolean,
|
||||
"host": string,
|
||||
"reply_ms": float,
|
||||
"pmtu": integer,
|
||||
"asymmetric_difference": integer,
|
||||
"reached": boolean
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ tracepath6 3ffe:2400:0:109::2 | jc --tracepath -p
|
||||
{
|
||||
"pmtu": 1480,
|
||||
"forward_hops": 2,
|
||||
"return_hops": 2,
|
||||
"hops": [
|
||||
{
|
||||
"ttl": 1,
|
||||
"guess": true,
|
||||
"host": "[LOCALHOST]",
|
||||
"reply_ms": null,
|
||||
"pmtu": 1500,
|
||||
"asymmetric_difference": null,
|
||||
"reached": false
|
||||
},
|
||||
{
|
||||
"ttl": 1,
|
||||
"guess": false,
|
||||
"host": "dust.inr.ac.ru",
|
||||
"reply_ms": 0.411,
|
||||
"pmtu": null,
|
||||
"asymmetric_difference": null,
|
||||
"reached": false
|
||||
},
|
||||
{
|
||||
"ttl": 2,
|
||||
"guess": false,
|
||||
"host": "dust.inr.ac.ru",
|
||||
"reply_ms": 0.39,
|
||||
"pmtu": 1480,
|
||||
"asymmetric_difference": 1,
|
||||
"reached": false
|
||||
},
|
||||
{
|
||||
"ttl": 2,
|
||||
"guess": false,
|
||||
"host": "3ffe:2400:0:109::2",
|
||||
"reply_ms": 463.514,
|
||||
"pmtu": null,
|
||||
"asymmetric_difference": null,
|
||||
"reached": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
$ tracepath6 3ffe:2400:0:109::2 | jc --tracepath -p -r
|
||||
{
|
||||
"pmtu": "1480",
|
||||
"forward_hops": "2",
|
||||
"return_hops": "2",
|
||||
"hops": [
|
||||
{
|
||||
"ttl": "1",
|
||||
"guess": true,
|
||||
"host": "[LOCALHOST]",
|
||||
"reply_ms": null,
|
||||
"pmtu": "1500",
|
||||
"asymmetric_difference": null,
|
||||
"reached": false
|
||||
},
|
||||
{
|
||||
"ttl": "1",
|
||||
"guess": false,
|
||||
"host": "dust.inr.ac.ru",
|
||||
"reply_ms": "0.411",
|
||||
"pmtu": null,
|
||||
"asymmetric_difference": null,
|
||||
"reached": false
|
||||
},
|
||||
{
|
||||
"ttl": "2",
|
||||
"guess": false,
|
||||
"host": "dust.inr.ac.ru",
|
||||
"reply_ms": "0.390",
|
||||
"pmtu": "1480",
|
||||
"asymmetric_difference": "1",
|
||||
"reached": false
|
||||
},
|
||||
{
|
||||
"ttl": "2",
|
||||
"guess": false,
|
||||
"host": "3ffe:2400:0:109::2",
|
||||
"reply_ms": "463.514",
|
||||
"pmtu": null,
|
||||
"asymmetric_difference": null,
|
||||
"reached": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
145
docs/parsers/traceroute.md
Normal file
145
docs/parsers/traceroute.md
Normal file
@@ -0,0 +1,145 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.traceroute
|
||||
jc - JSON CLI output utility `traceroute` command output parser
|
||||
|
||||
Supports `traceroute` and `traceroute6` output.
|
||||
|
||||
Note: On some operating systems you will need to redirect `STDERR` to `STDOUT` for destination info since the header line is sent to `STDERR`. A warning message will be printed to `STDERR` if the header row is not found.
|
||||
|
||||
e.g. `$ traceroute 8.8.8.8 2>&1 | jc --traceroute`
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ traceroute 1.2.3.4 | jc --traceroute
|
||||
|
||||
or
|
||||
|
||||
$ jc traceroute 1.2.3.4
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.traceroute
|
||||
result = jc.parsers.traceroute.parse(traceroute_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"destination_ip": string,
|
||||
"destination_name": string,
|
||||
"hops": [
|
||||
{
|
||||
"hop": integer,
|
||||
"probes": [
|
||||
{
|
||||
"annotation": string,
|
||||
"asn": integer,
|
||||
"ip": string,
|
||||
"name": string,
|
||||
"rtt": float
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ traceroute google.com | jc --traceroute -p
|
||||
{
|
||||
"destination_ip": "216.58.194.46",
|
||||
"destination_name": "google.com",
|
||||
"hops": [
|
||||
{
|
||||
"hop": 1,
|
||||
"probes": [
|
||||
{
|
||||
"annotation": null,
|
||||
"asn": null,
|
||||
"ip": "216.230.231.141",
|
||||
"name": "216-230-231-141.static.houston.tx.oplink.net",
|
||||
"rtt": 198.574
|
||||
},
|
||||
{
|
||||
"annotation": null,
|
||||
"asn": null,
|
||||
"ip": "216.230.231.141",
|
||||
"name": "216-230-231-141.static.houston.tx.oplink.net",
|
||||
"rtt": null
|
||||
},
|
||||
{
|
||||
"annotation": null,
|
||||
"asn": null,
|
||||
"ip": "216.230.231.141",
|
||||
"name": "216-230-231-141.static.houston.tx.oplink.net",
|
||||
"rtt": 198.65
|
||||
}
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
}
|
||||
|
||||
$ traceroute google.com | jc --traceroute -p -r
|
||||
{
|
||||
"destination_ip": "216.58.194.46",
|
||||
"destination_name": "google.com",
|
||||
"hops": [
|
||||
{
|
||||
"hop": "1",
|
||||
"probes": [
|
||||
{
|
||||
"annotation": null,
|
||||
"asn": null,
|
||||
"ip": "216.230.231.141",
|
||||
"name": "216-230-231-141.static.houston.tx.oplink.net",
|
||||
"rtt": "198.574"
|
||||
},
|
||||
{
|
||||
"annotation": null,
|
||||
"asn": null,
|
||||
"ip": "216.230.231.141",
|
||||
"name": "216-230-231-141.static.houston.tx.oplink.net",
|
||||
"rtt": null
|
||||
},
|
||||
{
|
||||
"annotation": null,
|
||||
"asn": null,
|
||||
"ip": "216.230.231.141",
|
||||
"name": "216-230-231-141.static.houston.tx.oplink.net",
|
||||
"rtt": "198.650"
|
||||
}
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
225
docs/parsers/ufw.md
Normal file
225
docs/parsers/ufw.md
Normal file
@@ -0,0 +1,225 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.ufw
|
||||
jc - JSON CLI output utility `ufw status` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ ufw status | jc --ufw
|
||||
|
||||
or
|
||||
|
||||
$ jc ufw status
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.ufw
|
||||
result = jc.parsers.ufw.parse(ufw_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"status": string,
|
||||
"logging": string,
|
||||
"logging_level": string,
|
||||
"default": string,
|
||||
"new_profiles": string,
|
||||
"rules": [
|
||||
{
|
||||
"action": string,
|
||||
"action_direction": string, # null if blank
|
||||
"index": integer, # null if blank
|
||||
"network_protocol": string,
|
||||
"to_ip": string,
|
||||
"to_ip_prefix": integer,
|
||||
"to_interface": string,
|
||||
"to_transport": string,
|
||||
"to_ports": [
|
||||
integer
|
||||
],
|
||||
"to_port_ranges": [
|
||||
{
|
||||
"start": integer,
|
||||
"end": integer
|
||||
}
|
||||
],
|
||||
"to_service": string, # null if any to ports or port_ranges are set
|
||||
"from_ip": string,
|
||||
"from_ip_prefix": integer,
|
||||
"from_interface": string,
|
||||
"from_transport": string,
|
||||
"from_ports": [
|
||||
integer
|
||||
],
|
||||
"from_port_ranges": [
|
||||
{
|
||||
"start": integer,
|
||||
"end": integer
|
||||
}
|
||||
],
|
||||
"from_service": string, # null if any from ports or port_ranges are set
|
||||
"comment": string # null if no comment
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ ufw status verbose | jc --ufw -p
|
||||
{
|
||||
"status": "active",
|
||||
"logging": "on",
|
||||
"logging_level": "low",
|
||||
"default": "deny (incoming), allow (outgoing), disabled (routed)",
|
||||
"new_profiles": "skip",
|
||||
"rules": [
|
||||
{
|
||||
"action": "ALLOW",
|
||||
"action_direction": "IN",
|
||||
"index": null,
|
||||
"network_protocol": "ipv4",
|
||||
"to_interface": "any",
|
||||
"to_transport": "any",
|
||||
"to_service": null,
|
||||
"to_ports": [
|
||||
22
|
||||
],
|
||||
"to_ip": "0.0.0.0",
|
||||
"to_ip_prefix": 0,
|
||||
"comment": null,
|
||||
"from_ip": "0.0.0.0",
|
||||
"from_ip_prefix": 0,
|
||||
"from_interface": "any",
|
||||
"from_transport": "any",
|
||||
"from_port_ranges": [
|
||||
{
|
||||
"start": 0,
|
||||
"end": 65535
|
||||
}
|
||||
],
|
||||
"from_service": null
|
||||
},
|
||||
{
|
||||
"action": "ALLOW",
|
||||
"action_direction": "IN",
|
||||
"index": null,
|
||||
"network_protocol": "ipv4",
|
||||
"to_interface": "any",
|
||||
"to_transport": "tcp",
|
||||
"to_service": null,
|
||||
"to_ports": [
|
||||
80,
|
||||
443
|
||||
],
|
||||
"to_ip": "0.0.0.0",
|
||||
"to_ip_prefix": 0,
|
||||
"comment": null,
|
||||
"from_ip": "0.0.0.0",
|
||||
"from_ip_prefix": 0,
|
||||
"from_interface": "any",
|
||||
"from_transport": "any",
|
||||
"from_port_ranges": [
|
||||
{
|
||||
"start": 0,
|
||||
"end": 65535
|
||||
}
|
||||
],
|
||||
"from_service": null
|
||||
},
|
||||
...
|
||||
]
|
||||
}
|
||||
|
||||
$ ufw status verbose | jc --ufw -p -r
|
||||
{
|
||||
"status": "active",
|
||||
"logging": "on",
|
||||
"logging_level": "low",
|
||||
"default": "deny (incoming), allow (outgoing), disabled (routed)",
|
||||
"new_profiles": "skip",
|
||||
"rules": [
|
||||
{
|
||||
"action": "ALLOW",
|
||||
"action_direction": "IN",
|
||||
"index": null,
|
||||
"network_protocol": "ipv4",
|
||||
"to_interface": "any",
|
||||
"to_transport": "any",
|
||||
"to_service": null,
|
||||
"to_ports": [
|
||||
"22"
|
||||
],
|
||||
"to_ip": "0.0.0.0",
|
||||
"to_ip_prefix": "0",
|
||||
"comment": null,
|
||||
"from_ip": "0.0.0.0",
|
||||
"from_ip_prefix": "0",
|
||||
"from_interface": "any",
|
||||
"from_transport": "any",
|
||||
"from_port_ranges": [
|
||||
{
|
||||
"start": "0",
|
||||
"end": "65535"
|
||||
}
|
||||
],
|
||||
"from_service": null
|
||||
},
|
||||
{
|
||||
"action": "ALLOW",
|
||||
"action_direction": "IN",
|
||||
"index": null,
|
||||
"network_protocol": "ipv4",
|
||||
"to_interface": "any",
|
||||
"to_transport": "tcp",
|
||||
"to_service": null,
|
||||
"to_ports": [
|
||||
"80",
|
||||
"443"
|
||||
],
|
||||
"to_ip": "0.0.0.0",
|
||||
"to_ip_prefix": "0",
|
||||
"comment": null,
|
||||
"from_ip": "0.0.0.0",
|
||||
"from_ip_prefix": "0",
|
||||
"from_interface": "any",
|
||||
"from_transport": "any",
|
||||
"from_port_ranges": [
|
||||
{
|
||||
"start": "0",
|
||||
"end": "65535"
|
||||
}
|
||||
],
|
||||
"from_service": null
|
||||
},
|
||||
...
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
158
docs/parsers/ufw_appinfo.md
Normal file
158
docs/parsers/ufw_appinfo.md
Normal file
@@ -0,0 +1,158 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.ufw_appinfo
|
||||
jc - JSON CLI output utility `ufw app info [application]` command output parser
|
||||
|
||||
Supports individual apps via `ufw app info [application]` and all apps list via `ufw app info all`.
|
||||
|
||||
Because `ufw` application definitions allow overlapping ports and port ranges, this parser preserves that behavior, but also provides `normalized` lists and ranges that remove duplicate ports and merge overlapping ranges.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ ufw app info OpenSSH | jc --ufw-appinfo
|
||||
|
||||
or
|
||||
|
||||
$ jc ufw app info OpenSSH
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.ufw_appinfo
|
||||
result = jc.parsers.ufw_appinfo.parse(ufw_appinfo_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"profile": string,
|
||||
"title": string,
|
||||
"description": string,
|
||||
"tcp_list": [
|
||||
integer
|
||||
],
|
||||
"tcp_ranges": [
|
||||
{
|
||||
"start": integer, # 'any' is converted to start/end: 0/65535
|
||||
"end": integer
|
||||
}
|
||||
],
|
||||
"udp_list": [
|
||||
integer
|
||||
],
|
||||
"udp_ranges": [
|
||||
{
|
||||
"start": integer, # 'any' is converted to start/end: 0/65535
|
||||
"end": integer
|
||||
}
|
||||
],
|
||||
"normalized_tcp_list": [
|
||||
integers # duplicates and overlapping are removed
|
||||
],
|
||||
"normalized_tcp_ranges": [
|
||||
{
|
||||
"start": integer, # 'any' is converted to start/end: 0/65535
|
||||
"end": integers # overlapping are merged
|
||||
}
|
||||
],
|
||||
"normalized_udp_list": [
|
||||
integers # duplicates and overlapping are removed
|
||||
],
|
||||
"normalized_udp_ranges": [
|
||||
{
|
||||
"start": integer, # 'any' is converted to start/end: 0/65535
|
||||
"end": integers # overlapping are merged
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ ufw app info MSN | jc --ufw-appinfo -p
|
||||
[
|
||||
{
|
||||
"profile": "MSN",
|
||||
"title": "MSN Chat",
|
||||
"description": "MSN chat protocol (with file transfer and voice)",
|
||||
"tcp_list": [
|
||||
1863,
|
||||
6901
|
||||
],
|
||||
"udp_list": [
|
||||
1863,
|
||||
6901
|
||||
],
|
||||
"tcp_ranges": [
|
||||
{
|
||||
"start": 6891,
|
||||
"end": 6900
|
||||
}
|
||||
],
|
||||
"normalized_tcp_list": [
|
||||
1863,
|
||||
6901
|
||||
],
|
||||
"normalized_tcp_ranges": [
|
||||
{
|
||||
"start": 6891,
|
||||
"end": 6900
|
||||
}
|
||||
],
|
||||
"normalized_udp_list": [
|
||||
1863,
|
||||
6901
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
$ ufw app info MSN | jc --ufw-appinfo -p -r
|
||||
[
|
||||
{
|
||||
"profile": "MSN",
|
||||
"title": "MSN Chat",
|
||||
"description": "MSN chat protocol (with file transfer and voice)",
|
||||
"tcp_list": [
|
||||
"1863",
|
||||
"6901"
|
||||
],
|
||||
"udp_list": [
|
||||
"1863",
|
||||
"6901"
|
||||
],
|
||||
"tcp_ranges": [
|
||||
{
|
||||
"start": "6891",
|
||||
"end": "6900"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
75
docs/parsers/uname.md
Normal file
75
docs/parsers/uname.md
Normal file
@@ -0,0 +1,75 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.uname
|
||||
jc - JSON CLI output utility `uname -a` command output parser
|
||||
|
||||
Note: Must use `uname -a`
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ uname -a | jc --uname
|
||||
|
||||
or
|
||||
|
||||
$ jc uname -a
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.uname
|
||||
result = jc.parsers.uname.parse(uname_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"kernel_name": string,
|
||||
"node_name": string,
|
||||
"kernel_release": string,
|
||||
"operating_system": string,
|
||||
"hardware_platform": string,
|
||||
"processor": string,
|
||||
"machine": string,
|
||||
"kernel_version": string
|
||||
}
|
||||
|
||||
Example:
|
||||
|
||||
$ uname -a | jc --uname -p
|
||||
{
|
||||
"kernel_name": "Linux",
|
||||
"node_name": "user-ubuntu",
|
||||
"kernel_release": "4.15.0-65-generic",
|
||||
"operating_system": "GNU/Linux",
|
||||
"hardware_platform": "x86_64",
|
||||
"processor": "x86_64",
|
||||
"machine": "x86_64",
|
||||
"kernel_version": "#74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019"
|
||||
}
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, freebsd
|
||||
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
222
docs/parsers/upower.md
Normal file
222
docs/parsers/upower.md
Normal file
@@ -0,0 +1,222 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.upower
|
||||
jc - JSON CLI output utility `upower` command output parser
|
||||
|
||||
The `updated_epoch` calculated timestamp field is naive (i.e. based on the local time of the system the parser is run on)
|
||||
|
||||
The `updated_epoch_utc` calculated timestamp field is timezone-aware and is only available if the timezone field is UTC.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ upower -d | jc --upower
|
||||
|
||||
or
|
||||
|
||||
$ jc upower -d
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.upower
|
||||
result = jc.parsers.upower.parse(upower_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"type": string,
|
||||
"device_name": string,
|
||||
"native_path": string,
|
||||
"power_supply": boolean,
|
||||
"updated": string,
|
||||
"updated_epoch": integer, # null if date-time conversion fails
|
||||
"updated_epoch_utc": integer, # null if date-time conversion fails
|
||||
"updated_seconds_ago": integer,
|
||||
"has_history": boolean,
|
||||
"has_statistics": boolean,
|
||||
"detail": {
|
||||
"type": string,
|
||||
"warning_level": string, # null if none
|
||||
"online": boolean,
|
||||
"icon_name": string
|
||||
"present": boolean,
|
||||
"rechargeable": boolean,
|
||||
"state": string,
|
||||
"energy": float,
|
||||
"energy_unit": string,
|
||||
"energy_empty": float,
|
||||
"energy_empty_unit": string,
|
||||
"energy_full": float,
|
||||
"energy_full_unit": string,
|
||||
"energy_full_design": float,
|
||||
"energy_full_design_unit": string,
|
||||
"energy_rate": float,
|
||||
"energy_rate_unit": string,
|
||||
"voltage": float,
|
||||
"voltage_unit": string,
|
||||
"time_to_full": float,
|
||||
"time_to_full_unit": string,
|
||||
"percentage": float,
|
||||
"capacity": float,
|
||||
"technology": string
|
||||
},
|
||||
"history_charge": [
|
||||
{
|
||||
"time": integer,
|
||||
"percent_charged": float,
|
||||
"status": string
|
||||
}
|
||||
],
|
||||
"history_rate":[
|
||||
{
|
||||
"time": integer,
|
||||
"percent_charged": float,
|
||||
"status": string
|
||||
}
|
||||
],
|
||||
"daemon_version": string,
|
||||
"on_battery": boolean,
|
||||
"lid_is_closed": boolean,
|
||||
"lid_is_present": boolean,
|
||||
"critical_action": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ upower -i /org/freedesktop/UPower/devices/battery | jc --upower -p
|
||||
[
|
||||
{
|
||||
"native_path": "/sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0",
|
||||
"vendor": "NOTEBOOK",
|
||||
"model": "BAT",
|
||||
"serial": "0001",
|
||||
"power_supply": true,
|
||||
"updated": "Thu 11 Mar 2021 06:28:08 PM UTC",
|
||||
"has_history": true,
|
||||
"has_statistics": true,
|
||||
"detail": {
|
||||
"type": "battery",
|
||||
"present": true,
|
||||
"rechargeable": true,
|
||||
"state": "charging",
|
||||
"energy": 22.3998,
|
||||
"energy_empty": 0.0,
|
||||
"energy_full": 52.6473,
|
||||
"energy_full_design": 62.16,
|
||||
"energy_rate": 31.6905,
|
||||
"voltage": 12.191,
|
||||
"time_to_full": 57.3,
|
||||
"percentage": 42.5469,
|
||||
"capacity": 84.6964,
|
||||
"technology": "lithium-ion",
|
||||
"energy_unit": "Wh",
|
||||
"energy_empty_unit": "Wh",
|
||||
"energy_full_unit": "Wh",
|
||||
"energy_full_design_unit": "Wh",
|
||||
"energy_rate_unit": "W",
|
||||
"voltage_unit": "V",
|
||||
"time_to_full_unit": "minutes"
|
||||
},
|
||||
"history_charge": [
|
||||
{
|
||||
"time": 1328809335,
|
||||
"percent_charged": 42.547,
|
||||
"status": "charging"
|
||||
},
|
||||
{
|
||||
"time": 1328809305,
|
||||
"percent_charged": 42.02,
|
||||
"status": "charging"
|
||||
}
|
||||
],
|
||||
"history_rate": [
|
||||
{
|
||||
"time": 1328809335,
|
||||
"percent_charged": 31.691,
|
||||
"status": "charging"
|
||||
}
|
||||
],
|
||||
"updated_seconds_ago": 441975,
|
||||
"updated_epoch": 1615516088,
|
||||
"updated_epoch_utc": 1615487288
|
||||
}
|
||||
]
|
||||
|
||||
$ upower -i /org/freedesktop/UPower/devices/battery | jc --upower -p -r
|
||||
[
|
||||
{
|
||||
"native_path": "/sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0",
|
||||
"vendor": "NOTEBOOK",
|
||||
"model": "BAT",
|
||||
"serial": "0001",
|
||||
"power_supply": "yes",
|
||||
"updated": "Thu 11 Mar 2021 06:28:08 PM UTC (441975 seconds ago)",
|
||||
"has_history": "yes",
|
||||
"has_statistics": "yes",
|
||||
"detail": {
|
||||
"type": "battery",
|
||||
"present": "yes",
|
||||
"rechargeable": "yes",
|
||||
"state": "charging",
|
||||
"energy": "22.3998 Wh",
|
||||
"energy_empty": "0 Wh",
|
||||
"energy_full": "52.6473 Wh",
|
||||
"energy_full_design": "62.16 Wh",
|
||||
"energy_rate": "31.6905 W",
|
||||
"voltage": "12.191 V",
|
||||
"time_to_full": "57.3 minutes",
|
||||
"percentage": "42.5469%",
|
||||
"capacity": "84.6964%",
|
||||
"technology": "lithium-ion"
|
||||
},
|
||||
"history_charge": [
|
||||
{
|
||||
"time": "1328809335",
|
||||
"percent_charged": "42.547",
|
||||
"status": "charging"
|
||||
},
|
||||
{
|
||||
"time": "1328809305",
|
||||
"percent_charged": "42.020",
|
||||
"status": "charging"
|
||||
}
|
||||
],
|
||||
"history_rate": [
|
||||
{
|
||||
"time": "1328809335",
|
||||
"percent_charged": "31.691",
|
||||
"status": "charging"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
93
docs/parsers/uptime.md
Normal file
93
docs/parsers/uptime.md
Normal file
@@ -0,0 +1,93 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.uptime
|
||||
jc - JSON CLI output utility `uptime` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ uptime | jc --uptime
|
||||
|
||||
or
|
||||
|
||||
$ jc uptime
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.uptime
|
||||
result = jc.parsers.uptime.parse(uptime_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"time": string,
|
||||
"time_hour": integer,
|
||||
"time_minute": integer,
|
||||
"time_second": integer, # null if not displayed
|
||||
"uptime": string,
|
||||
"uptime_days": integer,
|
||||
"uptime_hours": integer,
|
||||
"uptime_minutes": integer,
|
||||
"uptime_total_seconds": integer,
|
||||
"users": integer,
|
||||
"load_1m": float,
|
||||
"load_5m": float,
|
||||
"load_15m": float
|
||||
}
|
||||
|
||||
Example:
|
||||
|
||||
$ uptime | jc --uptime -p
|
||||
{
|
||||
"time": "11:35",
|
||||
"uptime": "3 days, 4:03",
|
||||
"users": 5,
|
||||
"load_1m": 1.88,
|
||||
"load_5m": 2.0,
|
||||
"load_15m": 1.94,
|
||||
"time_hour": 11,
|
||||
"time_minute": 35,
|
||||
"time_second": null,
|
||||
"uptime_days": 3,
|
||||
"uptime_hours": 4,
|
||||
"uptime_minutes": 3,
|
||||
"uptime_total_seconds": 273780
|
||||
}
|
||||
|
||||
$ uptime | jc --uptime -p -r
|
||||
{
|
||||
"time": "11:36",
|
||||
"uptime": "3 days, 4:04",
|
||||
"users": "5",
|
||||
"load_1m": "1.88",
|
||||
"load_5m": "1.99",
|
||||
"load_15m": "1.94"
|
||||
}
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
149
docs/parsers/vmstat.md
Normal file
149
docs/parsers/vmstat.md
Normal file
@@ -0,0 +1,149 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.vmstat
|
||||
jc - JSON CLI output utility `vmstat` command output parser
|
||||
|
||||
Options supported: `-a`, `-w`, `-d`, `-t`
|
||||
|
||||
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):
|
||||
|
||||
$ vmstat | jc --vmstat
|
||||
|
||||
or
|
||||
|
||||
$ jc vmstat
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.vmstat
|
||||
result = jc.parsers.vmstat.parse(vmstat_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"runnable_procs": integer,
|
||||
"uninterruptible_sleeping_procs": integer,
|
||||
"virtual_mem_used": integer,
|
||||
"free_mem": integer,
|
||||
"buffer_mem": integer,
|
||||
"cache_mem": integer,
|
||||
"inactive_mem": integer,
|
||||
"active_mem": integer,
|
||||
"swap_in": integer,
|
||||
"swap_out": integer,
|
||||
"blocks_in": integer,
|
||||
"blocks_out": integer,
|
||||
"interrupts": integer,
|
||||
"context_switches": integer,
|
||||
"user_time": integer,
|
||||
"system_time": integer,
|
||||
"idle_time": integer,
|
||||
"io_wait_time": integer,
|
||||
"stolen_time": integer,
|
||||
"disk": string,
|
||||
"total_reads": integer,
|
||||
"merged_reads": integer,
|
||||
"sectors_read": integer,
|
||||
"reading_ms": integer,
|
||||
"total_writes": integer,
|
||||
"merged_writes": integer,
|
||||
"sectors_written": integer,
|
||||
"writing_ms": integer,
|
||||
"current_io": integer,
|
||||
"io_seconds": integer,
|
||||
"timestamp": string,
|
||||
"timezone": string,
|
||||
"epoch": integer, # naive timestamp if -t flag is used
|
||||
"epoch_utc": integer # aware timestamp if -t flag is used and UTC TZ
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ vmstat | jc --vmstat -p
|
||||
[
|
||||
{
|
||||
"runnable_procs": 2,
|
||||
"uninterruptible_sleeping_procs": 0,
|
||||
"virtual_mem_used": 0,
|
||||
"free_mem": 2794468,
|
||||
"buffer_mem": 2108,
|
||||
"cache_mem": 741208,
|
||||
"inactive_mem": null,
|
||||
"active_mem": null,
|
||||
"swap_in": 0,
|
||||
"swap_out": 0,
|
||||
"blocks_in": 1,
|
||||
"blocks_out": 3,
|
||||
"interrupts": 29,
|
||||
"context_switches": 57,
|
||||
"user_time": 0,
|
||||
"system_time": 0,
|
||||
"idle_time": 99,
|
||||
"io_wait_time": 0,
|
||||
"stolen_time": 0,
|
||||
"timestamp": null,
|
||||
"timezone": null
|
||||
}
|
||||
]
|
||||
|
||||
$ vmstat | jc --vmstat -p -r
|
||||
[
|
||||
{
|
||||
"runnable_procs": "2",
|
||||
"uninterruptible_sleeping_procs": "0",
|
||||
"virtual_mem_used": "0",
|
||||
"free_mem": "2794468",
|
||||
"buffer_mem": "2108",
|
||||
"cache_mem": "741208",
|
||||
"inactive_mem": null,
|
||||
"active_mem": null,
|
||||
"swap_in": "0",
|
||||
"swap_out": "0",
|
||||
"blocks_in": "1",
|
||||
"blocks_out": "3",
|
||||
"interrupts": "29",
|
||||
"context_switches": "57",
|
||||
"user_time": "0",
|
||||
"system_time": "0",
|
||||
"idle_time": "99",
|
||||
"io_wait_time": "0",
|
||||
"stolen_time": "0",
|
||||
"timestamp": null,
|
||||
"timezone": null
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
114
docs/parsers/vmstat_s.md
Normal file
114
docs/parsers/vmstat_s.md
Normal file
@@ -0,0 +1,114 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.vmstat_s
|
||||
jc - JSON CLI output utility `vmstat` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines
|
||||
|
||||
Options supported: `-a`, `-w`, `-d`, `-t`
|
||||
|
||||
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):
|
||||
|
||||
$ vmstat | jc --vmstat-s
|
||||
|
||||
> Note: When piping `jc` converted `vmstat` output to other processes it may appear the output is hanging due to the OS pipe buffers. This is because `vmstat` output is too small to quickly fill up the buffer. Use the `-u` option to unbuffer the `jc` output if you would like immediate output. See the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output) for more information.
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.vmstat_s
|
||||
result = jc.parsers.vmstat_s.parse(vmstat_command_output.splitlines()) # result is an iterable object
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"runnable_procs": integer,
|
||||
"uninterruptible_sleeping_procs": integer,
|
||||
"virtual_mem_used": integer,
|
||||
"free_mem": integer,
|
||||
"buffer_mem": integer,
|
||||
"cache_mem": integer,
|
||||
"inactive_mem": integer,
|
||||
"active_mem": integer,
|
||||
"swap_in": integer,
|
||||
"swap_out": integer,
|
||||
"blocks_in": integer,
|
||||
"blocks_out": integer,
|
||||
"interrupts": integer,
|
||||
"context_switches": integer,
|
||||
"user_time": integer,
|
||||
"system_time": integer,
|
||||
"idle_time": integer,
|
||||
"io_wait_time": integer,
|
||||
"stolen_time": integer,
|
||||
"disk": string,
|
||||
"total_reads": integer,
|
||||
"merged_reads": integer,
|
||||
"sectors_read": integer,
|
||||
"reading_ms": integer,
|
||||
"total_writes": integer,
|
||||
"merged_writes": integer,
|
||||
"sectors_written": integer,
|
||||
"writing_ms": integer,
|
||||
"current_io": integer,
|
||||
"io_seconds": integer,
|
||||
"timestamp": string,
|
||||
"timezone": string,
|
||||
"epoch": integer, # naive timestamp if -t flag is used
|
||||
"epoch_utc": integer # aware timestamp if -t flag is used and UTC TZ
|
||||
"_jc_meta": # This object only exists if using -qq or ignore_exceptions=True
|
||||
{
|
||||
"success": booean, # true if successfully parsed, false if error
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ vmstat | jc --vmstat-s
|
||||
{"runnable_procs":2,"uninterruptible_sleeping_procs":0,"virtual_mem_used":0,"free_mem":2794468,"buffer_mem":2108,"cache_mem":741208,"inactive_mem":null,"active_mem":null,"swap_in":0,"swap_out":0,"blocks_in":1,"blocks_out":3,"interrupts":29,"context_switches":57,"user_time":0,"system_time":0,"idle_time":99,"io_wait_time":0,"stolen_time":0,"timestamp":null,"timezone":null}
|
||||
...
|
||||
|
||||
$ vmstat | jc --vmstat-s -r
|
||||
{"runnable_procs":"2","uninterruptible_sleeping_procs":"0","virtual_mem_used":"0","free_mem":"2794468","buffer_mem":"2108","cache_mem":"741208","inactive_mem":null,"active_mem":null,"swap_in":"0","swap_out":"0","blocks_in":"1","blocks_out":"3","interrupts":"29","context_switches":"57","user_time":"0","system_time":"0","idle_time":"99","io_wait_time":"0","stolen_time":"0","timestamp":null,"timezone":null}
|
||||
...
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterator object.
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (iterable) line-based text data to parse (e.g. sys.stdin or str.splitlines())
|
||||
raw: (boolean) output preprocessed JSON 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
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 0.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
131
docs/parsers/w.md
Normal file
131
docs/parsers/w.md
Normal file
@@ -0,0 +1,131 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.w
|
||||
jc - JSON CLI output utility `w` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ w | jc --w
|
||||
|
||||
or
|
||||
|
||||
$ jc w
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.w
|
||||
result = jc.parsers.w.parse(w_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"user": string, # '-' = null
|
||||
"tty": string, # '-' = null
|
||||
"from": string, # '-' = null
|
||||
"login_at": string, # '-' = null
|
||||
"idle": string, # '-' = null
|
||||
"jcpu": string,
|
||||
"pcpu": string,
|
||||
"what": string # '-' = null
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ w | jc --w -p
|
||||
[
|
||||
{
|
||||
"user": "root",
|
||||
"tty": "tty1",
|
||||
"from": null,
|
||||
"login_at": "07:49",
|
||||
"idle": "1:15m",
|
||||
"jcpu": "0.00s",
|
||||
"pcpu": "0.00s",
|
||||
"what": "-bash"
|
||||
},
|
||||
{
|
||||
"user": "root",
|
||||
"tty": "ttyS0",
|
||||
"from": null,
|
||||
"login_at": "06:24",
|
||||
"idle": "0.00s",
|
||||
"jcpu": "0.43s",
|
||||
"pcpu": "0.00s",
|
||||
"what": "w"
|
||||
},
|
||||
{
|
||||
"user": "root",
|
||||
"tty": "pts/0",
|
||||
"from": "192.168.71.1",
|
||||
"login_at": "06:29",
|
||||
"idle": "2:35m",
|
||||
"jcpu": "0.00s",
|
||||
"pcpu": "0.00s",
|
||||
"what": "-bash"
|
||||
}
|
||||
]
|
||||
|
||||
$ w | jc --w -p -r
|
||||
[
|
||||
{
|
||||
"user": "kbrazil",
|
||||
"tty": "tty1",
|
||||
"from": "-",
|
||||
"login_at": "07:49",
|
||||
"idle": "1:16m",
|
||||
"jcpu": "0.00s",
|
||||
"pcpu": "0.00s",
|
||||
"what": "-bash"
|
||||
},
|
||||
{
|
||||
"user": "kbrazil",
|
||||
"tty": "ttyS0",
|
||||
"from": "-",
|
||||
"login_at": "06:24",
|
||||
"idle": "2.00s",
|
||||
"jcpu": "0.46s",
|
||||
"pcpu": "0.00s",
|
||||
"what": "w"
|
||||
},
|
||||
{
|
||||
"user": "kbrazil",
|
||||
"tty": "pts/0",
|
||||
"from": "192.168.71.1",
|
||||
"login_at": "06:29",
|
||||
"idle": "2:36m",
|
||||
"jcpu": "0.00s",
|
||||
"pcpu": "0.00s",
|
||||
"what": "-bash"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
82
docs/parsers/wc.md
Normal file
82
docs/parsers/wc.md
Normal file
@@ -0,0 +1,82 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.wc
|
||||
jc - JSON CLI output utility `wc` command output parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ wc file.txt | jc --wc
|
||||
|
||||
or
|
||||
|
||||
$ jc wc file.txt
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.wc
|
||||
result = jc.parsers.wc.parse(wc_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"filename": string,
|
||||
"lines": integer,
|
||||
"words": integer,
|
||||
"characters": integer
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ wc * | jc --wc -p
|
||||
[
|
||||
{
|
||||
"filename": "airport-I.json",
|
||||
"lines": 1,
|
||||
"words": 30,
|
||||
"characters": 307
|
||||
},
|
||||
{
|
||||
"filename": "airport-I.out",
|
||||
"lines": 15,
|
||||
"words": 33,
|
||||
"characters": 348
|
||||
},
|
||||
{
|
||||
"filename": "airport-s.json",
|
||||
"lines": 1,
|
||||
"words": 202,
|
||||
"characters": 2152
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
160
docs/parsers/who.md
Normal file
160
docs/parsers/who.md
Normal file
@@ -0,0 +1,160 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.who
|
||||
jc - JSON CLI output utility `who` command output parser
|
||||
|
||||
Accepts any of the following who options (or no options): `-aTH`
|
||||
|
||||
The `epoch` calculated timestamp field is naive (i.e. based on the local time of the system the parser is run on)
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ who | jc --who
|
||||
|
||||
or
|
||||
|
||||
$ jc who
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.who
|
||||
result = jc.parsers.who.parse(who_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"user": string,
|
||||
"event": string,
|
||||
"writeable_tty": string,
|
||||
"tty": string,
|
||||
"time": string,
|
||||
"epoch": integer, # naive timestamp. null if time cannot be converted
|
||||
"idle": string,
|
||||
"pid": integer,
|
||||
"from": string,
|
||||
"comment": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ who -a | jc --who -p
|
||||
[
|
||||
{
|
||||
"event": "reboot",
|
||||
"time": "Feb 7 23:31",
|
||||
"pid": 1,
|
||||
"epoch": null
|
||||
},
|
||||
{
|
||||
"user": "joeuser",
|
||||
"writeable_tty": "-",
|
||||
"tty": "console",
|
||||
"time": "Feb 7 23:32",
|
||||
"idle": "old",
|
||||
"pid": 105,
|
||||
"epoch": null
|
||||
},
|
||||
{
|
||||
"user": "joeuser",
|
||||
"writeable_tty": "+",
|
||||
"tty": "ttys000",
|
||||
"time": "Feb 13 16:44",
|
||||
"idle": ".",
|
||||
"pid": 51217,
|
||||
"comment": "term=0 exit=0",
|
||||
"epoch": null
|
||||
},
|
||||
{
|
||||
"user": "joeuser",
|
||||
"writeable_tty": "?",
|
||||
"tty": "ttys003",
|
||||
"time": "Feb 28 08:59",
|
||||
"idle": "01:36",
|
||||
"pid": 41402,
|
||||
"epoch": null
|
||||
},
|
||||
{
|
||||
"user": "joeuser",
|
||||
"writeable_tty": "+",
|
||||
"tty": "ttys004",
|
||||
"time": "Mar 1 16:35",
|
||||
"idle": ".",
|
||||
"pid": 15679,
|
||||
"from": "192.168.1.5",
|
||||
"epoch": null
|
||||
}
|
||||
]
|
||||
|
||||
$ who -a | jc --who -p -r
|
||||
[
|
||||
{
|
||||
"event": "reboot",
|
||||
"time": "Feb 7 23:31",
|
||||
"pid": "1"
|
||||
},
|
||||
{
|
||||
"user": "joeuser",
|
||||
"writeable_tty": "-",
|
||||
"tty": "console",
|
||||
"time": "Feb 7 23:32",
|
||||
"idle": "old",
|
||||
"pid": "105"
|
||||
},
|
||||
{
|
||||
"user": "joeuser",
|
||||
"writeable_tty": "+",
|
||||
"tty": "ttys000",
|
||||
"time": "Feb 13 16:44",
|
||||
"idle": ".",
|
||||
"pid": "51217",
|
||||
"comment": "term=0 exit=0"
|
||||
},
|
||||
{
|
||||
"user": "joeuser",
|
||||
"writeable_tty": "?",
|
||||
"tty": "ttys003",
|
||||
"time": "Feb 28 08:59",
|
||||
"idle": "01:36",
|
||||
"pid": "41402"
|
||||
},
|
||||
{
|
||||
"user": "joeuser",
|
||||
"writeable_tty": "+",
|
||||
"tty": "ttys004",
|
||||
"time": "Mar 1 16:35",
|
||||
"idle": ".",
|
||||
"pid": "15679",
|
||||
"from": "192.168.1.5"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||
|
||||
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
98
docs/parsers/xml.md
Normal file
98
docs/parsers/xml.md
Normal file
@@ -0,0 +1,98 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.xml
|
||||
jc - JSON CLI output utility `XML` file parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat foo.xml | jc --xml
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.xml
|
||||
result = jc.parsers.xml.parse(xml_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
XML Document converted to a Dictionary
|
||||
See https://github.com/martinblech/xmltodict for details
|
||||
|
||||
{
|
||||
"key1": string/object,
|
||||
"key2": string/object
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat cd_catalog.xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CATALOG>
|
||||
<CD>
|
||||
<TITLE>Empire Burlesque</TITLE>
|
||||
<ARTIST>Bob Dylan</ARTIST>
|
||||
<COUNTRY>USA</COUNTRY>
|
||||
<COMPANY>Columbia</COMPANY>
|
||||
<PRICE>10.90</PRICE>
|
||||
<YEAR>1985</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>Hide your heart</TITLE>
|
||||
<ARTIST>Bonnie Tyler</ARTIST>
|
||||
<COUNTRY>UK</COUNTRY>
|
||||
<COMPANY>CBS Records</COMPANY>
|
||||
<PRICE>9.90</PRICE>
|
||||
<YEAR>1988</YEAR>
|
||||
</CD>
|
||||
...
|
||||
|
||||
$ cat cd_catalog.xml | jc --xml -p
|
||||
{
|
||||
"CATALOG": {
|
||||
"CD": [
|
||||
{
|
||||
"TITLE": "Empire Burlesque",
|
||||
"ARTIST": "Bob Dylan",
|
||||
"COUNTRY": "USA",
|
||||
"COMPANY": "Columbia",
|
||||
"PRICE": "10.90",
|
||||
"YEAR": "1985"
|
||||
},
|
||||
{
|
||||
"TITLE": "Hide your heart",
|
||||
"ARTIST": "Bonnie Tyler",
|
||||
"COUNTRY": "UK",
|
||||
"COMPANY": "CBS Records",
|
||||
"PRICE": "9.90",
|
||||
"YEAR": "1988"
|
||||
},
|
||||
...
|
||||
}
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
112
docs/parsers/yaml.md
Normal file
112
docs/parsers/yaml.md
Normal file
@@ -0,0 +1,112 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
|
||||
# jc.parsers.yaml
|
||||
jc - JSON CLI output utility `YAML` file parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat foo.yaml | jc --yaml
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc.parsers.yaml
|
||||
result = jc.parsers.yaml.parse(yaml_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
YAML Document converted to a Dictionary
|
||||
See https://pypi.org/project/ruamel.yaml for details
|
||||
|
||||
[
|
||||
{
|
||||
"key1": string/int/float/boolean/null/array/object,
|
||||
"key2": string/int/float/boolean/null/array/object
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat istio-mtls-permissive.yaml
|
||||
apiVersion: "authentication.istio.io/v1alpha1"
|
||||
kind: "Policy"
|
||||
metadata:
|
||||
name: "default"
|
||||
namespace: "default"
|
||||
spec:
|
||||
peers:
|
||||
- mtls: {}
|
||||
---
|
||||
apiVersion: "networking.istio.io/v1alpha3"
|
||||
kind: "DestinationRule"
|
||||
metadata:
|
||||
name: "default"
|
||||
namespace: "default"
|
||||
spec:
|
||||
host: "*.default.svc.cluster.local"
|
||||
trafficPolicy:
|
||||
tls:
|
||||
mode: ISTIO_MUTUAL
|
||||
|
||||
$ cat istio-mtls-permissive.yaml | jc --yaml -p
|
||||
[
|
||||
{
|
||||
"apiVersion": "authentication.istio.io/v1alpha1",
|
||||
"kind": "Policy",
|
||||
"metadata": {
|
||||
"name": "default",
|
||||
"namespace": "default"
|
||||
},
|
||||
"spec": {
|
||||
"peers": [
|
||||
{
|
||||
"mtls": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "networking.istio.io/v1alpha3",
|
||||
"kind": "DestinationRule",
|
||||
"metadata": {
|
||||
"name": "default",
|
||||
"namespace": "default"
|
||||
},
|
||||
"spec": {
|
||||
"host": "*.default.svc.cluster.local",
|
||||
"trafficPolicy": {
|
||||
"tls": {
|
||||
"mode": "ISTIO_MUTUAL"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info()
|
||||
```
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries representing the YAML documents.
|
||||
|
||||
## Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
75
docs/readme.md
Normal file
75
docs/readme.md
Normal file
@@ -0,0 +1,75 @@
|
||||
|
||||
# jc
|
||||
JC - JSON CLI output utility
|
||||
|
||||
* kellyjonbrazil@gmail.com
|
||||
|
||||
This package serializes the output of many standard unix command line tools to JSON format.
|
||||
|
||||
For documentation on each parser, see the [documentation site](https://kellyjonbrazil.github.io/jc/).
|
||||
|
||||
CLI Example:
|
||||
|
||||
$ dig example.com | jc --dig -p
|
||||
[
|
||||
{
|
||||
"id": 2951,
|
||||
"opcode": "QUERY",
|
||||
"status": "NOERROR",
|
||||
"flags": [
|
||||
"qr",
|
||||
"rd",
|
||||
"ra"
|
||||
],
|
||||
"query_num": 1,
|
||||
"answer_num": 1,
|
||||
"authority_num": 0,
|
||||
"additional_num": 1,
|
||||
"opt_pseudosection": {
|
||||
"edns": {
|
||||
"version": 0,
|
||||
"flags": [],
|
||||
"udp": 4096
|
||||
}
|
||||
},
|
||||
"question": {
|
||||
"name": "example.com.",
|
||||
"class": "IN",
|
||||
"type": "A"
|
||||
},
|
||||
"answer": [
|
||||
{
|
||||
"name": "example.com.",
|
||||
"class": "IN",
|
||||
"type": "A",
|
||||
"ttl": 39302,
|
||||
"data": "93.184.216.34"
|
||||
}
|
||||
],
|
||||
"query_time": 49,
|
||||
"server": "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
|
||||
"when": "Fri Apr 16 16:05:10 PDT 2021",
|
||||
"rcvd": 56,
|
||||
"when_epoch": 1618614310,
|
||||
"when_epoch_utc": null
|
||||
}
|
||||
]
|
||||
|
||||
Module Example:
|
||||
|
||||
>>> import jc.parsers.dig
|
||||
>>>
|
||||
>>> import subprocess
|
||||
>>> import jc.parsers.dig
|
||||
>>>
|
||||
>>> cmd_output = subprocess.check_output(['dig', 'example.com'], text=True)
|
||||
>>> data = jc.parsers.dig.parse(cmd_output)
|
||||
>>>
|
||||
>>> data
|
||||
[{'id': 64612, 'opcode': 'QUERY', 'status': 'NOERROR', 'flags': ['qr', 'rd', 'ra'], 'query_num': 1, 'answer_num':
|
||||
1, 'authority_num': 0, 'additional_num': 1, 'opt_pseudosection': {'edns': {'version': 0, 'flags': [], 'udp':
|
||||
4096}}, 'question': {'name': 'example.com.', 'class': 'IN', 'type': 'A'}, 'answer': [{'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}]
|
||||
|
||||
175
docs/utils.md
Normal file
175
docs/utils.md
Normal file
@@ -0,0 +1,175 @@
|
||||
|
||||
# utils
|
||||
jc - JSON CLI output utility utils
|
||||
|
||||
## warning_message
|
||||
```python
|
||||
warning_message(message_lines)
|
||||
```
|
||||
|
||||
Prints warning message for non-fatal issues. The first line is prepended with
|
||||
'jc: Warning - ' and subsequent lines are indented. Wraps text as needed based
|
||||
on the terminal width.
|
||||
|
||||
Parameters:
|
||||
|
||||
message: (list) list of string lines
|
||||
|
||||
Returns:
|
||||
|
||||
None - just prints output to STDERR
|
||||
|
||||
|
||||
## error_message
|
||||
```python
|
||||
error_message(message_lines)
|
||||
```
|
||||
|
||||
Prints an error message for fatal issues. The first line is prepended with
|
||||
'jc: Error - ' and subsequent lines are indented. Wraps text as needed based
|
||||
on the terminal width.
|
||||
|
||||
Parameters:
|
||||
|
||||
message: (list) list of string lines
|
||||
|
||||
Returns:
|
||||
|
||||
None - just prints output to STDERR
|
||||
|
||||
|
||||
## compatibility
|
||||
```python
|
||||
compatibility(mod_name, compatible, quiet=False)
|
||||
```
|
||||
Checks for the parser's compatibility with the running OS platform.
|
||||
|
||||
Parameters:
|
||||
|
||||
mod_name: (string) __name__ of the calling module
|
||||
|
||||
compatible: (list) sys.platform name(s) compatible with the parser
|
||||
compatible options:
|
||||
linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
quiet: (bool) supress compatibility message if True
|
||||
|
||||
Returns:
|
||||
|
||||
None - just prints output to STDERR
|
||||
|
||||
|
||||
## has_data
|
||||
```python
|
||||
has_data(data)
|
||||
```
|
||||
|
||||
Checks if the input contains data. If there are any non-whitespace characters then return True, else return False
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) input to check whether it contains data
|
||||
|
||||
Returns:
|
||||
|
||||
Boolean True if input string (data) contains non-whitespace characters, otherwise False
|
||||
|
||||
|
||||
## convert_to_int
|
||||
```python
|
||||
convert_to_int(value)
|
||||
```
|
||||
|
||||
Converts string and float input to int. Strips all non-numeric characters from strings.
|
||||
|
||||
Parameters:
|
||||
|
||||
value: (string/integer/float) Input value
|
||||
|
||||
Returns:
|
||||
|
||||
integer/None Integer if successful conversion, otherwise None
|
||||
|
||||
|
||||
## convert_to_float
|
||||
```python
|
||||
convert_to_float(value)
|
||||
```
|
||||
|
||||
Converts string and int input to float. Strips all non-numeric characters from strings.
|
||||
|
||||
Parameters:
|
||||
|
||||
value: (string) Input value
|
||||
|
||||
Returns:
|
||||
|
||||
float/None Float if successful conversion, otherwise None
|
||||
|
||||
|
||||
## convert_to_bool
|
||||
```python
|
||||
convert_to_bool(value)
|
||||
```
|
||||
|
||||
Converts string, integer, or float input to boolean by checking for 'truthy' values
|
||||
|
||||
Parameters:
|
||||
|
||||
value: (string/integer/float) Input value
|
||||
|
||||
Returns:
|
||||
|
||||
True/False False unless a 'truthy' number or string is found ('y', 'yes', 'true', '1', 1, -1, etc.)
|
||||
|
||||
|
||||
## stream_success
|
||||
```python
|
||||
stream_success(output_line, ignore_exceptions)
|
||||
```
|
||||
Add `_jc_meta` object to output line if `ignore_exceptions=True`
|
||||
|
||||
## stream_error
|
||||
```python
|
||||
stream_error(e, ignore_exceptions, line)
|
||||
```
|
||||
Reraise the stream exception with annotation or print an error `_jc_meta`
|
||||
field if `ignore_exceptions=True`
|
||||
|
||||
|
||||
## input_type_check
|
||||
```python
|
||||
input_type_check(data)
|
||||
```
|
||||
Ensure input data is a string
|
||||
|
||||
## streaming_input_type_check
|
||||
```python
|
||||
streaming_input_type_check(data)
|
||||
```
|
||||
Ensure input data is an iterable, but not a string or bytes
|
||||
|
||||
## streaming_line_input_type_check
|
||||
```python
|
||||
streaming_line_input_type_check(line)
|
||||
```
|
||||
Ensure each line is a string
|
||||
|
||||
## timestamp
|
||||
```python
|
||||
timestamp(datetime_string)
|
||||
```
|
||||
|
||||
Input a date-time text string of several formats and convert to a naive or timezone-aware epoch timestamp in UTC
|
||||
|
||||
Parameters:
|
||||
|
||||
datetime_string: (str) a string representation of a date-time in several supported formats
|
||||
|
||||
Attributes:
|
||||
|
||||
string (str) the input datetime string
|
||||
format (int) the format rule that was used to decode the datetime string. None if conversion fails
|
||||
naive (int) timestamp based on locally configured timezone. None if conversion fails
|
||||
utc (int) aware timestamp only if UTC timezone detected in datetime string. None if conversion fails
|
||||
|
||||
2
install.sh
Executable file
2
install.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
pip3 install --upgrade --user -e .
|
||||
117
jc/__init__.py
117
jc/__init__.py
@@ -2,58 +2,75 @@
|
||||
|
||||
* kellyjonbrazil@gmail.com
|
||||
|
||||
This module serializes standard unix command line output to structured JSON
|
||||
output.
|
||||
This package serializes the output of many standard unix command line tools to JSON format.
|
||||
|
||||
Example:
|
||||
For documentation on each parser, see the [documentation site](https://kellyjonbrazil.github.io/jc/).
|
||||
|
||||
$ ls -al | jc | jq .
|
||||
[
|
||||
{
|
||||
"filename": ".",
|
||||
"suffix": Null,
|
||||
"bytes": 224,
|
||||
"date_updated": "Oct 1 12:09",
|
||||
"owner_user": "joeuser",
|
||||
"owner_group": "staff",
|
||||
"flags": "drwxr-xr-x+",
|
||||
"link_to": Null,
|
||||
"links": 47
|
||||
},
|
||||
{
|
||||
"filename": "..",
|
||||
"suffix": Null,
|
||||
"bytes": 224,
|
||||
"date_updated": "Oct 1 12:09",
|
||||
"owner_user": "admin",
|
||||
"owner_group": "root",
|
||||
"flags": "drwxr-xr-x",
|
||||
"link_to": Null,
|
||||
"links": 7
|
||||
},
|
||||
{
|
||||
"filename": "testfile.txt",
|
||||
"suffix": "txt",
|
||||
"bytes": 14686,
|
||||
"date_updated": "Oct 1 12:09",
|
||||
"owner_user": "joeuser",
|
||||
"owner_group": "staff",
|
||||
"flags": "-rwxr-xr-x@",
|
||||
"link_to": Null,
|
||||
"links": 1
|
||||
},
|
||||
{
|
||||
"filename": "ncat",
|
||||
"suffix": Null,
|
||||
"bytes": 14686,
|
||||
"date_updated": "Oct 1 12:09",
|
||||
"owner_user": "joeuser",
|
||||
"owner_group": "staff",
|
||||
"flags": "lrwxr-xr-x",
|
||||
"link_to": "../Cellar/nmap/7.70/bin/ncat",
|
||||
"links": 1
|
||||
}
|
||||
]
|
||||
CLI Example:
|
||||
|
||||
$ dig example.com | jc --dig -p
|
||||
[
|
||||
{
|
||||
"id": 2951,
|
||||
"opcode": "QUERY",
|
||||
"status": "NOERROR",
|
||||
"flags": [
|
||||
"qr",
|
||||
"rd",
|
||||
"ra"
|
||||
],
|
||||
"query_num": 1,
|
||||
"answer_num": 1,
|
||||
"authority_num": 0,
|
||||
"additional_num": 1,
|
||||
"opt_pseudosection": {
|
||||
"edns": {
|
||||
"version": 0,
|
||||
"flags": [],
|
||||
"udp": 4096
|
||||
}
|
||||
},
|
||||
"question": {
|
||||
"name": "example.com.",
|
||||
"class": "IN",
|
||||
"type": "A"
|
||||
},
|
||||
"answer": [
|
||||
{
|
||||
"name": "example.com.",
|
||||
"class": "IN",
|
||||
"type": "A",
|
||||
"ttl": 39302,
|
||||
"data": "93.184.216.34"
|
||||
}
|
||||
],
|
||||
"query_time": 49,
|
||||
"server": "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
|
||||
"when": "Fri Apr 16 16:05:10 PDT 2021",
|
||||
"rcvd": 56,
|
||||
"when_epoch": 1618614310,
|
||||
"when_epoch_utc": null
|
||||
}
|
||||
]
|
||||
|
||||
Module Example:
|
||||
|
||||
>>> import jc.parsers.dig
|
||||
>>>
|
||||
>>> import subprocess
|
||||
>>> import jc.parsers.dig
|
||||
>>>
|
||||
>>> cmd_output = subprocess.check_output(['dig', 'example.com'], text=True)
|
||||
>>> data = jc.parsers.dig.parse(cmd_output)
|
||||
>>>
|
||||
>>> data
|
||||
[{'id': 64612, 'opcode': 'QUERY', 'status': 'NOERROR', 'flags': ['qr', 'rd', 'ra'], 'query_num': 1, 'answer_num':
|
||||
1, 'authority_num': 0, 'additional_num': 1, 'opt_pseudosection': {'edns': {'version': 0, 'flags': [], 'udp':
|
||||
4096}}, 'question': {'name': 'example.com.', 'class': 'IN', 'type': 'A'}, 'answer': [{'name': 'example.com.',
|
||||
'class': 'IN', 'type': 'A', 'ttl': 29658, 'data': '93.184.216.34'}], 'query_time': 52, 'server':
|
||||
'2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)', 'when': 'Fri Apr 16 16:13:00 PDT 2021', 'rcvd': 56,
|
||||
'when_epoch': 1618614780, 'when_epoch_utc': None}]
|
||||
"""
|
||||
|
||||
name = 'jc'
|
||||
__version__ = '1.17.3'
|
||||
|
||||
611
jc/appdirs.py
Normal file
611
jc/appdirs.py
Normal file
@@ -0,0 +1,611 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2005-2010 ActiveState Software Inc.
|
||||
# Copyright (c) 2013 Eddy Petrișor
|
||||
|
||||
'''
|
||||
# This is the MIT license
|
||||
|
||||
Copyright (c) 2010 ActiveState Software Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
'''
|
||||
|
||||
"""Utilities for determining application-specific dirs.
|
||||
|
||||
See <https://github.com/ActiveState/appdirs> for details and usage.
|
||||
"""
|
||||
# Dev Notes:
|
||||
# - MSDN on where to store app data files:
|
||||
# http://support.microsoft.com/default.aspx?scid=kb;en-us;310294#XSLTH3194121123120121120120
|
||||
# - Mac OS X: http://developer.apple.com/documentation/MacOSX/Conceptual/BPFileSystem/index.html
|
||||
# - XDG spec for Un*x: https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||
|
||||
__version__ = "1.4.4"
|
||||
__version_info__ = tuple(int(segment) for segment in __version__.split("."))
|
||||
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
PY3 = sys.version_info[0] == 3
|
||||
|
||||
if PY3:
|
||||
unicode = str
|
||||
|
||||
if sys.platform.startswith('java'):
|
||||
import platform
|
||||
os_name = platform.java_ver()[3][0]
|
||||
if os_name.startswith('Windows'): # "Windows XP", "Windows 7", etc.
|
||||
system = 'win32'
|
||||
elif os_name.startswith('Mac'): # "Mac OS X", etc.
|
||||
system = 'darwin'
|
||||
else: # "Linux", "SunOS", "FreeBSD", etc.
|
||||
# Setting this to "linux2" is not ideal, but only Windows or Mac
|
||||
# are actually checked for and the rest of the module expects
|
||||
# *sys.platform* style strings.
|
||||
system = 'linux2'
|
||||
else:
|
||||
system = sys.platform
|
||||
|
||||
|
||||
|
||||
def user_data_dir(appname=None, appauthor=None, version=None, roaming=False):
|
||||
r"""Return full path to the user-specific data dir for this application.
|
||||
|
||||
"appname" is the name of application.
|
||||
If None, just the system directory is returned.
|
||||
"appauthor" (only used on Windows) is the name of the
|
||||
appauthor or distributing body for this application. Typically
|
||||
it is the owning company name. This falls back to appname. You may
|
||||
pass False to disable it.
|
||||
"version" is an optional version path element to append to the
|
||||
path. You might want to use this if you want multiple versions
|
||||
of your app to be able to run independently. If used, this
|
||||
would typically be "<major>.<minor>".
|
||||
Only applied when appname is present.
|
||||
"roaming" (boolean, default False) can be set True to use the Windows
|
||||
roaming appdata directory. That means that for users on a Windows
|
||||
network setup for roaming profiles, this user data will be
|
||||
sync'd on login. See
|
||||
<http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>
|
||||
for a discussion of issues.
|
||||
|
||||
Typical user data directories are:
|
||||
Mac OS X: ~/Library/Application Support/<AppName>
|
||||
Unix: ~/.local/share/<AppName> # or in $XDG_DATA_HOME, if defined
|
||||
Win XP (not roaming): C:\Documents and Settings\<username>\Application Data\<AppAuthor>\<AppName>
|
||||
Win XP (roaming): C:\Documents and Settings\<username>\Local Settings\Application Data\<AppAuthor>\<AppName>
|
||||
Win 7 (not roaming): C:\Users\<username>\AppData\Local\<AppAuthor>\<AppName>
|
||||
Win 7 (roaming): C:\Users\<username>\AppData\Roaming\<AppAuthor>\<AppName>
|
||||
|
||||
For Unix, we follow the XDG spec and support $XDG_DATA_HOME.
|
||||
That means, by default "~/.local/share/<AppName>".
|
||||
"""
|
||||
if system == "win32":
|
||||
if appauthor is None:
|
||||
appauthor = appname
|
||||
const = roaming and "CSIDL_APPDATA" or "CSIDL_LOCAL_APPDATA"
|
||||
path = os.path.normpath(_get_win_folder(const))
|
||||
if appname:
|
||||
if appauthor is not False:
|
||||
path = os.path.join(path, appauthor, appname)
|
||||
else:
|
||||
path = os.path.join(path, appname)
|
||||
elif system == 'darwin':
|
||||
path = os.path.expanduser('~/Library/Application Support/')
|
||||
if appname:
|
||||
path = os.path.join(path, appname)
|
||||
else:
|
||||
path = os.getenv('XDG_DATA_HOME', os.path.expanduser("~/.local/share"))
|
||||
if appname:
|
||||
path = os.path.join(path, appname)
|
||||
if appname and version:
|
||||
path = os.path.join(path, version)
|
||||
return path
|
||||
|
||||
|
||||
def site_data_dir(appname=None, appauthor=None, version=None, multipath=False):
|
||||
r"""Return full path to the user-shared data dir for this application.
|
||||
|
||||
"appname" is the name of application.
|
||||
If None, just the system directory is returned.
|
||||
"appauthor" (only used on Windows) is the name of the
|
||||
appauthor or distributing body for this application. Typically
|
||||
it is the owning company name. This falls back to appname. You may
|
||||
pass False to disable it.
|
||||
"version" is an optional version path element to append to the
|
||||
path. You might want to use this if you want multiple versions
|
||||
of your app to be able to run independently. If used, this
|
||||
would typically be "<major>.<minor>".
|
||||
Only applied when appname is present.
|
||||
"multipath" is an optional parameter only applicable to *nix
|
||||
which indicates that the entire list of data dirs should be
|
||||
returned. By default, the first item from XDG_DATA_DIRS is
|
||||
returned, or '/usr/local/share/<AppName>',
|
||||
if XDG_DATA_DIRS is not set
|
||||
|
||||
Typical site data directories are:
|
||||
Mac OS X: /Library/Application Support/<AppName>
|
||||
Unix: /usr/local/share/<AppName> or /usr/share/<AppName>
|
||||
Win XP: C:\Documents and Settings\All Users\Application Data\<AppAuthor>\<AppName>
|
||||
Vista: (Fail! "C:\ProgramData" is a hidden *system* directory on Vista.)
|
||||
Win 7: C:\ProgramData\<AppAuthor>\<AppName> # Hidden, but writeable on Win 7.
|
||||
|
||||
For Unix, this is using the $XDG_DATA_DIRS[0] default.
|
||||
|
||||
WARNING: Do not use this on Windows. See the Vista-Fail note above for why.
|
||||
"""
|
||||
if system == "win32":
|
||||
if appauthor is None:
|
||||
appauthor = appname
|
||||
path = os.path.normpath(_get_win_folder("CSIDL_COMMON_APPDATA"))
|
||||
if appname:
|
||||
if appauthor is not False:
|
||||
path = os.path.join(path, appauthor, appname)
|
||||
else:
|
||||
path = os.path.join(path, appname)
|
||||
elif system == 'darwin':
|
||||
path = os.path.expanduser('/Library/Application Support')
|
||||
if appname:
|
||||
path = os.path.join(path, appname)
|
||||
else:
|
||||
# XDG default for $XDG_DATA_DIRS
|
||||
# only first, if multipath is False
|
||||
path = os.getenv('XDG_DATA_DIRS',
|
||||
os.pathsep.join(['/usr/local/share', '/usr/share']))
|
||||
pathlist = [os.path.expanduser(x.rstrip(os.sep)) for x in path.split(os.pathsep)]
|
||||
if appname:
|
||||
if version:
|
||||
appname = os.path.join(appname, version)
|
||||
pathlist = [os.sep.join([x, appname]) for x in pathlist]
|
||||
|
||||
if multipath:
|
||||
path = os.pathsep.join(pathlist)
|
||||
else:
|
||||
path = pathlist[0]
|
||||
return path
|
||||
|
||||
if appname and version:
|
||||
path = os.path.join(path, version)
|
||||
return path
|
||||
|
||||
|
||||
def user_config_dir(appname=None, appauthor=None, version=None, roaming=False):
|
||||
r"""Return full path to the user-specific config dir for this application.
|
||||
|
||||
"appname" is the name of application.
|
||||
If None, just the system directory is returned.
|
||||
"appauthor" (only used on Windows) is the name of the
|
||||
appauthor or distributing body for this application. Typically
|
||||
it is the owning company name. This falls back to appname. You may
|
||||
pass False to disable it.
|
||||
"version" is an optional version path element to append to the
|
||||
path. You might want to use this if you want multiple versions
|
||||
of your app to be able to run independently. If used, this
|
||||
would typically be "<major>.<minor>".
|
||||
Only applied when appname is present.
|
||||
"roaming" (boolean, default False) can be set True to use the Windows
|
||||
roaming appdata directory. That means that for users on a Windows
|
||||
network setup for roaming profiles, this user data will be
|
||||
sync'd on login. See
|
||||
<http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>
|
||||
for a discussion of issues.
|
||||
|
||||
Typical user config directories are:
|
||||
Mac OS X: ~/Library/Preferences/<AppName>
|
||||
Unix: ~/.config/<AppName> # or in $XDG_CONFIG_HOME, if defined
|
||||
Win *: same as user_data_dir
|
||||
|
||||
For Unix, we follow the XDG spec and support $XDG_CONFIG_HOME.
|
||||
That means, by default "~/.config/<AppName>".
|
||||
"""
|
||||
if system == "win32":
|
||||
path = user_data_dir(appname, appauthor, None, roaming)
|
||||
elif system == 'darwin':
|
||||
path = os.path.expanduser('~/Library/Preferences/')
|
||||
if appname:
|
||||
path = os.path.join(path, appname)
|
||||
else:
|
||||
path = os.getenv('XDG_CONFIG_HOME', os.path.expanduser("~/.config"))
|
||||
if appname:
|
||||
path = os.path.join(path, appname)
|
||||
if appname and version:
|
||||
path = os.path.join(path, version)
|
||||
return path
|
||||
|
||||
|
||||
def site_config_dir(appname=None, appauthor=None, version=None, multipath=False):
|
||||
r"""Return full path to the user-shared data dir for this application.
|
||||
|
||||
"appname" is the name of application.
|
||||
If None, just the system directory is returned.
|
||||
"appauthor" (only used on Windows) is the name of the
|
||||
appauthor or distributing body for this application. Typically
|
||||
it is the owning company name. This falls back to appname. You may
|
||||
pass False to disable it.
|
||||
"version" is an optional version path element to append to the
|
||||
path. You might want to use this if you want multiple versions
|
||||
of your app to be able to run independently. If used, this
|
||||
would typically be "<major>.<minor>".
|
||||
Only applied when appname is present.
|
||||
"multipath" is an optional parameter only applicable to *nix
|
||||
which indicates that the entire list of config dirs should be
|
||||
returned. By default, the first item from XDG_CONFIG_DIRS is
|
||||
returned, or '/etc/xdg/<AppName>', if XDG_CONFIG_DIRS is not set
|
||||
|
||||
Typical site config directories are:
|
||||
Mac OS X: same as site_data_dir
|
||||
Unix: /etc/xdg/<AppName> or $XDG_CONFIG_DIRS[i]/<AppName> for each value in
|
||||
$XDG_CONFIG_DIRS
|
||||
Win *: same as site_data_dir
|
||||
Vista: (Fail! "C:\ProgramData" is a hidden *system* directory on Vista.)
|
||||
|
||||
For Unix, this is using the $XDG_CONFIG_DIRS[0] default, if multipath=False
|
||||
|
||||
WARNING: Do not use this on Windows. See the Vista-Fail note above for why.
|
||||
"""
|
||||
if system == 'win32':
|
||||
path = site_data_dir(appname, appauthor)
|
||||
if appname and version:
|
||||
path = os.path.join(path, version)
|
||||
elif system == 'darwin':
|
||||
path = os.path.expanduser('/Library/Preferences')
|
||||
if appname:
|
||||
path = os.path.join(path, appname)
|
||||
else:
|
||||
# XDG default for $XDG_CONFIG_DIRS
|
||||
# only first, if multipath is False
|
||||
path = os.getenv('XDG_CONFIG_DIRS', '/etc/xdg')
|
||||
pathlist = [os.path.expanduser(x.rstrip(os.sep)) for x in path.split(os.pathsep)]
|
||||
if appname:
|
||||
if version:
|
||||
appname = os.path.join(appname, version)
|
||||
pathlist = [os.sep.join([x, appname]) for x in pathlist]
|
||||
|
||||
if multipath:
|
||||
path = os.pathsep.join(pathlist)
|
||||
else:
|
||||
path = pathlist[0]
|
||||
return path
|
||||
|
||||
|
||||
def user_cache_dir(appname=None, appauthor=None, version=None, opinion=True):
|
||||
r"""Return full path to the user-specific cache dir for this application.
|
||||
|
||||
"appname" is the name of application.
|
||||
If None, just the system directory is returned.
|
||||
"appauthor" (only used on Windows) is the name of the
|
||||
appauthor or distributing body for this application. Typically
|
||||
it is the owning company name. This falls back to appname. You may
|
||||
pass False to disable it.
|
||||
"version" is an optional version path element to append to the
|
||||
path. You might want to use this if you want multiple versions
|
||||
of your app to be able to run independently. If used, this
|
||||
would typically be "<major>.<minor>".
|
||||
Only applied when appname is present.
|
||||
"opinion" (boolean) can be False to disable the appending of
|
||||
"Cache" to the base app data dir for Windows. See
|
||||
discussion below.
|
||||
|
||||
Typical user cache directories are:
|
||||
Mac OS X: ~/Library/Caches/<AppName>
|
||||
Unix: ~/.cache/<AppName> (XDG default)
|
||||
Win XP: C:\Documents and Settings\<username>\Local Settings\Application Data\<AppAuthor>\<AppName>\Cache
|
||||
Vista: C:\Users\<username>\AppData\Local\<AppAuthor>\<AppName>\Cache
|
||||
|
||||
On Windows the only suggestion in the MSDN docs is that local settings go in
|
||||
the `CSIDL_LOCAL_APPDATA` directory. This is identical to the non-roaming
|
||||
app data dir (the default returned by `user_data_dir` above). Apps typically
|
||||
put cache data somewhere *under* the given dir here. Some examples:
|
||||
...\Mozilla\Firefox\Profiles\<ProfileName>\Cache
|
||||
...\Acme\SuperApp\Cache\1.0
|
||||
OPINION: This function appends "Cache" to the `CSIDL_LOCAL_APPDATA` value.
|
||||
This can be disabled with the `opinion=False` option.
|
||||
"""
|
||||
if system == "win32":
|
||||
if appauthor is None:
|
||||
appauthor = appname
|
||||
path = os.path.normpath(_get_win_folder("CSIDL_LOCAL_APPDATA"))
|
||||
if appname:
|
||||
if appauthor is not False:
|
||||
path = os.path.join(path, appauthor, appname)
|
||||
else:
|
||||
path = os.path.join(path, appname)
|
||||
if opinion:
|
||||
path = os.path.join(path, "Cache")
|
||||
elif system == 'darwin':
|
||||
path = os.path.expanduser('~/Library/Caches')
|
||||
if appname:
|
||||
path = os.path.join(path, appname)
|
||||
else:
|
||||
path = os.getenv('XDG_CACHE_HOME', os.path.expanduser('~/.cache'))
|
||||
if appname:
|
||||
path = os.path.join(path, appname)
|
||||
if appname and version:
|
||||
path = os.path.join(path, version)
|
||||
return path
|
||||
|
||||
|
||||
def user_state_dir(appname=None, appauthor=None, version=None, roaming=False):
|
||||
r"""Return full path to the user-specific state dir for this application.
|
||||
|
||||
"appname" is the name of application.
|
||||
If None, just the system directory is returned.
|
||||
"appauthor" (only used on Windows) is the name of the
|
||||
appauthor or distributing body for this application. Typically
|
||||
it is the owning company name. This falls back to appname. You may
|
||||
pass False to disable it.
|
||||
"version" is an optional version path element to append to the
|
||||
path. You might want to use this if you want multiple versions
|
||||
of your app to be able to run independently. If used, this
|
||||
would typically be "<major>.<minor>".
|
||||
Only applied when appname is present.
|
||||
"roaming" (boolean, default False) can be set True to use the Windows
|
||||
roaming appdata directory. That means that for users on a Windows
|
||||
network setup for roaming profiles, this user data will be
|
||||
sync'd on login. See
|
||||
<http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>
|
||||
for a discussion of issues.
|
||||
|
||||
Typical user state directories are:
|
||||
Mac OS X: same as user_data_dir
|
||||
Unix: ~/.local/state/<AppName> # or in $XDG_STATE_HOME, if defined
|
||||
Win *: same as user_data_dir
|
||||
|
||||
For Unix, we follow this Debian proposal <https://wiki.debian.org/XDGBaseDirectorySpecification#state>
|
||||
to extend the XDG spec and support $XDG_STATE_HOME.
|
||||
|
||||
That means, by default "~/.local/state/<AppName>".
|
||||
"""
|
||||
if system in ["win32", "darwin"]:
|
||||
path = user_data_dir(appname, appauthor, None, roaming)
|
||||
else:
|
||||
path = os.getenv('XDG_STATE_HOME', os.path.expanduser("~/.local/state"))
|
||||
if appname:
|
||||
path = os.path.join(path, appname)
|
||||
if appname and version:
|
||||
path = os.path.join(path, version)
|
||||
return path
|
||||
|
||||
|
||||
def user_log_dir(appname=None, appauthor=None, version=None, opinion=True):
|
||||
r"""Return full path to the user-specific log dir for this application.
|
||||
|
||||
"appname" is the name of application.
|
||||
If None, just the system directory is returned.
|
||||
"appauthor" (only used on Windows) is the name of the
|
||||
appauthor or distributing body for this application. Typically
|
||||
it is the owning company name. This falls back to appname. You may
|
||||
pass False to disable it.
|
||||
"version" is an optional version path element to append to the
|
||||
path. You might want to use this if you want multiple versions
|
||||
of your app to be able to run independently. If used, this
|
||||
would typically be "<major>.<minor>".
|
||||
Only applied when appname is present.
|
||||
"opinion" (boolean) can be False to disable the appending of
|
||||
"Logs" to the base app data dir for Windows, and "log" to the
|
||||
base cache dir for Unix. See discussion below.
|
||||
|
||||
Typical user log directories are:
|
||||
Mac OS X: ~/Library/Logs/<AppName>
|
||||
Unix: ~/.cache/<AppName>/log # or under $XDG_CACHE_HOME if defined
|
||||
Win XP: C:\Documents and Settings\<username>\Local Settings\Application Data\<AppAuthor>\<AppName>\Logs
|
||||
Vista: C:\Users\<username>\AppData\Local\<AppAuthor>\<AppName>\Logs
|
||||
|
||||
On Windows the only suggestion in the MSDN docs is that local settings
|
||||
go in the `CSIDL_LOCAL_APPDATA` directory. (Note: I'm interested in
|
||||
examples of what some windows apps use for a logs dir.)
|
||||
|
||||
OPINION: This function appends "Logs" to the `CSIDL_LOCAL_APPDATA`
|
||||
value for Windows and appends "log" to the user cache dir for Unix.
|
||||
This can be disabled with the `opinion=False` option.
|
||||
"""
|
||||
if system == "darwin":
|
||||
path = os.path.join(
|
||||
os.path.expanduser('~/Library/Logs'),
|
||||
appname)
|
||||
elif system == "win32":
|
||||
path = user_data_dir(appname, appauthor, version)
|
||||
version = False
|
||||
if opinion:
|
||||
path = os.path.join(path, "Logs")
|
||||
else:
|
||||
path = user_cache_dir(appname, appauthor, version)
|
||||
version = False
|
||||
if opinion:
|
||||
path = os.path.join(path, "log")
|
||||
if appname and version:
|
||||
path = os.path.join(path, version)
|
||||
return path
|
||||
|
||||
|
||||
class AppDirs(object):
|
||||
"""Convenience wrapper for getting application dirs."""
|
||||
def __init__(self, appname=None, appauthor=None, version=None,
|
||||
roaming=False, multipath=False):
|
||||
self.appname = appname
|
||||
self.appauthor = appauthor
|
||||
self.version = version
|
||||
self.roaming = roaming
|
||||
self.multipath = multipath
|
||||
|
||||
@property
|
||||
def user_data_dir(self):
|
||||
return user_data_dir(self.appname, self.appauthor,
|
||||
version=self.version, roaming=self.roaming)
|
||||
|
||||
@property
|
||||
def site_data_dir(self):
|
||||
return site_data_dir(self.appname, self.appauthor,
|
||||
version=self.version, multipath=self.multipath)
|
||||
|
||||
@property
|
||||
def user_config_dir(self):
|
||||
return user_config_dir(self.appname, self.appauthor,
|
||||
version=self.version, roaming=self.roaming)
|
||||
|
||||
@property
|
||||
def site_config_dir(self):
|
||||
return site_config_dir(self.appname, self.appauthor,
|
||||
version=self.version, multipath=self.multipath)
|
||||
|
||||
@property
|
||||
def user_cache_dir(self):
|
||||
return user_cache_dir(self.appname, self.appauthor,
|
||||
version=self.version)
|
||||
|
||||
@property
|
||||
def user_state_dir(self):
|
||||
return user_state_dir(self.appname, self.appauthor,
|
||||
version=self.version)
|
||||
|
||||
@property
|
||||
def user_log_dir(self):
|
||||
return user_log_dir(self.appname, self.appauthor,
|
||||
version=self.version)
|
||||
|
||||
|
||||
#---- internal support stuff
|
||||
|
||||
def _get_win_folder_from_registry(csidl_name):
|
||||
"""This is a fallback technique at best. I'm not sure if using the
|
||||
registry for this guarantees us the correct answer for all CSIDL_*
|
||||
names.
|
||||
"""
|
||||
if PY3:
|
||||
import winreg as _winreg
|
||||
else:
|
||||
import _winreg
|
||||
|
||||
shell_folder_name = {
|
||||
"CSIDL_APPDATA": "AppData",
|
||||
"CSIDL_COMMON_APPDATA": "Common AppData",
|
||||
"CSIDL_LOCAL_APPDATA": "Local AppData",
|
||||
}[csidl_name]
|
||||
|
||||
key = _winreg.OpenKey(
|
||||
_winreg.HKEY_CURRENT_USER,
|
||||
r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
|
||||
)
|
||||
dir, type = _winreg.QueryValueEx(key, shell_folder_name)
|
||||
return dir
|
||||
|
||||
|
||||
def _get_win_folder_with_ctypes(csidl_name):
|
||||
import ctypes
|
||||
|
||||
csidl_const = {
|
||||
"CSIDL_APPDATA": 26,
|
||||
"CSIDL_COMMON_APPDATA": 35,
|
||||
"CSIDL_LOCAL_APPDATA": 28,
|
||||
}[csidl_name]
|
||||
|
||||
buf = ctypes.create_unicode_buffer(1024)
|
||||
ctypes.windll.shell32.SHGetFolderPathW(None, csidl_const, None, 0, buf)
|
||||
|
||||
# Downgrade to short path name if have highbit chars. See
|
||||
# <http://bugs.activestate.com/show_bug.cgi?id=85099>.
|
||||
has_high_char = False
|
||||
for c in buf:
|
||||
if ord(c) > 255:
|
||||
has_high_char = True
|
||||
break
|
||||
if has_high_char:
|
||||
buf2 = ctypes.create_unicode_buffer(1024)
|
||||
if ctypes.windll.kernel32.GetShortPathNameW(buf.value, buf2, 1024):
|
||||
buf = buf2
|
||||
|
||||
return buf.value
|
||||
|
||||
def _get_win_folder_with_jna(csidl_name):
|
||||
import array
|
||||
from com.sun import jna
|
||||
from com.sun.jna.platform import win32
|
||||
|
||||
buf_size = win32.WinDef.MAX_PATH * 2
|
||||
buf = array.zeros('c', buf_size)
|
||||
shell = win32.Shell32.INSTANCE
|
||||
shell.SHGetFolderPath(None, getattr(win32.ShlObj, csidl_name), None, win32.ShlObj.SHGFP_TYPE_CURRENT, buf)
|
||||
dir = jna.Native.toString(buf.tostring()).rstrip("\0")
|
||||
|
||||
# Downgrade to short path name if have highbit chars. See
|
||||
# <http://bugs.activestate.com/show_bug.cgi?id=85099>.
|
||||
has_high_char = False
|
||||
for c in dir:
|
||||
if ord(c) > 255:
|
||||
has_high_char = True
|
||||
break
|
||||
if has_high_char:
|
||||
buf = array.zeros('c', buf_size)
|
||||
kernel = win32.Kernel32.INSTANCE
|
||||
if kernel.GetShortPathName(dir, buf, buf_size):
|
||||
dir = jna.Native.toString(buf.tostring()).rstrip("\0")
|
||||
|
||||
return dir
|
||||
|
||||
if system == "win32":
|
||||
try:
|
||||
from ctypes import windll
|
||||
except ImportError:
|
||||
try:
|
||||
import com.sun.jna
|
||||
except ImportError:
|
||||
_get_win_folder = _get_win_folder_from_registry
|
||||
else:
|
||||
_get_win_folder = _get_win_folder_with_jna
|
||||
else:
|
||||
_get_win_folder = _get_win_folder_with_ctypes
|
||||
|
||||
|
||||
#---- self test code
|
||||
|
||||
if __name__ == "__main__":
|
||||
appname = "MyApp"
|
||||
appauthor = "MyCompany"
|
||||
|
||||
props = ("user_data_dir",
|
||||
"user_config_dir",
|
||||
"user_cache_dir",
|
||||
"user_state_dir",
|
||||
"user_log_dir",
|
||||
"site_data_dir",
|
||||
"site_config_dir")
|
||||
|
||||
print("-- app dirs %s --" % __version__)
|
||||
|
||||
print("-- app dirs (with optional 'version')")
|
||||
dirs = AppDirs(appname, appauthor, version="1.0")
|
||||
for prop in props:
|
||||
print("%s: %s" % (prop, getattr(dirs, prop)))
|
||||
|
||||
print("\n-- app dirs (without optional 'version')")
|
||||
dirs = AppDirs(appname, appauthor)
|
||||
for prop in props:
|
||||
print("%s: %s" % (prop, getattr(dirs, prop)))
|
||||
|
||||
print("\n-- app dirs (without optional 'appauthor')")
|
||||
dirs = AppDirs(appname)
|
||||
for prop in props:
|
||||
print("%s: %s" % (prop, getattr(dirs, prop)))
|
||||
|
||||
print("\n-- app dirs (with disabled 'appauthor')")
|
||||
dirs = AppDirs(appname, appauthor=False)
|
||||
for prop in props:
|
||||
print("%s: %s" % (prop, getattr(dirs, prop)))
|
||||
687
jc/cli.py
Normal file
687
jc/cli.py
Normal file
@@ -0,0 +1,687 @@
|
||||
"""jc - JSON CLI output utility
|
||||
JC cli module
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import os.path
|
||||
import re
|
||||
import importlib
|
||||
import textwrap
|
||||
import signal
|
||||
import shlex
|
||||
import subprocess
|
||||
import json
|
||||
import jc
|
||||
from jc import appdirs
|
||||
import jc.utils
|
||||
import jc.tracebackplus
|
||||
from jc.exceptions import LibraryNotInstalled, ParseError
|
||||
|
||||
# make pygments import optional
|
||||
try:
|
||||
import pygments
|
||||
from pygments import highlight
|
||||
from pygments.style import Style
|
||||
from pygments.token import (Name, Number, String, Keyword)
|
||||
from pygments.lexers import JsonLexer
|
||||
from pygments.formatters import Terminal256Formatter
|
||||
PYGMENTS_INSTALLED = True
|
||||
except Exception:
|
||||
PYGMENTS_INSTALLED = False
|
||||
|
||||
|
||||
class info():
|
||||
version = jc.__version__
|
||||
description = 'JSON CLI output utility'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
website = 'https://github.com/kellyjonbrazil/jc'
|
||||
copyright = '© 2019-2021 Kelly Brazil'
|
||||
license = 'MIT License'
|
||||
|
||||
|
||||
__version__ = info.version
|
||||
|
||||
parsers = [
|
||||
'acpi',
|
||||
'airport',
|
||||
'airport-s',
|
||||
'arp',
|
||||
'blkid',
|
||||
'cksum',
|
||||
'crontab',
|
||||
'crontab-u',
|
||||
'csv',
|
||||
'csv-s',
|
||||
'date',
|
||||
'df',
|
||||
'dig',
|
||||
'dir',
|
||||
'dmidecode',
|
||||
'dpkg-l',
|
||||
'du',
|
||||
'env',
|
||||
'file',
|
||||
'finger',
|
||||
'free',
|
||||
'fstab',
|
||||
'group',
|
||||
'gshadow',
|
||||
'hash',
|
||||
'hashsum',
|
||||
'hciconfig',
|
||||
'history',
|
||||
'hosts',
|
||||
'id',
|
||||
'ifconfig',
|
||||
'ini',
|
||||
'iostat',
|
||||
'iostat-s',
|
||||
'iptables',
|
||||
'iw-scan',
|
||||
'jobs',
|
||||
'kv',
|
||||
'last',
|
||||
'ls',
|
||||
'ls-s',
|
||||
'lsblk',
|
||||
'lsmod',
|
||||
'lsof',
|
||||
'lsusb',
|
||||
'mount',
|
||||
'netstat',
|
||||
'ntpq',
|
||||
'passwd',
|
||||
'ping',
|
||||
'ping-s',
|
||||
'pip-list',
|
||||
'pip-show',
|
||||
'ps',
|
||||
'route',
|
||||
'rpm-qi',
|
||||
'sfdisk',
|
||||
'shadow',
|
||||
'ss',
|
||||
'stat',
|
||||
'sysctl',
|
||||
'systemctl',
|
||||
'systemctl-lj',
|
||||
'systemctl-ls',
|
||||
'systemctl-luf',
|
||||
'systeminfo',
|
||||
'time',
|
||||
'timedatectl',
|
||||
'tracepath',
|
||||
'traceroute',
|
||||
'ufw',
|
||||
'ufw-appinfo',
|
||||
'uname',
|
||||
'upower',
|
||||
'uptime',
|
||||
'vmstat',
|
||||
'vmstat-s',
|
||||
'w',
|
||||
'wc',
|
||||
'who',
|
||||
'xml',
|
||||
'yaml'
|
||||
]
|
||||
|
||||
JC_ERROR_EXIT = 100
|
||||
|
||||
|
||||
# List of custom or override parsers.
|
||||
# Allow any <user_data_dir>/jc/jcparsers/*.py
|
||||
local_parsers = []
|
||||
data_dir = appdirs.user_data_dir('jc', 'jc')
|
||||
local_parsers_dir = os.path.join(data_dir, 'jcparsers')
|
||||
if os.path.isdir(local_parsers_dir):
|
||||
sys.path.append(data_dir)
|
||||
for name in os.listdir(local_parsers_dir):
|
||||
if re.match(r'\w+\.py$', name) and os.path.isfile(os.path.join(local_parsers_dir, name)):
|
||||
plugin_name = name[0:-3]
|
||||
local_parsers.append(plugin_name)
|
||||
if plugin_name not in parsers:
|
||||
parsers.append(plugin_name)
|
||||
|
||||
|
||||
# We only support 2.3.0+, pygments changed color names in 2.4.0.
|
||||
# startswith is sufficient and avoids potential exceptions from split and int.
|
||||
if PYGMENTS_INSTALLED:
|
||||
if pygments.__version__.startswith('2.3.'):
|
||||
PYGMENT_COLOR = {
|
||||
'black': '#ansiblack',
|
||||
'red': '#ansidarkred',
|
||||
'green': '#ansidarkgreen',
|
||||
'yellow': '#ansibrown',
|
||||
'blue': '#ansidarkblue',
|
||||
'magenta': '#ansipurple',
|
||||
'cyan': '#ansiteal',
|
||||
'gray': '#ansilightgray',
|
||||
'brightblack': '#ansidarkgray',
|
||||
'brightred': '#ansired',
|
||||
'brightgreen': '#ansigreen',
|
||||
'brightyellow': '#ansiyellow',
|
||||
'brightblue': '#ansiblue',
|
||||
'brightmagenta': '#ansifuchsia',
|
||||
'brightcyan': '#ansiturquoise',
|
||||
'white': '#ansiwhite',
|
||||
}
|
||||
else:
|
||||
PYGMENT_COLOR = {
|
||||
'black': 'ansiblack',
|
||||
'red': 'ansired',
|
||||
'green': 'ansigreen',
|
||||
'yellow': 'ansiyellow',
|
||||
'blue': 'ansiblue',
|
||||
'magenta': 'ansimagenta',
|
||||
'cyan': 'ansicyan',
|
||||
'gray': 'ansigray',
|
||||
'brightblack': 'ansibrightblack',
|
||||
'brightred': 'ansibrightred',
|
||||
'brightgreen': 'ansibrightgreen',
|
||||
'brightyellow': 'ansibrightyellow',
|
||||
'brightblue': 'ansibrightblue',
|
||||
'brightmagenta': 'ansibrightmagenta',
|
||||
'brightcyan': 'ansibrightcyan',
|
||||
'white': 'ansiwhite',
|
||||
}
|
||||
|
||||
|
||||
def set_env_colors(env_colors=None):
|
||||
"""
|
||||
Return a dictionary to be used in Pygments custom style class.
|
||||
|
||||
Grab custom colors from JC_COLORS environment variable. JC_COLORS env variable takes 4 comma
|
||||
separated string values and should be in the format of:
|
||||
|
||||
JC_COLORS=<keyname_color>,<keyword_color>,<number_color>,<string_color>
|
||||
|
||||
Where colors are: black, red, green, yellow, blue, magenta, cyan, gray, brightblack, brightred,
|
||||
brightgreen, brightyellow, brightblue, brightmagenta, brightcyan, white, default
|
||||
|
||||
Default colors:
|
||||
|
||||
JC_COLORS=blue,brightblack,magenta,green
|
||||
or
|
||||
JC_COLORS=default,default,default,default
|
||||
"""
|
||||
input_error = False
|
||||
|
||||
if env_colors:
|
||||
color_list = env_colors.split(',')
|
||||
else:
|
||||
color_list = ['default', 'default', 'default', 'default']
|
||||
|
||||
if len(color_list) != 4:
|
||||
input_error = True
|
||||
|
||||
for color in color_list:
|
||||
if color != 'default' and color not in PYGMENT_COLOR:
|
||||
input_error = True
|
||||
|
||||
# if there is an issue with the env variable, just set all colors to default and move on
|
||||
if input_error:
|
||||
jc.utils.warning_message(['Could not parse JC_COLORS environment variable'])
|
||||
color_list = ['default', 'default', 'default', 'default']
|
||||
|
||||
# Try the color set in the JC_COLORS env variable first. If it is set to default, then fall back to default colors
|
||||
return {
|
||||
Name.Tag: f'bold {PYGMENT_COLOR[color_list[0]]}' if color_list[0] != 'default' else f"bold {PYGMENT_COLOR['blue']}", # key names
|
||||
Keyword: PYGMENT_COLOR[color_list[1]] if color_list[1] != 'default' else PYGMENT_COLOR['brightblack'], # true, false, null
|
||||
Number: PYGMENT_COLOR[color_list[2]] if color_list[2] != 'default' else PYGMENT_COLOR['magenta'], # numbers
|
||||
String: PYGMENT_COLOR[color_list[3]] if color_list[3] != 'default' else PYGMENT_COLOR['green'] # strings
|
||||
}
|
||||
|
||||
|
||||
def piped_output():
|
||||
"""Return False if stdout is a TTY. True if output is being piped to another program"""
|
||||
return not sys.stdout.isatty()
|
||||
|
||||
|
||||
def ctrlc(signum, frame):
|
||||
"""Exit with error on SIGINT"""
|
||||
sys.exit(JC_ERROR_EXIT)
|
||||
|
||||
|
||||
def parser_shortname(parser_arg):
|
||||
"""Return short name of the parser with dashes and no -- prefix"""
|
||||
return parser_arg[2:]
|
||||
|
||||
|
||||
def parser_argument(parser):
|
||||
"""Return short name of the parser with dashes and with -- prefix"""
|
||||
return f'--{parser}'
|
||||
|
||||
|
||||
def parser_mod_shortname(parser):
|
||||
"""Return short name of the parser's module name (no -- prefix and dashes converted to underscores)"""
|
||||
return parser.replace('--', '').replace('-', '_')
|
||||
|
||||
|
||||
def parser_module(parser):
|
||||
"""Import the module just in time and return the module object"""
|
||||
shortname = parser_mod_shortname(parser)
|
||||
path = ('jcparsers.' if shortname in local_parsers else 'jc.parsers.')
|
||||
return importlib.import_module(path + shortname)
|
||||
|
||||
|
||||
def parsers_text(indent=0, pad=0):
|
||||
"""Return the argument and description information from each parser"""
|
||||
ptext = ''
|
||||
for parser in parsers:
|
||||
parser_arg = parser_argument(parser)
|
||||
parser_mod = parser_module(parser)
|
||||
|
||||
if hasattr(parser_mod, 'info'):
|
||||
parser_desc = parser_mod.info.description
|
||||
padding = pad - len(parser_arg)
|
||||
padding_char = ' '
|
||||
indent_text = padding_char * indent
|
||||
padding_text = padding_char * padding
|
||||
ptext += indent_text + parser_arg + padding_text + parser_desc + '\n'
|
||||
|
||||
return ptext
|
||||
|
||||
|
||||
def about_jc():
|
||||
"""Return jc info and the contents of each parser.info as a dictionary"""
|
||||
parser_list = []
|
||||
|
||||
for parser in parsers:
|
||||
parser_mod = parser_module(parser)
|
||||
|
||||
if hasattr(parser_mod, 'info'):
|
||||
info_dict = {}
|
||||
info_dict['name'] = parser_mod.__name__.split('.')[-1]
|
||||
info_dict['argument'] = parser_argument(parser)
|
||||
parser_entry = vars(parser_mod.info)
|
||||
|
||||
for k, v in parser_entry.items():
|
||||
if not k.startswith('__'):
|
||||
info_dict[k] = v
|
||||
|
||||
parser_list.append(info_dict)
|
||||
|
||||
return {
|
||||
'name': 'jc',
|
||||
'version': info.version,
|
||||
'description': info.description,
|
||||
'author': info.author,
|
||||
'author_email': info.author_email,
|
||||
'website': info.website,
|
||||
'copyright': info.copyright,
|
||||
'license': info.license,
|
||||
'parser_count': len(parser_list),
|
||||
'parsers': parser_list
|
||||
}
|
||||
|
||||
|
||||
def helptext():
|
||||
"""Return the help text with the list of parsers"""
|
||||
parsers_string = parsers_text(indent=12, pad=17)
|
||||
|
||||
helptext_string = f'''\
|
||||
jc converts the output of many commands and file-types to JSON
|
||||
|
||||
Usage: COMMAND | jc PARSER [OPTIONS]
|
||||
|
||||
or magic syntax:
|
||||
|
||||
jc [OPTIONS] COMMAND
|
||||
|
||||
Parsers:
|
||||
{parsers_string}
|
||||
Options:
|
||||
-a about jc
|
||||
-d debug (-dd for verbose debug)
|
||||
-h help (-h --parser_name for parser documentation)
|
||||
-m monochrome output
|
||||
-p pretty print output
|
||||
-q quiet - suppress parser warnings (-qq to ignore streaming errors)
|
||||
-r raw JSON output
|
||||
-u unbuffer output
|
||||
-v version info
|
||||
|
||||
Examples:
|
||||
Standard Syntax:
|
||||
$ dig www.google.com | jc --dig -p
|
||||
|
||||
Magic Syntax:
|
||||
$ jc -p dig www.google.com
|
||||
|
||||
Parser Documentation:
|
||||
$ jc -h --dig
|
||||
'''
|
||||
return textwrap.dedent(helptext_string)
|
||||
|
||||
|
||||
def help_doc(options):
|
||||
"""
|
||||
Returns the parser documentation if a parser is found in the arguments, otherwise
|
||||
the general help text is returned.
|
||||
"""
|
||||
for arg in options:
|
||||
parser_name = parser_shortname(arg)
|
||||
|
||||
if parser_name in parsers:
|
||||
# load parser module just in time so we don't need to load all modules
|
||||
parser = parser_module(arg)
|
||||
compatible = ', '.join(parser.info.compatible)
|
||||
doc_text = \
|
||||
f'{parser.__doc__}\n'\
|
||||
f'Compatibility: {compatible}\n\n'\
|
||||
f'Version {parser.info.version} by {parser.info.author} ({parser.info.author_email})\n'
|
||||
|
||||
return doc_text
|
||||
|
||||
return helptext()
|
||||
|
||||
|
||||
def versiontext():
|
||||
"""Return the version text"""
|
||||
versiontext_string = f'''\
|
||||
jc version {info.version}
|
||||
{info.website}
|
||||
{info.copyright}'''
|
||||
return textwrap.dedent(versiontext_string)
|
||||
|
||||
|
||||
def json_out(data, pretty=False, env_colors=None, mono=False, piped_out=False):
|
||||
"""Return a JSON formatted string. String may include color codes or be pretty printed."""
|
||||
separators = (',', ':')
|
||||
indent = None
|
||||
|
||||
if pretty:
|
||||
separators = None
|
||||
indent = 2
|
||||
|
||||
if not mono and not piped_out:
|
||||
# set colors
|
||||
class JcStyle(Style):
|
||||
styles = set_env_colors(env_colors)
|
||||
|
||||
return str(highlight(json.dumps(data, indent=indent, separators=separators, ensure_ascii=False),
|
||||
JsonLexer(), Terminal256Formatter(style=JcStyle))[0:-1])
|
||||
|
||||
return json.dumps(data, indent=indent, separators=separators, ensure_ascii=False)
|
||||
|
||||
|
||||
def magic_parser(args):
|
||||
"""
|
||||
Parse command arguments for magic syntax: jc -p ls -al
|
||||
|
||||
Return a tuple:
|
||||
valid_command (bool) is this a valid command? (exists in magic dict)
|
||||
run_command (list) list of the user's command to run. None if no command.
|
||||
jc_parser (str) parser to use for this user's command.
|
||||
jc_options (list) list of jc options
|
||||
"""
|
||||
# bail immediately if there are no args or a parser is defined
|
||||
if len(args) <= 1 or args[1].startswith('--'):
|
||||
return False, None, None, []
|
||||
|
||||
args_given = args[1:]
|
||||
options = []
|
||||
|
||||
# find the options
|
||||
for arg in list(args_given):
|
||||
# parser found - use standard syntax
|
||||
if arg.startswith('--'):
|
||||
return False, None, None, []
|
||||
|
||||
# option found - populate option list
|
||||
if arg.startswith('-'):
|
||||
options.extend(args_given.pop(0)[1:])
|
||||
|
||||
# command found if iterator didn't already stop - stop iterating
|
||||
else:
|
||||
break
|
||||
|
||||
# if -h, -a, or -v found in options, then bail out
|
||||
if 'h' in options or 'a' in options or 'v' in options:
|
||||
return False, None, None, []
|
||||
|
||||
# all options popped and no command found - for case like 'jc -x'
|
||||
if len(args_given) == 0:
|
||||
return False, None, None, []
|
||||
|
||||
magic_dict = {}
|
||||
parser_info = about_jc()['parsers']
|
||||
|
||||
# create a dictionary of magic_commands to their respective parsers.
|
||||
for entry in parser_info:
|
||||
# Update the dict with all of the magic commands for this parser, if they exist.
|
||||
magic_dict.update({mc: entry['argument'] for mc in entry.get('magic_commands', [])})
|
||||
|
||||
# find the command and parser
|
||||
one_word_command = args_given[0]
|
||||
two_word_command = ' '.join(args_given[0:2])
|
||||
|
||||
# try to get a parser for two_word_command, otherwise get one for one_word_command
|
||||
found_parser = magic_dict.get(two_word_command, magic_dict.get(one_word_command))
|
||||
|
||||
return (
|
||||
bool(found_parser), # was a suitable parser found?
|
||||
args_given, # run_command
|
||||
found_parser, # the parser selected
|
||||
options # jc options to preserve
|
||||
)
|
||||
|
||||
|
||||
def run_user_command(command):
|
||||
"""Use subprocess to run the user's command. Returns the STDOUT, STDERR, and the Exit Code as a tuple."""
|
||||
proc = subprocess.Popen(command,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
close_fds=False, # Allows inheriting file descriptors. Useful for process substitution
|
||||
universal_newlines=True)
|
||||
stdout, stderr = proc.communicate()
|
||||
|
||||
return (
|
||||
stdout or '\n',
|
||||
stderr,
|
||||
proc.returncode
|
||||
)
|
||||
|
||||
|
||||
def combined_exit_code(program_exit=0, jc_exit=0):
|
||||
exit_code = program_exit + jc_exit
|
||||
exit_code = min(exit_code, 255)
|
||||
return exit_code
|
||||
|
||||
|
||||
def main():
|
||||
# break on ctrl-c keyboard interrupt
|
||||
signal.signal(signal.SIGINT, ctrlc)
|
||||
|
||||
# break on pipe error. need try/except for windows compatibility
|
||||
try:
|
||||
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
# enable colors for Windows cmd.exe terminal
|
||||
if sys.platform.startswith('win32'):
|
||||
os.system('')
|
||||
|
||||
# parse magic syntax first: e.g. jc -p ls -al
|
||||
magic_options = []
|
||||
valid_command, run_command, magic_found_parser, magic_options = magic_parser(sys.argv)
|
||||
|
||||
# set colors
|
||||
jc_colors = os.getenv('JC_COLORS')
|
||||
|
||||
# set options
|
||||
options = []
|
||||
options.extend(magic_options)
|
||||
|
||||
# find options if magic_parser did not find a command
|
||||
if not valid_command:
|
||||
for opt in sys.argv:
|
||||
if opt.startswith('-') and not opt.startswith('--'):
|
||||
options.extend(opt[1:])
|
||||
|
||||
about = 'a' in options
|
||||
debug = 'd' in options
|
||||
verbose_debug = options.count('d') > 1
|
||||
mono = 'm' in options
|
||||
help_me = 'h' in options
|
||||
pretty = 'p' in options
|
||||
quiet = 'q' in options
|
||||
ignore_exceptions = options.count('q') > 1
|
||||
raw = 'r' in options
|
||||
unbuffer = 'u' in options
|
||||
version_info = 'v' in options
|
||||
|
||||
if verbose_debug:
|
||||
jc.tracebackplus.enable(context=11)
|
||||
|
||||
if not PYGMENTS_INSTALLED:
|
||||
mono = True
|
||||
|
||||
if about:
|
||||
print(json_out(about_jc(), pretty=pretty, env_colors=jc_colors, mono=mono, piped_out=piped_output()))
|
||||
sys.exit(0)
|
||||
|
||||
if help_me:
|
||||
print(help_doc(sys.argv))
|
||||
sys.exit(0)
|
||||
|
||||
if version_info:
|
||||
print(versiontext())
|
||||
sys.exit(0)
|
||||
|
||||
# if magic syntax used, try to run the command and error if it's not found, etc.
|
||||
magic_stdout, magic_stderr, magic_exit_code = None, None, 0
|
||||
if run_command:
|
||||
try:
|
||||
run_command_str = shlex.join(run_command) # python 3.8+
|
||||
except AttributeError:
|
||||
run_command_str = ' '.join(run_command) # older python versions
|
||||
|
||||
if valid_command:
|
||||
try:
|
||||
magic_stdout, magic_stderr, magic_exit_code = run_user_command(run_command)
|
||||
if magic_stderr:
|
||||
print(magic_stderr[:-1], file=sys.stderr)
|
||||
|
||||
except FileNotFoundError:
|
||||
if debug:
|
||||
raise
|
||||
|
||||
jc.utils.error_message([f'"{run_command_str}" command could not be found. For details use the -d or -dd option.'])
|
||||
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
|
||||
|
||||
except OSError:
|
||||
if debug:
|
||||
raise
|
||||
|
||||
jc.utils.error_message([f'"{run_command_str}" command could not be run due to too many open files. For details use the -d or -dd option.'])
|
||||
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
|
||||
|
||||
except Exception:
|
||||
if debug:
|
||||
raise
|
||||
|
||||
jc.utils.error_message([f'"{run_command_str}" command could not be run. For details use the -d or -dd option.'])
|
||||
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
|
||||
|
||||
elif run_command is not None:
|
||||
jc.utils.error_message([f'"{run_command_str}" cannot be used with Magic syntax. Use "jc -h" for help.'])
|
||||
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
|
||||
|
||||
# find the correct parser
|
||||
if magic_found_parser:
|
||||
parser = parser_module(magic_found_parser)
|
||||
parser_name = parser_shortname(magic_found_parser)
|
||||
|
||||
else:
|
||||
found = False
|
||||
for arg in sys.argv:
|
||||
parser_name = parser_shortname(arg)
|
||||
|
||||
if parser_name in parsers:
|
||||
parser = parser_module(arg)
|
||||
found = True
|
||||
break
|
||||
|
||||
if not found:
|
||||
jc.utils.error_message(['Missing or incorrect arguments. Use "jc -h" for help.'])
|
||||
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
|
||||
|
||||
# check for input errors (pipe vs magic)
|
||||
if not sys.stdin.isatty() and magic_stdout:
|
||||
jc.utils.error_message(['Piped data and Magic syntax used simultaneously. Use "jc -h" for help.'])
|
||||
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
|
||||
|
||||
elif sys.stdin.isatty() and magic_stdout is None:
|
||||
jc.utils.error_message(['Missing piped data. Use "jc -h" for help.'])
|
||||
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
|
||||
|
||||
# parse and print to stdout
|
||||
try:
|
||||
# differentiate between regular and streaming parsers
|
||||
|
||||
# streaming
|
||||
if getattr(parser.info, 'streaming', None):
|
||||
result = parser.parse(sys.stdin, raw=raw, quiet=quiet, ignore_exceptions=ignore_exceptions)
|
||||
for line in result:
|
||||
print(json_out(line,
|
||||
pretty=pretty,
|
||||
env_colors=jc_colors,
|
||||
mono=mono,
|
||||
piped_out=piped_output()),
|
||||
flush=unbuffer)
|
||||
|
||||
sys.exit(combined_exit_code(magic_exit_code, 0))
|
||||
|
||||
# regular
|
||||
else:
|
||||
data = magic_stdout or sys.stdin.read()
|
||||
result = parser.parse(data, raw=raw, quiet=quiet)
|
||||
print(json_out(result,
|
||||
pretty=pretty,
|
||||
env_colors=jc_colors,
|
||||
mono=mono,
|
||||
piped_out=piped_output()),
|
||||
flush=unbuffer)
|
||||
|
||||
sys.exit(combined_exit_code(magic_exit_code, 0))
|
||||
|
||||
except (ParseError, LibraryNotInstalled) as e:
|
||||
if debug:
|
||||
raise
|
||||
|
||||
jc.utils.error_message([f'Parser issue with {parser_name}:',
|
||||
f'{e.__class__.__name__}: {e}',
|
||||
'For details use the -d or -dd option. Use "jc -h" for help.'])
|
||||
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
|
||||
|
||||
except json.JSONDecodeError:
|
||||
if debug:
|
||||
raise
|
||||
|
||||
jc.utils.error_message(['There was an issue generating the JSON output.',
|
||||
'For details use the -d or -dd option.'])
|
||||
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
|
||||
|
||||
except Exception:
|
||||
if debug:
|
||||
raise
|
||||
|
||||
streaming_msg = ''
|
||||
if getattr(parser.info, 'streaming', None):
|
||||
streaming_msg = 'Use the -qq option to ignore streaming parser errors.'
|
||||
|
||||
jc.utils.error_message([
|
||||
f'{parser_name} parser could not parse the input data. Did you use the correct parser?',
|
||||
f'{streaming_msg}',
|
||||
'For details use the -d or -dd option. Use "jc -h" for help.'
|
||||
])
|
||||
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user