From bed0b6be151b2eafd03111cd3782e2672d193443 Mon Sep 17 00:00:00 2001 From: kotfu Date: Fri, 27 Apr 2018 10:09:21 -0600 Subject: Create utils module for utility functions --- cmd2/utils.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 cmd2/utils.py (limited to 'cmd2/utils.py') diff --git a/cmd2/utils.py b/cmd2/utils.py new file mode 100644 index 00000000..33215dc0 --- /dev/null +++ b/cmd2/utils.py @@ -0,0 +1,13 @@ +# +# coding=utf-8 +"""Shared utility functions""" + +from . import constants + +def strip_ansi(text: str) -> str: + """Strip ANSI escape codes from a string. + + :param text: string which may contain ANSI escape codes + :return: the same string with any ANSI escape codes removed + """ + return constants.ANSI_ESCAPE_RE.sub('', text) -- cgit v1.2.1