From 846f4fb691a89cc4cb1373424f7e09351e0fac12 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Mon, 29 Apr 2024 14:09:14 -0700 Subject: [PATCH] doc update --- CHANGELOG | 3 ++- docs/parsers/traceroute.md | 2 +- jc/parsers/traceroute.py | 16 +++++++--------- man/jc.1 | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0e23eba6..e08dafdd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,9 +1,10 @@ jc changelog -20240428 v1.25.3 +20240429 v1.25.3 - Add `battery_percentage` field to `bluetoothctl` parser output - Fix `pci-ids` parser to correctly handle multiple subdevices - 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 - Documentation updates diff --git a/docs/parsers/traceroute.md b/docs/parsers/traceroute.md index 3024aedf..450cc962 100644 --- a/docs/parsers/traceroute.md +++ b/docs/parsers/traceroute.md @@ -145,4 +145,4 @@ Compatibility: linux, darwin, freebsd 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) diff --git a/jc/parsers/traceroute.py b/jc/parsers/traceroute.py index f0c0cf00..a55b8574 100644 --- a/jc/parsers/traceroute.py +++ b/jc/parsers/traceroute.py @@ -123,7 +123,7 @@ from copy import deepcopy class info(): """Provides parser metadata (version, author, etc.)""" - version = '1.6' + version = '1.7' description = '`traceroute` and `traceroute6` command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' @@ -238,6 +238,7 @@ class _Probe(object): text += "\n" return text + def _get_probes(hop_string: str): probes = [] 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 is_last_match_rtt: - probe = deepcopy(last_probe) + probe = deepcopy(last_probe) # type: ignore # Set RTT values probe.rtt = probe_rtt probe.annotation = match.groups()[2] or None # RTT is the last value shown for a hop if any([probe.ip, probe.asn, probe.annotation, probe.rtt, probe.name]): - probes.append(probe) + probes.append(probe) last_probe = probe probe = _Probe() - if match_type == "RTT": is_last_match_rtt = True @@ -290,6 +290,7 @@ def _get_probes(hop_string: str): return probes + def _loads(data): lines = data.splitlines() @@ -325,7 +326,6 @@ def _loads(data): probes = _get_probes(hop_string) for probe in probes: hop.add_probe(probe) - return traceroute @@ -336,6 +336,7 @@ class ParseError(Exception): ######################################################################################## + def _process(proc_data): """ Final processing to conform to the schema. @@ -441,7 +442,4 @@ def parse(data, raw=False, quiet=False): 'hops': hops_list } - if raw: - return raw_output - else: - return _process(raw_output) + return raw_output if raw else _process(raw_output) diff --git a/man/jc.1 b/man/jc.1 index b5c85fcd..8aa09b78 100644 --- a/man/jc.1 +++ b/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 \fBjc\fP \- JSON Convert JSONifies the output of many CLI tools, file-types, and strings