diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-04-27 14:21:40 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-27 14:21:40 -0400 |
commit | 1306eebade58d7ffe5d0ab4008006b7fb3501b54 (patch) | |
tree | 368134105548c83ee224af234081b981be157725 /cmd2/utils.py | |
parent | a93437308bc597ff2fa759db144fd97d4db31c98 (diff) | |
parent | bed0b6be151b2eafd03111cd3782e2672d193443 (diff) | |
download | cmd2-git-1306eebade58d7ffe5d0ab4008006b7fb3501b54.tar.gz |
Merge pull request #374 from python-cmd2/constants
Move constants and utility functions into separate files.
Diffstat (limited to 'cmd2/utils.py')
-rw-r--r-- | cmd2/utils.py | 13 |
1 files changed, 13 insertions, 0 deletions
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) |