]> gitweb.michael.orlitzky.com - djbdns-logparse.git/blobdiff - djbdns/dnscache.py
djbdns/*.py: don't clobber id() and type() built-ins.
[djbdns-logparse.git] / djbdns / dnscache.py
index 785121b65d0541d04005654ebf0c59a7a7144dd7..7fed987195c3d39b466512a57258f6b28411d818 100644 (file)
@@ -1,9 +1,11 @@
-from re import compile
+# Don't clobber the global compile() with a named import.
+import re
+
 from typing import Optional
 from djbdns.common import *
 
 # The regex to match dnscache log lines.
-dnscache_log_re = compile(fr'({timestamp_pat}) (\w+)(.*)')
+dnscache_log_re = re.compile(fr'({timestamp_pat}) (\w+)(.*)')
 
 
 def decode_client(words : list, i : int):
@@ -57,8 +59,8 @@ def decode_client(words : list, i : int):
 
     if len(chunks) == 3:
         # For a "query" entry's clientip:clientport:id field.
-        id = int(chunks[2], 16)
-        words[i] += f" (id {id})"
+        packet_id = int(chunks[2], 16)
+        words[i] += f" (id {packet_id})"
 
 def decode_ip(words : list, i : int):
     r"""
@@ -205,7 +207,7 @@ def decode_type(words : list, i : int):
 
     """
     qt = words[i]
-    words[i] = query_type.get(int(qt), qt)
+    words[i] = query_type_name.get(int(qt), qt)
 
 def handle_dnscache_log(line : str) -> Optional[str]:
     r"""