Skip to content

Commit

Permalink
utils.astring: Add ^c, ^!p and ^]104 to skip chars
Browse files Browse the repository at this point in the history
these are sometimes generated by kernel, ignore them.

Signed-off-by: Lukáš Doktor <[email protected]>
Signed-off-by: Sebastian Mitterle <[email protected]>
  • Loading branch information
ldoktor committed Sep 9, 2024
1 parent 506e44a commit 5f07ea1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aexpect/utils/astring.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def strip_console_codes(output, custom_codes=None):
output = f"\x1b[m{output}"
console_codes = "^%[G@8]|^\\[[@A-HJ-MPXa-hl-nqrsu\\`]"
console_codes += "|^\\[[\\d;]+[HJKgqnrm]|^#8|^\\([B0UK]|^\\)"
console_codes += "|^\\[\\?2004[lh]"
console_codes += "|^\\[\\?2004[lh]|^c|^\\[!p|^\\]\\d+"
if custom_codes is not None and custom_codes not in console_codes:
console_codes += f"|{custom_codes}"
while index < len(output):
Expand Down
2 changes: 2 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def test_strip_console_codes(self):
strip("\x1bskip-full-text"))
self.assertEqual("ignores last",
strip("ignores last\x1bbad"))
self.assertEqual("skips c [!p and ]104",
strip("skips\x1bc c \x1b[!p[!p and ]104\x1b]104"))
self.assertRaisesRegex(ValueError, "only is not included", strip,
"ignores\x1bonly\x1blast\x1bbad")
self.assertRaisesRegex(ValueError, "invalid-prefix.*included", strip,
Expand Down

0 comments on commit 5f07ea1

Please sign in to comment.