From 22fdcd2203ecd273419511064936ecaffbc36b77 Mon Sep 17 00:00:00 2001 From: nnshah1 Date: Fri, 17 May 2024 16:09:34 -0700 Subject: [PATCH] updated renaming for clarity --- qa/L0_logging/log_format_test.py | 33 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/qa/L0_logging/log_format_test.py b/qa/L0_logging/log_format_test.py index 8f62bcac6f..576339510a 100644 --- a/qa/L0_logging/log_format_test.py +++ b/qa/L0_logging/log_format_test.py @@ -41,14 +41,6 @@ import json import google.protobuf.text_format -def parse_timestamp(timestamp): - hours, minutes, seconds = timestamp.split(':') - hours = int(hours) - minutes = int(minutes) - seconds = float(seconds) - return datetime.timedelta(hours=hours, minutes=minutes, seconds=seconds) - - module_directory = os.path.split(os.path.abspath(__file__))[0] test_model_directory = os.path.abspath(os.path.join(module_directory, "log_models")) @@ -58,17 +50,17 @@ def parse_timestamp(timestamp): os.path.join(module_directory, "log_format_test_logs") ) - shutil.rmtree(test_logs_directory, ignore_errors=True) os.makedirs(test_logs_directory) -# Regular expression pattern to capture the headers and rows -# table is +# Regular expressions for Table +# Table format is: +# # border -# header +# header_row # border -# row * +# data_rows # border table_border_regex = re.compile(r'^\+[-+]+\+$') @@ -76,22 +68,29 @@ def parse_timestamp(timestamp): # Regular expression pattern for default log record -default_pattern = r'(?P\w)(?P\d{2})(?P\d{2}) (?P\d{2}:\d{2}:\d{2}\.\d{6}) (?P\d+) (?P[\w\.]+):(?P\d+)] (?P.*)' +default_log_record = r'(?P\w)(?P\d{2})(?P\d{2}) (?P\d{2}:\d{2}:\d{2}\.\d{6}) (?P\d+) (?P[\w\.]+):(?P\d+)] (?P.*)' # Compile the regex pattern -default_regex = re.compile(default_pattern, re.DOTALL) +default_log_record_regex = re.compile(default_log_record, re.DOTALL) LEVELS = set({"E", "W", "I"}) FORMATS = [ - ("default", default_regex), + ("default", default_log_record_regex), ("ISO8601", ""), - ("default_unescaped", default_regex), + ("default_unescaped", default_log_record_regex), ("ISO8601_unescaped", ""), ] IDS = ["default", "ISO8601", "default_unescaped", "ISO8601_unescaped"] +def parse_timestamp(timestamp): + hours, minutes, seconds = timestamp.split(':') + hours = int(hours) + minutes = int(minutes) + seconds = float(seconds) + return datetime.timedelta(hours=hours, minutes=minutes, seconds=seconds) + validators = {} def validator(func):