File: _utils.py

package info (click to toggle)
python-log-symbols 0.0.14-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 172 kB
  • sloc: python: 91; makefile: 3
file content (20 lines) | stat: -rw-r--r-- 387 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""Utilities for tests.
"""

import re

def strip_ansi(string):
    """Strip ANSI encoding from given string.

    Parameters
    ----------
    string : str
        String from which encoding needs to be removed

    Returns
    -------
    str
        Encoding free string
    """
    pattern = r'(\x1b\[|\x9b)[^@-_]*[@-_]|\x1b[@-_]'
    return re.sub(pattern, '', string, flags=re.I)