From: Michael Orlitzky Date: Fri, 16 Sep 2022 19:18:46 +0000 (-0400) Subject: bin/djbdns-logparse.py: add a dosctring for decode_serial(). X-Git-Tag: 0.0.1~27 X-Git-Url: http://gitweb.michael.orlitzky.com/?p=djbdns-logparse.git;a=commitdiff_plain;h=ecc0f1460b13cbfe3f50953431e85c0ec0785042 bin/djbdns-logparse.py: add a dosctring for decode_serial(). --- diff --git a/bin/djbdns-logparse.py b/bin/djbdns-logparse.py index 0abd5bc..1df2bf8 100755 --- a/bin/djbdns-logparse.py +++ b/bin/djbdns-logparse.py @@ -245,8 +245,39 @@ def decode_ttl(words : list, i : int): words[i] = f"TTL={words[i]}" def decode_serial(words : list, i : int): - serial = int(words[i]) - words[i] = f"#{serial}" + r""" + Helper function to decode the serial field in a dnscache log + entry. + + A single "serial" field is present in the drop and query entry + types. It's already in decimal; we simply prefix it with a hash. + + Parameters + ---------- + + words : list + The ``words`` list (a list of fields) from + :func:`handle_dnscache_log`. + + i : int + The index of the serial field within ``words`` + + Returns + ------- + + Nothing; the ``i``th entry in the ``words`` list is modified + in-place. + + Examples + -------- + + >>> words = ["1", "7f000001:a3db:4fb9", "1", "www.example.com."] + >>> decode_serial(words, 0) + >>> words + ['#1', '7f000001:a3db:4fb9', '1', 'www.example.com.'] + + """ + words[i] = f"#{words[i]}" def decode_type(words : list, i : int): qt = words[i]