X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=djbdns%2Fdnscache.py;fp=djbdns%2Fdnscache.py;h=ac8b41c5656ba747b458832f069123c6f028e06b;hb=49ee5a403cafc02a8e398c840b9bbc4c9d9e0f72;hp=a67060bb545ed0d57dbb5ab7da6345e9dc7a2fe3;hpb=db1cc70a2cd45943ed33520f82a773acd4f2a520;p=djbdns-logparse.git diff --git a/djbdns/dnscache.py b/djbdns/dnscache.py index a67060b..ac8b41c 100644 --- a/djbdns/dnscache.py +++ b/djbdns/dnscache.py @@ -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