diff --git a/debug-viewer/GstDebugViewer/Data.py b/debug-viewer/GstDebugViewer/Data.py index b989a53138..22616457ce 100644 --- a/debug-viewer/GstDebugViewer/Data.py +++ b/debug-viewer/GstDebugViewer/Data.py @@ -294,10 +294,14 @@ class LineCache (Producer): "I" : debug_level_info, "W" : debug_level_warning, "E" : debug_level_error, " " : debug_level_none} ANSI = "(?:\x1b\\[[0-9;]*m)?" - rexp = re.compile (r"\d:\d\d:\d\d\.\d+ " + ANSI + - r" *\d+" + ANSI + - r" +0x[0-9a-f]+ +" + ANSI + - r"([TFLDIEW ])") + ANSI_PATTERN = (r"\d:\d\d:\d\d\.\d+ " + ANSI + + r" *\d+" + ANSI + + r" +0x[0-9a-f]+ +" + ANSI + + r"([TFLDIEW ])") + BARE_PATTERN = ANSI_PATTERN.replace (ANSI, "") + rexp_bare = re.compile (BARE_PATTERN) + rexp_ansi = re.compile (ANSI_PATTERN) + rexp = rexp_bare # Moving attribute lookups out of the loop: readline = self.__fileobj.readline @@ -323,11 +327,17 @@ class LineCache (Producer): line = readline () if not line: break - # if line[18] == "\x1b": - # line = strip_escape (line) match = rexp_match (line) if match is None: - continue + if rexp is rexp_ansi or not "\x1b" in line: + continue + + match = rexp_ansi.match (line) + if match is None: + continue + # Switch to slower ANSI parsing: + rexp = rexp_ansi + rexp_match = rexp.match # Timestamp is in the very beginning of the row, and can be sorted # by lexical comparison. That's why we don't bother parsing the