From 01ec32d3983ae273165f75f5cdd48d59e193eaad Mon Sep 17 00:00:00 2001 From: "qwen.ai[bot]" Date: Wed, 12 Aug 2026 14:44:24 +0000 Subject: [PATCH] docs: add docstrings to parse_linux and parse_windows functions --- src/netsleuth/traceparse.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/netsleuth/traceparse.py b/src/netsleuth/traceparse.py index 7a66b52..2154b5b 100644 --- a/src/netsleuth/traceparse.py +++ b/src/netsleuth/traceparse.py @@ -105,6 +105,17 @@ def _unix_annotations(body: str) -> list[str]: def parse_linux(text: str) -> list[TraceHop]: + """Parse Linux traceroute output into structured hop data. + + Processes GNU-style traceroute output, extracting TTL, IP addresses, + reverse DNS, RTT probes, and annotations for each hop. + + Args: + text: Raw output from a Linux/GNU traceroute command. + + Returns: + A list of TraceHop objects, one per hop found in the output. + """ hops: list[TraceHop] = [] for line in text.splitlines(): match = _HOP_LINE_RE.match(line) @@ -133,6 +144,17 @@ _WIN_NAME_RE = re.compile(r"(?P[A-Za-z0-9._-]+)\s*\[") def parse_windows(text: str) -> list[TraceHop]: + """Parse Windows tracert output into structured hop data. + + Handles Windows-specific formatting including '<1 ms' notation, bracketed + IP addresses, and localized output variations. + + Args: + text: Raw output from a Windows tracert command. + + Returns: + A list of TraceHop objects, one per hop found in the output. + """ hops: list[TraceHop] = [] for line in text.splitlines(): match = _HOP_LINE_RE.match(line)