From 49c8a5c7289f710804e799ac360271b5b30f7e09 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 16 Sep 2022 14:57:32 -0400 Subject: [PATCH] bin/djbdns-logparse.py: add a docstring for decode_ttl(). --- bin/djbdns-logparse.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/bin/djbdns-logparse.py b/bin/djbdns-logparse.py index c6b9872..5262fe0 100755 --- a/bin/djbdns-logparse.py +++ b/bin/djbdns-logparse.py @@ -207,6 +207,38 @@ def decode_ip(words : list, i : int): words[i] = convert_ip(words[i]) def decode_ttl(words : list, i : int): + r""" + Helper function to decode the ttl field in a dnscache log + entry. + + A single "ttl" field is present in the nodata, nxdomain, and + rr entry types. + + Parameters + ---------- + + words : list + The ``words`` list (a list of fields) from + :func:`handle_dnscache_log`. + + i : int + The index of the ttl field within ``words`` + + Returns + ------- + + Nothing; the ``i``th entry in the ``words`` list is modified + in-place. + + Examples + -------- + + >>> words = ["c0a80101", "20865", "1", "www.example.com.", "5db8d822"] + >>> decode_ttl(words, 1) + >>> words + ['c0a80101', 'TTL=20865', '1', 'www.example.com.', '5db8d822'] + + """ words[i] = f"TTL={words[i]}" def decode_serial(words : list, i : int): -- 2.43.2