From: Michael Orlitzky Date: Fri, 16 Sep 2022 18:57:32 +0000 (-0400) Subject: bin/djbdns-logparse.py: add a docstring for decode_ttl(). X-Git-Tag: 0.0.1~29 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=49c8a5c7289f710804e799ac360271b5b30f7e09;p=djbdns-logparse.git bin/djbdns-logparse.py: add a docstring for decode_ttl(). --- 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):