From ecc0f1460b13cbfe3f50953431e85c0ec0785042 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 16 Sep 2022 15:18:46 -0400 Subject: [PATCH] bin/djbdns-logparse.py: add a dosctring for decode_serial(). --- bin/djbdns-logparse.py | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) 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] -- 2.43.2