Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ansi_escape_senquences -> ansi_escape_sequences #53

Merged
merged 3 commits into from
Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion osrf_pycommon/process_utils/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def execute_process(cmd, cwd=None, env=None, shell=False, emulate_tty=False):
If you want to ensure there is no color in the output from an executed
process, then use this function:

:py:func:`osrf_pycommon.terminal_color.remove_ansi_escape_senquences`
:py:func:`osrf_pycommon.terminal_color.remove_ansi_escape_sequences`

Exceptions can be raised by functions called by the implementation,
for example, :py:class:`subprocess.Popen` can raise an :py:exc:`OSError`
Expand Down
2 changes: 2 additions & 0 deletions osrf_pycommon/terminal_color/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
"""

from .ansi_re import remove_ansi_escape_senquences
from .ansi_re import remove_ansi_escape_sequences
from .ansi_re import split_by_ansi_escape_sequence

from .impl import ansi
Expand All @@ -168,6 +169,7 @@
'print_ansi_color_win32',
'print_color',
'remove_ansi_escape_senquences',
'remove_ansi_escape_sequences',
'sanitize',
'split_by_ansi_escape_sequence',
'test_colors',
Expand Down
6 changes: 5 additions & 1 deletion osrf_pycommon/terminal_color/ansi_re.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@ def split_by_ansi_escape_sequence(string, include_delimiters=False):
return _ansi_re.split(string)


def remove_ansi_escape_senquences(string):
def remove_ansi_escape_sequences(string):
"""
Removes any ansi escape sequences found in the given string and returns it.
"""
global _ansi_re
return _ansi_re.sub('', string)


# Backwards compatibility
remove_ansi_escape_senquences = remove_ansi_escape_sequences
8 changes: 4 additions & 4 deletions tests/unit/test_terminal_color/test_ansi_re.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ def test_split_by_ansi_escape_sequence(self):
expected = ["", "red ", "bold red ", "normal ", "red bg"]
self.assertEqual(expected, split_ansi(self.test_str, False))

def test_remove_ansi_escape_senquences(self):
remove_ansi = ansi_re.remove_ansi_escape_senquences
def test_remove_ansi_escape_sequences(self):
remove_ansi = ansi_re.remove_ansi_escape_sequences
expected = "red bold red normal red bg"
self.assertEqual(expected, remove_ansi(self.test_str))

def test_remove_ansi_escape_senquences_false_positives(self):
remove_ansi = ansi_re.remove_ansi_escape_senquences
def test_remove_ansi_escape_sequences_false_positives(self):
remove_ansi = ansi_re.remove_ansi_escape_sequences
false_positive = "Should not match: \1xb[1234m \033[m \1xb[3Om"
self.assertEqual(false_positive, remove_ansi(false_positive))