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):
"""
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
-------
>>> handle_dnscache_log(line)
"""
- match = dnscache_log_re.match(line)
+ match = DNSCACHE_LOG_RE.match(line)
if not match:
return None