We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f3b5007 commit 7a24539Copy full SHA for 7a24539
1 file changed
parse_logs.py
@@ -12,10 +12,29 @@
12
from pytest import CollectReport, TestReport
13
14
test_collection_stage = "test collection session"
15
+fe_bytes = "[\x40-\x5f]"
16
+parameter_bytes = "[\x30-\x3f]"
17
+intermediate_bytes = "[\x20-\x2f]"
18
+final_bytes = "[\x40-\x7e]"
19
+ansi_fe_escape_re = re.compile(
20
+ rf"""
21
+ \x1B # ESC
22
+ (?:
23
+ {fe_bytes} # single-byte Fe
24
+ |
25
+ \[ # CSI
26
+ {parameter_bytes}*
27
+ {intermediate_bytes}*
28
+ {final_bytes}*
29
+ )
30
+ """,
31
+ re.VERBOSE,
32
+)
33
34
35
def strip_ansi(msg):
- pass
36
+ """strip all ansi escape sequences"""
37
+ return ansi_fe_escape_re.sub("", msg)
38
39
40
@dataclass
0 commit comments