mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-09 01:05:53 +02:00
doc update
This commit is contained in:
@ -1,9 +1,10 @@
|
|||||||
jc changelog
|
jc changelog
|
||||||
|
|
||||||
20240428 v1.25.3
|
20240429 v1.25.3
|
||||||
- Add `battery_percentage` field to `bluetoothctl` parser output
|
- Add `battery_percentage` field to `bluetoothctl` parser output
|
||||||
- Fix `pci-ids` parser to correctly handle multiple subdevices
|
- Fix `pci-ids` parser to correctly handle multiple subdevices
|
||||||
- Fix `top` parsers to quiet uptime info parsing
|
- Fix `top` parsers to quiet uptime info parsing
|
||||||
|
- Fix `traceroute` parser to correctly handle hops with multiple IPs
|
||||||
- Optimize some tests by removing timezone settings and using quiet=True
|
- Optimize some tests by removing timezone settings and using quiet=True
|
||||||
- Documentation updates
|
- Documentation updates
|
||||||
|
|
||||||
|
@ -145,4 +145,4 @@ Compatibility: linux, darwin, freebsd
|
|||||||
|
|
||||||
Source: [`jc/parsers/traceroute.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/traceroute.py)
|
Source: [`jc/parsers/traceroute.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/traceroute.py)
|
||||||
|
|
||||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||||
|
@ -123,7 +123,7 @@ from copy import deepcopy
|
|||||||
|
|
||||||
class info():
|
class info():
|
||||||
"""Provides parser metadata (version, author, etc.)"""
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
version = '1.6'
|
version = '1.7'
|
||||||
description = '`traceroute` and `traceroute6` command parser'
|
description = '`traceroute` and `traceroute6` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -238,6 +238,7 @@ class _Probe(object):
|
|||||||
text += "\n"
|
text += "\n"
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
def _get_probes(hop_string: str):
|
def _get_probes(hop_string: str):
|
||||||
probes = []
|
probes = []
|
||||||
probe_asn_match = [ (match, "ASN") for match in RE_PROBE_ASN.finditer(hop_string)]
|
probe_asn_match = [ (match, "ASN") for match in RE_PROBE_ASN.finditer(hop_string)]
|
||||||
@ -272,16 +273,15 @@ def _get_probes(hop_string: str):
|
|||||||
|
|
||||||
# If the last match is a RTT, then copy all probe values and replace RTT field
|
# If the last match is a RTT, then copy all probe values and replace RTT field
|
||||||
if is_last_match_rtt:
|
if is_last_match_rtt:
|
||||||
probe = deepcopy(last_probe)
|
probe = deepcopy(last_probe) # type: ignore
|
||||||
# Set RTT values
|
# Set RTT values
|
||||||
probe.rtt = probe_rtt
|
probe.rtt = probe_rtt
|
||||||
probe.annotation = match.groups()[2] or None
|
probe.annotation = match.groups()[2] or None
|
||||||
# RTT is the last value shown for a hop
|
# RTT is the last value shown for a hop
|
||||||
if any([probe.ip, probe.asn, probe.annotation, probe.rtt, probe.name]):
|
if any([probe.ip, probe.asn, probe.annotation, probe.rtt, probe.name]):
|
||||||
probes.append(probe)
|
probes.append(probe)
|
||||||
last_probe = probe
|
last_probe = probe
|
||||||
probe = _Probe()
|
probe = _Probe()
|
||||||
|
|
||||||
|
|
||||||
if match_type == "RTT":
|
if match_type == "RTT":
|
||||||
is_last_match_rtt = True
|
is_last_match_rtt = True
|
||||||
@ -290,6 +290,7 @@ def _get_probes(hop_string: str):
|
|||||||
|
|
||||||
return probes
|
return probes
|
||||||
|
|
||||||
|
|
||||||
def _loads(data):
|
def _loads(data):
|
||||||
lines = data.splitlines()
|
lines = data.splitlines()
|
||||||
|
|
||||||
@ -325,7 +326,6 @@ def _loads(data):
|
|||||||
probes = _get_probes(hop_string)
|
probes = _get_probes(hop_string)
|
||||||
for probe in probes:
|
for probe in probes:
|
||||||
hop.add_probe(probe)
|
hop.add_probe(probe)
|
||||||
|
|
||||||
|
|
||||||
return traceroute
|
return traceroute
|
||||||
|
|
||||||
@ -336,6 +336,7 @@ class ParseError(Exception):
|
|||||||
|
|
||||||
########################################################################################
|
########################################################################################
|
||||||
|
|
||||||
|
|
||||||
def _process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
@ -441,7 +442,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
'hops': hops_list
|
'hops': hops_list
|
||||||
}
|
}
|
||||||
|
|
||||||
if raw:
|
return raw_output if raw else _process(raw_output)
|
||||||
return raw_output
|
|
||||||
else:
|
|
||||||
return _process(raw_output)
|
|
||||||
|
2
man/jc.1
2
man/jc.1
@ -1,4 +1,4 @@
|
|||||||
.TH jc 1 2024-04-28 1.25.3 "JSON Convert"
|
.TH jc 1 2024-04-29 1.25.3 "JSON Convert"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
\fBjc\fP \- JSON Convert JSONifies the output of many CLI tools, file-types,
|
\fBjc\fP \- JSON Convert JSONifies the output of many CLI tools, file-types,
|
||||||
and strings
|
and strings
|
||||||
|
Reference in New Issue
Block a user