]> gitweb.michael.orlitzky.com - djbdns-logparse.git/blobdiff - djbdns/dnscache.py
djbdns/*.py: capitalize global variables.
[djbdns-logparse.git] / djbdns / dnscache.py
index a67060bb545ed0d57dbb5ab7da6345e9dc7a2fe3..ac8b41c5656ba747b458832f069123c6f028e06b 100644 (file)
@@ -2,10 +2,10 @@
 import re
 
 from typing import Optional
-from djbdns.common import convert_ip, query_type_name, timestamp_pat
+from djbdns.common import QUERY_TYPE_NAME, TIMESTAMP_PAT, convert_ip
 
 # The regex to match dnscache log lines.
-dnscache_log_re = re.compile(fr'({timestamp_pat}) (\w+)(.*)')
+DNSCACHE_LOG_RE = re.compile(fr'({TIMESTAMP_PAT}) (\w+)(.*)')
 
 
 def decode_client(words : list, i : int):
@@ -207,17 +207,17 @@ def decode_type(words : list, i : int):
 
     """
     qt = words[i]
-    words[i] = query_type_name.get(int(qt), qt)
+    words[i] = QUERY_TYPE_NAME.get(int(qt), qt)
 
 def handle_dnscache_log(line : str) -> Optional[str]:
     r"""
-    Handle a single log line if it matches the ``dnscache_log_re`` regex.
+    Handle a single log line if it matches the ``DNSCACHE_LOG_RE`` regex.
 
     Parameters
     ----------
 
     line : string
-        The log line that might match ``dnscache_log_re``.
+        The log line that might match ``DNSCACHE_LOG_RE``.
 
     Returns
     -------
@@ -253,7 +253,7 @@ def handle_dnscache_log(line : str) -> Optional[str]:
         >>> handle_dnscache_log(line)
 
     """
-    match = dnscache_log_re.match(line)
+    match = DNSCACHE_LOG_RE.match(line)
     if not match:
         return None